Configuration Reference

All configuration for the MCP server is done when you instantiate the FastApiMCP class. This page details all the available parameters.

__init__ Parameters

mcp = FastApiMCP(
    fastapi=app,
    name="My Custom MCP",
    # ... other parameters
)

Here is the full list of parameters for FastApiMCP:

  • fastapi (FastAPI, required): The FastAPI application instance to generate the MCP server from.

  • name (Optional[str], optional): A user-friendly name for the MCP server. If not provided, it defaults to your FastAPI application's title.

  • description (Optional[str], optional): A description for the MCP server. If not provided, it defaults to your FastAPI application's description.

  • describe_all_responses (bool, optional): If True, the generated tool descriptions will include information about all possible HTTP responses (e.g., 404, 422), not just the successful ones (2xx). Defaults to False.

  • describe_full_response_schema (bool, optional): If True, the tool descriptions will include the full JSON schema of the response body, providing a detailed structure for the LLM. Defaults to False.

  • http_client (Optional[httpx.AsyncClient], optional): A custom httpx.AsyncClient instance for making internal requests to your FastAPI endpoints. By default, fastapi-mcp uses an efficient in-memory ASGI transport. You can override this to set a custom base_url, timeouts, or other client settings. See the Custom HTTP Client guide for more.

  • include_operations (Optional[List[str]], optional): A list of operation_ids to include. If provided, only these endpoints will be exposed as tools. Cannot be used with exclude_operations. See Filtering Endpoints.

  • exclude_operations (Optional[List[str]], optional): A list of operation_ids to exclude. All endpoints except these will be exposed. Cannot be used with include_operations. See Filtering Endpoints.

  • include_tags (Optional[List[str]], optional): A list of tags. Only endpoints with at least one of these tags will be exposed. Cannot be used with exclude_tags. See Filtering Endpoints.

  • exclude_tags (Optional[List[str]], optional): A list of tags. Endpoints with any of these tags will be excluded. Cannot be used with include_tags. See Filtering Endpoints.

  • auth_config (Optional[AuthConfig], optional): Configuration for enabling MCP authentication and authorization, including OAuth 2.0 support. See the Authentication guide for a detailed explanation.

  • headers (List[str], optional): A list of HTTP header names to forward from the incoming MCP request to the underlying FastAPI endpoint call. By default, only the Authorization header is forwarded. This is case-insensitive. Example: headers=["authorization", "x-request-id"].