Skip to content

Commit 08a6ca3

Browse files
Revert optimization tool from task-based to synchronous
No MCP clients currently support the experimental Tasks API: - MCP Inspector: task support not available - Claude Desktop/CLI: returns error -32601 (task augmentation required) - Goose: falls back to other tools Changes: - Remove task-based OptimizationTask.ts implementation - Re-enable synchronous OptimizationTool.ts (with polling) - Remove task capabilities from server (taskStore, InMemoryTaskStore, etc.) - Update OptimizeDeliveriesPrompt to remove task-based language - Tool now blocks for 5-10 seconds during optimization (necessary trade-off) The synchronous version: - Works in all current MCP clients - Still does async polling internally (POST job, GET results) - Returns results when optimization completes - All 422 tests passing We can convert back to task-based when clients add support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 79d72f5 commit 08a6ca3

3 files changed

Lines changed: 4 additions & 447 deletions

File tree

src/index.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ import {
1515
ListPromptsRequestSchema,
1616
GetPromptRequestSchema
1717
} from '@modelcontextprotocol/sdk/types.js';
18-
import {
19-
InMemoryTaskStore,
20-
InMemoryTaskMessageQueue
21-
} from '@modelcontextprotocol/sdk/experimental/tasks/stores/in-memory.js';
2218
import { parseToolConfigFromArgs, filterTools } from './config/toolConfig.js';
2319
import { getAllTools } from './tools/toolRegistry.js';
2420
import { getAllResources } from './resources/resourceRegistry.js';
2521
import { getAllPrompts, getPromptByName } from './prompts/promptRegistry.js';
2622
import { getVersionInfo } from './utils/versionUtils.js';
27-
import { registerOptimizationTask } from './tools/optimization-tool/OptimizationTask.js';
28-
import { httpRequest } from './utils/httpPipeline.js';
2923
import {
3024
initializeTracing,
3125
shutdownTracing,
@@ -68,9 +62,6 @@ const enabledTools = filterTools(allTools, config);
6862
// Get all resources
6963
const allResources = getAllResources();
7064

71-
// Create task store for async operations
72-
const taskStore = new InMemoryTaskStore();
73-
7465
// Create an MCP server
7566
const server = new McpServer(
7667
{
@@ -81,26 +72,16 @@ const server = new McpServer(
8172
capabilities: {
8273
tools: {},
8374
resources: {},
84-
prompts: {},
85-
tasks: { requests: { tools: { call: {} } } }
86-
},
87-
taskStore,
88-
taskMessageQueue: new InMemoryTaskMessageQueue()
75+
prompts: {}
76+
}
8977
}
9078
);
9179

9280
// Register enabled tools to the server
9381
enabledTools.forEach((tool) => {
94-
// Skip OptimizationTool as it's registered as a task instead
95-
if (tool.name === 'optimization_tool') {
96-
return;
97-
}
9882
tool.installTo(server);
9983
});
10084

101-
// Register task-based tools
102-
registerOptimizationTask(server, httpRequest);
103-
10485
// Register all resources to the server
10586
allResources.forEach((resource) => {
10687
resource.installTo(server);

src/prompts/OptimizeDeliveriesPrompt.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,14 @@ Please follow these steps:
6363
2. Use optimization_tool to find the optimal route:
6464
- Pass coordinates array
6565
- Set profile to mapbox/${mode}
66-
- The tool will run as an async task - you'll get a task ID immediately
67-
3. Poll the task until it completes (the tool handles this automatically)
68-
4. Once results are available, display:
66+
- The tool will process the optimization (this may take 5-10 seconds for complex routes)
67+
3. Once results are available, display:
6968
- Optimized sequence of stops (which location to visit in what order)
7069
- Total distance and estimated travel time
7170
- Estimated arrival time at each stop
7271
- Map visualization showing the optimized route
7372
- Any locations that couldn't be included (dropped items)
7473
75-
IMPORTANT: The optimization_tool is task-based and runs asynchronously. The tool will submit the job and poll for results in the background. Present the results once the task completes.
76-
7774
Format the output to be clear with:
7875
- Numbered list of stops in optimal order
7976
- ETAs at each location

0 commit comments

Comments
 (0)