Skip to content

Commit 5e6544b

Browse files
committed
exclude mcp endpoints from openapi schema
1 parent 0c286e2 commit 5e6544b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fastapi_mcp/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def mount(self, router: Optional[FastAPI | APIRouter] = None, mount_path: str =
142142
sse_transport = FastApiSseTransport(f"{mount_path}/messages/")
143143

144144
# Route for MCP connection
145-
@router.get(mount_path)
145+
@router.get(mount_path, include_in_schema=False)
146146
async def handle_mcp_connection(request: Request):
147147
async with sse_transport.connect_sse(request.scope, request.receive, request._send) as (reader, writer):
148148
await self.server.run(
@@ -152,7 +152,7 @@ async def handle_mcp_connection(request: Request):
152152
)
153153

154154
# Route for MCP messages
155-
@router.post(f"{mount_path}/messages/")
155+
@router.post(f"{mount_path}/messages/", include_in_schema=False)
156156
async def handle_post_message(request: Request):
157157
return await sse_transport.handle_fastapi_post_message(request)
158158

0 commit comments

Comments
 (0)