Skip to main content

Module mcp_service

Module mcp_service 

Source
Expand description

MCP (Model Context Protocol) service — UUID-keyed tool registry

This service provides an MCP-compliant interface for AI coding assistants (Claude Code, Cursor, etc.) to interact with hyprstream via:

  • HTTP/SSE transport (for web clients with streaming)
  • ZMQ control plane (for internal service communication)

§Architecture

Tools are registered in a HashMap<Uuid, ToolEntry>, announced and called by UUID. Sync tools return JSON via ZMQ REQ/REP. Streaming tools use StreamHandle (DH + SUB + HMAC verify) to bridge ZMQ streams to MCP SSE.

§Token Authentication

The service reads HYPRSTREAM_TOKEN from environment (stdio) or Authorization: Bearer <token> header (HTTP) and validates:

  1. JWT signature via Ed25519
  2. Token expiration
  3. Backend services enforce authorization via Casbin policies

Structs§

McpConfig
Configuration for McpService
McpService
MCP service implementation — UUID-keyed tool registry
ToolCallContext
Context passed to handler — carries auth + optional ServiceContext
ToolRegistry
UUID-keyed tool registry

Enums§

ToolResult
Handler return type — sync or streaming

Constants§

SERVICE_NAME
Service name for registration