test(server): clean up read-only manifest filter assertions
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
- `registerTool(server, tool, options)`: passes execution through `wrapExecute` if supplied.
|
- `registerTool(server, tool, options)`: passes execution through `wrapExecute` if supplied.
|
||||||
- `registerAllTools(server, options)`: forwards `wrapExecute` to each tool registration.
|
- `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`:
|
In `tests/tools.test.ts`:
|
||||||
```typescript
|
```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`
|
Run: `bun test tests/tools.test.ts`
|
||||||
Expected: FAIL (options parameter or wrapExecute behavior not implemented).
|
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`:
|
In `src/tools/common.ts`:
|
||||||
Update `registerTool`:
|
Update `registerTool`:
|
||||||
@@ -126,12 +126,12 @@ export interface RegisterToolsOptions {
|
|||||||
```
|
```
|
||||||
And pass `options` to each tool registration.
|
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`
|
Run: `bun test tests/tools.test.ts`
|
||||||
Expected: PASS.
|
Expected: PASS.
|
||||||
|
|
||||||
- [ ] **Step 5: Commit**
|
- [x] **Step 5: Commit**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git add src/tools/common.ts src/tools/index.ts tests/tools.test.ts
|
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<void>; stop: () => Promise<void> }`
|
- `OpenProjectMcpServer`: `{ server: McpServer; client: OpenProjectClient; start: (transport?: Transport) => Promise<void>; stop: () => Promise<void> }`
|
||||||
- `createServer(config: AppConfig): OpenProjectMcpServer`
|
- `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`:
|
In `tests/mcp-server.test.ts`:
|
||||||
```typescript
|
```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`
|
Run: `bun test tests/mcp-server.test.ts`
|
||||||
Expected: FAIL with module `../src/server` not found.
|
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`:
|
In `src/server.ts`:
|
||||||
```typescript
|
```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`
|
Run: `bun test tests/mcp-server.test.ts`
|
||||||
Expected: PASS.
|
Expected: PASS.
|
||||||
|
|
||||||
- [ ] **Step 5: Commit**
|
- [x] **Step 5: Commit**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git add src/server.ts tests/mcp-server.test.ts
|
git add src/server.ts tests/mcp-server.test.ts
|
||||||
|
|||||||
@@ -101,25 +101,6 @@ describe("Read-Only Mode Enforcement", () => {
|
|||||||
execute: async () => ({ content: [{ type: "text", text: "created" }] }),
|
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
|
// Also verify registerAllTools explicitly filters out mutating tools when readOnly is true
|
||||||
const standaloneServer = new McpServer({ name: "test-server", version: "1.0.0" });
|
const standaloneServer = new McpServer({ name: "test-server", version: "1.0.0" });
|
||||||
|
|||||||
Reference in New Issue
Block a user