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
Copy file name to clipboardExpand all lines: CLAUDE.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,19 @@ The SDK is organized into three main layers:
62
62
-`Server` (`packages/server/src/server/server.ts`) - Server implementation extending Protocol with request handler registration
63
63
-`McpServer` (`packages/server/src/server/mcp.ts`) - High-level server API with simplified resource/tool/prompt registration
64
64
65
+
### Public API Exports
66
+
67
+
The SDK has a two-layer export structure to separate internal code from the public API:
68
+
69
+
-**`@modelcontextprotocol/core`** (main entry, `packages/core/src/index.ts`) — Internal barrel. Exports everything (including Zod schemas, Protocol class, stdio utils). Only consumed by sibling packages within the monorepo (`private: true`).
70
+
-**`@modelcontextprotocol/core/public`** (`packages/core/src/exports/public/index.ts`) — Curated public API. Exports only TypeScript types, error classes, constants, and guards. Re-exported by client and server packages.
71
+
-**`@modelcontextprotocol/client`** and **`@modelcontextprotocol/server`** (`packages/*/src/index.ts`) — Final public surface. Package-specific exports (named explicitly) plus re-exports from `core/public`.
72
+
73
+
When modifying exports:
74
+
- Use explicit named exports, not `export *`, in package `index.ts` files and `core/public`.
75
+
- Adding a symbol to a package `index.ts` makes it public API — do so intentionally.
76
+
- Internal helpers should stay in the core internal barrel and not be added to `core/public` or package index files.
77
+
65
78
### Transport System
66
79
67
80
Transports (`packages/core/src/shared/transport.ts`) provide the communication layer:
|`@modelcontextprotocol/sdk/types.js`|`@modelcontextprotocol/client` or `@modelcontextprotocol/server`|
65
+
|`@modelcontextprotocol/sdk/shared/protocol.js`|`@modelcontextprotocol/client` or `@modelcontextprotocol/server`|
66
+
|`@modelcontextprotocol/sdk/shared/transport.js`|`@modelcontextprotocol/client` or `@modelcontextprotocol/server`|
67
+
|`@modelcontextprotocol/sdk/shared/uriTemplate.js`|`@modelcontextprotocol/client` or `@modelcontextprotocol/server`|
68
+
|`@modelcontextprotocol/sdk/shared/auth.js`|`@modelcontextprotocol/client` or `@modelcontextprotocol/server`|
69
+
|`@modelcontextprotocol/sdk/shared/stdio.js`|`@modelcontextprotocol/client` or `@modelcontextprotocol/server`|
70
70
71
71
Notes:
72
72
73
-
-`@modelcontextprotocol/client` and `@modelcontextprotocol/server` both re-export everything from `@modelcontextprotocol/core`, so you can import types from whichever package you already depend on.
73
+
-`@modelcontextprotocol/client` and `@modelcontextprotocol/server` both re-export shared types from `@modelcontextprotocol/core`, so import from whichever package you already depend on. Do not import from `@modelcontextprotocol/core` directly — it is an internal package.
74
74
- When multiple v1 imports map to the same v2 package, consolidate them into a single import statement.
75
-
- If code imports from `sdk/client/...`, install `@modelcontextprotocol/client`. If from `sdk/server/...`, install `@modelcontextprotocol/server`. If from `sdk/types.js` or `sdk/shared/...` only, install `@modelcontextprotocol/core`.
if (errorinstanceofOAuthError&&error.code===OAuthErrorCode.InvalidClient) { ... }
204
203
```
205
204
@@ -210,7 +209,7 @@ Zod schemas, all callback return types. Note: `callTool()` and `request()` signa
210
209
211
210
The variadic `.tool()`, `.prompt()`, `.resource()` methods are removed. Use the `register*` methods with a config object.
212
211
213
-
**IMPORTANT**: v2 requires schema objects implementing [Standard Schema](https://standardschema.dev/) — raw shapes like `{ name: z.string() }` are no longer supported. Wrap with `z.object()` (Zod v4), or use ArkType's `type({...})`, or Valibot. For raw JSON Schema, wrap with `fromJsonSchema(schema, validator)` from `@modelcontextprotocol/core`. Applies to `inputSchema`, `outputSchema`, and `argsSchema`.
212
+
**IMPORTANT**: v2 requires schema objects implementing [Standard Schema](https://standardschema.dev/) — raw shapes like `{ name: z.string() }` are no longer supported. Wrap with `z.object()` (Zod v4), or use ArkType's `type({...})`, or Valibot. For raw JSON Schema, wrap with `fromJsonSchema(schema, validator)` from `@modelcontextprotocol/server`. Applies to `inputSchema`, `outputSchema`, and `argsSchema`.
Note: `@modelcontextprotocol/client` and `@modelcontextprotocol/server` both re-export everything from `@modelcontextprotocol/core`, so you can import types from whichever package you already depend on.
60
+
Note: `@modelcontextprotocol/client` and `@modelcontextprotocol/server` both re-export shared types from `@modelcontextprotocol/core`, so you can import types and error classes from whichever package you already depend on. Do not import from `@modelcontextprotocol/core` directly — it is an internal package.
62
61
63
62
### Dropped Node.js 18 and CommonJS
64
63
@@ -117,7 +116,7 @@ Server-side OAuth/auth has been removed entirely from the SDK. This includes `mc
117
116
118
117
Use a dedicated auth library (e.g., `better-auth`) or a full Authorization Server instead. See the [examples](../examples/server/src/) for a working demo with `better-auth`.
119
118
120
-
Note: `AuthInfo` has moved from `server/auth/types.ts` to `@modelcontextprotocol/core` (it's now a core type).
119
+
Note: `AuthInfo` has moved from `server/auth/types.ts` to the core types and is now re-exported by `@modelcontextprotocol/client` and `@modelcontextprotocol/server`.
For **production in-process connections**, use `StreamableHTTPClientTransport` with a local server URL, or connect client and server via paired streams.
451
+
437
452
### Removed type aliases and deprecated exports
438
453
439
454
The following deprecated type aliases have been removed from `@modelcontextprotocol/core`:
@@ -447,9 +462,9 @@ The following deprecated type aliases have been removed from `@modelcontextproto
|`AuthInfo` (from `server/auth/types.js`) |`AuthInfo` (now in `@modelcontextprotocol/core`) |
465
+
|`AuthInfo` (from `server/auth/types.js`) |`AuthInfo` (now re-exported by `@modelcontextprotocol/client` and `@modelcontextprotocol/server`) |
451
466
452
-
All other types and schemas exported from `@modelcontextprotocol/sdk/types.js` retain their original names in `@modelcontextprotocol/core`.
467
+
All other types and schemas exported from `@modelcontextprotocol/sdk/types.js` retain their original names — import them from `@modelcontextprotocol/client` or `@modelcontextprotocol/server`.
0 commit comments