mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
createMcpToolName, mcpNamespace, normalizeMcpInputSchema, limitMcpContent (with a caller-provided saver) and validation of the standard mcpServers shape move from coding-agent into pi-mcp, so other applications name and limit MCP tools exactly like pi. Applications validate their own fields on the tagged result; coding-agent keeps exposure, auth.provider and its Client ID Metadata Document rule.
24 lines
826 B
TypeScript
24 lines
826 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { normalizeMcpInputSchema } from "../src/index.ts";
|
|
|
|
describe("normalizeMcpInputSchema", () => {
|
|
it("adds type object and empty properties when missing", () => {
|
|
expect(normalizeMcpInputSchema({})).toEqual({ type: "object", properties: {} });
|
|
expect(normalizeMcpInputSchema({ type: "object" })).toEqual({ type: "object", properties: {} });
|
|
});
|
|
|
|
it("keeps the schema's own keywords", () => {
|
|
const schema = {
|
|
type: "object",
|
|
properties: { query: { type: "string" } },
|
|
required: ["query"],
|
|
additionalProperties: false,
|
|
};
|
|
expect(normalizeMcpInputSchema(schema)).toEqual(schema);
|
|
expect(normalizeMcpInputSchema({ properties: { a: {} }, $defs: { x: {} } })).toEqual({
|
|
type: "object",
|
|
properties: { a: {} },
|
|
$defs: { x: {} },
|
|
});
|
|
});
|
|
});
|