Skip to content

Commit ddb333d

Browse files
author
shiraayal-tadata
committed
move the mounting to happen after the tool creation so handle_mcp_conneciton won't be created as a tool
1 parent f31a2b4 commit ddb333d

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

fastapi_mcp/http_tools.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ def create_mcp_tools_from_openapi(
8383
if not operation_id:
8484
continue
8585

86-
# Skip MCP's internal tool that doesn't follow the same patterns
87-
if operation_id == "handle_mcp_connection_mcp_get":
88-
continue
89-
9086
# Create MCP tool for this operation
9187
create_http_tool(
9288
mcp_server=mcp_server,

fastapi_mcp/server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ async def handle_mcp_connection(request: Request):
8787
mcp_server._mcp_server.create_initialization_options(),
8888
)
8989

90-
# Mount the MCP connection handler
91-
app.get(mount_path)(handle_mcp_connection)
92-
app.mount(f"{mount_path}/messages/", app=sse_transport.handle_post_message)
93-
9490
# Serve tools from the FastAPI app if requested
9591
if serve_tools:
9692
create_mcp_tools_from_openapi(
@@ -100,6 +96,11 @@ async def handle_mcp_connection(request: Request):
10096
describe_all_responses=describe_all_responses,
10197
describe_full_response_schema=describe_full_response_schema,
10298
)
99+
100+
# Mount the MCP connection handler
101+
app.get(mount_path)(handle_mcp_connection)
102+
app.mount(f"{mount_path}/messages/", app=sse_transport.handle_post_message)
103+
103104

104105

105106
def add_mcp_server(

0 commit comments

Comments
 (0)