Skip to content

Commit 0854b8e

Browse files
Merge pull request modelcontextprotocol#16 from modelcontextprotocol/justin/fixes-2
Update "Development Tools"
2 parents 4438d62 + f67a8ac commit 0854b8e

File tree

2 files changed

+79
-176
lines changed

2 files changed

+79
-176
lines changed

docs/tools/debugging.mdx

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
---
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
44
---
55

66
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.
77

8+
<Info>
9+
This guide is for macOS. Guides for other platforms are coming soon.
10+
</Info>
11+
812
## Debugging tools overview
913

1014
MCP provides several tools for debugging at different levels:
1115

1216
1. **MCP Inspector**
1317
- Interactive debugging interface
1418
- Direct server testing
15-
- See the [Inspector Guide](docs/tools/inspector) for details
19+
- See the [Inspector guide](/docs/tools/inspector) for details
1620

17-
2. **Claude.app Developer Tools**
21+
2. **Claude Desktop Developer Tools**
1822
- Integration testing
1923
- Log collection
2024
- Chrome DevTools integration
@@ -24,28 +28,26 @@ MCP provides several tools for debugging at different levels:
2428
- Error tracking
2529
- Performance monitoring
2630

27-
## Debugging in Claude.app
31+
## Debugging in Claude Desktop
2832

2933
### Checking server status
3034

3135
The Claude.app interface provides basic server status information:
3236

3337
1. Click the 🔌 icon to view:
3438
- Connected servers
35-
- Available prompts
36-
- Accessible resources
37-
- Supported tools
39+
- Available prompts and resources
3840

39-
### Enabling logging
41+
2. Click the 🔨 icon to view:
42+
- Tools made available to the model
4043

41-
Get detailed logs from Claude.app:
44+
### Viewing logs
4245

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:
4647

48+
```bash
4749
# Follow logs in real-time
48-
tail -n 100 -f ~/Claude.log
50+
tail -n 20 -f ~/Logs/Claude/mcp*.log
4951
```
5052

5153
The logs capture:
@@ -56,7 +58,7 @@ The logs capture:
5658

5759
### Using Chrome DevTools
5860

59-
Access Chrome's developer tools for deeper inspection:
61+
Access Chrome's developer tools inside Claude Desktop to investigate client-side errors:
6062

6163
1. Enable DevTools:
6264
```bash
@@ -70,25 +72,26 @@ Note: You'll see two DevTools windows:
7072
- Main content window
7173
- App title bar window
7274

75+
Use the Console panel to inspect client-side errors.
76+
7377
Use the Network panel to inspect:
74-
- WebSocket connections
75-
- Server-sent events
7678
- Message payloads
7779
- Connection timing
7880

7981
## Common issues
8082

8183
### Environment variables
8284

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`:
8488

8589
```json
8690
{
8791
"myserver": {
8892
"command": "mcp-server-myapp",
8993
"env": {
90-
"HOME": "/Users/username",
91-
"PATH": "/usr/local/bin:/usr/bin:/bin"
94+
"MYAPP_API_KEY": "some_key",
9295
}
9396
}
9497
}
@@ -117,23 +120,41 @@ Common initialization problems:
117120

118121
When servers fail to connect:
119122

120-
1. Check Claude.app logs
123+
1. Check Claude Desktop logs
121124
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)
126+
4. Verify protocol compatibility
125127

126128
## Implementing logging
127129

128130
### Server-side logging
129131

130-
Implement custom logging in your server:
131-
132-
```typescript
133-
server.setNotificationHandler(LoggingMessageNotificationSchema, (notification) => {
134-
console.log(`[${notification.params.level}] ${notification.params.data}`);
135-
});
136-
```
132+
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+
<Tab title="Python">
142+
```python
143+
server.request_context.session.send_log_message(
144+
level="info",
145+
data="Server started successfully",
146+
)
147+
```
148+
</Tab>
149+
<Tab title="TypeScript">
150+
```typescript
151+
server.sendLoggingMessage({
152+
level: "info",
153+
data: "Server started successfully",
154+
});
155+
```
156+
</Tab>
157+
</Tabs>
137158

138159
Important events to log:
139160
- Initialization steps
@@ -156,27 +177,22 @@ In client applications:
156177
### Development cycle
157178

158179
1. Initial Development
159-
- Use Inspector for basic testing
180+
- Use [Inspector](/docs/tools/inspector) for basic testing
160181
- Implement core functionality
161182
- Add logging points
162183

163184
2. Integration Testing
164-
- Test in Claude.app
185+
- Test in Claude Desktop
165186
- Monitor logs
166187
- Check error handling
167188

168-
3. Production Deployment
169-
- Verify logging
170-
- Monitor performance
171-
- Track errors
172-
173189
### Testing changes
174190

175191
To test changes efficiently:
176192

177-
- **Configuration changes**: Restart Claude.app
193+
- **Configuration changes**: Restart Claude Desktop
178194
- **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
180196

181197
## Best practices
182198

@@ -220,14 +236,13 @@ When encountering issues:
220236

221237
1. **First Steps**
222238
- Check server logs
223-
- Test with Inspector
239+
- Test with [Inspector](/docs/tools/inspector)
224240
- Review configuration
225241
- Verify environment
226242

227243
2. **Support Channels**
228-
- #mcp-sig channel
229244
- GitHub issues
230-
- MCP Asana project
245+
- GitHub discussions
231246

232247
3. **Providing Information**
233248
- Log excerpts
@@ -239,4 +254,4 @@ When encountering issues:
239254

240255
- Learn to use the [MCP Inspector](/docs/tools/inspector)
241256
- Review [Protocol Overview](/api-reference/protocol-overview)
242-
- Study [Error Handling](/api-reference/error-handling)
257+
- Study [Error Handling](/api-reference/error-handling)

0 commit comments

Comments
 (0)