-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(sdk): @modelcontextprotocol/sdk meta-package with v1 deep-import subpaths #1913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
felixweinberger
wants to merge
7
commits into
fweinberger/v2-bc-d1-base
Choose a base branch
from
fweinberger/v2-bc-sdk-meta-package
base: fweinberger/v2-bc-d1-base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6a98c9b
feat(compat): add @modelcontextprotocol/sdk meta-package with v1 deep…
felixweinberger 0342b8a
fix(sdk): unify server/auth/* on server-auth-legacy; drop stdio from …
felixweinberger d82c17d
fix(sdk): add top-level types field for legacy moduleResolution
felixweinberger 6f8c2a1
feat(sdk): re-export Protocol/ProtocolSpec from shared/protocol; add …
felixweinberger ec3650c
fix(sdk): dedupe types field; add SseError/SSEServerTransportOptions/…
felixweinberger 55f4068
docs(sdk): note optional express/hono peers for auth and sse subpaths
felixweinberger 677968c
feat(sdk): re-export LegacyToolCallback/LegacyPromptCallback from sdk…
felixweinberger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@modelcontextprotocol/sdk': patch | ||
| --- | ||
|
|
||
| Add `@modelcontextprotocol/sdk` meta-package: re-exports `@modelcontextprotocol/server` + `client` + `node` and preserves v1 deep-import subpaths (`/types.js`, `/server/mcp.js`, `/client/index.js`, `/shared/transport.js`, `/server/auth/errors.js`, etc.). The package is the recommended primary entry point; the split packages remain available for bundle-conscious consumers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # @modelcontextprotocol/sdk | ||
|
|
||
| The **primary entry point** for the Model Context Protocol TypeScript SDK. | ||
|
|
||
| This meta-package re-exports the full public surface of [`@modelcontextprotocol/server`](../server), [`@modelcontextprotocol/client`](../client), and [`@modelcontextprotocol/node`](../middleware/node), so most applications can depend on this package alone: | ||
|
|
||
| ```ts | ||
| import { McpServer, Client, NodeStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk'; | ||
| ``` | ||
|
|
||
| ## Upgrading from v1 | ||
|
|
||
| `@modelcontextprotocol/sdk` v2 is a drop-in upgrade for most v1 servers — just bump the version. v1 deep-import paths (`@modelcontextprotocol/sdk/types.js`, `/server/mcp.js`, `/client/index.js`, `/shared/transport.js`, etc.) are preserved as compatibility subpaths that re-export | ||
| the matching v2 symbols and emit one-time deprecation warnings where the API shape changed. | ||
|
|
||
| See [`docs/migration.md`](../../docs/migration.md) for the full mapping. | ||
|
|
||
| ## When to use the sub-packages directly | ||
|
|
||
| Bundle-sensitive targets (browsers, Cloudflare Workers) should import from `@modelcontextprotocol/client` or `@modelcontextprotocol/server` directly to avoid pulling in Node-only transports. | ||
|
|
||
| ## Optional subpaths | ||
|
|
||
| The `./server/auth/*` subpaths re-export the legacy Authorization Server helpers from `@modelcontextprotocol/server-auth-legacy`, which require `express` to be installed by the consumer. Similarly, `./server/sse.js` (the deprecated `SSEServerTransport`) is provided by | ||
| `@modelcontextprotocol/node`. Both `express` and `hono` are optional peer dependencies — install them only if you use those subpaths. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // @ts-check | ||
|
|
||
| import baseConfig from '@modelcontextprotocol/eslint-config'; | ||
|
|
||
| export default [ | ||
| ...baseConfig, | ||
| { | ||
| settings: { | ||
| 'import/internal-regex': '^@modelcontextprotocol/' | ||
| } | ||
| }, | ||
| { | ||
| // This package is the v1-compat surface; deprecated re-exports are intentional. | ||
| // import/no-unresolved: subpaths re-export from sibling packages (server-auth-legacy, | ||
| // node/sse, server/zod-schemas) that don't exist on this branch standalone — they | ||
| // land via separate PRs in this BC series. Resolves once those merge. | ||
| // import/export: types.ts deliberately shadows `export *` names with v1-compat aliases | ||
| // (TS spec: named export wins over re-export). | ||
| // unicorn/filename-case: validation/ajv-provider.ts etc. match v1 subpath names. | ||
| rules: { | ||
| '@typescript-eslint/no-deprecated': 'off', | ||
| 'import/no-unresolved': 'off', | ||
| 'import/export': 'off', | ||
| 'unicorn/filename-case': 'off' | ||
| } | ||
| } | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,332 @@ | ||
| { | ||
| "name": "@modelcontextprotocol/sdk", | ||
| "version": "2.0.0-alpha.2", | ||
| "description": "Model Context Protocol implementation for TypeScript - Full SDK (re-exports client, server, and node middleware)", | ||
| "license": "MIT", | ||
| "author": "Anthropic, PBC (https://anthropic.com)", | ||
| "homepage": "https://modelcontextprotocol.io", | ||
| "bugs": "https://github.com/modelcontextprotocol/typescript-sdk/issues", | ||
| "type": "module", | ||
| "types": "./dist/index.d.ts", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/modelcontextprotocol/typescript-sdk.git" | ||
| }, | ||
| "engines": { | ||
| "node": ">=20" | ||
| }, | ||
| "keywords": [ | ||
| "modelcontextprotocol", | ||
| "mcp" | ||
| ], | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.mjs" | ||
| }, | ||
| "./stdio": { | ||
| "types": "./dist/stdio.d.ts", | ||
| "import": "./dist/stdio.mjs" | ||
| }, | ||
| "./types.js": { | ||
| "types": "./dist/types.d.ts", | ||
| "import": "./dist/types.mjs" | ||
| }, | ||
| "./types": { | ||
| "types": "./dist/types.d.ts", | ||
| "import": "./dist/types.mjs" | ||
| }, | ||
| "./server/index.js": { | ||
| "types": "./dist/server/index.d.ts", | ||
| "import": "./dist/server/index.mjs" | ||
| }, | ||
| "./server/index": { | ||
| "types": "./dist/server/index.d.ts", | ||
| "import": "./dist/server/index.mjs" | ||
| }, | ||
| "./server/mcp.js": { | ||
| "types": "./dist/server/mcp.d.ts", | ||
| "import": "./dist/server/mcp.mjs" | ||
| }, | ||
| "./server/mcp": { | ||
| "types": "./dist/server/mcp.d.ts", | ||
| "import": "./dist/server/mcp.mjs" | ||
| }, | ||
| "./server/zod-compat.js": { | ||
| "types": "./dist/server/zod-compat.d.ts", | ||
| "import": "./dist/server/zod-compat.mjs" | ||
| }, | ||
| "./server/zod-compat": { | ||
| "types": "./dist/server/zod-compat.d.ts", | ||
| "import": "./dist/server/zod-compat.mjs" | ||
| }, | ||
| "./server/stdio.js": { | ||
| "types": "./dist/server/stdio.d.ts", | ||
| "import": "./dist/server/stdio.mjs" | ||
| }, | ||
| "./server/stdio": { | ||
| "types": "./dist/server/stdio.d.ts", | ||
| "import": "./dist/server/stdio.mjs" | ||
| }, | ||
| "./server/streamableHttp.js": { | ||
| "types": "./dist/server/streamableHttp.d.ts", | ||
| "import": "./dist/server/streamableHttp.mjs" | ||
| }, | ||
| "./server/streamableHttp": { | ||
| "types": "./dist/server/streamableHttp.d.ts", | ||
| "import": "./dist/server/streamableHttp.mjs" | ||
| }, | ||
| "./server/auth/types.js": { | ||
| "types": "./dist/server/auth/types.d.ts", | ||
| "import": "./dist/server/auth/types.mjs" | ||
| }, | ||
| "./server/auth/types": { | ||
| "types": "./dist/server/auth/types.d.ts", | ||
| "import": "./dist/server/auth/types.mjs" | ||
| }, | ||
| "./server/auth/errors.js": { | ||
| "types": "./dist/server/auth/errors.d.ts", | ||
| "import": "./dist/server/auth/errors.mjs" | ||
| }, | ||
| "./server/auth/errors": { | ||
| "types": "./dist/server/auth/errors.d.ts", | ||
| "import": "./dist/server/auth/errors.mjs" | ||
| }, | ||
| "./client": { | ||
| "types": "./dist/client/index.d.ts", | ||
| "import": "./dist/client/index.mjs" | ||
| }, | ||
| "./client/index.js": { | ||
| "types": "./dist/client/index.d.ts", | ||
| "import": "./dist/client/index.mjs" | ||
| }, | ||
| "./client/index": { | ||
| "types": "./dist/client/index.d.ts", | ||
| "import": "./dist/client/index.mjs" | ||
| }, | ||
| "./client/stdio.js": { | ||
| "types": "./dist/client/stdio.d.ts", | ||
| "import": "./dist/client/stdio.mjs" | ||
| }, | ||
| "./client/stdio": { | ||
| "types": "./dist/client/stdio.d.ts", | ||
| "import": "./dist/client/stdio.mjs" | ||
| }, | ||
| "./client/streamableHttp.js": { | ||
| "types": "./dist/client/streamableHttp.d.ts", | ||
| "import": "./dist/client/streamableHttp.mjs" | ||
| }, | ||
| "./client/streamableHttp": { | ||
| "types": "./dist/client/streamableHttp.d.ts", | ||
| "import": "./dist/client/streamableHttp.mjs" | ||
| }, | ||
| "./client/sse.js": { | ||
| "types": "./dist/client/sse.d.ts", | ||
| "import": "./dist/client/sse.mjs" | ||
| }, | ||
| "./client/sse": { | ||
| "types": "./dist/client/sse.d.ts", | ||
| "import": "./dist/client/sse.mjs" | ||
| }, | ||
| "./client/auth.js": { | ||
| "types": "./dist/client/auth.d.ts", | ||
| "import": "./dist/client/auth.mjs" | ||
| }, | ||
| "./client/auth": { | ||
| "types": "./dist/client/auth.d.ts", | ||
| "import": "./dist/client/auth.mjs" | ||
| }, | ||
| "./shared/protocol.js": { | ||
| "types": "./dist/shared/protocol.d.ts", | ||
| "import": "./dist/shared/protocol.mjs" | ||
| }, | ||
| "./shared/protocol": { | ||
| "types": "./dist/shared/protocol.d.ts", | ||
| "import": "./dist/shared/protocol.mjs" | ||
| }, | ||
| "./shared/transport.js": { | ||
| "types": "./dist/shared/transport.d.ts", | ||
| "import": "./dist/shared/transport.mjs" | ||
| }, | ||
| "./shared/transport": { | ||
| "types": "./dist/shared/transport.d.ts", | ||
| "import": "./dist/shared/transport.mjs" | ||
| }, | ||
| "./shared/auth.js": { | ||
| "types": "./dist/shared/auth.d.ts", | ||
| "import": "./dist/shared/auth.mjs" | ||
| }, | ||
| "./shared/auth": { | ||
| "types": "./dist/shared/auth.d.ts", | ||
| "import": "./dist/shared/auth.mjs" | ||
| }, | ||
| "./server/auth/middleware/bearerAuth.js": { | ||
| "types": "./dist/server/auth/middleware/bearerAuth.d.ts", | ||
| "import": "./dist/server/auth/middleware/bearerAuth.mjs" | ||
| }, | ||
| "./server/auth/middleware/bearerAuth": { | ||
| "types": "./dist/server/auth/middleware/bearerAuth.d.ts", | ||
| "import": "./dist/server/auth/middleware/bearerAuth.mjs" | ||
| }, | ||
| "./server/auth/router.js": { | ||
| "types": "./dist/server/auth/router.d.ts", | ||
| "import": "./dist/server/auth/router.mjs" | ||
| }, | ||
| "./server/auth/router": { | ||
| "types": "./dist/server/auth/router.d.ts", | ||
| "import": "./dist/server/auth/router.mjs" | ||
| }, | ||
| "./server/auth/provider.js": { | ||
| "types": "./dist/server/auth/provider.d.ts", | ||
| "import": "./dist/server/auth/provider.mjs" | ||
| }, | ||
| "./server/auth/provider": { | ||
| "types": "./dist/server/auth/provider.d.ts", | ||
| "import": "./dist/server/auth/provider.mjs" | ||
| }, | ||
| "./server/auth/clients.js": { | ||
| "types": "./dist/server/auth/clients.d.ts", | ||
| "import": "./dist/server/auth/clients.mjs" | ||
| }, | ||
| "./server/auth/clients": { | ||
| "types": "./dist/server/auth/clients.d.ts", | ||
| "import": "./dist/server/auth/clients.mjs" | ||
| }, | ||
| "./inMemory.js": { | ||
| "types": "./dist/inMemory.d.ts", | ||
| "import": "./dist/inMemory.mjs" | ||
| }, | ||
| "./inMemory": { | ||
| "types": "./dist/inMemory.d.ts", | ||
| "import": "./dist/inMemory.mjs" | ||
| }, | ||
| "./server/completable.js": { | ||
| "types": "./dist/server/completable.d.ts", | ||
| "import": "./dist/server/completable.mjs" | ||
| }, | ||
| "./server/completable": { | ||
| "types": "./dist/server/completable.d.ts", | ||
| "import": "./dist/server/completable.mjs" | ||
| }, | ||
| "./server/sse.js": { | ||
| "types": "./dist/server/sse.d.ts", | ||
| "import": "./dist/server/sse.mjs" | ||
| }, | ||
| "./server/sse": { | ||
| "types": "./dist/server/sse.d.ts", | ||
| "import": "./dist/server/sse.mjs" | ||
| }, | ||
| "./experimental/tasks": { | ||
| "types": "./dist/experimental/tasks.d.ts", | ||
| "import": "./dist/experimental/tasks.mjs" | ||
| }, | ||
| "./server": { | ||
| "types": "./dist/server/index.d.ts", | ||
| "import": "./dist/server/index.mjs" | ||
| }, | ||
| "./server.js": { | ||
| "types": "./dist/server/index.d.ts", | ||
| "import": "./dist/server/index.mjs" | ||
| }, | ||
| "./client.js": { | ||
| "types": "./dist/client/index.d.ts", | ||
| "import": "./dist/client/index.mjs" | ||
| }, | ||
| "./server/webStandardStreamableHttp.js": { | ||
| "types": "./dist/server/webStandardStreamableHttp.d.ts", | ||
| "import": "./dist/server/webStandardStreamableHttp.mjs" | ||
| }, | ||
| "./server/webStandardStreamableHttp": { | ||
| "types": "./dist/server/webStandardStreamableHttp.d.ts", | ||
| "import": "./dist/server/webStandardStreamableHttp.mjs" | ||
| }, | ||
| "./shared/stdio.js": { | ||
| "types": "./dist/shared/stdio.d.ts", | ||
| "import": "./dist/shared/stdio.mjs" | ||
| }, | ||
| "./shared/stdio": { | ||
| "types": "./dist/shared/stdio.d.ts", | ||
| "import": "./dist/shared/stdio.mjs" | ||
| }, | ||
| "./validation/types.js": { | ||
| "types": "./dist/validation/types.d.ts", | ||
| "import": "./dist/validation/types.mjs" | ||
| }, | ||
| "./validation/types": { | ||
| "types": "./dist/validation/types.d.ts", | ||
| "import": "./dist/validation/types.mjs" | ||
| }, | ||
| "./validation/cfworker-provider.js": { | ||
| "types": "./dist/validation/cfworker-provider.d.ts", | ||
| "import": "./dist/validation/cfworker-provider.mjs" | ||
| }, | ||
| "./validation/cfworker-provider": { | ||
| "types": "./dist/validation/cfworker-provider.d.ts", | ||
| "import": "./dist/validation/cfworker-provider.mjs" | ||
| }, | ||
| "./validation/ajv-provider.js": { | ||
| "types": "./dist/validation/ajv-provider.d.ts", | ||
| "import": "./dist/validation/ajv-provider.mjs" | ||
| }, | ||
| "./validation/ajv-provider": { | ||
| "types": "./dist/validation/ajv-provider.d.ts", | ||
| "import": "./dist/validation/ajv-provider.mjs" | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "typecheck": "tsgo -p tsconfig.json --noEmit", | ||
| "build": "tsdown && tsc -p tsconfig.build.json", | ||
| "lint": "eslint src/ && prettier --ignore-path ../../.prettierignore --check .", | ||
| "lint:fix": "eslint src/ --fix && prettier --ignore-path ../../.prettierignore --write .", | ||
| "check": "pnpm run typecheck && pnpm run lint", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest", | ||
| "prepack": "pnpm run build" | ||
| }, | ||
| "dependencies": { | ||
|
claude[bot] marked this conversation as resolved.
|
||
| "@modelcontextprotocol/client": "workspace:^", | ||
| "@modelcontextprotocol/node": "workspace:^", | ||
| "@modelcontextprotocol/server": "workspace:^", | ||
| "@modelcontextprotocol/server-auth-legacy": "workspace:^" | ||
| }, | ||
| "peerDependencies": { | ||
| "express": "^4.18.0 || ^5.0.0", | ||
| "hono": "*" | ||
| }, | ||
| "peerDependenciesMeta": { | ||
| "express": { | ||
| "optional": true | ||
| }, | ||
| "hono": { | ||
| "optional": true | ||
| } | ||
| }, | ||
|
felixweinberger marked this conversation as resolved.
|
||
| "devDependencies": { | ||
| "@modelcontextprotocol/core": "workspace:^", | ||
| "@modelcontextprotocol/eslint-config": "workspace:^", | ||
| "@modelcontextprotocol/test-helpers": "workspace:^", | ||
| "@modelcontextprotocol/tsconfig": "workspace:^", | ||
| "@modelcontextprotocol/vitest-config": "workspace:^", | ||
| "@typescript/native-preview": "catalog:devTools", | ||
| "eslint": "catalog:devTools", | ||
| "prettier": "catalog:devTools", | ||
| "tsdown": "catalog:devTools", | ||
| "typescript": "catalog:devTools", | ||
| "vitest": "catalog:devTools", | ||
| "zod": "catalog:runtimeShared" | ||
| }, | ||
| "typesVersions": { | ||
| "*": { | ||
| "*.js": [ | ||
| "dist/*.d.ts" | ||
| ], | ||
| "*": [ | ||
| "dist/*.d.ts", | ||
| "dist/*/index.d.ts" | ||
| ] | ||
| } | ||
| } | ||
|
felixweinberger marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from '@modelcontextprotocol/client'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from '@modelcontextprotocol/client'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { SSEClientTransport, type SSEClientTransportOptions, SseError } from '@modelcontextprotocol/client'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.