qyl-mcp-server 7.3.0 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +52 -5
  2. package/dist/ci.js +1 -1
  3. package/dist/ci.js.map +1 -1
  4. package/dist/collector.d.ts +9 -6
  5. package/dist/collector.js +19 -4
  6. package/dist/collector.js.map +1 -1
  7. package/dist/contract-validation.d.ts +17 -0
  8. package/dist/contract-validation.js +65 -0
  9. package/dist/contract-validation.js.map +1 -1
  10. package/dist/data.d.ts +36 -13
  11. package/dist/data.js +74 -23
  12. package/dist/data.js.map +1 -1
  13. package/dist/events.js +1 -1
  14. package/dist/events.js.map +1 -1
  15. package/dist/http-security.d.ts +1 -0
  16. package/dist/http-security.js +1 -1
  17. package/dist/http-security.js.map +1 -1
  18. package/dist/main.js +1 -4
  19. package/dist/main.js.map +1 -1
  20. package/dist/mcp-app.html +1 -1
  21. package/dist/mcp-dashboard.html +1 -1
  22. package/dist/mcp-home.html +1 -1
  23. package/dist/metrics-tools.d.ts +4 -11
  24. package/dist/metrics-tools.js +43 -44
  25. package/dist/metrics-tools.js.map +1 -1
  26. package/dist/metrics.d.ts +21 -39
  27. package/dist/metrics.js +58 -53
  28. package/dist/metrics.js.map +1 -1
  29. package/dist/paging.d.ts +16 -0
  30. package/dist/paging.js +33 -0
  31. package/dist/paging.js.map +1 -0
  32. package/dist/server.js +44 -38
  33. package/dist/server.js.map +1 -1
  34. package/dist/summaries.d.ts +13 -2
  35. package/dist/summaries.js +20 -4
  36. package/dist/summaries.js.map +1 -1
  37. package/dist/telemetry.js +7 -0
  38. package/dist/telemetry.js.map +1 -1
  39. package/dist/tools.js +66 -16
  40. package/dist/tools.js.map +1 -1
  41. package/package.json +2 -2
  42. package/dist/contract-operations.d.ts +0 -37
  43. package/dist/contract-operations.js +0 -124
  44. package/dist/contract-operations.js.map +0 -1
@@ -1,124 +0,0 @@
1
- /**
2
- * Tool INPUT shapes derived from the published operation parameters.
3
- *
4
- * contract-validation.ts binds every response body and every `Mcp.Tools.*`
5
- * shape the contract publishes. The metrics read API arrived in
6
- * @ancplua/qyl-api-schema 8.0.0 with its response bodies but without
7
- * `Mcp.Tools.*Metric*` input shapes, so there is nothing there to bind for the
8
- * arguments of `list_metrics`, `get_metric_series`, and `query_metric`.
9
- *
10
- * Hand-writing those three objects is exactly what architecture gate G10a
11
- * exists to prevent, and an exemption would carve the hole in the one place the
12
- * gate names first ("request, response, or tool-input shapes"). So the inputs
13
- * are generated too — from the other artifact the contract package publishes,
14
- * its OpenAPI document. Every name, type, bound, default, enum, and description
15
- * a metrics tool advertises is read out of `@ancplua/qyl-api-schema/openapi` at
16
- * startup; nothing here is typed by hand except which operation a tool wraps,
17
- * which is the same standing as `Operations.TracesApi_list.Response.200` being
18
- * named in contract-validation.ts. A parameter added, retyped, or re-bounded on
19
- * the collector side therefore moves the tool's advertised input and fails the
20
- * G10b manifest snapshot, instead of drifting silently.
21
- *
22
- * This module is deliberately NOT re-exported through contract-validation.ts:
23
- * the OpenAPI document is ~730 KB and that module is also imported by the
24
- * dashboard and workbench browser bundles.
25
- *
26
- * When the contract publishes `Mcp.Tools.ListMetricsInput` and friends, delete
27
- * this file and bind them in contract-validation.ts like every other tool.
28
- */
29
- import { createRequire } from "node:module";
30
- import * as z from "zod/v4";
31
- const COMPONENT_SCHEMA_PREFIX = "#/components/schemas/";
32
- // require() rather than an import attribute: the package's "./openapi" export
33
- // declares no "types" condition, so a static JSON import has no type to resolve
34
- // and `verbatimModuleSyntax` would have to be worked around at every call site.
35
- const publishedOpenApi = createRequire(import.meta.url)("@ancplua/qyl-api-schema/openapi");
36
- /**
37
- * Rewrite a published parameter schema into the subset `z.fromJSONSchema`
38
- * accepts, resolving component references as it goes.
39
- *
40
- * Two published constructs need it, for the same reasons the contract package's
41
- * own zod adapter documents: `unevaluatedProperties` is rejected outright by
42
- * `z.fromJSONSchema` and is only ever used to seal an object, and a
43
- * `#/components/schemas/...` reference has no meaning once the parameter is
44
- * lifted out of the OpenAPI document. Resolution is by inlining, which is exact
45
- * for the enums and scalars parameters actually use and would need a `$defs`
46
- * carrier if a parameter ever referenced a recursive model.
47
- */
48
- function resolvePublishedSchema(node, seen = []) {
49
- if (Array.isArray(node))
50
- return node.map((item) => resolvePublishedSchema(item, seen));
51
- if (typeof node !== "object" || node === null)
52
- return node;
53
- const source = node;
54
- const resolved = {};
55
- for (const [key, value] of Object.entries(source)) {
56
- if (key === "unevaluatedProperties" || key === "$ref")
57
- continue;
58
- resolved[key] = resolvePublishedSchema(value, seen);
59
- }
60
- const reference = source.$ref;
61
- if (typeof reference !== "string")
62
- return resolved;
63
- if (!reference.startsWith(COMPONENT_SCHEMA_PREFIX)) {
64
- throw new Error(`contract-operations: unsupported parameter reference ${reference}`);
65
- }
66
- const name = reference.slice(COMPONENT_SCHEMA_PREFIX.length);
67
- if (seen.includes(name)) {
68
- throw new Error(`contract-operations: ${name} is recursive; a parameter referencing it needs a ` +
69
- "$defs carrier rather than inlining");
70
- }
71
- const target = publishedOpenApi.components.schemas[name];
72
- if (target === undefined) {
73
- throw new Error(`contract-operations: ${reference} is not a published component schema`);
74
- }
75
- // A `$ref` with siblings is how the contract spells "this published model,
76
- // with this default" — `aggregation` is `MetricAggregation` plus
77
- // `default: "avg"`. Dropping the siblings would silently drop the default and
78
- // leave the tool advertising a required-looking enum with no fallback, so the
79
- // resolved target is merged UNDER them: the local keywords win.
80
- return { ...resolvePublishedSchema(target, [...seen, name]), ...resolved };
81
- }
82
- /**
83
- * The tool-input schema for one published GET operation.
84
- *
85
- * Header parameters are excluded: `ProjectScopeHeader` is the server-owned
86
- * collector project scope, which QYL_PROJECT sets and a model never supplies —
87
- * the same boundary the root README states for every other tool.
88
- */
89
- export function operationInputSchema(pathname) {
90
- const operation = publishedOpenApi.paths[pathname]?.get;
91
- if (operation === undefined) {
92
- throw new Error(`contract-operations: the contract publishes no GET ${pathname}`);
93
- }
94
- const properties = {};
95
- const required = [];
96
- for (const parameter of operation.parameters ?? []) {
97
- // A $ref parameter is a shared component; the only one the metrics
98
- // operations use is the project-scope header.
99
- if (parameter.$ref !== undefined || parameter.name === undefined)
100
- continue;
101
- if (parameter.in === "header")
102
- continue;
103
- const schema = resolvePublishedSchema(parameter.schema);
104
- properties[parameter.name] = parameter.description === undefined
105
- ? schema
106
- : { ...schema, description: parameter.description };
107
- if (parameter.required === true)
108
- required.push(parameter.name);
109
- }
110
- if (Object.keys(properties).length === 0) {
111
- throw new Error(`contract-operations: GET ${pathname} publishes no model-supplied parameters`);
112
- }
113
- // The assembled document is JSON Schema by construction — every property came
114
- // out of the published parameter list — but it is built as plain data, so the
115
- // cast is what tells the compiler that.
116
- const assembled = {
117
- type: "object",
118
- properties,
119
- ...(required.length === 0 ? {} : { required }),
120
- additionalProperties: false,
121
- };
122
- return z.fromJSONSchema(assembled);
123
- }
124
- //# sourceMappingURL=contract-operations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract-operations.js","sourceRoot":"","sources":["../src/contract-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,MAAM,uBAAuB,GAAG,uBAAuB,CAAC;AAgBxD,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CACrD,iCAAiC,CACf,CAAC;AAErB;;;;;;;;;;;GAWG;AACH,SAAS,sBAAsB,CAAC,IAAa,EAAE,IAAI,GAAsB,EAAE;IACzE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CA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