Skip to content

Commit d384e41

Browse files
chughtapanclaude
andcommitted
Add extensions field to ServerCapabilities
Extensions currently must use the experimental field as a workaround. This adds a dedicated extensions field (record of URI → object) to ServerCapabilitiesSchema, enabling capabilities like extensions["io.modelcontextprotocol/grouping"]: { listChanged: true }. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5a2c8a6 commit d384e41

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

packages/core/src/types/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,11 @@ export const ServerCapabilitiesSchema = z.object({
604604
/**
605605
* Present if the server supports task creation.
606606
*/
607-
tasks: ServerTasksCapabilitySchema.optional()
607+
tasks: ServerTasksCapabilitySchema.optional(),
608+
/**
609+
* Extensions that the server supports. Keys are extension URIs.
610+
*/
611+
extensions: z.record(z.string(), AssertObjectSchema).optional()
608612
});
609613

610614
/**

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,33 @@ describe('Zod v4', () => {
338338
message: 'Completed step 3 of 3'
339339
});
340340
});
341+
342+
/***
343+
* Test: Extensions capability registration
344+
*/
345+
test('should register and advertise extensions capability', async () => {
346+
const mcpServer = new McpServer({
347+
name: 'test server',
348+
version: '1.0'
349+
});
350+
const client = new Client({
351+
name: 'test client',
352+
version: '1.0'
353+
});
354+
355+
mcpServer.server.registerCapabilities({
356+
extensions: {
357+
'io.modelcontextprotocol/grouping': { listChanged: true }
358+
}
359+
});
360+
361+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
362+
await Promise.all([client.connect(clientTransport), mcpServer.connect(serverTransport)]);
363+
364+
const capabilities = client.getServerCapabilities();
365+
expect(capabilities?.extensions).toBeDefined();
366+
expect(capabilities?.extensions?.['io.modelcontextprotocol/grouping']).toEqual({ listChanged: true });
367+
});
341368
});
342369

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

0 commit comments

Comments
 (0)