up-mcp-bridge 1.0.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 +21 -0
- package/README.md +448 -0
- package/dist/chunk-EOYXIWZ7.js +21532 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +140 -0
- package/dist/proxy.d.ts +1 -0
- package/dist/proxy.js +246 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Cloudflare, Inc.
|
|
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
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
# `mcp-remote`
|
|
2
|
+
|
|
3
|
+
Connect an MCP Client that only supports local (stdio) servers to a Remote MCP Server, with auth support:
|
|
4
|
+
|
|
5
|
+
**Note: this is a working proof-of-concept** but should be considered **experimental**.
|
|
6
|
+
|
|
7
|
+
## Why is this necessary?
|
|
8
|
+
|
|
9
|
+
So far, the majority of MCP servers in the wild are installed locally, using the stdio transport. This has some benefits: both the client and the server can implicitly trust each other as the user has granted them both permission to run. Adding secrets like API keys can be done using environment variables and never leave your machine. And building on `npx` and `uvx` has allowed users to avoid explicit install steps, too.
|
|
10
|
+
|
|
11
|
+
But there's a reason most software that _could_ be moved to the web _did_ get moved to the web: it's so much easier to find and fix bugs & iterate on new features when you can push updates to all your users with a single deploy.
|
|
12
|
+
|
|
13
|
+
With the latest MCP [Authorization specification](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization), we now have a secure way of sharing our MCP servers with the world _without_ running code on user's laptops. Or at least, you would, if all the popular MCP _clients_ supported it yet. Most are stdio-only, and those that _do_ support HTTP+SSE don't yet support the OAuth flows required.
|
|
14
|
+
|
|
15
|
+
That's where `mcp-remote` comes in. As soon as your chosen MCP client supports remote, authorized servers, you can remove it. Until that time, drop in this one liner and dress for the MCP clients you want!
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
All the most popular MCP clients (Claude Desktop, Cursor & Windsurf) use the following config format:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"remote-example": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": [
|
|
27
|
+
"mcp-remote",
|
|
28
|
+
"https://remote.mcp.server/sse"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Custom Headers
|
|
36
|
+
|
|
37
|
+
To bypass authentication, or to emit custom headers on all requests to your remote server, pass `--header` CLI arguments:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"remote-example": {
|
|
43
|
+
"command": "npx",
|
|
44
|
+
"args": [
|
|
45
|
+
"mcp-remote",
|
|
46
|
+
"https://remote.mcp.server/sse",
|
|
47
|
+
"--header",
|
|
48
|
+
"Authorization: Bearer ${AUTH_TOKEN}"
|
|
49
|
+
],
|
|
50
|
+
"env": {
|
|
51
|
+
"AUTH_TOKEN": "..."
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Note:** Cursor and Claude Desktop (Windows) have a bug where spaces inside `args` aren't escaped when it invokes `npx`, which ends up mangling these values. You can work around it using:
|
|
59
|
+
|
|
60
|
+
```jsonc
|
|
61
|
+
{
|
|
62
|
+
// rest of config...
|
|
63
|
+
"args": [
|
|
64
|
+
"mcp-remote",
|
|
65
|
+
"https://remote.mcp.server/sse",
|
|
66
|
+
"--header",
|
|
67
|
+
"Authorization:${AUTH_HEADER}" // note no spaces around ':'
|
|
68
|
+
],
|
|
69
|
+
"env": {
|
|
70
|
+
"AUTH_HEADER": "Bearer <auth-token>" // spaces OK in env vars
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Multiple Instances
|
|
76
|
+
|
|
77
|
+
To run multiple instances of the same remote server with different configurations (e.g., different Atlassian tenants), use the `--resource` flag to isolate OAuth sessions:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"mcpServers": {
|
|
82
|
+
"atlassian_tenant1": {
|
|
83
|
+
"command": "npx",
|
|
84
|
+
"args": [
|
|
85
|
+
"mcp-remote",
|
|
86
|
+
"https://mcp.atlassian.com/v1/sse",
|
|
87
|
+
"--resource",
|
|
88
|
+
"https://tenant1.atlassian.net/"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"atlassian_tenant2": {
|
|
92
|
+
"command": "npx",
|
|
93
|
+
"args": [
|
|
94
|
+
"mcp-remote",
|
|
95
|
+
"https://mcp.atlassian.com/v1/sse",
|
|
96
|
+
"--resource",
|
|
97
|
+
"https://tenant2.atlassian.net/"
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Each unique combination of server URL, resource, and custom headers will maintain separate OAuth sessions and token storage.
|
|
105
|
+
|
|
106
|
+
### Flags
|
|
107
|
+
|
|
108
|
+
* If `npx` is producing errors, consider adding `-y` as the first argument to auto-accept the installation of the `mcp-remote` package.
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
"command": "npx",
|
|
112
|
+
"args": [
|
|
113
|
+
"-y"
|
|
114
|
+
"mcp-remote",
|
|
115
|
+
"https://remote.mcp.server/sse"
|
|
116
|
+
]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
* To force `npx` to always check for an updated version of `mcp-remote`, add the `@latest` flag:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
"args": [
|
|
123
|
+
"mcp-remote@latest",
|
|
124
|
+
"https://remote.mcp.server/sse"
|
|
125
|
+
]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
* To change which port `mcp-remote` listens for an OAuth redirect (by default `3334`), add an additional argument after the server URL. Note that whatever port you specify, if it is unavailable an open port will be chosen at random.
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
"args": [
|
|
132
|
+
"mcp-remote",
|
|
133
|
+
"https://remote.mcp.server/sse",
|
|
134
|
+
"9696"
|
|
135
|
+
]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
* To change which host `mcp-remote` registers as the OAuth callback URL (by default `localhost`), add the `--host` flag.
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
"args": [
|
|
142
|
+
"mcp-remote",
|
|
143
|
+
"https://remote.mcp.server/sse",
|
|
144
|
+
"--host",
|
|
145
|
+
"127.0.0.1"
|
|
146
|
+
]
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
* To allow HTTP connections in trusted private networks, add the `--allow-http` flag. Note: This should only be used in secure private networks where traffic cannot be intercepted.
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
"args": [
|
|
153
|
+
"mcp-remote",
|
|
154
|
+
"http://internal-service.vpc/sse",
|
|
155
|
+
"--allow-http"
|
|
156
|
+
]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
* To enable detailed debugging logs, add the `--debug` flag. This will write verbose logs to `~/.mcp-auth/{server_hash}_debug.log` with timestamps and detailed information about the auth process, connections, and token refreshing.
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
"args": [
|
|
163
|
+
"mcp-remote",
|
|
164
|
+
"https://remote.mcp.server/sse",
|
|
165
|
+
"--debug"
|
|
166
|
+
]
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
* To enable an outbound HTTP(S) proxy for mcp-remote, add the `--enable-proxy` flag. When enabled, mcp-remote will use the proxy settings from common environment variables (for example `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`).
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
"args": [
|
|
173
|
+
"mcp-remote",
|
|
174
|
+
"https://remote.mcp.server/sse",
|
|
175
|
+
"--enable-proxy"
|
|
176
|
+
],
|
|
177
|
+
"env": {
|
|
178
|
+
"HTTPS_PROXY": "http://127.0.0.1:3128",
|
|
179
|
+
"NO_PROXY": "localhost,127.0.0.1"
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
* To ignore specific tools from the remote server, add the `--ignore-tool` flag. This will filter out tools matching the specified patterns from both `tools/list` responses and block `tools/call` requests. Supports wildcard patterns with `*`.
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
"args": [
|
|
187
|
+
"mcp-remote",
|
|
188
|
+
"https://remote.mcp.server/sse",
|
|
189
|
+
"--ignore-tool",
|
|
190
|
+
"delete*",
|
|
191
|
+
"--ignore-tool",
|
|
192
|
+
"remove*"
|
|
193
|
+
]
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
You can specify multiple `--ignore-tool` flags to ignore different patterns. Examples:
|
|
197
|
+
- `delete*` - ignores all tools starting with "delete" (e.g., `deleteTask`, `deleteUser`)
|
|
198
|
+
- `*account` - ignores all tools ending with "account" (e.g., `getAccount`, `updateAccount`)
|
|
199
|
+
- `exactTool` - ignores only the tool named exactly "exactTool"
|
|
200
|
+
|
|
201
|
+
* To change the timeout for the OAuth callback (by default `30` seconds), add the `--auth-timeout` flag with a value in seconds. This is useful if the authentication process on the server side takes a long time.
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
"args": [
|
|
205
|
+
"mcp-remote",
|
|
206
|
+
"https://remote.mcp.server/sse",
|
|
207
|
+
"--auth-timeout",
|
|
208
|
+
"60"
|
|
209
|
+
]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Auto-Reconnect (Experimental)
|
|
213
|
+
|
|
214
|
+
⚠️ **This feature is experimental and has known issues being investigated.**
|
|
215
|
+
|
|
216
|
+
To enable automatic reconnection when the remote server restarts, add the `--auto-reconnect` flag:
|
|
217
|
+
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"mcpServers": {
|
|
221
|
+
"remote-example": {
|
|
222
|
+
"command": "npx",
|
|
223
|
+
"args": [
|
|
224
|
+
"up-mcp-bridge",
|
|
225
|
+
"https://remote.mcp.server/sse",
|
|
226
|
+
"--auto-reconnect"
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
This enables:
|
|
234
|
+
- Automatic reconnection with exponential backoff when the server becomes unavailable
|
|
235
|
+
- Message queuing during reconnection attempts
|
|
236
|
+
- MCP session re-initialization after successful reconnection
|
|
237
|
+
- Transparent handling for the MCP client
|
|
238
|
+
|
|
239
|
+
**Default parameters:**
|
|
240
|
+
- Max reconnection attempts: 20
|
|
241
|
+
- Base delay: 1000ms
|
|
242
|
+
- Max delay: 15000ms
|
|
243
|
+
- Connection timeout: 5000ms
|
|
244
|
+
|
|
245
|
+
**Optional explicit configuration:**
|
|
246
|
+
```json
|
|
247
|
+
"args": [
|
|
248
|
+
"up-mcp-bridge",
|
|
249
|
+
"https://remote.mcp.server/sse",
|
|
250
|
+
"--auto-reconnect",
|
|
251
|
+
"--max-reconnect-attempts", "10",
|
|
252
|
+
"--max-reconnect-delay-ms", "30000",
|
|
253
|
+
"--connection-timeout-ms", "10000"
|
|
254
|
+
]
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### Known Issues Under Investigation
|
|
258
|
+
|
|
259
|
+
1. **MCP calls may hang after server restart**: In some scenarios, MCP tool calls hang indefinitely after the remote server restarts, even though the proxy reports a successful reconnection. A full restart cycle (stop client → restart server → start client) resolves the issue, but this defeats the purpose of auto-reconnect.
|
|
260
|
+
|
|
261
|
+
2. **npx execution issues**: When using `npx up-mcp-bridge`, environment variables (like `NODE_TLS_REJECT_UNAUTHORIZED`) may not propagate correctly to the spawned process, causing SSL issues with self-signed certificates.
|
|
262
|
+
|
|
263
|
+
3. **HTTP vs HTTPS behavior**: The proxy behaves differently when connecting via HTTP vs HTTPS. HTTP connections (even on localhost) may exhibit different hanging behavior.
|
|
264
|
+
|
|
265
|
+
**Status**: These issues are being actively investigated. If you encounter problems, please report them with:
|
|
266
|
+
- Your configuration (sanitized)
|
|
267
|
+
- Steps to reproduce
|
|
268
|
+
- Logs from the proxy (`--debug` flag)
|
|
269
|
+
|
|
270
|
+
### Transport Strategies
|
|
271
|
+
|
|
272
|
+
MCP Remote supports different transport strategies when connecting to an MCP server. This allows you to control whether it uses Server-Sent Events (SSE) or HTTP transport, and in what order it tries them.
|
|
273
|
+
|
|
274
|
+
Specify the transport strategy with the `--transport` flag:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
npx mcp-remote https://example.remote/server --transport sse-only
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Available Strategies:**
|
|
281
|
+
|
|
282
|
+
- `http-first` (default): Tries HTTP transport first, falls back to SSE if HTTP fails with a 404 error
|
|
283
|
+
- `sse-first`: Tries SSE transport first, falls back to HTTP if SSE fails with a 405 error
|
|
284
|
+
- `http-only`: Only uses HTTP transport, fails if the server doesn't support it
|
|
285
|
+
- `sse-only`: Only uses SSE transport, fails if the server doesn't support it
|
|
286
|
+
|
|
287
|
+
### Static OAuth Client Metadata
|
|
288
|
+
|
|
289
|
+
MCP Remote supports providing static OAuth client metadata instead of using the mcp-remote defaults.
|
|
290
|
+
This is useful when connecting to OAuth servers that expect specific client/software IDs or scopes.
|
|
291
|
+
|
|
292
|
+
Provide the client metadata as a JSON string or as a `@` prefixed filepath with the `--static-oauth-client-metadata` flag:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
npx mcp-remote https://example.remote/server --static-oauth-client-metadata '{ "scope": "space separated scopes" }'
|
|
296
|
+
# uses node readfile, so you probably want to use absolute paths if you're not sure what the cwd is
|
|
297
|
+
npx mcp-remote https://example.remote/server --static-oauth-client-metadata '@/Users/username/Library/Application Support/Claude/oauth_client_metadata.json'
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Static OAuth Client Information
|
|
301
|
+
|
|
302
|
+
Per the [spec](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization#2-4-dynamic-client-registration),
|
|
303
|
+
servers are encouraged but not required to support [OAuth dynamic client registration](https://datatracker.ietf.org/doc/html/rfc7591).
|
|
304
|
+
|
|
305
|
+
For these servers, MCP Remote supports providing static OAuth client information instead.
|
|
306
|
+
This is useful when connecting to OAuth servers that require pre-registered clients.
|
|
307
|
+
|
|
308
|
+
Provide the client metadata as a JSON string or as a `@` prefixed filepath with the `--static-oauth-client-info` flag:
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
export MCP_REMOTE_CLIENT_ID=xxx
|
|
312
|
+
export MCP_REMOTE_CLIENT_SECRET=yyy
|
|
313
|
+
npx mcp-remote https://example.remote/server --static-oauth-client-info "{ \"client_id\": \"$MCP_REMOTE_CLIENT_ID\", \"client_secret\": \"$MCP_REMOTE_CLIENT_SECRET\" }"
|
|
314
|
+
# uses node readfile, so you probably want to use absolute paths if you're not sure what the cwd is
|
|
315
|
+
npx mcp-remote https://example.remote/server --static-oauth-client-info '@/Users/username/Library/Application Support/Claude/oauth_client_info.json'
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Claude Desktop
|
|
319
|
+
|
|
320
|
+
[Official Docs](https://modelcontextprotocol.io/quickstart/user)
|
|
321
|
+
|
|
322
|
+
In order to add an MCP server to Claude Desktop you need to edit the configuration file located at:
|
|
323
|
+
|
|
324
|
+
* macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
325
|
+
* Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
326
|
+
|
|
327
|
+
If it does not exist yet, [you may need to enable it under Settings > Developer](https://modelcontextprotocol.io/quickstart/user#2-add-the-filesystem-mcp-server).
|
|
328
|
+
|
|
329
|
+
Restart Claude Desktop to pick up the changes in the configuration file.
|
|
330
|
+
Upon restarting, you should see a hammer icon in the bottom right corner
|
|
331
|
+
of the input box.
|
|
332
|
+
|
|
333
|
+
### Cursor
|
|
334
|
+
|
|
335
|
+
[Official Docs](https://docs.cursor.com/context/model-context-protocol). The configuration file is located at `~/.cursor/mcp.json`.
|
|
336
|
+
|
|
337
|
+
As of version `0.48.0`, Cursor supports unauthed SSE servers directly. If your MCP server is using the official MCP OAuth authorization protocol, you still need to add a **"command"** server and call `mcp-remote`.
|
|
338
|
+
|
|
339
|
+
### Windsurf
|
|
340
|
+
|
|
341
|
+
[Official Docs](https://docs.codeium.com/windsurf/mcp). The configuration file is located at `~/.codeium/windsurf/mcp_config.json`.
|
|
342
|
+
|
|
343
|
+
## Building Remote MCP Servers
|
|
344
|
+
|
|
345
|
+
For instructions on building & deploying remote MCP servers, including acting as a valid OAuth client, see the following resources:
|
|
346
|
+
|
|
347
|
+
* https://developers.cloudflare.com/agents/guides/remote-mcp-server/
|
|
348
|
+
|
|
349
|
+
In particular, see:
|
|
350
|
+
|
|
351
|
+
* https://github.com/cloudflare/workers-oauth-provider for defining an MCP-comlpiant OAuth server in Cloudflare Workers
|
|
352
|
+
* https://github.com/cloudflare/agents/tree/main/examples/mcp for defining an `McpAgent` using the [`agents`](https://npmjs.com/package/agents) framework.
|
|
353
|
+
|
|
354
|
+
For more information about testing these servers, see also:
|
|
355
|
+
|
|
356
|
+
* https://developers.cloudflare.com/agents/guides/test-remote-mcp-server/
|
|
357
|
+
|
|
358
|
+
Know of more resources you'd like to share? Please add them to this Readme and send a PR!
|
|
359
|
+
|
|
360
|
+
## Troubleshooting
|
|
361
|
+
|
|
362
|
+
### Clear your `~/.mcp-auth` directory
|
|
363
|
+
|
|
364
|
+
`mcp-remote` stores all the credential information inside `~/.mcp-auth` (or wherever your `MCP_REMOTE_CONFIG_DIR` points to). If you're having persistent issues, try running:
|
|
365
|
+
|
|
366
|
+
```sh
|
|
367
|
+
rm -rf ~/.mcp-auth
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
Then restarting your MCP client.
|
|
371
|
+
|
|
372
|
+
### Check your Node version
|
|
373
|
+
|
|
374
|
+
Make sure that the version of Node you have installed is [18 or
|
|
375
|
+
higher](https://modelcontextprotocol.io/quickstart/server). Claude
|
|
376
|
+
Desktop will use your system version of Node, even if you have a newer
|
|
377
|
+
version installed elsewhere.
|
|
378
|
+
|
|
379
|
+
### Restart Claude
|
|
380
|
+
|
|
381
|
+
When modifying `claude_desktop_config.json` it can helpful to completely restart Claude
|
|
382
|
+
|
|
383
|
+
### VPN Certs
|
|
384
|
+
|
|
385
|
+
You may run into issues if you are behind a VPN, you can try setting the `NODE_EXTRA_CA_CERTS`
|
|
386
|
+
environment variable to point to the CA certificate file. If using `claude_desktop_config.json`,
|
|
387
|
+
this might look like:
|
|
388
|
+
|
|
389
|
+
```json
|
|
390
|
+
{
|
|
391
|
+
"mcpServers": {
|
|
392
|
+
"remote-example": {
|
|
393
|
+
"command": "npx",
|
|
394
|
+
"args": [
|
|
395
|
+
"mcp-remote",
|
|
396
|
+
"https://remote.mcp.server/sse"
|
|
397
|
+
],
|
|
398
|
+
"env": {
|
|
399
|
+
"NODE_EXTRA_CA_CERTS": "{your CA certificate file path}.pem"
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Check the logs
|
|
407
|
+
|
|
408
|
+
* [Follow Claude Desktop logs in real-time](https://modelcontextprotocol.io/docs/tools/debugging#debugging-in-claude-desktop)
|
|
409
|
+
* MacOS / Linux:<br/>`tail -n 20 -F ~/Library/Logs/Claude/mcp*.log`
|
|
410
|
+
* For bash on WSL:<br/>`tail -n 20 -f "C:\Users\YourUsername\AppData\Local\Claude\Logs\mcp.log"`
|
|
411
|
+
* Powershell: <br/>`Get-Content "C:\Users\YourUsername\AppData\Local\Claude\Logs\mcp.log" -Wait -Tail 20`
|
|
412
|
+
|
|
413
|
+
## Debugging
|
|
414
|
+
|
|
415
|
+
### Debug Logs
|
|
416
|
+
|
|
417
|
+
For troubleshooting complex issues, especially with token refreshing or authentication problems, use the `--debug` flag:
|
|
418
|
+
|
|
419
|
+
```json
|
|
420
|
+
"args": [
|
|
421
|
+
"mcp-remote",
|
|
422
|
+
"https://remote.mcp.server/sse",
|
|
423
|
+
"--debug"
|
|
424
|
+
]
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
This creates detailed logs in `~/.mcp-auth/{server_hash}_debug.log` with timestamps and complete information about every step of the connection and authentication process. When you find issues with token refreshing, laptop sleep/resume issues, or auth problems, provide these logs when seeking support.
|
|
428
|
+
|
|
429
|
+
### Authentication Errors
|
|
430
|
+
|
|
431
|
+
If you encounter the following error, returned by the `/callback` URL:
|
|
432
|
+
|
|
433
|
+
```
|
|
434
|
+
Authentication Error
|
|
435
|
+
Token exchange failed: HTTP 400
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
You can run `rm -rf ~/.mcp-auth` to clear any locally stored state and tokens.
|
|
439
|
+
|
|
440
|
+
### "Client" mode
|
|
441
|
+
|
|
442
|
+
Run the following on the command line (not from an MCP server):
|
|
443
|
+
|
|
444
|
+
```shell
|
|
445
|
+
npx -p mcp-remote@latest mcp-remote-client https://remote.mcp.server/sse
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
This will run through the entire authorization flow and attempt to list the tools & resources at the remote URL. Try this after running `rm -rf ~/.mcp-auth` to see if stale credentials are your problem, otherwise hopefully the issue will be more obvious in these logs than those in your MCP client.
|