You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fastapi_mcp/server.py
+25-3Lines changed: 25 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
This module provides functionality for creating and mounting MCP servers to FastAPI applications.
5
5
"""
6
6
7
-
fromtypingimportDict, Optional, Union, Any
7
+
fromtypingimportDict, Optional, Any
8
8
9
9
fromfastapiimportFastAPI
10
10
frommcp.server.fastmcpimportFastMCP
@@ -53,6 +53,8 @@ def mount_mcp_server(
53
53
mount_path: str="/mcp",
54
54
serve_tools: bool=True,
55
55
base_url: Optional[str] =None,
56
+
describe_all_responses: bool=False,
57
+
describe_full_response_schema: bool=False,
56
58
) ->None:
57
59
"""
58
60
Mount an MCP server to a FastAPI app.
@@ -63,6 +65,8 @@ def mount_mcp_server(
63
65
mount_path: Path where the MCP server will be mounted
64
66
serve_tools: Whether to serve tools from the FastAPI app
65
67
base_url: Base URL for API requests
68
+
describe_all_responses: Whether to include all possible response schemas in tool descriptions. Recommended to keep False, as the LLM will probably derive if there is an error.
69
+
describe_full_response_schema: Whether to include full json schema for responses in tool descriptions. Recommended to keep False, as examples are more LLM friendly, and save tokens.
capabilities: Optional capabilities for the MCP server
112
124
serve_tools: Whether to serve tools from the FastAPI app
113
125
base_url: Base URL for API requests (defaults to http://localhost:$PORT)
126
+
describe_all_responses: Whether to include all possible response schemas in tool descriptions. Recommended to keep False, as the LLM will probably derive if there is an error.
127
+
describe_full_response_schema: Whether to include full json schema for responses in tool descriptions. Recommended to keep False, as examples are more LLM friendly, and save tokens.
0 commit comments