Skip to content

Commit ce27e57

Browse files
authored
Update CLAUDE.md
1 parent bf68604 commit ce27e57

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed

CLAUDE.md

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -293,50 +293,6 @@ import { createMCPServer } from '../shared/dist/index.js'; // Direct dist path
293293

294294
This setup was established in commits #89, #91, #92 to resolve TypeScript build and npm publish issues. Modifying these import paths will break the publishing workflow.
295295

296-
## Logging Best Practices
297-
298-
**CRITICAL**: All MCP servers must use proper logging to maintain protocol compliance.
299-
300-
### The Problem
301-
302-
The MCP protocol requires that stdout contains only JSON messages. Any `console.log()` statements in server code will break the protocol and cause errors like:
303-
304-
```
305-
Error from MCP server: SyntaxError: Unexpected token 'C', "Configured"... is not valid JSON
306-
```
307-
308-
### The Solution
309-
310-
All servers should implement a centralized logging module (`shared/src/logging.ts`) that outputs to stderr:
311-
312-
```typescript
313-
import { logServerStart, logError, logWarning, logDebug } from '../shared/logging.js';
314-
315-
// ✅ CORRECT - Logs to stderr
316-
logServerStart('MyServer');
317-
logError('functionName', error);
318-
logWarning('functionName', 'Something unexpected happened');
319-
logDebug('functionName', 'Debug information');
320-
321-
// ❌ WRONG - Outputs to stdout, breaks MCP protocol
322-
console.log('Server started');
323-
```
324-
325-
### Logging Functions
326-
327-
- `logServerStart(serverName)` - Log server startup
328-
- `logError(context, error)` - Log errors with context and stack traces
329-
- `logWarning(context, message)` - Log warnings
330-
- `logDebug(context, message)` - Log debug info (only when NODE_ENV=development or DEBUG=true)
331-
332-
### Where This Applies
333-
334-
- All runtime server code (index.ts, tools, resources, etc.)
335-
- Does NOT apply to:
336-
- Build scripts (prepare-publish.js, setup-dev.js)
337-
- Test files
338-
- Scripts that don't run during MCP server operation
339-
340296
## Additional Documentation
341297

342298
Each server directory contains its own CLAUDE.md with specific implementation details.

0 commit comments

Comments
 (0)