单一 Connection 服务器
Connection 命名
windsor/gmail-mcp -> gmail-mcp。
如果你在 dispatch("gmail", ...) 中硬编码了不同的名称,请求会失败。对于只有一个 Connection 的服务器,请使用自动分发(auto-dispatch)。
支持多个 Connection 的服务器
connection_name:
Connection 的命名与解析方式
gmail = Connection(secrets=SecretKeys(token="GMAIL_TOKEN")) # 无需名称
async def _req(method, path, body=None):
ctx = get_context()
return await ctx.dispatch(HttpRequest(method=method, path=path, body=body))
windsor/gmail-mcp -> gmail-mcp。
如果你在 dispatch("gmail", ...) 中硬编码了不同的名称,请求会失败。对于只有一个 Connection 的服务器,请使用自动分发(auto-dispatch)。
await ctx.dispatch("gmail", HttpRequest(...))
await ctx.dispatch("calendar", HttpRequest(...))
connection_name:
# API creates session with explicit connection name
session = await admin_api.create_oauth_session(
server_id=deployment_id,
scopes=["gmail.readonly"],
connection_name="gmail", # 以此名称存储
)
@tool(description="Debug")
async def debug() -> dict:
ctx = get_context()
return {"connections": list(ctx.runtime.get("connections", {}).keys())}
此页面对您有帮助吗?