Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/hide handle mcp connection #31

Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.6]

### Fixed
- [Issue #23](https://github.com/tadata-org/fastapi_mcp/issues/23): Hide handle_mcp_connection tool.

## [0.1.5]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion fastapi_mcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Created by Tadata Inc. (https://github.com/tadata-org)
"""

__version__ = "0.1.5"
__version__ = "0.1.6"

from .server import add_mcp_server, create_mcp_server, mount_mcp_server
from .http_tools import create_mcp_tools_from_openapi
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "fastapi-mcp"
version = "0.1.5"
version = "0.1.6"
description = "Automatic MCP server generator for FastAPI applications - converts FastAPI endpoints to MCP tools for LLM integration"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="fastapi-mcp",
version="0.1.5",
version="0.1.6",
description="Automatic MCP server generator for FastAPI applications - converts FastAPI endpoints to MCP tools for LLM integration",
author="Tadata Inc.",
author_email="[email protected]",
Expand Down
16 changes: 0 additions & 16 deletions tests/test_tool_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ def test_tool_generation_basic(sample_app):
assert hasattr(tool, "parameters"), "Tool missing 'parameters' property"
assert hasattr(tool, "fn_metadata"), "Tool missing 'fn_metadata' property"

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

# With describe_all_responses=False by default, description should only include success response code
assert "200" in tool.description, f"Expected success response code in description for {tool.name}"
assert "422" not in tool.description, f"Expected not to see 422 response in tool description for {tool.name}"
Expand Down Expand Up @@ -104,10 +100,6 @@ def test_tool_generation_with_full_schema(sample_app):

# Check all tools have the appropriate schema information
for tool in tools:
# Skip MCP's internal tool that doesn't follow the same patterns
if tool.name == "handle_mcp_connection_mcp_get":
continue

description = tool.description
# Check that the tool includes information about the Item schema
assert "Item" in description, f"Item schema should be included in the description for {tool.name}"
Expand All @@ -126,10 +118,6 @@ def test_tool_generation_with_all_responses(sample_app):

# Check all API tools include all response status codes
for tool in tools:
# Skip MCP's internal tool that doesn't follow the same patterns
if tool.name == "handle_mcp_connection_mcp_get":
continue

assert "200" in tool.description, f"Expected success response code in description for {tool.name}"
assert "422" in tool.description, f"Expected 422 response code in description for {tool.name}"

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

# Check all tools include all response status codes and the full output schema
for tool in tools:
# Skip MCP's internal tool that doesn't follow the same patterns
if tool.name == "handle_mcp_connection_mcp_get":
continue

assert "200" in tool.description, f"Expected success response code in description for {tool.name}"
assert "422" in tool.description, f"Expected 422 response code in description for {tool.name}"
assert "Output Schema" in tool.description, f"Expected output schema in description for {tool.name}"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.