|
| 1 | +# @mcpdotdirect/create-mcp-server |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +A CLI tool to create a new Model Context Protocol (MCP) server project. This package provides a template for building custom MCP servers that can be used by AI agents to interact with external systems and data sources. |
| 8 | + |
| 9 | +## 📋 Usage |
| 10 | + |
| 11 | +You can create a new MCP server project using npx: |
| 12 | + |
| 13 | +```bash |
| 14 | +# Create a new MCP server in the current directory |
| 15 | +npx @mcpdotdirect/create-mcp-server |
| 16 | + |
| 17 | +# Or with npm |
| 18 | +npm init @mcpdotdirect/create-mcp-server |
| 19 | +``` |
| 20 | + |
| 21 | +This will create a new MCP server project in the current directory with all the necessary files. You'll need to install the dependencies manually after creation. |
| 22 | + |
| 23 | +## 🔭 What's Included |
| 24 | + |
| 25 | +The template includes: |
| 26 | + |
| 27 | +- Basic server setup with both stdio and HTTP transport options |
| 28 | +- Structure for defining MCP tools, resources, and prompts |
| 29 | +- TypeScript configuration |
| 30 | +- Development scripts and configuration |
| 31 | + |
| 32 | +## ✨ Features |
| 33 | + |
| 34 | +- **Dual Transport Support**: Run your MCP server over stdio or HTTP |
| 35 | +- **TypeScript**: Full TypeScript support for type safety |
| 36 | +- **MCP SDK**: Built on the official Model Context Protocol SDK |
| 37 | +- **Extensible**: Easy to add custom tools, resources, and prompts |
| 38 | + |
| 39 | +## 🚀 Getting Started |
| 40 | + |
| 41 | +After creating your project: |
| 42 | + |
| 43 | +1. Install dependencies using your preferred package manager: |
| 44 | + ```bash |
| 45 | + # Using npm |
| 46 | + npm install |
| 47 | + |
| 48 | + # Using yarn |
| 49 | + yarn |
| 50 | + |
| 51 | + # Using pnpm |
| 52 | + pnpm install |
| 53 | + |
| 54 | + # Using bun |
| 55 | + bun install |
| 56 | + ``` |
| 57 | + |
| 58 | +2. Start the server: |
| 59 | + ```bash |
| 60 | + # Start the stdio server |
| 61 | + npm start |
| 62 | + |
| 63 | + # Or start the HTTP server |
| 64 | + npm run start:http |
| 65 | + ``` |
| 66 | + |
| 67 | +3. For development with auto-reload: |
| 68 | + ```bash |
| 69 | + # Development mode with stdio |
| 70 | + npm run dev |
| 71 | + |
| 72 | + # Development mode with HTTP |
| 73 | + npm run dev:http |
| 74 | + ``` |
| 75 | + |
| 76 | +> **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. |
| 77 | +
|
| 78 | +## 🛠️ Adding Custom Tools and Resources |
| 79 | + |
| 80 | +When adding custom tools, resources, or prompts to your MCP server: |
| 81 | + |
| 82 | +1. Use underscores (`_`) instead of hyphens (`-`) in all resource, tool, and prompt names |
| 83 | + ```typescript |
| 84 | + // Good: Uses underscores |
| 85 | + server.tool( |
| 86 | + "my_custom_tool", |
| 87 | + "Description of my custom tool", |
| 88 | + { |
| 89 | + param_name: z.string().describe("Parameter description") |
| 90 | + }, |
| 91 | + async (params) => { |
| 92 | + // Tool implementation |
| 93 | + } |
| 94 | + ); |
| 95 | + |
| 96 | + // Bad: Uses hyphens, may cause issues with Cursor |
| 97 | + server.tool( |
| 98 | + "my-custom-tool", |
| 99 | + "Description of my custom tool", |
| 100 | + { |
| 101 | + param-name: z.string().describe("Parameter description") |
| 102 | + }, |
| 103 | + async (params) => { |
| 104 | + // Tool implementation |
| 105 | + } |
| 106 | + ); |
| 107 | + ``` |
| 108 | + |
| 109 | +2. This naming convention ensures compatibility with Cursor and other AI tools that interact with your MCP server |
| 110 | + |
| 111 | +## 📚 Documentation |
| 112 | + |
| 113 | +For more information about the Model Context Protocol, visit the [MCP Documentation](https://modelcontextprotocol.io/introduction). |
| 114 | + |
| 115 | +## 📄 License |
| 116 | + |
| 117 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments