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
Copy file name to clipboardExpand all lines: docs/tools/debugging.mdx
+59-44Lines changed: 59 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,24 @@
1
1
---
2
-
title: Debugging MCP servers
3
-
description: A comprehensive guide to debugging Model Context Protocol (MCP) servers and integrations
2
+
title: Debugging
3
+
description: A comprehensive guide to debugging Model Context Protocol (MCP) integrations
4
4
---
5
5
6
6
Effective debugging is essential when developing MCP servers or integrating them with applications. This guide covers the debugging tools and approaches available in the MCP ecosystem.
7
7
8
+
<Info>
9
+
This guide is for macOS. Guides for other platforms are coming soon.
10
+
</Info>
11
+
8
12
## Debugging tools overview
9
13
10
14
MCP provides several tools for debugging at different levels:
11
15
12
16
1.**MCP Inspector**
13
17
- Interactive debugging interface
14
18
- Direct server testing
15
-
- See the [Inspector Guide](docs/tools/inspector) for details
19
+
- See the [Inspector guide](/docs/tools/inspector) for details
16
20
17
-
2.**Claude.app Developer Tools**
21
+
2.**Claude Desktop Developer Tools**
18
22
- Integration testing
19
23
- Log collection
20
24
- Chrome DevTools integration
@@ -24,28 +28,26 @@ MCP provides several tools for debugging at different levels:
24
28
- Error tracking
25
29
- Performance monitoring
26
30
27
-
## Debugging in Claude.app
31
+
## Debugging in Claude Desktop
28
32
29
33
### Checking server status
30
34
31
35
The Claude.app interface provides basic server status information:
32
36
33
37
1. Click the 🔌 icon to view:
34
38
- Connected servers
35
-
- Available prompts
36
-
- Accessible resources
37
-
- Supported tools
39
+
- Available prompts and resources
38
40
39
-
### Enabling logging
41
+
2. Click the 🔨 icon to view:
42
+
- Tools made available to the model
40
43
41
-
Get detailed logs from Claude.app:
44
+
### Viewing logs
42
45
43
-
```bash
44
-
# Launch with logging enabled
45
-
open /Applications/Claude.app --stdout ~/Claude.log --stderr ~/Claude.log
46
+
Review detailed MCP logs from Claude Desktop:
46
47
48
+
```bash
47
49
# Follow logs in real-time
48
-
tail -n 100 -f ~/Claude.log
50
+
tail -n 20 -f ~/Logs/Claude/mcp*.log
49
51
```
50
52
51
53
The logs capture:
@@ -56,7 +58,7 @@ The logs capture:
56
58
57
59
### Using Chrome DevTools
58
60
59
-
Access Chrome's developer tools for deeper inspection:
61
+
Access Chrome's developer tools inside Claude Desktop to investigate client-side errors:
60
62
61
63
1. Enable DevTools:
62
64
```bash
@@ -70,25 +72,26 @@ Note: You'll see two DevTools windows:
70
72
- Main content window
71
73
- App title bar window
72
74
75
+
Use the Console panel to inspect client-side errors.
76
+
73
77
Use the Network panel to inspect:
74
-
- WebSocket connections
75
-
- Server-sent events
76
78
- Message payloads
77
79
- Connection timing
78
80
79
81
## Common issues
80
82
81
83
### Environment variables
82
84
83
-
MCP servers don't inherit environment variables automatically. Configure them in `claude_desktop_config.json`:
85
+
MCP servers inherit only a subset of environment variables automatically, like `USER`, `HOME`, and `PATH`.
86
+
87
+
To override the default variables or provide your own, you can specify an `env` key in `claude_desktop_config.json`:
84
88
85
89
```json
86
90
{
87
91
"myserver": {
88
92
"command": "mcp-server-myapp",
89
93
"env": {
90
-
"HOME": "/Users/username",
91
-
"PATH": "/usr/local/bin:/usr/bin:/bin"
94
+
"MYAPP_API_KEY": "some_key",
92
95
}
93
96
}
94
97
}
@@ -117,23 +120,41 @@ Common initialization problems:
117
120
118
121
When servers fail to connect:
119
122
120
-
1. Check Claude.app logs
123
+
1. Check Claude Desktop logs
121
124
2. Verify server process is running
122
-
3. Test standalone with Inspector
123
-
4. Check network connectivity
124
-
5. Verify protocol compatibility
125
+
3. Test standalone with [Inspector](/docs/tools/inspector)
When building a server that uses the local stdio [transport](/docs/concepts/transports), all messages logged to stderr (standard error) will be captured by the client (e.g., Claude Desktop) automatically.
133
+
134
+
<Warning>
135
+
Local MCP servers should not log messages to stdout (standard out), as this will interfere with protocol operation.
136
+
</Warning>
137
+
138
+
For all [transports](/docs/concepts/transports), you can also provide logging to the client by sending a log message notification:
139
+
140
+
<Tabs>
141
+
<Tabtitle="Python">
142
+
```python
143
+
server.request_context.session.send_log_message(
144
+
level="info",
145
+
data="Server started successfully",
146
+
)
147
+
```
148
+
</Tab>
149
+
<Tabtitle="TypeScript">
150
+
```typescript
151
+
server.sendLoggingMessage({
152
+
level: "info",
153
+
data: "Server started successfully",
154
+
});
155
+
```
156
+
</Tab>
157
+
</Tabs>
137
158
138
159
Important events to log:
139
160
- Initialization steps
@@ -156,27 +177,22 @@ In client applications:
156
177
### Development cycle
157
178
158
179
1. Initial Development
159
-
- Use Inspector for basic testing
180
+
- Use [Inspector](/docs/tools/inspector) for basic testing
160
181
- Implement core functionality
161
182
- Add logging points
162
183
163
184
2. Integration Testing
164
-
- Test in Claude.app
185
+
- Test in Claude Desktop
165
186
- Monitor logs
166
187
- Check error handling
167
188
168
-
3. Production Deployment
169
-
- Verify logging
170
-
- Monitor performance
171
-
- Track errors
172
-
173
189
### Testing changes
174
190
175
191
To test changes efficiently:
176
192
177
-
-**Configuration changes**: Restart Claude.app
193
+
-**Configuration changes**: Restart Claude Desktop
178
194
-**Server code changes**: Use Command-R to reload
179
-
-**Quick iteration**: Use Inspector during development
195
+
-**Quick iteration**: Use [Inspector](/docs/tools/inspector) during development
180
196
181
197
## Best practices
182
198
@@ -220,14 +236,13 @@ When encountering issues:
220
236
221
237
1.**First Steps**
222
238
- Check server logs
223
-
- Test with Inspector
239
+
- Test with [Inspector](/docs/tools/inspector)
224
240
- Review configuration
225
241
- Verify environment
226
242
227
243
2.**Support Channels**
228
-
- #mcp-sig channel
229
244
- GitHub issues
230
-
-MCP Asana project
245
+
-GitHub discussions
231
246
232
247
3.**Providing Information**
233
248
- Log excerpts
@@ -239,4 +254,4 @@ When encountering issues:
239
254
240
255
- Learn to use the [MCP Inspector](/docs/tools/inspector)
0 commit comments