Skip to main content

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

Full sequence:

Supported MCP Methods

tools/list Resolution

Tool list is built in three layers using a Map for deduplication (higher priority overrides lower):
Private tools are named as {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:
This writes a timestamp to 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):
  1. Gateway strips username prefix → resolves actual skillId
  2. Constructs internal request to /v1/execute with user’s Authorization header
  3. handleExecuteSkill performs full auth → billing → execution pipeline
  4. Result formatted via formatToolResponse() → pushed to SSE stream as event: message