
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
expressjs-mcp
Advanced tools
Expose your Express endpoints as MCP tools with zero configuration, schema preservation, and streaming support
Expose your Express endpoints as MCP tools (mount to your app or run a standalone HTTP gateway), preserving schemas and auth behavior.
npx expressjs-mcp
and bunx expressjs-mcp
# Install globally or locally
npm install -g expressjs-mcp
# or with pnpm
pnpm add -g expressjs-mcp
# Use with npx (no installation required)
npx expressjs-mcp init
git clone https://github.com/bowen31337/expressjs_mcp.git
cd expressjs_mcp
pnpm install && pnpm build
# Initialize in your project (works with npm package or locally built)
npx expressjs-mcp init
# or if installed locally: node bin/express-mcp.cjs init
# Start your server
node server.js
# Test connection
npx expressjs-mcp test --url http://localhost:3000/mcp
# or if installed locally: node bin/express-mcp.cjs test --url http://localhost:3000/mcp
npm install expressjs-mcp
# or
pnpm add expressjs-mcp
Express-MCP now includes a native MCP server using the official @modelcontextprotocol/sdk
:
# Connect to your Express app
npx expressjs-mcp --url http://localhost:3000/mcp
# With debug logging
npx expressjs-mcp --debug
import express from 'express';
import { ExpressMCP } from 'expressjs-mcp';
const app = express();
app.use(express.json());
app.get('/hello', (_req, res) => res.json({ message: 'world' }));
const mcp = new ExpressMCP(app, { mountPath: '/mcp' });
await mcp.init();
mcp.mount('/mcp');
Once your Express server is running with MCP endpoints, you need to configure your MCP client to connect to it. Here are instructions for popular MCP clients:
Open Cursor Settings:
Cmd/Ctrl + ,
to open settingsAdd MCP Server Configuration:
{
"mcpServers": {
"expressjs-mcp": {
"command": "node",
"args": ["/path/to/your/project/server.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}
Alternative: Use Native MCP Server:
{
"mcpServers": {
"expressjs-mcp": {
"command": "npx",
"args": ["expressjs-mcp", "--url", "http://localhost:3000/mcp"]
}
}
}
Edit Configuration File:
claude_desktop_config.json
in your Claude Desktop settings~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
Add MCP Server:
{
"mcpServers": {
"expressjs-mcp": {
"command": "node",
"args": ["/absolute/path/to/your/project/server.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}
Restart Claude Desktop after making changes
Access MCP Settings:
Add Server Configuration:
{
"mcpServers": {
"expressjs-mcp": {
"command": "node",
"args": ["/path/to/your/project/server.js"]
}
}
}
Install MCP Extension:
Configure in settings.json:
{
"mcp.servers": {
"expressjs-mcp": {
"command": "node",
"args": ["/path/to/your/project/server.js"]
}
}
}
Most MCP clients follow a similar configuration pattern:
{
"mcpServers": {
"expressjs-mcp": {
"command": "node",
"args": ["/path/to/your/project/server.js"],
"env": {
"NODE_ENV": "production"
}
}
}
}
command
: The command to run (usually node
for JavaScript/TypeScript)args
: Array of arguments (path to your server file)env
: Environment variables (optional)cwd
: Working directory (optional)Start your Express server:
node server.js
Test MCP endpoints:
# Check available tools
curl http://localhost:3000/mcp/tools
# Test a tool invocation
curl -X POST http://localhost:3000/mcp/invoke \
-H "Content-Type: application/json" \
-d '{"toolName": "GET_/hello", "args": {}}'
Verify in your MCP client:
Common Issues:
NODE_ENV=production
for better performanceDebug Mode:
# Run with debug logging
NODE_ENV=development node server.js
# Or use the native MCP server with debug
npx expressjs-mcp --url http://localhost:3000/mcp --debug
Check MCP Server Status:
# Test if MCP endpoints are working
curl http://localhost:3000/mcp/tools | jq .
# Check server health
curl http://localhost:3000/health
Express MCP supports three types of streaming for real-time data:
app.get('/api/chunked', (req, res) => {
res.setHeader('Transfer-Encoding', 'chunked');
res.write('Processing...\n');
// Stream data in chunks
});
app.get('/api/sse', (req, res) => {
res.setHeader('Content-Type', 'text/event-stream');
res.setHeader('Cache-Control', 'no-cache');
let count = 0;
const interval = setInterval(() => {
res.write(`data: ${JSON.stringify({ count: ++count })}\n\n`);
if (count >= 10) {
clearInterval(interval);
res.end();
}
}, 1000);
});
app.get('/api/ndjson', (req, res) => {
res.setHeader('Content-Type', 'application/x-ndjson');
const data = [{ id: 1 }, { id: 2 }];
data.forEach(item => {
res.write(JSON.stringify(item) + '\n');
});
res.end();
});
# HTTP Streaming via MCP
curl -X POST http://localhost:3000/mcp/invoke \
-H "Content-Type: application/json" \
-d '{"toolName": "GET /api/stream", "args": {}, "streaming": true}'
# stdio Streaming via MCP Bridge (npm package)
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"GET /api/ndjson","arguments":{"_streaming":true}}}' | \
npx expressjs-mcp bridge
# Test with native MCP server:
npx expressjs-mcp --url http://localhost:3000/mcp --debug
# Direct endpoint testing
curl http://localhost:3000/api/sse # SSE
curl http://localhost:3000/api/ndjson # NDJSON
curl http://localhost:3000/api/chunked # Chunked
pnpm install
pnpm test # Run tests
pnpm build # Build for production
pnpm lint # Check code quality
FAQs
Expose your Express endpoints as MCP tools with zero configuration, schema preservation, and streaming support
We found that expressjs-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.