template-mcp-server
A CLI tool to quickly get started building your very own MCP (Model Context Protocol) server.
@mcpdotdirect/template-mcp-server
A CLI tool to quickly get started building your very own MCP (Model Context Protocol) server.
๐ Usage
# with npx
npx @mcpdotdirect/create-mcp-server
# Or with npm
npm init @mcpdotdirect/create-mcp-server
๐ญ What's Included
The template includes:
- Basic server setup with both stdio and HTTP transport options
- Structure for defining MCP tools, resources, and prompts
- TypeScript configuration
- Development scripts and configuration
โจ Features
- Dual Transport Support: Run your MCP server over stdio or HTTP
- TypeScript: Full TypeScript support for type safety
- MCP SDK: Built on the official Model Context Protocol SDK
- Extensible: Easy to add custom tools, resources, and prompts
๐ Getting Started
After creating your project:
-
Install dependencies using your preferred package manager:
# Using npm npm install # Using yarn yarn # Using pnpm pnpm install # Using bun bun install -
Start the server:
# Start the stdio server npm start # Or start the HTTP server npm run start:http -
For development with auto-reload:
# Development mode with stdio npm run dev # Development mode with HTTP npm run dev:http
Note: The default scripts in package.json use Bun as the runtime (e.g.,
bun run src/index.ts). If you prefer to use a different package manager or runtime, you can modify these scripts in your package.json file to use Node.js or another runtime of your choice.
๐ ๏ธ Adding Custom Tools and Resources
When adding custom tools, resources, or prompts to your MCP server:
-
Use underscores (
_) instead of hyphens (-) in all resource, tool, and prompt names// Good: Uses underscores server.tool( "my_custom_tool", "Description of my custom tool", { param_name: z.string().describe("Parameter description") }, async (params) => { // Tool implementation } ); // Bad: Uses hyphens, may cause issues with Cursor server.tool( "my-custom-tool", "Description of my custom tool", { param-name: z.string().describe("Parameter description") }, async (params) => { // Tool implementation } ); -
This naming convention ensures compatibility with Cursor and other AI tools that interact with your MCP server
๐ Documentation
For more information about the Model Context Protocol, visit the MCP Documentation.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.