
Company News
Socket Joins New OpenJS Program to Fund Node.js Security Work
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.
@modelcontextprotocol/node
Advanced tools
Model Context Protocol implementation for TypeScript - Node.js middleware
@modelcontextprotocol/nodeNode.js adapters for the MCP TypeScript server SDK.
This package is a thin Node.js integration layer for @modelcontextprotocol/server. It provides a Streamable HTTP transport that works with Node’s IncomingMessage / ServerResponse.
For web‑standard runtimes (Cloudflare Workers, Deno, Bun, etc.), use WebStandardStreamableHTTPServerTransport from @modelcontextprotocol/server directly.
npm install @modelcontextprotocol/server @modelcontextprotocol/node
NodeStreamableHTTPServerTransportStreamableHTTPServerTransportOptions (type alias for WebStandardStreamableHTTPServerTransportOptions)toNodeHandler(handler, opts?) — adapt a web-standard { fetch } MCP handler to a Node (req, res, parsedBody?) handlerhostHeaderValidation(allowedHostnames) / localhostHostValidation() — Host header guards for hand-wired node:http serversoriginValidation(allowedOriginHostnames) / localhostOriginValidation() — Origin header guards for hand-wired node:http serversToNodeHandlerOptions, FetchLikeMcpHandler, NodeMcpRequestHandler (types for toNodeHandler)toWebRequest(req, parsedBody?, opts?) — the Node IncomingMessage → web-standard Request conversion toNodeHandler performs internally, exported on its own (for example to feed isLegacyRequest() from a hand-wired (req, res) handler)ToWebRequestOptions (options type for toWebRequest)NodeIncomingMessageLike, NodeServerResponseLike (structural Node request/response shapes)import { createMcpExpressApp } from '@modelcontextprotocol/express';
import { NodeStreamableHTTPServerTransport } from '@modelcontextprotocol/node';
import { McpServer } from '@modelcontextprotocol/server';
const server = new McpServer({ name: 'my-server', version: '1.0.0' });
const app = createMcpExpressApp();
app.post('/mcp', async (req, res) => {
const transport = new NodeStreamableHTTPServerTransport({ sessionIdGenerator: undefined });
await server.connect(transport);
// If you use Express JSON parsing, pass the pre-parsed body to avoid re-reading the stream.
await transport.handleRequest(req, res, req.body);
});
http serverPlain node:http has no middleware chain, so bind loopback explicitly and
compose the Host/Origin guards in front of the transport — matching the
defaults the framework app factories (createMcpExpressApp,
createMcpHonoApp, createMcpFastifyApp) apply for you. The guards answer
rejected requests with 403 themselves and return false, so the handler
must not touch the request further.
import { createServer } from 'node:http';
import { localhostHostValidation, localhostOriginValidation, NodeStreamableHTTPServerTransport } from '@modelcontextprotocol/node';
import { McpServer } from '@modelcontextprotocol/server';
const server = new McpServer({ name: 'my-server', version: '1.0.0' });
const validateHost = localhostHostValidation();
const validateOrigin = localhostOriginValidation();
createServer(async (req, res) => {
if (!validateHost(req, res) || !validateOrigin(req, res)) return;
const transport = new NodeStreamableHTTPServerTransport({ sessionIdGenerator: undefined });
await server.connect(transport);
await transport.handleRequest(req, res);
}).listen(3000, '127.0.0.1');
FAQs
Model Context Protocol implementation for TypeScript - Node.js middleware
The npm package @modelcontextprotocol/node receives a total of 723,940 weekly downloads. As such, @modelcontextprotocol/node popularity was classified as popular.
We found that @modelcontextprotocol/node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.

Company News
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.

Security News
Two compromised GitHub Actions were re-enabled with malicious tags intact, exposing thousands of downstream repositories to Mini Shai-Hulud.

Research
/Security News
A malicious Firefox extension fetches its payload after installation to evade detection, steal Google session cookies, and automate account takeover.