feat(everything): add SEP-1686 Tasks support

- Add tasks capability with list, cancel, and requests.tools.call
- Add InMemoryTaskStore and InMemoryTaskMessageQueue from SDK experimental
- Add simulate-research-query tool demonstrating task lifecycle
- Task demonstrates working -> input_required -> completed status flow
- Uses elicitation for ambiguous queries when client supports it

Closes #3037

🦉 Generated with [Claude Code](https://claude.ai/code)
This commit is contained in:
olaservo
2026-01-09 05:58:49 -07:00
parent 9691b958ec
commit 0208e93f85
4 changed files with 389 additions and 1 deletions

View File

@@ -1,4 +1,8 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import {
InMemoryTaskStore,
InMemoryTaskMessageQueue,
} from "@modelcontextprotocol/sdk/experimental";
import {
setSubscriptionHandlers,
stopSimulatedResourceUpdates,
@@ -32,6 +36,10 @@ export const createServer: () => ServerFactoryResponse = () => {
// Read the server instructions
const instructions = readInstructions();
// Create task store and message queue for task support
const taskStore = new InMemoryTaskStore();
const taskMessageQueue = new InMemoryTaskMessageQueue();
// Create the server
const server = new McpServer(
{
@@ -52,8 +60,19 @@ export const createServer: () => ServerFactoryResponse = () => {
listChanged: true,
},
logging: {},
tasks: {
list: {},
cancel: {},
requests: {
tools: {
call: {},
},
},
},
},
instructions,
taskStore,
taskMessageQueue,
}
);
@@ -89,6 +108,8 @@ export const createServer: () => ServerFactoryResponse = () => {
// Stop any simulated logging or resource updates that may have been initiated.
stopSimulatedLogging(sessionId);
stopSimulatedResourceUpdates(sessionId);
// Clean up task store timers
taskStore.cleanup();
},
} satisfies ServerFactoryResponse;
};