FastAPI-MCP logo

FastAPI-MCP

by tadata-org

FastAPI-MCP is a zero-configuration tool that automatically exposes FastAPI endpoints as Model Context Protocol (MCP) tools. It allows for direct integration and automatic discovery of endpoints, preserving schemas and documentation.

View on GitHub

Last updated: N/A

What is FastAPI-MCP?

FastAPI-MCP is a tool that simplifies the process of exposing FastAPI endpoints as MCP tools. It eliminates the need for manual configuration by automatically discovering and converting endpoints, making it easy to integrate FastAPI applications with MCP-compatible clients.

How to use FastAPI-MCP?

To use FastAPI-MCP, install the package using pip or uv. Then, instantiate the FastApiMCP class with your FastAPI app instance. Optionally, provide a name, description, and base URL. Finally, mount the MCP server to your FastAPI app using mcp.mount(). You can then connect to the MCP server using an MCP client.

Key features of FastAPI-MCP

  • Direct integration with FastAPI

  • Zero configuration required

  • Automatic discovery of FastAPI endpoints

  • Preserves request and response model schemas

  • Preserves endpoint documentation

  • Flexible deployment options

Use cases of FastAPI-MCP

  • Exposing FastAPI APIs to MCP-compatible clients

  • Integrating FastAPI applications with AI tools and assistants

  • Creating a unified interface for accessing multiple FastAPI services

  • Simplifying the development of MCP-based applications

FAQ from FastAPI-MCP

What is MCP?

Model Context Protocol (MCP) is a protocol that allows applications to expose their functionality as tools that can be used by other applications, such as AI assistants.

Do I need to configure anything to use FastAPI-MCP?

No, FastAPI-MCP is designed to be zero-configuration. It automatically discovers and converts your FastAPI endpoints to MCP tools.

Can I customize which endpoints are exposed as MCP tools?

Yes, you can use the include_operations, exclude_operations, include_tags, and exclude_tags parameters to control which endpoints are exposed.

Can I deploy the MCP server separately from my FastAPI app?

Yes, you can create an MCP server from one FastAPI app and mount it to a different app.

How do I connect to the MCP server?

You can connect to the MCP server using any MCP client that supports SSE, such as Cursor, or by using mcp-proxy to convert the SSE stream to stdio.