mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-21 05:15:21 +02:00
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:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user