Skip to main content

Model Context Protocol (MCP) Libraries for Node.js 2026

·PkgPulse Team

Anthropic's Model Context Protocol has become the USB standard for AI tool integration — and within 12 months of its release, virtually every major AI development environment (Claude, Cursor, Cline, Continue.dev, VS Code Copilot) adopted it. The npm ecosystem now has a growing set of packages for building MCP servers and clients in Node.js, with the official TypeScript SDK leading the way.

TL;DR

The @modelcontextprotocol/sdk is the official, required foundation for any MCP implementation in Node.js. For faster development with less boilerplate, FastMCP offers a higher-level API built on top of it. MCP is now the de facto standard for giving AI models access to tools, resources, and prompts — and Node.js is the dominant implementation language.

Key Takeaways

  • @modelcontextprotocol/sdk: Official Anthropic SDK, supports stdio and Streamable HTTP transports
  • MCP v2 spec stabilized in early 2026, adding Streamable HTTP as the preferred remote transport
  • FastMCP provides a decorator-style API that reduces MCP server boilerplate by ~70%
  • MCP servers expose three primitives: Tools (callable functions), Resources (readable data), Prompts (reusable templates)
  • Claude Desktop, Cursor, Cline, Continue.dev, and VS Code Copilot all support MCP natively
  • The @modelcontextprotocol/server-filesystem, @modelcontextprotocol/server-github packages are pre-built reference servers
  • MCP clients use the same SDK to connect to any MCP server via stdio or HTTP

What Is the Model Context Protocol?

MCP is an open protocol (created by Anthropic, now maintained by the MCP community) that standardizes how AI models connect to external tools and data sources. Instead of every AI tool implementing its own plugin system, MCP provides a universal interface.

The key insight: instead of building custom integrations for each AI model and each tool, you build one MCP server that exposes your tools, and one MCP client per AI model. This is the same value proposition as USB — one standard connector replaces dozens of proprietary ones.

The Three MCP Primitives

Tools: Functions the model can call (like search_database, read_file, create_ticket) Resources: Data the model can read (like file://path/to/file, database://table/schema) Prompts: Reusable prompt templates with parameters

@modelcontextprotocol/sdk

Package: @modelcontextprotocol/sdk GitHub: modelcontextprotocol/typescript-sdk Current version: 1.x (v2 targeted Q2 2026) License: MIT

This is the official TypeScript SDK for MCP. Every serious MCP implementation in Node.js is built on it.

Installation

npm install @modelcontextprotocol/sdk

Building an MCP Server

import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { z } from 'zod';

const server = new McpServer({
  name: 'my-tools-server',
  version: '1.0.0',
});

// Register a Tool
server.tool(
  'search_docs',
  'Search the documentation',
  {
    query: z.string().describe('Search query'),
    limit: z.number().optional().default(5),
  },
  async ({ query, limit }) => {
    const results = await searchDocumentation(query, limit);
    return {
      content: [{ type: 'text', text: JSON.stringify(results) }],
    };
  }
);

// Register a Resource
server.resource(
  'current_time',
  'Current server time',
  async () => ({
    contents: [{ uri: 'system://time', text: new Date().toISOString() }],
  })
);

// Register a Resource Template (parameterized)
server.resource(
  new ResourceTemplate('file://{path}', { list: undefined }),
  'Read a file',
  async ({ path }) => ({
    contents: [{ uri: `file://${path}`, text: await fs.readFile(path, 'utf-8') }],
  })
);

// Register a Prompt
server.prompt(
  'code_review',
  'Review code for issues',
  { code: z.string(), language: z.string().optional() },
  ({ code, language }) => ({
    messages: [{
      role: 'user',
      content: {
        type: 'text',
        text: `Review this ${language || 'code'} for bugs and improvements:\n\n${code}`,
      },
    }],
  })
);

// Start with stdio transport (for Claude Desktop, Cursor, etc.)
const transport = new StdioServerTransport();
await server.connect(transport);

Streamable HTTP Transport (MCP v2)

For remote MCP servers (accessed over the network rather than as a local process):

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
import express from 'express';

const app = express();
app.use(express.json());

const transports = new Map<string, StreamableHTTPServerTransport>();

app.post('/mcp', async (req, res) => {
  const sessionId = req.headers['mcp-session-id'] as string;

  let transport = transports.get(sessionId);
  if (!transport) {
    transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => sessionId });
    const server = createMcpServer(); // Your server setup
    await server.connect(transport);
    transports.set(sessionId, transport);
  }

  await transport.handleRequest(req, res, req.body);
});

app.listen(3000, () => console.log('MCP server running on :3000'));

Building an MCP Client

import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';

const transport = new StdioClientTransport({
  command: 'node',
  args: ['path/to/mcp-server.js'],
});

const client = new Client({ name: 'my-client', version: '1.0.0' }, {
  capabilities: { tools: {} },
});

await client.connect(transport);

// List available tools
const { tools } = await client.listTools();
console.log('Available tools:', tools.map(t => t.name));

// Call a tool
const result = await client.callTool({
  name: 'search_docs',
  arguments: { query: 'authentication', limit: 3 },
});
console.log(result.content);

await client.close();

FastMCP

Package: fastmcp GitHub: punkpeye/fastmcp GitHub stars: ~3K License: MIT

FastMCP provides a higher-level API that reduces boilerplate significantly:

import { FastMCP } from 'fastmcp';
import { z } from 'zod';

const server = new FastMCP('My Tools Server');

// Tools are defined with a simple decorator-style API
server.addTool({
  name: 'get_weather',
  description: 'Get current weather for a location',
  parameters: z.object({
    location: z.string(),
    units: z.enum(['celsius', 'fahrenheit']).default('celsius'),
  }),
  execute: async ({ location, units }) => {
    const data = await fetchWeather(location, units);
    return `Temperature: ${data.temp}°${units === 'celsius' ? 'C' : 'F'}, ${data.condition}`;
  },
});

server.addResource({
  uri: 'config://app',
  name: 'Application Config',
  description: 'Current application configuration',
  load: async () => ({
    text: JSON.stringify(appConfig),
  }),
});

server.start({ transportType: 'stdio' });

FastMCP also includes a testing CLI tool, authentication support for HTTP transport, and error handling with user-friendly messages.

Pre-Built MCP Servers (Reference Implementations)

Anthropic provides official pre-built MCP servers as npm packages:

# File system access
npm install @modelcontextprotocol/server-filesystem

# GitHub integration
npm install @modelcontextprotocol/server-github

# Web search (Brave)
npm install @modelcontextprotocol/server-brave-search

# PostgreSQL database
npm install @modelcontextprotocol/server-postgres

# Memory (key-value store)
npm install @modelcontextprotocol/server-memory

# Slack
npm install @modelcontextprotocol/server-slack

These are production-ready servers you can run directly:

// Claude Desktop mcp_servers.json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "@modelcontextprotocol/server-filesystem",
        "/Users/yourname/Documents"
      ]
    },
    "github": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-github"],
      "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "your-token" }
    }
  }
}

Express and Hono Middleware Packages

npm install @modelcontextprotocol/express  # Express.js helpers
npm install @modelcontextprotocol/hono     # Hono helpers

These packages simplify adding MCP Streamable HTTP support to existing web servers:

import { Hono } from 'hono';
import { mcpMiddleware } from '@modelcontextprotocol/hono';

const app = new Hono();
app.use('/mcp/*', mcpMiddleware({ server: createMcpServer() }));

Integration with AI Frameworks

With Vercel AI SDK

AI SDK doesn't have native MCP client support yet, but you can bridge them:

import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { tool } from 'ai';
import { z } from 'zod';

// Convert MCP tools to AI SDK tools
async function mcpToolsToAiSdkTools(client: Client) {
  const { tools } = await client.listTools();
  return Object.fromEntries(
    tools.map(mcpTool => [
      mcpTool.name,
      tool({
        description: mcpTool.description || '',
        parameters: z.object({}), // Parse mcpTool.inputSchema
        execute: async (args) => {
          const result = await client.callTool({
            name: mcpTool.name,
            arguments: args,
          });
          return result.content[0]?.text || '';
        },
      }),
    ])
  );
}

With LangChain.js

LangChain has first-class MCP support:

import { MultiServerMCPClient } from '@langchain/mcp-adapters';

const mcpClient = new MultiServerMCPClient({
  filesystem: {
    transport: 'stdio',
    command: 'npx',
    args: ['@modelcontextprotocol/server-filesystem', '/tmp'],
  },
  github: {
    transport: 'stdio',
    command: 'npx',
    args: ['@modelcontextprotocol/server-github'],
    env: { GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_TOKEN },
  },
});

const tools = await mcpClient.getTools();
// tools is array of LangChain Tool objects, ready to use with agents

Comparison: SDK vs FastMCP

Aspect@modelcontextprotocol/sdkFastMCP
OfficialYes (Anthropic)Community
API styleVerbose, explicitConcise, opinionated
BoilerplateHighLow
FlexibilityMaximumGood
TypeScriptExcellentGood
TestingManualBuilt-in test runner
Auth supportManualBuilt-in
HTTP transportManual setupSimplified

Testing Your MCP Server

The MCP ecosystem provides testing tools:

# Official MCP Inspector (web UI for testing servers)
npx @modelcontextprotocol/inspector node path/to/server.js

# FastMCP built-in test runner
fastmcp dev path/to/server.ts

The MCP Inspector opens a web UI where you can list tools, call them with arguments, and inspect responses.

Configuration for Claude Desktop

// ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["/path/to/your/mcp-server.js"],
      "env": {
        "DATABASE_URL": "postgresql://..."
      }
    }
  }
}

The MCP Ecosystem in 2026

MCP has matured significantly since its November 2023 launch:

  • Specification: v2 stabilized, Streamable HTTP replaces SSE as the standard remote transport
  • Adoption: All major AI coding tools support it natively
  • Registry: Unofficial MCP server registries aggregate hundreds of community-built servers
  • Security: Authentication and authorization primitives added in v1.5+

The most common MCP server use cases in production: database access, file system operations, web search, API integrations, internal tooling, and code execution sandboxes.

Explore on PkgPulse

See download trends and version history for MCP packages on PkgPulse.

Comments

Stay Updated

Get the latest package insights, npm trends, and tooling tips delivered to your inbox.