Skip to content
1 min read 239 words

Build a Custom MCP Server in 10 Minutes (Node.js)

Create a custom Model Context Protocol server with the official SDK: tools schema, CallTool handlers, and STDIO transport pitfalls.

WorkFlowAI editorial · Trust

#mcp #nodejs #typescript #tutorial

Building a custom MCP server is the fastest way to expose your internal APIs to Claude or Cursor. This walkthrough uses the official TypeScript SDK and STDIO transport.

Engineer building custom MCP server tools and APIs

Register tools with clear names and JSON Schema so agents call them reliably.

Architecture in one minute

  • Client spawns your process.
  • Communication is JSON-RPC over STDIO.
  • You advertise tools via ListTools, handle CallTool.

Critical rule: never pollute stdout

console.log on stdout breaks the protocol. Use stderr for debug logs.

Minimal Node server

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
  CallToolRequestSchema,
  ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";

const server = new Server(
  { name: "system-status-checker", version: "1.0.0" },
  { capabilities: { tools: {} } }
);

server.setRequestHandler(ListToolsRequestSchema, async () => ({
  tools: [
    {
      name: "get_disk_space",
      description: "Report approximate free disk capacity.",
      inputSchema: { type: "object", properties: {}, required: [] },
    },
  ],
}));

server.setRequestHandler(CallToolRequestSchema, async (request) => {
  if (request.params.name === "get_disk_space") {
    console.error("Running disk check...");
    return {
      content: [{ type: "text", text: "Disk status: ok (example)" }],
    };
  }
  throw new Error("Unknown tool");
});

const transport = new StdioServerTransport();
await server.connect(transport);
console.error("MCP server online");

TypeScript source for a custom MCP server project

Keep the server package small; one responsibility per tool works best for agents.

About the publisher

WorkFlowAI is an open catalog of AI automation workflows, MCP servers, and tools. Guides are written to help operators install and evaluate recipes — with honest Verified vs Community labels.

Related reading

Use this in the library

← All posts