38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
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)
|
|
}
|
|
})
|