MCP Hub
Back to servers

@mazhu/create-mcp-server

Validation Failed

One command to create a production-ready MCP Server. CLI + SDK for building Model Context Protocol servers in TypeScript.

npm131/wk
Stars
1
Updated
Apr 19, 2026
Validated
Apr 28, 2026

Validation Error:

Process exited with code 1. stderr: file:///home/runner/.npm/_npx/b2382e2127dad7f8/node_modules/@mazhu/create-mcp-server/dist/cli/index.js:12 Object.defineProperty(exports, "__esModule", { value: true }); ^ ReferenceError: exports is not defined in ES module scope at file:///home/runner/.npm/_npx/b2382e2127dad7f8/node_modules/@mazhu/create-mcp-server/dist/cli/index.js:12:23 at ModuleJob.run (node:internal/modules/esm/module_job:325:25) at async ModuleLoader.import (node:internal/modules/esm/loade

Quick Install

npx -y @mazhu/create-mcp-server

create-mcp-server

One command to create a production-ready MCP Server

npm version License: MIT

MCP (Model Context Protocol) is the standard for connecting AI assistants like Claude to external tools and data sources. This package provides:

  1. CLI - Scaffold a complete MCP Server project in seconds
  2. SDK - Ergonomic TypeScript API for building servers

Quick Start

# Create a new MCP server project
npx create-mcp-server my-server

# Or start from an example
npx create-mcp-server my-server --example calculator

cd my-server
npm install
npm run dev

That's it! You now have a working MCP Server with:

  • ✅ TypeScript setup
  • ✅ Tool, resource, and prompt examples
  • ✅ Build configuration
  • ✅ Claude Desktop integration guide

CLI Usage

npx create-mcp-server <project-name> [options]

Options:
  --example <name>    Start with an example (calculator, filesystem, weather, github, database)
  -h, --help          Show help
  -v, --version       Show version

Examples

ExampleDescription
calculatorMath operations (add, subtract, multiply, divide, power, sqrt)
filesystemFile operations (read, write, list, info, create, delete)
weatherWeather data via wttr.in (current, forecast)
githubGitHub API (repo info, issues, user data)
databaseDatabase operations (query, insert, create table)

SDK Usage

The generated project uses @modelcontextprotocol/sdk directly. Here's the pattern:

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

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

// Register a tool
server.tool(
  "greet",
  "Greet someone by name",
  { name: z.string().describe("Name to greet") },
  async ({ name }) => ({
    content: [{ type: "text", text: `Hello, ${name}!` }],
  })
);

// Register a resource
server.resource(
  "config",
  "config://app",
  { description: "Application config" },
  async (uri) => ({
    contents: [{ uri: uri.href, text: JSON.stringify({ version: "1.0.0" }) }],
  })
);

// Register a prompt
server.prompt(
  "help",
  { description: "Get help" },
  async () => ({
    messages: [{ role: "user", content: { type: "text", text: "How can I help?" } }],
  })
);

// Start the server
const transport = new StdioServerTransport();
await server.connect(transport);

Using with Claude Desktop

Add your server to Claude Desktop's config:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["/path/to/my-server/dist/index.js"]
    }
  }
}

Restart Claude Desktop and your tools will be available!

Project Structure

my-server/
├── src/
│   └── index.ts      # Server entry point
├── dist/             # Compiled JavaScript
├── package.json
├── tsconfig.json
└── README.md

API Reference

Tools

Tools let AI models invoke actions on your server:

server.tool(
  "tool-name",           // Unique identifier
  "Description",         // Human-readable description
  {                      // Input schema (Zod)
    param: z.string(),
  },
  async (args) => {      // Handler
    return {
      content: [{ type: "text", text: "result" }],
    };
  }
);

Resources

Resources expose read-only data:

server.resource(
  "resource-name",
  "resource://uri",      // URI pattern
  { description: "..." },
  async (uri) => ({
    contents: [{ uri: uri.href, text: "data" }],
  })
);

Prompts

Prompts are reusable templates:

server.prompt(
  "prompt-name",
  { description: "..." },
  async () => ({
    messages: [
      { role: "user", content: { type: "text", text: "..." } },
    ],
  })
);

Why create-mcp-server?

  • Zero config - Works out of the box
  • Type-safe - Full TypeScript support with Zod schemas
  • Production-ready - Proper build setup, error handling, docs
  • Examples - Real-world examples to learn from
  • Minimal deps - Only @modelcontextprotocol/sdk and zod

Comparison

Featurecreate-mcp-serverManual Setup
Time to first tool~30 seconds~30 minutes
TypeScript config✅ IncludedManual
Build setup✅ IncludedManual
Examples✅ 5 examplesNone
Claude Desktop guide✅ IncludedFind yourself

Contributing

Contributions welcome! See GitHub.

License

MIT © Mike Wang

Links

Reviews

No reviews yet

Sign in to write a review