Skip to main content

Server metadata

You can define the MCP server name and description by modifying:
from fastapi import FastAPI from fastapi_mcp import FastApiMCP  app = FastAPI()  mcp = FastApiMCP(  app,  name="My API MCP",  description="Very cool MCP server", ) mcp.mount_http() 

Tool and schema descriptions

When creating the MCP server you can include all possible response schemas in tool descriptions by changing the flag describe_all_responses, or include full JSON schema in tool descriptions by changing describe_full_response_schema:
from fastapi import FastAPI from fastapi_mcp import FastApiMCP  app = FastAPI()  mcp = FastApiMCP(  app,  name="My API MCP",  description="Very cool MCP server",  describe_all_responses=True,  describe_full_response_schema=True )  mcp.mount_http() 

Customizing Exposed Endpoints

You can control which FastAPI endpoints are exposed as MCP tools using Open API operation IDs or tags to:
  • Only include specific operations
  • Exclude specific operations
  • Only include operations with specific tags
  • Exclude operations with specific tags
  • Combine operation IDs and tags

Code samples

The relevant arguments for these configurations are include_operations, exclude_operations, include_tags, exclude_tags and can be used as follows:
from fastapi import FastAPI from fastapi_mcp import FastApiMCP  app = FastAPI()  mcp = FastApiMCP(  app,  include_operations=["get_user", "create_user"] ) mcp.mount_http() 

Notes on filtering

  • You cannot use both include_operations and exclude_operations at the same time
  • You cannot use both include_tags and exclude_tags at the same time
  • You can combine operation filtering with tag filtering (e.g., use include_operations with include_tags)
  • When combining filters, a greedy approach will be taken. Endpoints matching either criteria will be included