Skip to content

Commit f32e234

Browse files
Simplify error handling, switch to primarily integration tests
1 parent 0e010d7 commit f32e234

37 files changed

+4302
-4557
lines changed

.cursor/rules/general.mdc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
Work step-by-step. If presented with an implementation plan, implement the plan exactly. If the plan presents more than one implementation option, consult with the human user to decide between options. If you are tempted to embellish or imporve upon the plan, consult with the human user. Always complete the current task and wait for human review before proceeding to the next task.

babel.config.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', { targets: { node: 'current' } }],
4+
'@babel/preset-typescript',
5+
],
6+
};

index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
44
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
55
import { TaskManager } from "./src/server/TaskManager.js";
6-
import { ALL_TOOLS, executeToolWithErrorHandling } from "./src/server/tools.js";
6+
import { ALL_TOOLS, executeToolAndHandleErrors } from "./src/server/tools.js";
77
import { ListToolsRequestSchema, CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
88

99
// Create server with capabilities BEFORE setting up handlers
@@ -39,11 +39,16 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
3939
});
4040

4141
server.setRequestHandler(CallToolRequestSchema, async (request) => {
42-
return executeToolWithErrorHandling(
42+
// Directly call the handler. It either returns a result object (success or isError:true)
43+
// OR it throws a tagged protocol error.
44+
return await executeToolAndHandleErrors(
4345
request.params.name,
4446
request.params.arguments || {},
4547
taskManager
4648
);
49+
// SDK automatically handles:
50+
// - Wrapping the returned value (success data or isError:true object) in `result: { ... }`
51+
// - Catching re-thrown protocol errors and formatting the top-level `error: { ... }`
4752
});
4853

4954
// Start the server

jest.config.cjs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
const { createDefaultEsmPreset } = require('ts-jest');
2-
3-
const presetConfig = createDefaultEsmPreset({
4-
useESM: true,
5-
});
6-
71
module.exports = {
8-
...presetConfig,
92
testEnvironment: 'node',
103
moduleNameMapper: {
11-
'^(\\.{1,2}/.*)\\.js$': '$1',
4+
'^(\\.{1,2}/.*)\\.js$': '$1'
125
},
136
modulePathIgnorePatterns: ['<rootDir>/dist/'],
147
// Force Jest to exit after all tests have completed

0 commit comments

Comments
 (0)