Overview
UniSkill Gateway implements the Model Context Protocol (MCP) via Cloudflare Durable Objects, enabling persistent stateful SSE connections for AI agent integrations (Claude Desktop, Cursor, Cline, OpenClaw).Session Lifecycle
Supported MCP Methods
tools/list Resolution
Tool list is built in three layers using a Map for deduplication (higher priority overrides lower):{username}_{skillId} (max 64 chars, special chars → _).
Key Design Decisions
Global Tool Refresh
When skills are updated, trigger a broadcast to all active MCP sessions:mcp_broadcast:tools_changed in KV. Sessions check this key to invalidate their tool list cache on the next tools/list call.
Private Tool Execution Flow
When a user calls a private tool (e.g.alice_my_custom_skill):
- Gateway strips username prefix → resolves actual
skillId - Constructs internal request to
/v1/executewith user’sAuthorizationheader handleExecuteSkillperforms full auth → billing → execution pipeline- Result formatted via
formatToolResponse()→ pushed to SSE stream asevent: message