From 4994b2c8db1343310b37ce8c99135ed9f038b0fc Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Sun, 6 Sep 2026 19:16:04 +0200 Subject: [PATCH] test(server): clean up read-only manifest filter assertions --- docs/plans/2026-09-06-mcp-server-plan.md | 20 ++++++++++---------- tests/read-only.test.ts | 19 ------------------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/docs/plans/2026-09-06-mcp-server-plan.md b/docs/plans/2026-09-06-mcp-server-plan.md index 42981c6..c296691 100644 --- a/docs/plans/2026-09-06-mcp-server-plan.md +++ b/docs/plans/2026-09-06-mcp-server-plan.md @@ -33,7 +33,7 @@ - `registerTool(server, tool, options)`: passes execution through `wrapExecute` if supplied. - `registerAllTools(server, options)`: forwards `wrapExecute` to each tool registration. -- [ ] **Step 1: Write failing tests for tool execution wrapping** +- [x] **Step 1: Write failing tests for tool execution wrapping** In `tests/tools.test.ts`: ```typescript @@ -63,12 +63,12 @@ describe("Tool Execution Wrapper", () => { }); ``` -- [ ] **Step 2: Run test to verify it fails** +- [x] **Step 2: Run test to verify it fails** Run: `bun test tests/tools.test.ts` Expected: FAIL (options parameter or wrapExecute behavior not implemented). -- [ ] **Step 3: Implement wrapExecute in `src/tools/common.ts` and `src/tools/index.ts`** +- [x] **Step 3: Implement wrapExecute in `src/tools/common.ts` and `src/tools/index.ts`** In `src/tools/common.ts`: Update `registerTool`: @@ -126,12 +126,12 @@ export interface RegisterToolsOptions { ``` And pass `options` to each tool registration. -- [ ] **Step 4: Run test to verify it passes** +- [x] **Step 4: Run test to verify it passes** Run: `bun test tests/tools.test.ts` Expected: PASS. -- [ ] **Step 5: Commit** +- [x] **Step 5: Commit** ```bash git add src/tools/common.ts src/tools/index.ts tests/tools.test.ts @@ -152,7 +152,7 @@ git commit -m "feat(tools): add execution wrapper support to tool registration" - `OpenProjectMcpServer`: `{ server: McpServer; client: OpenProjectClient; start: (transport?: Transport) => Promise; stop: () => Promise }` - `createServer(config: AppConfig): OpenProjectMcpServer` -- [ ] **Step 1: Write failing tests for server factory** +- [x] **Step 1: Write failing tests for server factory** In `tests/mcp-server.test.ts`: ```typescript @@ -189,12 +189,12 @@ describe("MCP Server Factory", () => { }); ``` -- [ ] **Step 2: Run test to verify it fails** +- [x] **Step 2: Run test to verify it fails** Run: `bun test tests/mcp-server.test.ts` Expected: FAIL with module `../src/server` not found. -- [ ] **Step 3: Implement `src/server.ts`** +- [x] **Step 3: Implement `src/server.ts`** In `src/server.ts`: ```typescript @@ -261,12 +261,12 @@ export function createServer(config: AppConfig): OpenProjectMcpServer { } ``` -- [ ] **Step 4: Run test to verify it passes** +- [x] **Step 4: Run test to verify it passes** Run: `bun test tests/mcp-server.test.ts` Expected: PASS. -- [ ] **Step 5: Commit** +- [x] **Step 5: Commit** ```bash git add src/server.ts tests/mcp-server.test.ts diff --git a/tests/read-only.test.ts b/tests/read-only.test.ts index d7d7674..05f9c6b 100644 --- a/tests/read-only.test.ts +++ b/tests/read-only.test.ts @@ -101,25 +101,6 @@ describe("Read-Only Mode Enforcement", () => { execute: async () => ({ content: [{ type: "text", text: "created" }] }), }; - const mcpServer = createServer({ - baseUrl: "http://localhost:8080", - apiKey: "test-key", - readOnly: true, - }); - - // Manually register a mutating tool through the server to test filtering - const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair(); - await mcpServer.start(serverTransport); - - const client = new Client({ name: "client", version: "1" }); - await client.connect(clientTransport); - - const toolsResult = await client.listTools(); - const names = toolsResult.tools.map((t) => t.name); - expect(names).not.toContain("openproject_create_work_package_synthetic"); - - await client.close(); - await mcpServer.stop(); // Also verify registerAllTools explicitly filters out mutating tools when readOnly is true const standaloneServer = new McpServer({ name: "test-server", version: "1.0.0" });