Skip to main content

Module mcp_bridge

Module mcp_bridge 

Source
Expand description

Generic MCP-to-NATS bridge.

McpBridge exposes any NATS service as Model Context Protocol (MCP) tools. It runs as a stdio MCP server (JSON-RPC 2.0 over stdin/stdout), routing tools/list and tools/call requests to the correct NATS services.

§Protocol

MCP uses JSON-RPC 2.0 over stdio. Each message is a newline-delimited JSON object.

tools/list flow:

  1. Client sends {"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}
  2. Bridge sends {service}.cmd.tools to each configured NATS service
  3. Returns combined tool list from all services

tools/call flow:

  1. Client sends {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"code_search","arguments":{...}}}
  2. Bridge routes to {service}.cmd.{tool_suffix} via NATS request/reply
  3. Returns NATS response as MCP content

§Tool naming convention

NATS handler commands use underscore-separated suffixes (e.g. codegraph.cmd.search). MCP tool names use the full code_{command} format (e.g. code_search). The bridge maps: code_searchcodegraph.cmd.search

§Binary

nusy-mcp-bridge --nats nats://192.168.8.110:4222 --services codegraph

Structs§

McpBridge
Generic MCP-to-NATS bridge.
ServiceConfig
Configuration for a single NATS service exposed via MCP.