mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-17 15:43:24 +02:00
Add experimental.tasks mock for new task-based tools
The upstream main added simulate-research-query and async tools that use server.experimental.tasks.registerToolTask. Update mock servers to include this API. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,7 +48,7 @@ describe('Registration Index Files', () => {
|
|||||||
it('should register conditional tools based on capabilities', async () => {
|
it('should register conditional tools based on capabilities', async () => {
|
||||||
const { registerConditionalTools } = await import('../tools/index.js');
|
const { registerConditionalTools } = await import('../tools/index.js');
|
||||||
|
|
||||||
// Server with all capabilities
|
// Server with all capabilities including experimental tasks API
|
||||||
const mockServerWithCapabilities = {
|
const mockServerWithCapabilities = {
|
||||||
registerTool: vi.fn(),
|
registerTool: vi.fn(),
|
||||||
server: {
|
server: {
|
||||||
@@ -58,11 +58,16 @@ describe('Registration Index Files', () => {
|
|||||||
sampling: {},
|
sampling: {},
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
|
experimental: {
|
||||||
|
tasks: {
|
||||||
|
registerToolTask: vi.fn(),
|
||||||
|
},
|
||||||
|
},
|
||||||
} as unknown as McpServer;
|
} as unknown as McpServer;
|
||||||
|
|
||||||
registerConditionalTools(mockServerWithCapabilities);
|
registerConditionalTools(mockServerWithCapabilities);
|
||||||
|
|
||||||
// Should register 3 conditional tools when all capabilities present
|
// Should register 3 conditional tools + 3 task-based tools when all capabilities present
|
||||||
expect(mockServerWithCapabilities.registerTool).toHaveBeenCalledTimes(3);
|
expect(mockServerWithCapabilities.registerTool).toHaveBeenCalledTimes(3);
|
||||||
|
|
||||||
const registeredTools = (
|
const registeredTools = (
|
||||||
@@ -71,6 +76,9 @@ describe('Registration Index Files', () => {
|
|||||||
expect(registeredTools).toContain('get-roots-list');
|
expect(registeredTools).toContain('get-roots-list');
|
||||||
expect(registeredTools).toContain('trigger-elicitation-request');
|
expect(registeredTools).toContain('trigger-elicitation-request');
|
||||||
expect(registeredTools).toContain('trigger-sampling-request');
|
expect(registeredTools).toContain('trigger-sampling-request');
|
||||||
|
|
||||||
|
// Task-based tools are registered via experimental.tasks.registerToolTask
|
||||||
|
expect(mockServerWithCapabilities.experimental.tasks.registerToolTask).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not register conditional tools when capabilities missing', async () => {
|
it('should not register conditional tools when capabilities missing', async () => {
|
||||||
@@ -81,11 +89,16 @@ describe('Registration Index Files', () => {
|
|||||||
server: {
|
server: {
|
||||||
getClientCapabilities: vi.fn(() => ({})),
|
getClientCapabilities: vi.fn(() => ({})),
|
||||||
},
|
},
|
||||||
|
experimental: {
|
||||||
|
tasks: {
|
||||||
|
registerToolTask: vi.fn(),
|
||||||
|
},
|
||||||
|
},
|
||||||
} as unknown as McpServer;
|
} as unknown as McpServer;
|
||||||
|
|
||||||
registerConditionalTools(mockServerNoCapabilities);
|
registerConditionalTools(mockServerNoCapabilities);
|
||||||
|
|
||||||
// Should not register any tools when capabilities are missing
|
// Should not register any capability-gated tools when capabilities are missing
|
||||||
expect(mockServerNoCapabilities.registerTool).not.toHaveBeenCalled();
|
expect(mockServerNoCapabilities.registerTool).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user