MCP 應用程式與 AG-UI 的相容性

MAF 不提供 MCP Apps 專屬的設定或執行時行為。 MCP 應用程式的支援是由 MAF AG-UI 端點之外的中介軟體實作,該端點持續接收標準 AG-UI 請求。

關於中介軟體設定與相容性需求,請使用所選 AG-UI 客戶端或中介軟體的文件。

代理框架Python AG-UI端點相容於 AG-UI 生態系統的 MCP Apps 功能。 MCP Apps 允許前端應用程式將 MCP 驅動的工具與資源嵌入 AG-UI 代理中——Python端無需更改。

Architecture

MCP Apps 支援由 CopilotKit 的 TypeScript MCPAppsMiddleware (@ag-ui/mcp-apps-middleware) 提供,它位於前端與您的 Agent Framework 後端之間:

┌─────────────────────────┐
│  Frontend               │
│  (CopilotKit / AG-UI)   │
└────────┬────────────────┘
         │
         ▼
┌─────────────────────────┐
│  CopilotKit Runtime /   │
│  Node.js Proxy          │
│  + MCPAppsMiddleware    │
└────────┬────────────────┘
         │ AG-UI protocol
         ▼
┌─────────────────────────┐
│  Agent Framework        │
│  FastAPI AG-UI Endpoint │
└─────────────────────────┘

中介軟體層負責 MCP 工具偵測、iframe 代理資源請求及 ui/resourceUri 解析。 你的Python AG-UI端點接收標準的 AG-UI 請求,卻不知道 MCP Apps 層。

不需要 Python 端的變更

MCP Apps 的整合完全由 TypeScript 中介軟體負責。 您現有的 add_agent_framework_fastapi_endpoint() 設定可以依現狀運作:

from agent_framework import Agent
from agent_framework.ag_ui import add_agent_framework_fastapi_endpoint
from fastapi import FastAPI

app = FastAPI()
agent = Agent(name="my-agent", instructions="...", client=chat_client)

# This endpoint is MCP Apps-compatible with no additional configuration
add_agent_framework_fastapi_endpoint(app, agent, "/")

這種做法與 MCP Apps 與其他 AG-UI Python 整合的運作方式一致——MCP Apps 層始終位於 TypeScript 中介軟體中,而非Python後端。

設定中介軟體

若要在 Agent Framework 後端使用 MCP Apps,請設定包含 MCPAppsMiddleware 且指向您的 Python 端點的 CopilotKit 執行階段或 Node.js Proxy:

// Example Node.js proxy configuration (TypeScript)
import { MCPAppsMiddleware } from "@ag-ui/mcp-apps-middleware";

const middleware = new MCPAppsMiddleware({
  agents: [
    {
      name: "my-agent",
      url: "http://localhost:8888/",  // Your MAF AG-UI endpoint
    },
  ],
  mcpApps: [
    // MCP app configurations
  ],
});

完整設定說明請參閱 CopilotKit MCP Apps 文件 及 AG-UI agentic Protocols 文件。

不在範圍內的內容

以下不是 Python AG-UI 集成的一部分:

  • No Python MCPAppsMiddleware:MCP Apps 中介軟體僅在 TypeScript 層執行。
  • 無需 FastAPI 處理 iframe Proxy 的 MCP 要求:資源 Proxy 由 Node.js 中介軟體處理。
  • 無需 Python 端 ui/resourceUri 探索:資源 URI 解析是中介軟體的關注點。

如果你的應用程式不需要 MCP Apps 中介軟體層,你的代理框架 AG-UI 端點可以直接與任何 AG-UI 相容的客戶端運作。

下一步

其他資源

MAF Go 不提供 MCP Apps 專屬的設定或執行時行為。 MCP 應用程式的支援是由 MAF AG-UI 端點之外的中介軟體實作。