This commit is contained in:
2025-06-09 03:15:04 +08:00
parent 8226a78482
commit 343e8c3611
6 changed files with 179 additions and 61 deletions
+23
View File
@@ -0,0 +1,23 @@
from fastmcp import FastMCP
from main import application
from fastmcp.server.openapi import RouteMap, MCPType, HTTPRoute
def custom_route_mapper(route: HTTPRoute, mcp_type: MCPType) -> MCPType | None:
"""Advanced route type mapping."""
# Convert all admin routes to tools regardless of HTTP method
if "/open/" in route.path and route.method in ["GET"]:
return MCPType.TOOL
else:
return MCPType.EXCLUDE
mcp = FastMCP.from_fastapi(
app=application,
name="My Custom Server",
timeout=5.0, # Custom component names
port=1486,
route_map_fn=custom_route_mapper,
)
mcp.run(transport="streamable-http")