Skip to content

Commit 3dab53b

Browse files
chughtapanclaude
andcommitted
Add extensions field to ClientCapabilities
Addresses PR feedback: extensions need to be on both client and server capability objects per SEP-2133. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a6af4bd commit 3dab53b

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

packages/core/src/types/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,11 @@ export const ClientCapabilitiesSchema = z.object({
526526
/**
527527
* Present if the client supports task creation.
528528
*/
529-
tasks: ClientTasksCapabilitySchema.optional()
529+
tasks: ClientTasksCapabilitySchema.optional(),
530+
/**
531+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
532+
*/
533+
extensions: z.record(z.string(), AssertObjectSchema).optional()
530534
});
531535

532536
export const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({

test/integration/test/server/mcp.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ describe('Zod v4', () => {
342342
/***
343343
* Test: Extensions capability registration
344344
*/
345-
test('should register and advertise extensions capability', async () => {
345+
test('should register and advertise server extensions capability', async () => {
346346
const mcpServer = new McpServer({
347347
name: 'test server',
348348
version: '1.0'
@@ -365,6 +365,33 @@ describe('Zod v4', () => {
365365
expect(capabilities?.extensions).toBeDefined();
366366
expect(capabilities?.extensions?.['io.modelcontextprotocol/test-extension']).toEqual({ listChanged: true });
367367
});
368+
369+
test('should advertise client extensions capability to server', async () => {
370+
const mcpServer = new McpServer({
371+
name: 'test server',
372+
version: '1.0'
373+
});
374+
const client = new Client(
375+
{
376+
name: 'test client',
377+
version: '1.0'
378+
},
379+
{
380+
capabilities: {
381+
extensions: {
382+
'io.modelcontextprotocol/test-extension': { streaming: true }
383+
}
384+
}
385+
}
386+
);
387+
388+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
389+
await Promise.all([client.connect(clientTransport), mcpServer.connect(serverTransport)]);
390+
391+
const capabilities = mcpServer.server.getClientCapabilities();
392+
expect(capabilities?.extensions).toBeDefined();
393+
expect(capabilities?.extensions?.['io.modelcontextprotocol/test-extension']).toEqual({ streaming: true });
394+
});
368395
});
369396

370397
describe('ResourceTemplate', () => {

0 commit comments

Comments
 (0)