Skip to content

Commit e965e03

Browse files
authored
Merge pull request #31 from shiraayal-tadata/fix/hide-handle-mcp-connection
Fix/hide handle mcp connection
2 parents 964a318 + 2944743 commit e965e03

File tree

7 files changed

+14
-24
lines changed

7 files changed

+14
-24
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.6]
9+
10+
### Fixed
11+
- [Issue #23](https://github.com/tadata-org/fastapi_mcp/issues/23): Hide handle_mcp_connection tool.
12+
813
## [0.1.5]
914

1015
### Fixed

fastapi_mcp/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Created by Tadata Inc. (https://github.com/tadata-org)
55
"""
66

7-
__version__ = "0.1.5"
7+
__version__ = "0.1.6"
88

99
from .server import add_mcp_server, create_mcp_server, mount_mcp_server
1010
from .http_tools import create_mcp_tools_from_openapi

fastapi_mcp/server.py

+5-4
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(

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "fastapi-mcp"
7-
version = "0.1.5"
7+
version = "0.1.6"
88
description = "Automatic MCP server generator for FastAPI applications - converts FastAPI endpoints to MCP tools for LLM integration"
99
readme = "README.md"
1010
requires-python = ">=3.10"

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name="fastapi-mcp",
13-
version="0.1.5",
13+
version="0.1.6",
1414
description="Automatic MCP server generator for FastAPI applications - converts FastAPI endpoints to MCP tools for LLM integration",
1515
author="Tadata Inc.",
1616
author_email="[email protected]",

tests/test_tool_generation.py

-16
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ def test_tool_generation_basic(sample_app):
7171
assert hasattr(tool, "parameters"), "Tool missing 'parameters' property"
7272
assert hasattr(tool, "fn_metadata"), "Tool missing 'fn_metadata' property"
7373

74-
# Skip MCP's internal tool that doesn't follow the same patterns
75-
if tool.name == "handle_mcp_connection_mcp_get":
76-
continue
77-
7874
# With describe_all_responses=False by default, description should only include success response code
7975
assert "200" in tool.description, f"Expected success response code in description for {tool.name}"
8076
assert "422" not in tool.description, f"Expected not to see 422 response in tool description for {tool.name}"
@@ -104,10 +100,6 @@ def test_tool_generation_with_full_schema(sample_app):
104100

105101
# Check all tools have the appropriate schema information
106102
for tool in tools:
107-
# Skip MCP's internal tool that doesn't follow the same patterns
108-
if tool.name == "handle_mcp_connection_mcp_get":
109-
continue
110-
111103
description = tool.description
112104
# Check that the tool includes information about the Item schema
113105
assert "Item" in description, f"Item schema should be included in the description for {tool.name}"
@@ -126,10 +118,6 @@ def test_tool_generation_with_all_responses(sample_app):
126118

127119
# Check all API tools include all response status codes
128120
for tool in tools:
129-
# Skip MCP's internal tool that doesn't follow the same patterns
130-
if tool.name == "handle_mcp_connection_mcp_get":
131-
continue
132-
133121
assert "200" in tool.description, f"Expected success response code in description for {tool.name}"
134122
assert "422" in tool.description, f"Expected 422 response code in description for {tool.name}"
135123

@@ -150,10 +138,6 @@ def test_tool_generation_with_all_responses_and_full_schema(sample_app):
150138

151139
# Check all tools include all response status codes and the full output schema
152140
for tool in tools:
153-
# Skip MCP's internal tool that doesn't follow the same patterns
154-
if tool.name == "handle_mcp_connection_mcp_get":
155-
continue
156-
157141
assert "200" in tool.description, f"Expected success response code in description for {tool.name}"
158142
assert "422" in tool.description, f"Expected 422 response code in description for {tool.name}"
159143
assert "Output Schema" in tool.description, f"Expected output schema in description for {tool.name}"

uv.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)