Skip to content

Commit 92ce327

Browse files
committed
docs: add MCP protocol compliance learning from PR #127
1 parent ce27e57 commit 92ce327

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

CLAUDE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,14 @@ Don't add: basic TypeScript fixes, standard npm troubleshooting, obvious file op
336336
- Always ensure CI passes before considering a PR complete
337337
- Pre-commit hooks automatically run lint-staged, but manual linting should still be run before pushing to avoid CI failures
338338

339+
### MCP Protocol Compliance
340+
341+
- **Critical Insight**: The MCP protocol requires stdout to contain only JSON messages. Any `console.log()` statement in server runtime code will cause protocol violations and errors like "Unexpected token...is not valid JSON"
342+
- **Solution**: Always use a centralized logging module that outputs to stderr, never stdout
343+
- **Detection**: These errors often appear when using MCP inspector or when clients try to parse server output
344+
- **Prevention**: Use the standardized logging infrastructure (`shared/src/logging.ts`) in all MCP servers
345+
- **Debugging Tip**: When users report JSON parsing errors, immediately check for console.log statements in the execution path
346+
339347
### Publishing Process
340348

341349
- See [PUBLISHING_SERVERS.md](./docs/PUBLISHING_SERVERS.md) for the complete publishing process

0 commit comments

Comments
 (0)