You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A CLI tool to quickly get started building your very own MCP (Model Context Protocol) server.
6
+
A CLI tool to quickly get started building your very own MCP (Model Context Protocol) server using FastMCP.
8
7
9
8
## 📋 Usage
10
9
@@ -13,23 +12,23 @@ A CLI tool to quickly get started building your very own MCP (Model Context Prot
13
12
npx @mcpdotdirect/create-mcp-server
14
13
15
14
# Or with npm
16
-
npm init @mcpdotdirect/create-mcp-server
15
+
npm init @mcpdotdirect/mcp-server
17
16
```
18
17
19
18
## 🔭 What's Included
20
19
21
20
The template includes:
22
21
23
-
- Basic server setup with both stdio and HTTP transport options
22
+
- Basic server setup with both stdio and HTTP transport options using FastMCP
24
23
- Structure for defining MCP tools, resources, and prompts
25
24
- TypeScript configuration
26
25
- Development scripts and configuration
27
26
28
27
## ✨ Features
29
28
29
+
-**FastMCP**: Built using the FastMCP framework for simpler implementation
30
30
-**Dual Transport Support**: Run your MCP server over stdio or HTTP
31
31
-**TypeScript**: Full TypeScript support for type safety
32
-
-**MCP SDK**: Built on the official Model Context Protocol SDK
33
32
-**Extensible**: Easy to add custom tools, resources, and prompts
34
33
35
34
## 🚀 Getting Started
@@ -71,41 +70,214 @@ After creating your project:
71
70
72
71
> **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.
73
72
73
+
## 📖 Detailed Usage
74
+
75
+
### Transport Methods
76
+
77
+
The MCP server supports two transport methods:
78
+
79
+
1.**stdio Transport** (Command Line Mode):
80
+
- Runs on your **local machine**
81
+
- Managed automatically by Cursor
82
+
- Communicates directly via `stdout`
83
+
- Only accessible by you locally
84
+
- Ideal for personal development and tools
85
+
86
+
2.**SSE Transport** (HTTP Web Mode):
87
+
- Can run **locally or remotely**
88
+
- Managed and run by you
89
+
- Communicates **over the network**
90
+
- Can be **shared** across machines
91
+
- Ideal for team collaboration and shared tools
92
+
93
+
### Running the Server Locally
94
+
95
+
#### stdio Transport (CLI Mode)
96
+
97
+
Start the server in stdio mode for CLI tools:
98
+
99
+
```bash
100
+
# Start the stdio server
101
+
npm start
102
+
# or with other package managers
103
+
yarn start
104
+
pnpm start
105
+
bun start
106
+
107
+
# Start the server in development mode with auto-reload
108
+
npm run dev
109
+
# or
110
+
yarn dev
111
+
pnpm dev
112
+
bun dev
113
+
```
114
+
115
+
#### HTTP Transport (Web Mode)
116
+
117
+
Start the server in HTTP mode for web applications:
118
+
119
+
```bash
120
+
# Start the HTTP server
121
+
npm run start:http
122
+
# or
123
+
yarn start:http
124
+
pnpm start:http
125
+
bun start:http
126
+
127
+
# Start the HTTP server in development mode with auto-reload
128
+
npm run dev:http
129
+
# or
130
+
yarn dev:http
131
+
pnpm dev:http
132
+
bun dev:http
133
+
```
134
+
135
+
By default, the HTTP server runs on port 3001. You can change this by setting the PORT environment variable:
136
+
137
+
```bash
138
+
# Start the HTTP server on a custom port
139
+
PORT=8080 npm run start:http
140
+
```
141
+
142
+
### Connecting to the Server
143
+
144
+
#### Connecting from Cursor
145
+
146
+
To connect to your MCP server from Cursor:
147
+
148
+
1. Open Cursor and go to Settings (gear icon in the bottom left)
149
+
2. Click on "Features" in the left sidebar
150
+
3. Scroll down to "MCP Servers" section
151
+
4. Click "Add new MCP server"
152
+
5. Enter the following details:
153
+
- Server name: `my-mcp-server` (or any name you prefer)
154
+
- For stdio mode:
155
+
- Type: `command`
156
+
- Command: The path to your server executable, e.g., `npm start`
157
+
- For SSE mode:
158
+
- Type: `url`
159
+
- URL: `http://localhost:3001/sse`
160
+
6. Click "Save"
161
+
162
+
#### Using mcp.json with Cursor
163
+
164
+
For a more portable configuration, create an `.cursor/mcp.json` file in your project's root directory:
165
+
166
+
```json
167
+
{
168
+
"mcpServers": {
169
+
"my-mcp-stdio": {
170
+
"command": "npm",
171
+
"args": [
172
+
"start"
173
+
],
174
+
"env": {
175
+
"NODE_ENV": "development"
176
+
}
177
+
},
178
+
"my-mcp-sse": {
179
+
"url": "http://localhost:3001/sse"
180
+
}
181
+
}
182
+
}
183
+
```
184
+
185
+
You can also create a global configuration at `~/.cursor/mcp.json` to make your MCP servers available in all your Cursor workspaces.
186
+
187
+
Note:
188
+
- The `command` type entries run the server in stdio mode
189
+
- The `url` type entry connects to the HTTP server using SSE transport
190
+
- You can provide environment variables using the `env` field
191
+
- When connecting via SSE with FastMCP, use the full URL including the `/sse` path: `http://localhost:3001/sse`
192
+
193
+
### Testing Your Server with CLI Tools
194
+
195
+
FastMCP provides built-in tools for testing your server:
196
+
197
+
```bash
198
+
# Test with mcp-cli
199
+
npx fastmcp dev server.js
200
+
201
+
# Inspect with MCP Inspector
202
+
npx fastmcp inspect server.ts
203
+
```
204
+
205
+
### Using Environment Variables
206
+
207
+
You can customize the server using environment variables:
208
+
209
+
```bash
210
+
# Change the HTTP port (default is 3001)
211
+
PORT=8080 npm run start:http
212
+
213
+
# Change the host binding (default is 0.0.0.0)
214
+
HOST=127.0.0.1 npm run start:http
215
+
```
216
+
74
217
## 🛠️ Adding Custom Tools and Resources
75
218
76
-
When adding custom tools, resources, or prompts to your MCP server:
77
-
78
-
1. Use underscores (`_`) instead of hyphens (`-`) in all resource, tool, and prompt names
0 commit comments