Перейти к основному содержимому

MCP Server

The orchestrator embeds an MCP (Model Context Protocol) server that agent runtimes connect to as clients. This is how agents access platform capabilities — push notifications, user data, conversation history, artifacts, and workflows — without holding credentials.


How It Works

The MCP server is mounted at /mcp/v1 on the orchestrator. Agent runtimes connect via HTTP with Server-Sent Events (SSE) for streaming.

  1. At startup, the runtime discovers available tools by calling ListTools on the MCP endpoint
  2. During a conversation turn, the agent's LLM decides to call a tool
  3. The runtime sends a tools/call request to the MCP server
  4. The orchestrator authenticates, executes the tool, audits the call, and returns the result
  5. The result is fed back into the LLM context
к сведению

No tool names are hardcoded in the runtime. All tools are discovered dynamically from the MCP server. Adding a new tool to the orchestrator makes it available to all runtimes without a pod restart.


Authentication

Every MCP request carries a Bearer token in the Authorization header:

  • Token format: Base64URL payload + HMAC-SHA256 signature
  • Payload: Encodes the calling user ID and workspace ID
  • Validation: Constant-time signature comparison on every request
  • Signing key: Shared between orchestrator and runtime via Kubernetes Secret

The orchestrator extracts the user and workspace identity from the token — tool handlers never need to parse auth themselves.


Tool Categories

The MCP server registers tools across 6 categories:

Push Notifications

ToolDescription
send_push_notificationSend a push notification to the user's mobile device

User Context

ToolDescription
get_user_profileFetch user name, email, nickname, and preferences
get_workspace_infoGet workspace details and agent list
list_conversationsList all conversations with titles and timestamps
search_past_messagesSearch messages by keyword within conversations

Agent Collaboration

ToolDescription
create_agent_historyRecord notable events in an agent's history log
send_message_to_agentSend a message to another agent and get a response

Artifact Management

ToolDescription
create_artifactCreate a shared document or code artifact
read_artifactRead artifact content with version history
update_artifactUpdate artifact (optimistic locking via expected_version)
review_artifactReview with outcome: approved, changes_requested, or commented

Workflow Engine

ToolDescription
create_workflowDefine a multi-step agent workflow
trigger_workflowStart a workflow with optional initial context
check_workflow_statusCheck workflow progress
list_workflowsList all workflow definitions

Memory Palace

19 tools for the memory system — see the Memory Palace Guide for full details.


Audit Logging

Every MCP tool call is logged to the database:

  • Tool name
  • Input arguments (capped at 4,096 bytes)
  • Output result (capped at 4,096 bytes)
  • User ID and workspace ID
  • Success/failure status
  • Duration in milliseconds

This audit trail is accessible via the agent history API and is used for compliance reporting.


Adding a New MCP Tool

  1. Add a register* function in internal/orchestrator/server/mcp/ (e.g., tools_myfeature.go)
  2. Call it from registerTools() in register.go
  3. The tool receives *Deps with access to all services (DB, logger, signing key, MCPService, AuditService, drawer repo, KG, embedder, etc.)
  4. Use sdkmcp.AddTool(server, toolDef, handler) to register
  5. The runtime discovers the new tool automatically on next ListTools call

Source Files

FilePurpose
internal/orchestrator/server/mcp/server.goMCP server creation, auth middleware, handler
internal/orchestrator/server/mcp/register.goTool registration orchestrator
internal/orchestrator/server/mcp/deps.goShared dependencies struct
internal/orchestrator/server/mcp/tools_memory.goMemory Palace tools (19 tools)
internal/orchestrator/server/mcp/tools_*.goOther tool categories

What's next: See the Agent Runtime Tools page for how tools are consumed by agents, or the gRPC Contracts for the streaming protocol.