@myatkyawthu/mcp-connect 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +393 -169
- package/package.json +59 -63
- package/src/cli.js +41 -23
- package/src/defineMCP.js +3 -21
- package/src/index.js +2 -30
- package/src/server/dashboard.js +212 -0
- package/src/server/mcpServer.js +460 -145
- package/src/server/relay.js +162 -0
- package/src/types/mcp.js +0 -69
- package/src/utils/configLoader.js +96 -0
- package/src/utils/configValidation.js +84 -123
- package/src/utils/crypto.js +57 -0
- package/src/utils/logger.js +2 -137
- package/src/utils/validation.js +4 -34
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 myat-kyaw-thu
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 myat-kyaw-thu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,170 +1,394 @@
|
|
|
1
|
-
# mcp-connect
|
|
2
|
-
|
|
3
|
-
> Dead simple MCP
|
|
4
|
-
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
1
|
+
# mcp-connect
|
|
2
|
+
|
|
3
|
+
> Dead simple MCP server framework. Define your tools as async functions — it handles the protocol, transport, security, and dashboard.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@myatkyawthu/mcp-connect)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## What is this?
|
|
11
|
+
|
|
12
|
+
**Model Context Protocol (MCP)** is the standard way AI tools (Claude, Cursor, Cline, etc.) call your app's functions. Think of it like a plugin system — any MCP-compatible AI can discover and call your tools.
|
|
13
|
+
|
|
14
|
+
`mcp-connect` removes all the boilerplate. You write async functions. It handles the rest: JSON-RPC wiring, transport, schema advertisement, rate limiting, auth, error handling, and a live inspector dashboard.
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { defineMCP } from "@myatkyawthu/mcp-connect";
|
|
18
|
+
|
|
19
|
+
export default defineMCP({
|
|
20
|
+
name: "my-server",
|
|
21
|
+
version: "1.0.0",
|
|
22
|
+
tools: [
|
|
23
|
+
["hello", async ({ name = "World" }) => `Hello ${name}!`],
|
|
24
|
+
{
|
|
25
|
+
name: "echo",
|
|
26
|
+
description: "Echo back the input",
|
|
27
|
+
schema: {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: { message: { type: "string" } },
|
|
30
|
+
required: ["message"]
|
|
31
|
+
},
|
|
32
|
+
handler: async ({ message }) => `Echo: ${message}`
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Global CLI (recommended)
|
|
44
|
+
npm install -g @myatkyawthu/mcp-connect
|
|
45
|
+
|
|
46
|
+
# Or as a project dependency
|
|
47
|
+
npm install @myatkyawthu/mcp-connect
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Requires **Node.js 18+**.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# 1. Create a config file
|
|
58
|
+
mcp-connect init
|
|
59
|
+
|
|
60
|
+
# 2. Edit mcp.config.js and add your tools
|
|
61
|
+
|
|
62
|
+
# 3. Run it
|
|
63
|
+
mcp-connect # STDIO mode (for Claude Desktop)
|
|
64
|
+
mcp-connect --port 3000 # SSE/HTTP mode (for web clients, IDEs)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Three Modes — Pick One
|
|
70
|
+
|
|
71
|
+
### Mode 1 — STDIO (Local, for Claude Desktop)
|
|
72
|
+
|
|
73
|
+
Your AI tool spawns the process. Communication happens via stdin/stdout pipes. No port, no HTTP.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
mcp-connect mcp.config.js
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Claude Desktop config** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"my-app": {
|
|
84
|
+
"command": "mcp-connect",
|
|
85
|
+
"args": ["/absolute/path/to/mcp.config.js"]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Mode 2 — SSE / HTTP (Deployed on a Server)
|
|
94
|
+
|
|
95
|
+
Starts an HTTP server. AI clients connect to `/sse` and send requests to `/message`. **This is the mode for deploying on a VPS or cloud** so any client can reach it over the internet.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
mcp-connect mcp.config.js --port 3000
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Once deployed behind HTTPS, clients connect to:
|
|
102
|
+
```
|
|
103
|
+
https://yourserver.com/sse
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Client compatibility:**
|
|
107
|
+
|
|
108
|
+
| Client | SSE Support |
|
|
109
|
+
| :--- | :---: |
|
|
110
|
+
| Claude.ai (web) | ✅ |
|
|
111
|
+
| Cursor | ✅ |
|
|
112
|
+
| Cline (VS Code) | ✅ |
|
|
113
|
+
| Windsurf | ✅ |
|
|
114
|
+
| Continue.dev | ✅ |
|
|
115
|
+
| Zed | ✅ |
|
|
116
|
+
| Claude Desktop | ❌ (STDIO only) |
|
|
117
|
+
|
|
118
|
+
**Endpoints exposed:**
|
|
119
|
+
|
|
120
|
+
| Endpoint | Description |
|
|
121
|
+
| :--- | :--- |
|
|
122
|
+
| `GET /sse` | AI client connects here (long-lived SSE stream) |
|
|
123
|
+
| `POST /message` | AI client sends JSON-RPC requests |
|
|
124
|
+
| `GET /health` | JSON health check with tool list |
|
|
125
|
+
| `GET /` | Live inspector dashboard |
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### Mode 3 — Tunnel (Behind NAT, No Open Port)
|
|
130
|
+
|
|
131
|
+
If your machine can't receive inbound connections (home laptop, office network), use the tunnel. Run a tiny relay on any $5/month VPS — your local machine connects outbound to it. Remote clients hit the VPS and get proxied to your machine.
|
|
132
|
+
|
|
133
|
+
**Step 1 — Start the relay on your VPS (one-time setup):**
|
|
134
|
+
```bash
|
|
135
|
+
mcp-connect relay --port 4000
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Step 2 — Start your server on your local machine:**
|
|
139
|
+
```bash
|
|
140
|
+
mcp-connect mcp.config.js --port 3111 --tunnel
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Your terminal will print:
|
|
144
|
+
```
|
|
145
|
+
MCP Tunnel bridge active!
|
|
146
|
+
Remote SSE endpoint: http://your-vps.com/t/<tunnelId>/sse
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Share that URL with any MCP client. Done.
|
|
150
|
+
|
|
151
|
+
> The relay auto-reconnects if the tunnel drops. All payloads can be AES-256-GCM encrypted end-to-end (see Security section below).
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Tool Definition Formats
|
|
156
|
+
|
|
157
|
+
### Short format (tuple)
|
|
158
|
+
For simple one-liner tools:
|
|
159
|
+
```js
|
|
160
|
+
["toolName", async (args) => result]
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Full format (object)
|
|
164
|
+
For tools that need schema validation, descriptions, or a security confirmation gate:
|
|
165
|
+
```js
|
|
166
|
+
{
|
|
167
|
+
name: "delete_record",
|
|
168
|
+
description: "Permanently delete a record by ID",
|
|
169
|
+
schema: {
|
|
170
|
+
type: "object",
|
|
171
|
+
properties: {
|
|
172
|
+
id: { type: "string", description: "Record ID to delete" }
|
|
173
|
+
},
|
|
174
|
+
required: ["id"]
|
|
175
|
+
},
|
|
176
|
+
confirm: true, // asks "y/N?" in terminal before executing
|
|
177
|
+
handler: async ({ id }) => {
|
|
178
|
+
await db.delete(id);
|
|
179
|
+
return `Deleted ${id}`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The AI receives the schema and knows exactly what arguments to pass. You don't have to document it separately.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Security
|
|
189
|
+
|
|
190
|
+
All security features are optional — enable only what you need.
|
|
191
|
+
|
|
192
|
+
### Bearer Token Auth
|
|
193
|
+
|
|
194
|
+
Protect the `/sse` and `/message` endpoints. Any request without the correct token gets a `401`.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Set via environment variable
|
|
198
|
+
MCP_TUNNEL_TOKEN=my-secret-token mcp-connect mcp.config.js --port 3000
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Or in config:
|
|
202
|
+
```js
|
|
203
|
+
server: {
|
|
204
|
+
tunnel: { token: "my-secret-token" }
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Clients must send: `Authorization: Bearer my-secret-token`
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### CORS Origin Allowlist
|
|
213
|
+
|
|
214
|
+
Restrict which origins can connect. Without this, all origins are allowed (`*`).
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
server: {
|
|
218
|
+
cors: {
|
|
219
|
+
origins: ["https://claude.ai", "https://cursor.sh"]
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Requests from unlisted origins get `403 Origin not allowed`.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### End-to-End Encryption (Tunnel mode)
|
|
229
|
+
|
|
230
|
+
Encrypt all payloads over the tunnel so the relay server only sees ciphertext. Uses AES-256-GCM.
|
|
231
|
+
|
|
232
|
+
```js
|
|
233
|
+
server: {
|
|
234
|
+
tunnel: {
|
|
235
|
+
encryptionKey: "my-32-char-passphrase-or-64hex"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The relay cannot read your tool calls or responses even if it's compromised.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
### Confirm Gate for Dangerous Tools
|
|
245
|
+
|
|
246
|
+
Add `confirm: true` to any tool. Before it runs, the terminal prompts you:
|
|
247
|
+
```
|
|
248
|
+
⚠️ [MCP SECURITY] Allow tool "delete_record" execution? (y/N):
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
The tool only runs if you type `y`. Otherwise it's rejected with an error.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Built-in Protections (Always On)
|
|
256
|
+
|
|
257
|
+
These run automatically without any config:
|
|
258
|
+
|
|
259
|
+
| Protection | Detail |
|
|
260
|
+
| :--- | :--- |
|
|
261
|
+
| **Rate limiting** | 100 requests/minute per server |
|
|
262
|
+
| **Tool timeout** | 30 seconds max per tool call |
|
|
263
|
+
| **Response size cap** | 1MB max, truncated if exceeded |
|
|
264
|
+
| **Error sanitization** | Stack traces stripped before returning to AI |
|
|
265
|
+
| **Circular reference guard** | Safe JSON serialization |
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Inspector Dashboard
|
|
270
|
+
|
|
271
|
+
Available at `http://localhost:<port>/` whenever running in SSE mode.
|
|
272
|
+
|
|
273
|
+
- **Logs tab** — live feed of every tool call with timestamp, duration, pass/fail status. Click any row to see full request args and response.
|
|
274
|
+
- **Test Tool tab** — pick a tool, fill in args as JSON, hit Execute. See the response immediately. No AI client needed for debugging.
|
|
275
|
+
|
|
276
|
+
The dashboard connects to `/api/events` over SSE — it updates in real-time without refreshing.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Full Config Reference
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
import { defineMCP } from "@myatkyawthu/mcp-connect";
|
|
284
|
+
|
|
285
|
+
export default defineMCP({
|
|
286
|
+
name: "my-server", // required
|
|
287
|
+
version: "1.0.0", // required
|
|
288
|
+
description: "...", // optional
|
|
289
|
+
|
|
290
|
+
server: {
|
|
291
|
+
port: 3000, // optional — same as --port flag
|
|
292
|
+
|
|
293
|
+
cors: {
|
|
294
|
+
origins: [ // optional — allowlist of origins
|
|
295
|
+
"https://claude.ai",
|
|
296
|
+
"http://localhost:5173"
|
|
297
|
+
]
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
tunnel: {
|
|
301
|
+
enabled: true, // optional — same as --tunnel flag
|
|
302
|
+
relayUrl: "http://your-vps.com:4000", // relay address
|
|
303
|
+
token: "secret", // bearer token for auth
|
|
304
|
+
encryptionKey: "..." // AES-256-GCM key (passphrase or 64-char hex)
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
tools: [
|
|
309
|
+
// Short format
|
|
310
|
+
["hello", async ({ name = "World" }) => `Hello ${name}!`],
|
|
311
|
+
|
|
312
|
+
// Full format
|
|
313
|
+
{
|
|
314
|
+
name: "echo",
|
|
315
|
+
description: "Echo back the input",
|
|
316
|
+
schema: {
|
|
317
|
+
type: "object",
|
|
318
|
+
properties: {
|
|
319
|
+
message: { type: "string" }
|
|
320
|
+
},
|
|
321
|
+
required: ["message"]
|
|
322
|
+
},
|
|
323
|
+
handler: async ({ message }) => `Echo: ${message}`
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
// Dangerous tool with confirmation gate
|
|
327
|
+
{
|
|
328
|
+
name: "delete_all",
|
|
329
|
+
description: "Wipe everything",
|
|
330
|
+
confirm: true,
|
|
331
|
+
handler: async () => {
|
|
332
|
+
await nuke();
|
|
333
|
+
return "Done.";
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
]
|
|
337
|
+
});
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## CLI Reference
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
mcp-connect init # Scaffold mcp.config.js in current directory
|
|
346
|
+
mcp-connect [config.js] # Start in STDIO mode
|
|
347
|
+
mcp-connect [config.js] --port <port> # Start in SSE/HTTP mode
|
|
348
|
+
mcp-connect [config.js] --tunnel # Start with outbound tunnel
|
|
349
|
+
mcp-connect relay --port <port> # Run a relay gateway (deploy on VPS)
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Config file defaults to `mcp.config.js` in the current directory if not specified.
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Deployment Recipes
|
|
357
|
+
|
|
358
|
+
### Deploy on Railway / Render / Fly.io
|
|
359
|
+
|
|
360
|
+
1. Push your repo with `mcp.config.js`
|
|
361
|
+
2. Set start command: `mcp-connect mcp.config.js --port 3000`
|
|
362
|
+
3. Set env var: `MCP_TUNNEL_TOKEN=your-secret`
|
|
363
|
+
4. Add your domain/URL to your AI client as the MCP server URL: `https://yourapp.railway.app/sse`
|
|
364
|
+
|
|
365
|
+
### Self-hosted VPS (nginx + HTTPS)
|
|
366
|
+
|
|
367
|
+
```nginx
|
|
368
|
+
location / {
|
|
369
|
+
proxy_pass http://localhost:3000;
|
|
370
|
+
proxy_http_version 1.1;
|
|
371
|
+
proxy_set_header Connection ''; # keep SSE alive
|
|
372
|
+
proxy_buffering off; # required for SSE streaming
|
|
373
|
+
proxy_cache off;
|
|
374
|
+
proxy_set_header Host $host;
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Then run: `mcp-connect mcp.config.js --port 3000`
|
|
379
|
+
|
|
380
|
+
### Laptop behind NAT (tunnel setup)
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# On VPS
|
|
384
|
+
mcp-connect relay --port 4000
|
|
385
|
+
|
|
386
|
+
# On laptop
|
|
387
|
+
MCP_TUNNEL_TOKEN=secret mcp-connect mcp.config.js --port 3111 --tunnel
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## License
|
|
393
|
+
|
|
170
394
|
MIT © [myat-kyaw-thu](https://github.com/myat-kyaw-thu)
|