Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move the mounting to happen after the tool creation so handle_mcp_con…
…neciton won't be created as a tool
  • Loading branch information
shiraayal-tadata committed Apr 6, 2025
commit ddb333dcfd9399d17223e851304558f6d98f80d8
4 changes: 0 additions & 4 deletions fastapi_mcp/http_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ def create_mcp_tools_from_openapi(
if not operation_id:
continue

# Skip MCP's internal tool that doesn't follow the same patterns
if operation_id == "handle_mcp_connection_mcp_get":
continue

# Create MCP tool for this operation
create_http_tool(
mcp_server=mcp_server,
Expand Down
9 changes: 5 additions & 4 deletions fastapi_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ async def handle_mcp_connection(request: Request):
mcp_server._mcp_server.create_initialization_options(),
)

# Mount the MCP connection handler
app.get(mount_path)(handle_mcp_connection)
app.mount(f"{mount_path}/messages/", app=sse_transport.handle_post_message)

# Serve tools from the FastAPI app if requested
if serve_tools:
create_mcp_tools_from_openapi(
Expand All @@ -100,6 +96,11 @@ async def handle_mcp_connection(request: Request):
describe_all_responses=describe_all_responses,
describe_full_response_schema=describe_full_response_schema,
)

# Mount the MCP connection handler
app.get(mount_path)(handle_mcp_connection)
app.mount(f"{mount_path}/messages/", app=sse_transport.handle_post_message)



def add_mcp_server(
Expand Down