@mcpdotdirect/template-mcp-server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A CLI tool to quickly get started building your very own MCP (Model Context Protocol) server using FastMCP
📋 Usage
🔭 What's Included
The template includes:
- Basic server setup with both stdio and HTTP transport options using FastMCP
- Structure for defining MCP tools, resources, and prompts
- TypeScript configuration
- Development scripts and configuration
✨ Features
- **FastMCP**: Built using the FastMCP framework for simpler implementation
- **Dual Transport Support**: Run your MCP server over stdio or HTTP
- **TypeScript**: Full TypeScript support for type safety
- **Extensible**: Easy to add custom tools, resources, and prompts
🚀 Getting Started
After creating your project:
1. Install dependencies using your preferred package manager:
2. Start the server:
3. For development with auto-reload:
> **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.
📖 Detailed Usage
Transport Methods
The MCP server supports two transport methods:
1. **stdio Transport** (Command Line Mode):
- Runs on your **local machine**
- Managed automatically by Cursor
- Communicates directly via stdout
- Only accessible by you locally
- Ideal for personal development and tools
2. **SSE Transport** (HTTP Web Mode):
- Can run **locally or remotely**
- Managed and run by you
- Communicates **over the network**
- Can be **shared** across machines
- Ideal for team collaboration and shared tools
Running the Server Locally
stdio Transport (CLI Mode)
Start the server in stdio mode for CLI tools:
HTTP Transport (Web Mode)
Start the server in HTTP mode for web applications:
By default, the HTTP server runs on port 3001. You can change this by setting the PORT environment variable:
Connecting to the Server
Connecting from Cursor
To connect to your MCP server from Cursor:
1. Open Cursor and go to Settings (gear icon in the bottom left)
2. Click on "Features" in the left sidebar
3. Scroll down to "MCP Servers" section
4. Click "Add new MCP server"
5. Enter the following details:
- Server name: my-mcp-server (or any name you prefer)
- For stdio mode:
- Type: command
- Command: The path to your server executable, e.g., npm start
- For SSE mode:
- Type: url
- URL: http://localhost:3001/sse
6. Click "Save"
Using mcp.json with Cursor
For a more portable configuration, create an .cursor/mcp.json file in your project's root directory:
You can also create a global configuration at ~/.cursor/mcp.json to make your MCP servers available in all your Cursor workspaces.
Note:
- The command type entries run the server in stdio mode