build: complete upgrade to fastapi 0.141, mcp sdk v2, fastmcp 4 and httpx2

This commit is contained in:
lda
2026-09-06 12:17:15 +07:00 Verified
parent 5b901557bd
commit 6d5b6741fb
42 changed files with 946 additions and 737 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ from __future__ import annotations
from typing import Any
from mcp.server.fastmcp import FastMCP
from mcp.server.mcpserver import MCPServer
from wf_api.models import (
DeleteDeploymentResult,
@@ -20,7 +20,7 @@ from ..workflow_surface.models import RunDeploymentResult
from .service import WfMcpService
def register_artifact_tools(server: FastMCP, service: WfMcpService) -> None:
def register_artifact_tools(server: MCPServer, service: WfMcpService) -> None:
"""Register stable MCP tools for saved workflow artifact inspection."""
handlers = WorkflowSurfaceHandlers(service)
+2 -2
View File
@@ -1,6 +1,6 @@
from __future__ import annotations
from mcp.server.fastmcp import FastMCP
from mcp.server.mcpserver import MCPServer
from .service import WfMcpService
@@ -18,7 +18,7 @@ smallest reusable piece before saving a larger workflow artifact.
"""
def register_broker_prompts(server: FastMCP, service: WfMcpService) -> None:
def register_broker_prompts(server: MCPServer, service: WfMcpService) -> None:
"""Register broker prompt handlers on a FastMCP server."""
@server.prompt(
+2 -2
View File
@@ -3,12 +3,12 @@ from __future__ import annotations
import json
from dataclasses import asdict
from mcp.server.fastmcp import FastMCP
from mcp.server.mcpserver import MCPServer
from .service import WfMcpService
def register_broker_resources(server: FastMCP, service: WfMcpService) -> None:
def register_broker_resources(server: MCPServer, service: WfMcpService) -> None:
"""Register broker resource handlers on a FastMCP server."""
@server.resource("wf-mcp://catalog", name="catalog.all")
+3 -3
View File
@@ -1,6 +1,6 @@
from __future__ import annotations
from mcp.server.fastmcp import FastMCP
from mcp.server.mcpserver import MCPServer
from wf_api import (
WorkflowAdminApi,
@@ -28,8 +28,8 @@ from .service.workflow_operation_context import context_from_service
from .tools import register_broker_tools
def create_broker_server(service: WfMcpService) -> FastMCP:
server = FastMCP(
def create_broker_server(service: WfMcpService) -> MCPServer:
server = MCPServer(
"wf-mcp-broker",
instructions=(
"A broker MCP server over one or more upstream MCP connections. "
@@ -7,9 +7,9 @@ from dataclasses import dataclass, field
from typing import Any
import anyio
import httpx
import httpx2
from mcp.client.streamable_http import StreamableHTTPError
from mcp.shared.exceptions import McpError
from mcp.shared.exceptions import MCPError
from wf_artifacts import (
DependencyDiagnostic,
@@ -399,8 +399,8 @@ _LIVE_SOURCE_CHECK_FAILURES = (
anyio.ClosedResourceError,
anyio.EndOfStream,
anyio.BrokenResourceError,
httpx.HTTPError,
McpError,
httpx2.HTTPError,
MCPError,
StreamableHTTPError,
)
+2 -2
View File
@@ -1,12 +1,12 @@
from __future__ import annotations
from mcp.server.fastmcp import FastMCP
from mcp.server.mcpserver import MCPServer
from ..admin_surface import register_service_admin_tools
from .service import WfMcpService
def register_broker_tools(server: FastMCP, service: WfMcpService) -> None:
def register_broker_tools(server: MCPServer, service: WfMcpService) -> None:
"""Register legacy bare-name broker tools from the shared admin registrar."""
register_service_admin_tools(
server,
+1 -1
View File
@@ -15,7 +15,7 @@ def map_event_to_notifications(event: McpEvent) -> list[mcp_types.ServerNotifica
notification = _list_changed_notification(event)
if notification is None:
return []
return [mcp_types.ServerNotification(notification)]
return [notification]
def _list_changed_notification(
+2 -2
View File
@@ -34,7 +34,7 @@ class FastMcpNotificationContext(Protocol):
async def send_notification(
self,
notification: mcp_types.ServerNotificationType,
notification: mcp_types.ServerNotification,
) -> None: ...
@@ -46,4 +46,4 @@ class FastMcpContextNotificationSink:
async def send_event(self, event: McpEvent) -> None:
for notification in map_event_to_notifications(event):
await self._context.send_notification(notification.root)
await self._context.send_notification(notification)
+4 -4
View File
@@ -9,12 +9,12 @@ from pathlib import Path
from typing import Any, Generic, TypeVar
import anyio
import httpx
import httpx2
from fastmcp import FastMCP
from fastmcp.client.transports.config import MCPConfigTransport
from fastmcp.server.providers.proxy import FastMCPProxy, StatefulProxyClient
from mcp.client.streamable_http import StreamableHTTPError
from mcp.shared.exceptions import McpError
from mcp.shared.exceptions import MCPError
from ..models import BrokerConfig, ConnectionConfig
from ..proxy_config import broker_config_to_fastmcp_config
@@ -33,8 +33,8 @@ _PROXY_LIST_FAILURES = (
anyio.ClosedResourceError,
anyio.EndOfStream,
anyio.BrokenResourceError,
httpx.HTTPError,
McpError,
httpx2.HTTPError,
MCPError,
StreamableHTTPError,
)
logger = logging.getLogger(__name__)