Skip to content

Commit 9b24aaf

Browse files
committed
CLAUDE.md file for vibe coders is created for vibe MCPing 🌴
1 parent 56ed994 commit 9b24aaf

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

CLAUDE.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This repository implements a **learning-edition MCP calculator server using STDIO transport**. It demonstrates the Model Context Protocol (MCP) with newline-delimited JSON-RPC communication over stdin/stdout, showcasing both modern MCP SDK usage and custom JSON-RPC implementation patterns.
8+
9+
## Development Commands
10+
11+
### Core Development
12+
- `npm install` - Install dependencies
13+
- `npm start` - Run the production STDIO server (`dist/server-stdio.js`)
14+
- `npm run dev` - Development mode with auto-reload
15+
- `npm run build` - Build TypeScript to JavaScript (may fail due to legacy API usage)
16+
- `npm run clean` - Remove dist directory
17+
18+
### Testing & Quality
19+
- `npm test` - Run all tests (3/4 pass, 1 skipped progress test)
20+
- `npm run test:watch` - Run tests in watch mode
21+
- `npm run test:coverage` - Run tests with coverage
22+
- `npm run lint` - Run ESLint
23+
- `npm run lint:fix` - Fix linting issues
24+
- `npm run typecheck` - TypeScript type checking
25+
26+
### MCP Inspection
27+
- `npx @modelcontextprotocol/inspector --cli node dist/mcp-server.js --method tools/list` - List all 7 tools with schemas
28+
- `npx @modelcontextprotocol/inspector --cli node dist/mcp-server.js --method prompts/list` - List all 3 prompts
29+
- `npx @modelcontextprotocol/inspector --cli node dist/mcp-server.js --method resources/list` - List all 4 resources
30+
- `npx @modelcontextprotocol/inspector --cli node dist/mcp-server.js --method resources/read --uri "calculator://constants"` - Read specific resource
31+
32+
### Manual Testing
33+
- `echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"calculate","arguments":{"a":7,"b":6,"op":"multiply"}}}' | node dist/mcp-server.js` - Test MCP SDK server
34+
- `echo '{"jsonrpc":"2.0","id":1,"method":"calculate","params":{"a":7,"b":6,"op":"multiply"}}' | node dist/server-stdio.js` - Test custom JSON-RPC server
35+
36+
## Architecture
37+
38+
### Dual Server Implementation
39+
The project provides **two functional server implementations**:
40+
41+
1. **`dist/mcp-server.js`** - Modern MCP SDK server using `registerTool()`, `registerResource()`, `registerPrompt()` APIs
42+
2. **`dist/server-stdio.js`** - Custom newline-delimited JSON-RPC server with manual message handling
43+
44+
Both servers implement the same 7 tools, 3 prompts, and 4 resources but use different communication protocols.
45+
46+
### MCP Golden Standard Features
47+
- **7 Tools**: `calculate`, `batch_calculate`, `advanced_calculate`, `demo_progress`, `solve_math_problem`, `explain_formula`, `calculator_assistant`
48+
- **3 Prompts**: `explain-calculation`, `generate-problems`, `calculator-tutor`
49+
- **4 Resources**: `calculator://constants`, `calculator://stats`, `formulas://library`, `calculator://history/{id}`
50+
51+
### State Management Architecture
52+
- **Process Memory**: All state (calculation history, request counters, uptime) stored in-memory
53+
- **Per-Process Isolation**: State resets when process exits (by design for STDIO transport)
54+
- **History Limit**: Maximum 50 calculation entries stored
55+
- **Resource Limits**: Batch operations limited to 100 items
56+
57+
### Protocol Architecture
58+
- **STDIO Transport**: Pure stdin/stdout communication with newline-delimited JSON-RPC
59+
- **Progress Notifications**: Long-running operations emit progress updates via JSON-RPC notifications
60+
- **Exit Codes**: Standard Unix exit codes (0=success, 65=data error, 70=software error)
61+
- **Concurrent Processing**: Maintains `Map<id, PromiseResolver>` for in-flight requests
62+
63+
## TypeScript Compilation Issues
64+
65+
**Important**: The TypeScript source files use legacy MCP SDK APIs and will fail compilation. The working JavaScript files are committed to `dist/` and should be used directly. When making changes:
66+
67+
1. Edit the working JavaScript files in `dist/` directly
68+
2. Do not rely on `npm run build` - it will fail due to API version mismatches
69+
3. The `src/` TypeScript files are reference implementations but not actively built
70+
71+
## Testing Strategy
72+
73+
The test suite focuses on STDIO transport validation:
74+
- **stdio-transport.test.ts**: Tests the custom JSON-RPC server directly via process spawning
75+
- **Progress Test Skipped**: The `demo_progress` test is intentionally skipped due to timeout issues
76+
- **3/4 Tests Pass**: Basic calculate, batch calculate, and error handling tests all pass
77+
78+
## Message Protocol Specifics
79+
80+
### STDIO JSON-RPC Format
81+
```
82+
→ {"jsonrpc":"2.0","id":1,"method":"calculate","params":{"a":5,"b":3,"op":"add"}}
83+
{"jsonrpc":"2.0","id":1,"result":{"value":8,"meta":{"calculationId":"abc123","timestamp":"2024-..."}}}
84+
```
85+
86+
### MCP SDK Format
87+
```
88+
→ {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"calculate","arguments":{"a":5,"b":3,"op":"add"}}}
89+
{"result":{"content":[{"type":"text","text":"5 + 3 = 8"}]},"jsonrpc":"2.0","id":1}
90+
```
91+
92+
## Key Implementation Files
93+
94+
- **`dist/mcp-server.js`** - Modern MCP SDK server (669 lines, production-ready)
95+
- **`dist/server-stdio.js`** - Custom JSON-RPC server (504 lines, reference implementation)
96+
- **`src/tests/stdio-transport.test.ts`** - Integration tests for STDIO protocol
97+
- **`mcp-demo-manifest.json`** - Feature matrix documentation
98+
99+
When working with this codebase, prioritize the working `dist/` JavaScript files over the TypeScript source files.

0 commit comments

Comments
 (0)