Skip to content

Commit 5374142

Browse files
Merge branch 'v1.x' into fix/registerToolTask-v1
2 parents d044ace + 9edbab7 commit 5374142

12 files changed

Lines changed: 425 additions & 201 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/sdk': minor
3+
---
4+
5+
Add `extensions` field to `ClientCapabilities` and `ServerCapabilities` to allow servers and clients to advertise extension support per SEP-2133
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/sdk': patch
3+
---
4+
5+
Add `"types"` condition to `exports` map for subpath imports (`.`, `./client`, `./server`, `./*`), enabling TypeScript to resolve type declarations with `moduleResolution: "bundler"` or `"node16"` without requiring manual `tsconfig.json` `paths` workarounds.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/sdk': patch
3+
---
4+
5+
Always set windowsHide to true when spawning stdio server processes on Windows, not just in Electron environments.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/sdk': patch
3+
---
4+
5+
Prioritize `error.issues[].message` over `error.message` in `getParseErrorMessage` so custom Zod error messages surface correctly. In Zod v4, `error.message` is a JSON blob of all issues, not a readable string.

package-lock.json

Lines changed: 246 additions & 187 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/sdk",
3-
"version": "1.28.0",
3+
"version": "1.29.0",
44
"description": "Model Context Protocol implementation for TypeScript",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",
@@ -20,38 +20,47 @@
2020
],
2121
"exports": {
2222
".": {
23+
"types": "./dist/esm/index.d.ts",
2324
"import": "./dist/esm/index.js",
2425
"require": "./dist/cjs/index.js"
2526
},
2627
"./client": {
28+
"types": "./dist/esm/client/index.d.ts",
2729
"import": "./dist/esm/client/index.js",
2830
"require": "./dist/cjs/client/index.js"
2931
},
3032
"./server": {
33+
"types": "./dist/esm/server/index.d.ts",
3134
"import": "./dist/esm/server/index.js",
3235
"require": "./dist/cjs/server/index.js"
3336
},
3437
"./validation": {
38+
"types": "./dist/esm/validation/index.d.ts",
3539
"import": "./dist/esm/validation/index.js",
3640
"require": "./dist/cjs/validation/index.js"
3741
},
3842
"./validation/ajv": {
43+
"types": "./dist/esm/validation/ajv-provider.d.ts",
3944
"import": "./dist/esm/validation/ajv-provider.js",
4045
"require": "./dist/cjs/validation/ajv-provider.js"
4146
},
4247
"./validation/cfworker": {
48+
"types": "./dist/esm/validation/cfworker-provider.d.ts",
4349
"import": "./dist/esm/validation/cfworker-provider.js",
4450
"require": "./dist/cjs/validation/cfworker-provider.js"
4551
},
4652
"./experimental": {
53+
"types": "./dist/esm/experimental/index.d.ts",
4754
"import": "./dist/esm/experimental/index.js",
4855
"require": "./dist/cjs/experimental/index.js"
4956
},
5057
"./experimental/tasks": {
58+
"types": "./dist/esm/experimental/tasks/index.d.ts",
5159
"import": "./dist/esm/experimental/tasks/index.js",
5260
"require": "./dist/cjs/experimental/tasks/index.js"
5361
},
5462
"./*": {
63+
"types": "./dist/esm/*.d.ts",
5564
"import": "./dist/esm/*",
5665
"require": "./dist/cjs/*"
5766
}

src/client/stdio.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class StdioClientTransport implements Transport {
125125
},
126126
stdio: ['pipe', 'pipe', this._serverParams.stderr ?? 'inherit'],
127127
shell: false,
128-
windowsHide: process.platform === 'win32' && isElectron(),
128+
windowsHide: process.platform === 'win32',
129129
cwd: this._serverParams.cwd
130130
});
131131

@@ -257,7 +257,3 @@ export class StdioClientTransport implements Transport {
257257
});
258258
}
259259
}
260-
261-
function isElectron() {
262-
return 'type' in process;
263-
}

src/server/zod-compat.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,43 @@ export function normalizeObjectSchema(schema: AnySchema | ZodRawShapeCompat | un
188188
return undefined;
189189
}
190190

191+
function getDotPath(path: (string | number)[]) {
192+
if (path.length === 0) {
193+
return 'object root';
194+
}
195+
return path.reduce((acc, seg, index) => {
196+
if (index === 0) {
197+
return String(seg);
198+
}
199+
if (typeof seg === 'number') {
200+
return `${acc}[${seg}]`;
201+
}
202+
return `${acc}.${seg}`;
203+
}, '');
204+
}
205+
191206
// --- Error message extraction ---
192207
/**
193208
* Safely extracts an error message from a parse result error.
194209
* Zod errors can have different structures, so we handle various cases.
195210
*/
196211
export function getParseErrorMessage(error: unknown): string {
197212
if (error && typeof error === 'object') {
213+
// When present, prioritize zod issues and format as a message and path
214+
if ('issues' in error && Array.isArray(error.issues) && error.issues.length > 0) {
215+
return error.issues
216+
.map((i: { message: string; path?: (string | number)[] }) => {
217+
if (!i.path?.length) {
218+
return i.message;
219+
}
220+
return `${i.message} at ${getDotPath(i.path)}`;
221+
})
222+
.join('\n');
223+
}
198224
// Try common error structures
199225
if ('message' in error && typeof error.message === 'string') {
200226
return error.message;
201227
}
202-
if ('issues' in error && Array.isArray(error.issues) && error.issues.length > 0) {
203-
const firstIssue = error.issues[0];
204-
if (firstIssue && typeof firstIssue === 'object' && 'message' in firstIssue) {
205-
return String(firstIssue.message);
206-
}
207-
}
208228
// Fallback: try to stringify the error
209229
try {
210230
return JSON.stringify(error);

src/spec.types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@ export interface ClientCapabilities {
383383
};
384384
};
385385
};
386+
/**
387+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
388+
*/
389+
extensions?: { [key: string]: object };
386390
}
387391

388392
/**
@@ -461,6 +465,10 @@ export interface ServerCapabilities {
461465
};
462466
};
463467
};
468+
/**
469+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
470+
*/
471+
extensions?: { [key: string]: object };
464472
}
465473

466474
/**

src/types.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,11 @@ export const ClientCapabilitiesSchema = z.object({
511511
/**
512512
* Present if the client supports task creation.
513513
*/
514-
tasks: ClientTasksCapabilitySchema.optional()
514+
tasks: ClientTasksCapabilitySchema.optional(),
515+
/**
516+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
517+
*/
518+
extensions: z.record(z.string(), AssertObjectSchema).optional()
515519
});
516520

517521
export const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
@@ -589,7 +593,11 @@ export const ServerCapabilitiesSchema = z.object({
589593
/**
590594
* Present if the server supports task creation.
591595
*/
592-
tasks: ServerTasksCapabilitySchema.optional()
596+
tasks: ServerTasksCapabilitySchema.optional(),
597+
/**
598+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
599+
*/
600+
extensions: z.record(z.string(), AssertObjectSchema).optional()
593601
});
594602

595603
/**

0 commit comments

Comments
 (0)