Offers a Node.js library for creating and managing MCP hosts, with support for registering tools dynamically and handling authentication.
Provides full TypeScript definitions and type safety through optional Zod schema validation for tool inputs and parameters.
Integrates with Zod for enhanced type safety and validation, automatically converting Zod schemas to JSON Schema for MCP tool definitions.
MCP Host RPC Bridge
A Node.js library that bridges MCP (Model Context Protocol) tool calls to JSON-RPC function calls. Supports both Unix socket connections (default) and HTTP transport for flexible integration with any application architecture.
Features
🚀 Dual Transport Modes: Unix sockets for local IPC, HTTP for web integration
🔐 JWT Authentication: Secure context passing with cryptographic signatures
🔧 Framework Agnostic: Works with Express, Fastify, Next.js, or raw Node.js
📝 TypeScript Support: Full type definitions included
🎯 Zod Integration: Automatic schema conversion for type-safe tools
Related MCP server: Toolhouse MCP Server
Installation
Quick Start
Socket Mode (Default)
HTTP Mode
Documentation
Socket Mode Guide - Detailed documentation for Unix socket transport
HTTP Mode Guide - Complete guide for HTTP transport integration
Core Concepts
Transport Modes
Socket Mode (default) - Uses Unix domain sockets for high-performance local IPC
HTTP Mode - Uses HTTP POST requests for web integration and remote access
Context-Based Security
Every tool handler receives a verified context object extracted from JWT tokens:
Tool Registration
Tools can be registered with JSON Schema or Zod schemas:
API Reference
new McpHost(options)
Creates a new MCP host instance.
host.registerTool(name, config, handler)
Register a tool with the host.
host.getMCPServerConfig(name, tools, context, options?)
Get MCP server configuration for claude_desktop_config.json.
host.handleHttpRequest(req, res)
Handle HTTP requests (HTTP mode only).
host.start() / host.stop()
Start or stop the host server.
Examples
Check out the examples/ directory for complete examples:
simple-example.js- Basic socket mode usagezod-example.js- Zod schema validationhttp-express-example.js- Express.js HTTP integrationhttp-fastify-example.js- Fastify HTTP integrationhttp-raw-example.js- Raw Node.js HTTP server
Running Examples
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.