zabbix-graphql-api/src/test/mcp_operations_validation.test.ts
Andreas Hilbig 9a79fc8e4c feat: add MCP tools, refined recipe steps for schema extension verification and update Docker requirements
- Add mcp/operations/importHosts.graphql for flexible, name-based host provisioning.
- Split schema verification operations into createVerificationHost.graphql and verifySchemaExtension.graphql to support Apollo MCP server requirements.
- Improve mcp/operations/createHost.graphql with better type mapping and error message retrieval.
- Fix syntax error in importHosts.graphql by replacing unsupported triple-quote docstrings with standard comments.
- Add src/test/mcp_operations_validation.test.ts to automatically validate MCP operations against the GraphQL schema.
- Update docs/howtos/cookbook.md with 🤖 AI/MCP guidance and refined recipe steps for schema extension verification.
- Update README.md, docs/howtos/mcp.md, and .junie/guidelines.md to:
  - Add Docker (v27+) and Docker Compose (v2.29+) version requirements to the Tech Stack.
  - Enforce the use of docker compose (without hyphen) for all commands in the Environment guidelines.
  - Replace legacy docker-compose references across all documentation with the new command format.
2026-01-31 03:31:40 +01:00

28 lines
937 B
TypeScript

import {schema_loader} from "../api/schema.js";
import {readdirSync, readFileSync} from "node:fs";
import {parse, validate} from "graphql";
import path from "node:path";
describe("MCP Operations Validation", () => {
let schema: any;
beforeAll(async () => {
schema = await schema_loader();
});
const operationsDir = "./mcp/operations";
const files = readdirSync(operationsDir).filter(f => f.endsWith(".graphql"));
test.each(files)("Operation file %s should be valid against schema", (file) => {
const filePath = path.join(operationsDir, file);
const content = readFileSync(filePath, "utf-8");
const document = parse(content);
const errors = validate(schema, document);
if (errors.length > 0) {
console.error(`Validation errors in ${file}:`, errors.map(e => e.message));
}
expect(errors).toHaveLength(0);
});
});