備註
MCP Apps 的 .NET AG-UI 整合相容性文件即將發布。
代理框架Python AG-UI端點相容於 AG-UI 生態系統的 MCP Apps 功能。 MCP Apps 允許前端應用程式將 MCP 驅動的工具與資源嵌入 AG-UI 代理中——Python端無需更改。
建築
MCP Apps 支援由 CopilotKit 的 TypeScript 提供MCPAppsMiddleware,該 TypeScript @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 Runtime 或 Node.js 代理:
// 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 MCP Apps 文件。
不在範圍內的內容
以下不是 Python AG-UI 集成的一部分:
-
No Python
MCPAppsMiddleware:MCP Apps 中介軟體僅在 TypeScript 層執行。 - FastAPI 無法處理 iframe 代理的 MCP 請求:資源代理由 Node.js 中介軟體進行處理。
-
沒有 Python 端
ui/resourceUri的發現:資源 URI 的解析是中介軟體的考量。
如果你的應用程式不需要 MCP Apps 中介軟體層,你的代理框架 AG-UI 端點可以直接與任何 AG-UI 相容的客戶端運作。