This commit is contained in:
2026-03-09 18:30:23 +08:00
parent fffee149ec
commit 621023bf34
10 changed files with 955 additions and 241 deletions
+3 -6
View File
@@ -1,10 +1,10 @@
from fastmcp import FastMCP
from main import application
from fastmcp.server.openapi import MCPType, HTTPRoute
from fastmcp.server.providers.openapi import MCPType
from config.main import config
def custom_route_mapper(route: HTTPRoute, mcp_type: MCPType) -> MCPType | None:
def custom_route_mapper(route, 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"]:
@@ -16,10 +16,7 @@ mcp = FastMCP.from_fastapi(
app=application,
name="Dcalc_MCP",
instructions="DNF相关的MCP服务",
timeout=60,
host="0.0.0.0",
port=config.MCPPORT,
route_map_fn=custom_route_mapper,
)
mcp.run(transport="streamable-http")
mcp.run(transport="streamable-http", host="0.0.0.0", port=config.MCPPORT)