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'stitle. -
description(Optional[str], optional): A description for the MCP server. If not provided, it defaults to your FastAPI application'sdescription. -
describe_all_responses(bool, optional): IfTrue, the generated tool descriptions will include information about all possible HTTP responses (e.g., 404, 422), not just the successful ones (2xx). Defaults toFalse. -
describe_full_response_schema(bool, optional): IfTrue, the tool descriptions will include the full JSON schema of the response body, providing a detailed structure for the LLM. Defaults toFalse. -
http_client(Optional[httpx.AsyncClient], optional): A customhttpx.AsyncClientinstance for making internal requests to your FastAPI endpoints. By default,fastapi-mcpuses an efficient in-memory ASGI transport. You can override this to set a custombase_url, timeouts, or other client settings. See the Custom HTTP Client guide for more. -
include_operations(Optional[List[str]], optional): A list ofoperation_ids to include. If provided, only these endpoints will be exposed as tools. Cannot be used withexclude_operations. See Filtering Endpoints. -
exclude_operations(Optional[List[str]], optional): A list ofoperation_ids to exclude. All endpoints except these will be exposed. Cannot be used withinclude_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 withexclude_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 withinclude_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 theAuthorizationheader is forwarded. This is case-insensitive. Example:headers=["authorization", "x-request-id"].