You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works with multi-package repos, or single-package repos to help you version and publish your code. You can find the full documentation for it
We have a quick list of common questions to get you started engaging with this project in [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
pnpm --filter @modelcontextprotocol/core test -- path/to/file.test.ts
22
+
pnpm --filter @modelcontextprotocol/core test -- -t "test name"
16
23
```
17
24
18
25
## Code Style Guidelines
@@ -31,64 +38,64 @@ npm run typecheck # Type-check without emitting
31
38
32
39
The SDK is organized into three main layers:
33
40
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.
35
42
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.
37
44
38
45
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
42
49
43
50
### Transport System
44
51
45
-
Transports (`src/shared/transport.ts`) provide the communication layer:
52
+
Transports (`packages/core/src/shared/transport.ts`) provide the communication layer:
46
53
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
50
57
51
58
### Server-Side Features
52
59
53
60
-**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`
56
63
57
64
### Client-Side Features
58
65
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`
61
68
-**Sampling**: Clients can handle `sampling/createMessage` requests from servers (LLM completions)
62
69
-**Elicitation**: Clients can handle `elicitation/create` requests for user input (form or URL mode)
63
70
-**Roots**: Clients can expose filesystem roots to servers via `roots/list`
64
71
65
72
### Experimental Features
66
73
67
-
Located in `src/experimental/`:
74
+
Located in `packages/*/src/experimental/`:
68
75
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/`)
70
77
71
78
### Zod Compatibility
72
79
73
80
The SDK uses `zod/v4` internally but supports both v3 and v4 APIs. Compatibility utilities:
74
81
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
0 commit comments