Registry / ai-ml / mcp-lite

mcp-lite

JSON →
library0.10.0jsnpmunverified

A lightweight, fetch-first implementation of the Model Context Protocol (MCP) server APIs. v0.10.0, actively developed. Rewrites the TypeScript MCP SDK from scratch, keeping only server essentials: JSON-RPC handling, typed tool definitions, and HTTP+SSE transport using the Fetch API (works on Node, Bun, Cloudflare Workers, Deno, Supabase Edge Functions, browsers with Service Workers). Zero runtime dependencies in core, opt-in adapters for sessions and client calls. Differentiator: minimal footprint, no heavy SDK baggage, Standard Schema support (Zod, Valibot, Effect, ArkType).

npm install mcp-lite
INSTALL
IMPORT
SIG · MCP-LITE
M
mcp-lite
ai-mljavascriptv0.10.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

McpServer
import { McpServer } from 'mcp-lite'
import McpServer from 'mcp-lite'
Named export only. Default import will fail.
StreamableHttpTransport
import { StreamableHttpTransport } from 'mcp-lite'
const { StreamableHttpTransport } = require('mcp-lite')
ESM-only package, require() is not supported.
type ToolHandler
import type { ToolHandler } from 'mcp-lite'
TypeScript users should use 'import type' for type-only imports to avoid runtime overhead.

Sets up a minimal MCP server with Hono, defines a tool with Zod, and binds it to HTTP transport.

import { Hono } from 'hono'; import { McpServer, StreamableHttpTransport } from 'mcp-lite'; import { z } from 'zod'; const mcp = new McpServer({ name: 'example-server', version: '1.0.0', schemaAdapter: (schema) => z.toJSONSchema(schema as z.ZodType), }); const InputSchema = z.object({ location: z.string() }); mcp.tool('getWeather', { description: 'Gets weather information for a location', inputSchema: InputSchema, handler: (args) => ({ content: [{ type: 'text', text: `Weather in ${args.location}: 22°C, sunny` }], }), }); const transport = new StreamableHttpTransport(); const httpHandler = transport.bind(mcp); const app = new Hono(); app.all('/mcp', async (c) => { const response = await httpHandler(c.req.raw); return response; });
Debug
Known issues
breakingMcpServer constructor requires 'schemaAdapter' since v0.8.0
fix
Provide a schemaAdapter function (e.g., (schema) => z.toJSONSchema(schema as z.ZodType)) in the options object.
affects: >=0.8.0
breakingStreamableHttpTransport is now the primary transport; SseHttpTransport removed in v0.9.0
fix
Use StreamableHttpTransport instead of any removed SSE transport.
affects: >=0.9.0
gotchaThe 'structuredContent' property in tool handler response requires an 'outputSchema' defined on the tool; otherwise it is stripped
fix
Add outputSchema to the tool definition to retain structuredContent.
affects: >=0.9.0
gotchaESM-only package: require() will throw ERR_REQUIRE_ESM on Node.js
fix
Use dynamic import() or switch to 'type': 'module' in package.json.
affects: >=0.8.0
deprecatedThe legacy 'McpServer' without options (no config object) is deprecated since v0.9.0
fix
Pass a config object with name and version to McpServer constructor.
affects: >=0.9.0
Errors
Common errors & fixes
Error: Cannot find module 'mcp-lite'
Package not installed or mismatched import path.
fix
Run 'npm install mcp-lite' and ensure import path is correct (no subpath).
TypeError: mcp.tool is not a function
Trying to call tool() on a non-McpServer instance or before initialization.
fix
Ensure you instantiate McpServer correctly: const mcp = new McpServer({ name: '...', version: '...', schemaAdapter: ... });
SyntaxError: Unexpected token 'export'
Node.js version < 12 or CJS context; package is ESM-only.
fix
Use Node >= 12, set 'type': 'module' in package.json, or use dynamic import().
Upgrade
Version history
0.10.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
mcp-lite — npm install mcp-lite · libregistry