Skip to content

Commit 3e80c82

Browse files
committed
update README docs
1 parent d828014 commit 3e80c82

18 files changed

+283
-785
lines changed

CLAUDE.md

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
55
## Build & Test Commands
66

77
```sh
8-
npm run build # Build ESM and CJS versions
9-
npm run lint # Run ESLint and Prettier check
10-
npm run lint:fix # Auto-fix lint and formatting issues
11-
npm test # Run all tests (vitest)
12-
npm run test:watch # Run tests in watch mode
13-
npx vitest path/to/file.test.ts # Run specific test file
14-
npx vitest -t "test name" # Run tests matching pattern
15-
npm run typecheck # Type-check without emitting
8+
pnpm install # Install all workspace dependencies
9+
10+
pnpm build:all # Build all packages
11+
pnpm lint:all # Run ESLint + Prettier checks across all packages
12+
pnpm lint:fix:all # Auto-fix lint and formatting issues across all packages
13+
pnpm typecheck:all # Type-check all packages
14+
pnpm test:all # Run all tests (vitest) across all packages
15+
pnpm check:all # typecheck + lint across all packages
16+
17+
# Run a single package script (examples)
18+
# Run a single package script from the repo root with pnpm filter
19+
pnpm --filter @modelcontextprotocol/sdk-core test # vitest run (core)
20+
pnpm --filter @modelcontextprotocol/sdk-core test:watch # vitest (watch)
21+
pnpm --filter @modelcontextprotocol/sdk-core test -- path/to/file.test.ts
22+
pnpm --filter @modelcontextprotocol/sdk-core test -- -t "test name"
1623
```
1724

1825
## Code Style Guidelines
@@ -31,64 +38,64 @@ npm run typecheck # Type-check without emitting
3138

3239
The SDK is organized into three main layers:
3340

34-
1. **Types Layer** (`src/types.ts`) - Protocol types generated from the MCP specification. All JSON-RPC message types, schemas, and protocol constants are defined here using Zod v4.
41+
1. **Types Layer** (`packages/core/src/types/types.ts`) - Protocol types generated from the MCP specification. All JSON-RPC message types, schemas, and protocol constants are defined here using Zod v4.
3542

36-
2. **Protocol Layer** (`src/shared/protocol.ts`) - The abstract `Protocol` class that handles JSON-RPC message routing, request/response correlation, capability negotiation, and transport management. Both `Client` and `Server` extend this class.
43+
2. **Protocol Layer** (`packages/core/src/shared/protocol.ts`) - The abstract `Protocol` class that handles JSON-RPC message routing, request/response correlation, capability negotiation, and transport management. Both `Client` and `Server` extend this class.
3744

3845
3. **High-Level APIs**:
39-
- `Client` (`src/client/index.ts`) - Low-level client extending Protocol with typed methods for all MCP operations
40-
- `Server` (`src/server/index.ts`) - Low-level server extending Protocol with request handler registration
41-
- `McpServer` (`src/server/mcp.ts`) - High-level server API with simplified resource/tool/prompt registration
46+
- `Client` (`packages/client/src/client/client.ts`) - Client implementation extending Protocol with typed methods for MCP operations
47+
- `Server` (`packages/server/src/server/server.ts`) - Server implementation extending Protocol with request handler registration
48+
- `McpServer` (`packages/server/src/server/mcp.ts`) - High-level server API with simplified resource/tool/prompt registration
4249

4350
### Transport System
4451

45-
Transports (`src/shared/transport.ts`) provide the communication layer:
52+
Transports (`packages/core/src/shared/transport.ts`) provide the communication layer:
4653

47-
- **Streamable HTTP** (`src/server/streamableHttp.ts`, `src/client/streamableHttp.ts`) - Recommended transport for remote servers, supports SSE for streaming
48-
- **SSE** (`src/server/sse.ts`, `src/client/sse.ts`) - Legacy HTTP+SSE transport for backwards compatibility
49-
- **stdio** (`src/server/stdio.ts`, `src/client/stdio.ts`) - For local process-spawned integrations
54+
- **Streamable HTTP** (`packages/server/src/server/streamableHttp.ts`, `packages/client/src/client/streamableHttp.ts`) - Recommended transport for remote servers, supports SSE for streaming
55+
- **SSE** (`packages/server/src/server/sse.ts`, `packages/client/src/client/sse.ts`) - Legacy HTTP+SSE transport for backwards compatibility
56+
- **stdio** (`packages/server/src/server/stdio.ts`, `packages/client/src/client/stdio.ts`) - For local process-spawned integrations
5057

5158
### Server-Side Features
5259

5360
- **Tools/Resources/Prompts**: Registered via `McpServer.tool()`, `.resource()`, `.prompt()` methods
54-
- **OAuth/Auth**: Full OAuth 2.0 server implementation in `src/server/auth/`
55-
- **Completions**: Auto-completion support via `src/server/completable.ts`
61+
- **OAuth/Auth**: Full OAuth 2.0 server implementation in `packages/server/src/server/auth/`
62+
- **Completions**: Auto-completion support via `packages/server/src/server/completable.ts`
5663

5764
### Client-Side Features
5865

59-
- **Auth**: OAuth client support in `src/client/auth.ts` and `src/client/auth-extensions.ts`
60-
- **Middleware**: Request middleware in `src/client/middleware.ts`
66+
- **Auth**: OAuth client support in `packages/client/src/client/auth.ts` and `packages/client/src/client/auth-extensions.ts`
67+
- **Middleware**: Request middleware in `packages/client/src/client/middleware.ts`
6168
- **Sampling**: Clients can handle `sampling/createMessage` requests from servers (LLM completions)
6269
- **Elicitation**: Clients can handle `elicitation/create` requests for user input (form or URL mode)
6370
- **Roots**: Clients can expose filesystem roots to servers via `roots/list`
6471

6572
### Experimental Features
6673

67-
Located in `src/experimental/`:
74+
Located in `packages/*/src/experimental/`:
6875

69-
- **Tasks**: Long-running task support with polling/resumption (`src/experimental/tasks/`)
76+
- **Tasks**: Long-running task support with polling/resumption (`packages/core/src/experimental/tasks/`)
7077

7178
### Zod Compatibility
7279

7380
The SDK uses `zod/v4` internally but supports both v3 and v4 APIs. Compatibility utilities:
7481

75-
- `src/server/zod-compat.ts` - Schema parsing helpers that work across versions
76-
- `src/server/zod-json-schema-compat.ts` - Converts Zod schemas to JSON Schema
82+
- `packages/core/src/util/zod-compat.ts` - Schema parsing helpers that work across versions
83+
- `packages/core/src/util/zod-json-schema-compat.ts` - Converts Zod schemas to JSON Schema
7784

7885
### Validation
7986

80-
Pluggable JSON Schema validation (`src/validation/`):
87+
Pluggable JSON Schema validation (`packages/core/src/validation/`):
8188

8289
- `ajv-provider.ts` - Default Ajv-based validator
8390
- `cfworker-provider.ts` - Cloudflare Workers-compatible alternative
8491

8592
### Examples
8693

87-
Runnable examples in `src/examples/`:
94+
Runnable examples in `examples/`:
8895

89-
- `server/` - Various server configurations (stateful, stateless, OAuth, etc.)
90-
- `client/` - Client examples (basic, OAuth, parallel calls, etc.)
91-
- `shared/` - Shared utilities like in-memory event store
96+
- `examples/server/src/` - Various server configurations (stateful, stateless, OAuth, etc.)
97+
- `examples/client/src/` - Client examples (basic, OAuth, parallel calls, etc.)
98+
- `examples/shared/src/` - Shared utilities (OAuth demo provider, etc.)
9299

93100
## Message Flow (Bidirectional Protocol)
94101

@@ -98,9 +105,9 @@ MCP is bidirectional: both client and server can send requests. Understanding th
98105

99106
```
100107
Protocol (abstract base)
101-
├── Client (src/client/index.ts) - can send requests TO server, handle requests FROM server
102-
└── Server (src/server/index.ts) - can send requests TO client, handle requests FROM client
103-
└── McpServer (src/server/mcp.ts) - high-level wrapper around Server
108+
├── Client (packages/client/src/client/client.ts) - can send requests TO server, handle requests FROM server
109+
└── Server (packages/server/src/server/server.ts) - can send requests TO client, handle requests FROM client
110+
└── McpServer (packages/server/src/server/mcp.ts) - high-level wrapper around Server
104111
```
105112

106113
### Outbound Flow: Sending Requests

0 commit comments

Comments
 (0)