fix(mcp): exclude archived records

This commit is contained in:
2026-09-09 14:19:34 +02:00
parent a6f55b61e4
commit d0bc8a5e0f
5 changed files with 96 additions and 53 deletions

View File

@@ -0,0 +1,37 @@
import assert from "node:assert/strict"
import test from "node:test"
import { mcpTools } from "../src/mcp/registry"
import { asToolResult } from "../src/mcp/result"
test("removes archived records from MCP text and structured output", () => {
const result = asToolResult({
rows: [
{ id: 1, archived: false, name: "Aktiv" },
{ id: 2, archived: true, name: "Archiviert" },
],
nested: {
current: { id: 3, archived: false },
previous: { id: 4, archived: true },
},
})
assert.deepEqual(result.structuredContent, {
rows: [{ id: 1, archived: false, name: "Aktiv" }],
nested: { current: { id: 3, archived: false } },
})
assert.deepEqual(JSON.parse(result.content[0].text), result.structuredContent)
})
test("does not expose a singular archived record", () => {
const result = asToolResult({ task: { id: 1, archived: true } })
assert.deepEqual(result.structuredContent, {})
assert.deepEqual(JSON.parse(result.content[0].text), {})
})
test("does not advertise includeArchived on MCP tools", () => {
for (const tool of mcpTools) {
const properties = (tool.inputSchema.properties || {}) as Record<string, unknown>
assert.equal(properties.includeArchived, undefined, tool.name)
}
})