@mazhu/create-mcp-server
v1.0.0
Published
One command to create a production-ready MCP Server. CLI + SDK for building Model Context Protocol servers in TypeScript.
Maintainers
Readme
create-mcp-server
One command to create a production-ready MCP Server ⚡
MCP (Model Context Protocol) is the standard for connecting AI assistants like Claude to external tools and data sources. This package provides:
- CLI - Scaffold a complete MCP Server project in seconds
- 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 devThat'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 versionExamples
| Example | Description |
|---------|-------------|
| calculator | Math operations (add, subtract, multiply, divide, power, sqrt) |
| filesystem | File operations (read, write, list, info, create, delete) |
| weather | Weather data via wttr.in (current, forecast) |
| github | GitHub API (repo info, issues, user data) |
| database | Database 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.mdAPI 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/sdkandzod
Comparison
| Feature | create-mcp-server | Manual Setup | |---------|-------------------|--------------| | Time to first tool | ~30 seconds | ~30 minutes | | TypeScript config | ✅ Included | Manual | | Build setup | ✅ Included | Manual | | Examples | ✅ 5 examples | None | | Claude Desktop guide | ✅ Included | Find yourself |
Contributing
Contributions welcome! See GitHub.
License
MIT © Mike Wang
