fix(mcp): exclude archived records
This commit is contained in:
37
backend/tests/mcpArchivedResults.test.ts
Normal file
37
backend/tests/mcpArchivedResults.test.ts
Normal 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)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user