All Projects

mcp-kit: Cross-Runtime MCP Toolkit

Model Context Protocol toolkit for building servers across Node.js, Bun, Cloudflare Workers, and edge platforms.

TypeScript Hono MCP Edge Runtime

The Problem

Building Model Context Protocol (MCP) servers today means choosing a runtime and getting locked in. Node.js servers don’t run on edge. Edge workers can’t do filesystem operations. Developers end up maintaining separate codebases for different deployment targets.

The Solution

mcp-kit keeps one server codebase portable across Node.js, Bun, Cloudflare Workers, Vercel Edge, and Netlify Edge. It uses Hono for the HTTP layer, runtime detection, and conditional feature loading.

Benchmark: Native Cold Start

PlatformDeploymentCold Start (Native)
Node.jsLocal (M1 Pro)83ms
BunLocal (M1 Pro)111ms

mcp-kit uses Hono’s lightweight middleware model and keeps tool handler logic shared across runtimes. The point of the benchmark is not to crown a runtime; it is to keep startup cost visible while preserving portability.

Reproduction: To verify the baseline startup latency of these runtimes on your own machine:

  1. Clone the Benchmark:
    git clone https://gist.github.com/omar391/da94c3ea15f5dc31e136cb33dca51b4a mcp-bench
    cd mcp-bench
  2. Execute the Script:
    chmod +x mcp_bench.sh && ./mcp_bench.sh

Universal Runtime Abstraction

The core of mcp-kit is a runtime abstraction layer that detects the environment and swaps implementations for platform-specific capabilities (like fs vs. KV).

// Universal tool handler with runtime-aware capability detection
export const filesystemTool = defineTool({
  name: "read_file",
  handler: async (args, { runtime }) => {
    if (runtime.hasFilesystem) {
      return await runtime.fs.readFile(args.path);
    }
    // Transparently fall back to KV or S3 on edge
    return await runtime.storage.get(args.path);
  },
});

Key Features

  • Runtime Support: Single codebase for Node.js, Bun, Cloudflare Workers, Vercel Edge, Netlify Edge
  • Hono Framework: Lightweight HTTP framework chosen for fast startup and cross-runtime portability
  • Cross-Runtime Compatibility: Runtime detection and conditional feature loading
  • Type-Safe Tool Handlers: Strongly typed MCP tool definitions with validation
  • Multi-Target Builds: Separate optimized builds for different runtime environments
  • Multi-Instance Coordination: Version-aware upgrade flow for deployments

Architecture

I split universal features from local-only features, so edge deployments avoid filesystem/process code while local deployments can keep those capabilities.