@mastra/server 1.84.0-alpha.6 → 1.84.0-alpha.7
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.
- package/dist/{api-schema-manifest-C889XFn5.js → api-schema-manifest-DCzvjHv-.js} +2 -2
- package/dist/{api-schema-manifest-C889XFn5.js.map → api-schema-manifest-DCzvjHv-.js.map} +1 -1
- package/dist/{api-schema-manifest-Cn9tPyZh.cjs → api-schema-manifest-fgF8cSPB.cjs} +2 -2
- package/dist/{api-schema-manifest-Cn9tPyZh.cjs.map → api-schema-manifest-fgF8cSPB.cjs.map} +1 -1
- package/dist/{catalogue-COgS_54R.cjs → catalogue-Cx07-xfS.cjs} +200 -23
- package/dist/catalogue-Cx07-xfS.cjs.map +1 -0
- package/dist/{catalogue-C2Frc4-i.js → catalogue-Nzu-ZF0D.js} +200 -24
- package/dist/catalogue-Nzu-ZF0D.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-server-mcp.md +55 -1
- package/dist/docs/references/reference-observability-tracing-advanced-queries.md +31 -0
- package/dist/docs/references/reference-server-builtin-mcp-tools.md +2 -2
- package/dist/{observability-Z2tDxHS1.js → observability-CCh5zFpG.js} +2 -2
- package/dist/{observability-Z2tDxHS1.js.map → observability-CCh5zFpG.js.map} +1 -1
- package/dist/{observability-BCJsmSH0.cjs → observability-CJpRP8-U.cjs} +2 -2
- package/dist/{observability-BCJsmSH0.cjs.map → observability-CJpRP8-U.cjs.map} +1 -1
- package/dist/{observability-new-endpoints-dr0XcNkP.js → observability-new-endpoints-BUYXgPTJ.js} +65 -9
- package/dist/observability-new-endpoints-BUYXgPTJ.js.map +1 -0
- package/dist/{observability-new-endpoints-C_HEkpZ1.cjs → observability-new-endpoints-JU-OS7aM.cjs} +64 -8
- package/dist/observability-new-endpoints-JU-OS7aM.cjs.map +1 -0
- package/dist/{routes-pkh0aVDt.cjs → routes-DKXsOYPs.cjs} +110 -7
- package/dist/routes-DKXsOYPs.cjs.map +1 -0
- package/dist/{routes-DGoYe50m.js → routes-V4gD8fd0.js} +110 -7
- package/dist/routes-V4gD8fd0.js.map +1 -0
- package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +16 -16
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +1 -1
- package/dist/server/handlers/observability-shared.cjs +17 -10
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +6 -4
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +17 -10
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability.cjs +2 -2
- package/dist/server/handlers/observability.js +2 -2
- package/dist/server/handlers/system.cjs +2 -2
- package/dist/server/handlers/system.d.ts +8 -4
- package/dist/server/handlers/system.d.ts.map +1 -1
- package/dist/server/handlers/system.js +2 -2
- package/dist/server/handlers.cjs +1 -1
- package/dist/server/handlers.js +1 -1
- package/dist/server/mcp/catalogue.d.ts +15 -1
- package/dist/server/mcp/catalogue.d.ts.map +1 -1
- package/dist/server/mcp/config.d.ts +4 -0
- package/dist/server/mcp/config.d.ts.map +1 -1
- package/dist/server/mcp/route.d.ts +2 -0
- package/dist/server/mcp/route.d.ts.map +1 -1
- package/dist/server/mcp/toolsets/observability-summary.d.ts +15 -0
- package/dist/server/mcp/toolsets/observability-summary.d.ts.map +1 -0
- package/dist/server/mcp/toolsets/observability.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +1 -1
- package/dist/server/schemas/index.js +1 -1
- package/dist/server/schemas/system.d.ts +8 -4
- package/dist/server/schemas/system.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +2 -2
- package/dist/server/server-adapter/index.js +2 -2
- package/dist/server/server-adapter/routes/conversations.d.ts +3 -3
- package/dist/server/server-adapter/routes/observability.d.ts +8 -8
- package/dist/server/server-adapter/routes/responses.d.ts +11 -11
- package/dist/server/server-adapter/routes/system.d.ts +8 -4
- package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
- package/dist/{server-adapter-CB8qI6YQ.js → server-adapter-Cps8XkTM.js} +2 -2
- package/dist/{server-adapter-CB8qI6YQ.js.map → server-adapter-Cps8XkTM.js.map} +1 -1
- package/dist/{server-adapter-9QWRzNZI.cjs → server-adapter-D6KmPiB1.cjs} +2 -2
- package/dist/{server-adapter-9QWRzNZI.cjs.map → server-adapter-D6KmPiB1.cjs.map} +1 -1
- package/dist/{system-FnU7vyxd.js → system-CKTXaHMZ.js} +5 -3
- package/dist/system-CKTXaHMZ.js.map +1 -0
- package/dist/{system-DdMSBAOY.cjs → system-DKCYwd0y.cjs} +5 -3
- package/dist/system-DKCYwd0y.cjs.map +1 -0
- package/package.json +11 -7
- package/src/server/mcp/apps-module.d.ts +9 -0
- package/dist/catalogue-C2Frc4-i.js.map +0 -1
- package/dist/catalogue-COgS_54R.cjs.map +0 -1
- package/dist/observability-new-endpoints-C_HEkpZ1.cjs.map +0 -1
- package/dist/observability-new-endpoints-dr0XcNkP.js.map +0 -1
- package/dist/routes-DGoYe50m.js.map +0 -1
- package/dist/routes-pkh0aVDt.cjs.map +0 -1
- package/dist/system-DdMSBAOY.cjs.map +0 -1
- package/dist/system-FnU7vyxd.js.map +0 -1
|
@@ -3,12 +3,12 @@ import "./constants-0xZU_h4R.js";
|
|
|
3
3
|
import { G as getAgentFromSystem, f as GENERATE_AGENT_ROUTE, h as GET_AGENT_BY_ID_ROUTE, v as LIST_AGENTS_ROUTE } from "./agents-CEgQ1Sj5.js";
|
|
4
4
|
import { a as LIST_TOOLS_ROUTE, i as GET_TOOL_BY_ID_ROUTE, n as EXECUTE_TOOL_ROUTE, o as findTool } from "./tools-BuFpB7Lk.js";
|
|
5
5
|
import { _ as RESUME_ASYNC_WORKFLOW_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, k as listWorkflowsFromSystem, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, t as CANCEL_WORKFLOW_RUN_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE } from "./workflows-9Q28sHTz.js";
|
|
6
|
-
import { o as checkRouteRBAC, r as authorizeRoute, s as dispatchRoute } from "./server-adapter-
|
|
7
|
-
import { c as getBuiltinMCPCapabilities, s as getEffectivePermission } from "./routes-
|
|
6
|
+
import { o as checkRouteRBAC, r as authorizeRoute, s as dispatchRoute } from "./server-adapter-Cps8XkTM.js";
|
|
7
|
+
import { c as getBuiltinMCPCapabilities, s as getEffectivePermission } from "./routes-V4gD8fd0.js";
|
|
8
8
|
import "./utils-BfySxdfF.js";
|
|
9
9
|
import { E as UPDATE_THREAD_ROUTE, b as LIST_THREADS_ROUTE, d as GET_MEMORY_STATUS_ROUTE, f as GET_OBSERVATIONAL_MEMORY_ROUTE, g as GET_WORKING_MEMORY_ROUTE, h as GET_THREAD_BY_ID_ROUTE, i as CREATE_THREAD_ROUTE, l as GET_MEMORY_CONFIG_ROUTE, n as CLONE_THREAD_ROUTE, p as GET_RESOURCE_WORKING_MEMORY_ROUTE, t as AWAIT_BUFFER_STATUS_ROUTE, v as LIST_MESSAGES_ROUTE } from "./memory-DS2tEXzG.js";
|
|
10
|
-
import { a as GET_TRACE_ROUTE, i as GET_TRACE_LIGHT_ROUTE, o as GET_TRACE_TRAJECTORY_ROUTE, r as GET_SPAN_ROUTE, u as LIST_TRACES_ROUTE } from "./observability-
|
|
11
|
-
import { A as GET_TRACE_QUERY_FIELDS, D as GET_SCORE_TIME_SERIES, E as GET_SCORE_PERCENTILES, F as LIST_SCORES, L as QUERY_SPANS, M as LIST_FEEDBACK, N as LIST_LOGS, R as QUERY_THREADS, S as GET_METRIC_TIME_SERIES, T as GET_SCORE_BREAKDOWN, _ as GET_METRIC_BREAKDOWN, b as GET_METRIC_NAMES, f as GET_FEEDBACK_AGGREGATE, g as GET_METRIC_AGGREGATE, h as GET_FEEDBACK_TIME_SERIES, j as GET_TRACE_QUERY_VALUES, m as GET_FEEDBACK_PERCENTILES, n as AGGREGATE_TRACES, p as GET_FEEDBACK_BREAKDOWN, t as AGGREGATE_SPANS, v as GET_METRIC_LABEL_KEYS, w as GET_SCORE_AGGREGATE, x as GET_METRIC_PERCENTILES, y as GET_METRIC_LABEL_VALUES, z as QUERY_TRACES } from "./observability-new-endpoints-
|
|
10
|
+
import { a as GET_TRACE_ROUTE, i as GET_TRACE_LIGHT_ROUTE, o as GET_TRACE_TRAJECTORY_ROUTE, r as GET_SPAN_ROUTE, u as LIST_TRACES_ROUTE } from "./observability-CCh5zFpG.js";
|
|
11
|
+
import { A as GET_TRACE_QUERY_FIELDS, D as GET_SCORE_TIME_SERIES, E as GET_SCORE_PERCENTILES, F as LIST_SCORES, L as QUERY_SPANS, M as LIST_FEEDBACK, N as LIST_LOGS, O as GET_SERVICE_NAMES, R as QUERY_THREADS, S as GET_METRIC_TIME_SERIES, T as GET_SCORE_BREAKDOWN, _ as GET_METRIC_BREAKDOWN, b as GET_METRIC_NAMES, c as GET_ENTITY_NAMES, f as GET_FEEDBACK_AGGREGATE, g as GET_METRIC_AGGREGATE, h as GET_FEEDBACK_TIME_SERIES, j as GET_TRACE_QUERY_VALUES, k as GET_TAGS, l as GET_ENTITY_TYPES, m as GET_FEEDBACK_PERCENTILES, n as AGGREGATE_TRACES, p as GET_FEEDBACK_BREAKDOWN, s as GET_CAPABILITIES, t as AGGREGATE_SPANS, u as GET_ENVIRONMENTS, v as GET_METRIC_LABEL_KEYS, w as GET_SCORE_AGGREGATE, x as GET_METRIC_PERCENTILES, y as GET_METRIC_LABEL_VALUES, z as QUERY_TRACES } from "./observability-new-endpoints-BUYXgPTJ.js";
|
|
12
12
|
import { t as GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE } from "./editor-builder-Dd10fik0.js";
|
|
13
13
|
import { CREATE_STORED_AGENT_ROUTE, GET_STORED_AGENT_ROUTE, LIST_STORED_AGENTS_ROUTE, UPDATE_STORED_AGENT_ROUTE } from "./server/handlers/stored-agents.js";
|
|
14
14
|
import { O as updateStoredAgentBodySchema, n as createStoredAgentBodySchema } from "./stored-agents-DmN_pIIl.js";
|
|
@@ -366,6 +366,134 @@ async function addMemoryTools(kit) {
|
|
|
366
366
|
})
|
|
367
367
|
}, signal));
|
|
368
368
|
}
|
|
369
|
+
// src/server/mcp/toolsets/observability-summary.ts
|
|
370
|
+
const DETAILS = "Call get_trace with a traceId for its span tree, and get_span for a span’s full input and output.";
|
|
371
|
+
const isRow = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
372
|
+
const rowsOf = (output, key) => Array.isArray(output[key]) ? output[key].filter(isRow) : [];
|
|
373
|
+
const text = (value, max) => {
|
|
374
|
+
if (typeof value !== "string" || !value) return void 0;
|
|
375
|
+
const line = value.replace(/\s+/g, " ").trim();
|
|
376
|
+
return line.length > max ? `${line.slice(0, max)}…` : line;
|
|
377
|
+
};
|
|
378
|
+
function duration(row) {
|
|
379
|
+
if (typeof row.durationMs === "number") return `${row.durationMs}ms`;
|
|
380
|
+
const start = Date.parse(String(row.startedAt));
|
|
381
|
+
const end = Date.parse(String(row.endedAt));
|
|
382
|
+
return Number.isNaN(start) || Number.isNaN(end) ? void 0 : `${end - start}ms`;
|
|
383
|
+
}
|
|
384
|
+
function errorOf(row) {
|
|
385
|
+
const error = row.errorPreview ?? (isRow(row.error) ? row.error.message : row.error);
|
|
386
|
+
const message = text(error, 200);
|
|
387
|
+
return message && `error: ${message}`;
|
|
388
|
+
}
|
|
389
|
+
const cells = (...values) => values.filter((value) => typeof value === "string" && value !== "").join(" | ");
|
|
390
|
+
const entity = (row) => cells(row.entityType ?? row.spanType, text(row.entityName ?? row.name, 80));
|
|
391
|
+
const status = (row) => typeof row.status === "string" ? row.status : row.error ? "error" : void 0;
|
|
392
|
+
/** Paging the model can act on: the clip note from `fitRows`, a keyset cursor, or offset pages. */
|
|
393
|
+
function paging(output) {
|
|
394
|
+
const lines = [];
|
|
395
|
+
if (typeof output.truncated === "string") lines.push(output.truncated);
|
|
396
|
+
const page = isRow(output.page) ? output.page : void 0;
|
|
397
|
+
if (typeof page?.next === "string") lines.push(`More rows: call again with page.after = "${page.next}".`);
|
|
398
|
+
const pagination = isRow(output.pagination) ? output.pagination : void 0;
|
|
399
|
+
if (pagination?.hasMore) lines.push(`${String(pagination.total)} rows in all. More rows: call again with page = ${Number(pagination.page) + 1}.`);
|
|
400
|
+
return lines;
|
|
401
|
+
}
|
|
402
|
+
function summary(heading, lines, output, footer = DETAILS) {
|
|
403
|
+
return [
|
|
404
|
+
heading,
|
|
405
|
+
...lines,
|
|
406
|
+
...paging(output),
|
|
407
|
+
footer
|
|
408
|
+
].join("\n");
|
|
409
|
+
}
|
|
410
|
+
/** Trace rows: `query_traces` returns them under `traces`, `list_traces` (root spans) under `spans`. */
|
|
411
|
+
function summarizeTraces(key) {
|
|
412
|
+
return (output) => {
|
|
413
|
+
if (Array.isArray(output.groups)) {
|
|
414
|
+
const groups = rowsOf(output, "groups");
|
|
415
|
+
return summary(`${groups.length} threads matched (threadId):`, groups.map((group) => `- ${cells(group.threadId)}`), output, "Call query_traces with a threadId filter for the traces in a thread.");
|
|
416
|
+
}
|
|
417
|
+
const rows = rowsOf(output, key);
|
|
418
|
+
return summary(`${rows.length} traces, shown to the user in the observability explorer (traceId | entity | status | started | duration):`, rows.map((row) => `- ${cells(row.traceId, entity(row), status(row), row.startedAt, duration(row), errorOf(row), text(row.inputPreview, 80) && `input: ${text(row.inputPreview, 80)}`)}`), output);
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
/** A log's `data` as one line of JSON, without stack traces, which `list_logs` still returns in full. */
|
|
422
|
+
function dataOf(row) {
|
|
423
|
+
if (!isRow(row.data) || !Object.keys(row.data).length) return void 0;
|
|
424
|
+
const line = text(JSON.stringify(row.data, (key, value) => key === "stack" ? void 0 : value), 160);
|
|
425
|
+
return line && `data: ${line}`;
|
|
426
|
+
}
|
|
427
|
+
function summarizeLogs(output) {
|
|
428
|
+
const rows = rowsOf(output, "logs");
|
|
429
|
+
return summary(`${rows.length} logs, shown to the user in the observability explorer (time | level | entity | message | data | trace and span):`, rows.map((row) => {
|
|
430
|
+
const where = typeof row.traceId === "string" ? `trace ${row.traceId}${row.spanId ? ` span ${String(row.spanId)}` : ""}` : void 0;
|
|
431
|
+
return `- ${cells(row.timestamp, row.level, row.entityName ? entity(row) : void 0, text(row.message, 200), dataOf(row), where)}`;
|
|
432
|
+
}), output);
|
|
433
|
+
}
|
|
434
|
+
/** A light trace as an indented span tree, children under their parent in start order. */
|
|
435
|
+
function summarizeTrace(output) {
|
|
436
|
+
const spans = rowsOf(output, "spans");
|
|
437
|
+
const ids = new Set(spans.map((span) => span.spanId));
|
|
438
|
+
const children = /* @__PURE__ */ new Map();
|
|
439
|
+
for (const span of spans) {
|
|
440
|
+
const parent = ids.has(span.parentSpanId) ? span.parentSpanId : null;
|
|
441
|
+
children.set(parent, [...children.get(parent) ?? [], span]);
|
|
442
|
+
}
|
|
443
|
+
const lines = [];
|
|
444
|
+
const walk = (parent, depth) => {
|
|
445
|
+
for (const span of children.get(parent) ?? []) {
|
|
446
|
+
lines.push(`${" ".repeat(depth)}- ${cells(span.spanId, cells(span.spanType, text(span.name, 80)), status(span), duration(span), errorOf(span))}`);
|
|
447
|
+
walk(span.spanId, depth + 1);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
walk(null, 0);
|
|
451
|
+
const count = typeof output.spanCount === "number" ? output.spanCount : spans.length;
|
|
452
|
+
const rest = typeof output.nextOffset === "number" ? [`More spans: call get_trace again with offset = ${output.nextOffset}.`] : [];
|
|
453
|
+
return [
|
|
454
|
+
`Trace ${String(output.traceId)}: ${count} spans, shown to the user in Studio's trace viewer (spanId | type and name | status | duration):`,
|
|
455
|
+
...lines,
|
|
456
|
+
...rest,
|
|
457
|
+
"Call get_span with the traceId and a spanId for its full input, output, and attributes."
|
|
458
|
+
].join("\n");
|
|
459
|
+
}
|
|
460
|
+
/** Three decimals, but small nonzero values (a $0.0004 cost) keep three significant digits instead of reading 0. */
|
|
461
|
+
function num(value) {
|
|
462
|
+
if (typeof value !== "number") return void 0;
|
|
463
|
+
if (value === 0 || Math.abs(value) >= 1) return String(Math.round(value * 1e3) / 1e3);
|
|
464
|
+
return String(Number(value.toPrecision(3)));
|
|
465
|
+
}
|
|
466
|
+
/** A series as its range and endpoints: the app charts every point. */
|
|
467
|
+
function seriesLine(label, series) {
|
|
468
|
+
const points = rowsOf(series, "points").filter((point) => typeof point.value === "number");
|
|
469
|
+
if (!points.length) return `- ${label}: no data`;
|
|
470
|
+
const values = points.map((point) => point.value);
|
|
471
|
+
const first = points[0];
|
|
472
|
+
const last = points[points.length - 1];
|
|
473
|
+
return `- ${label}: ${points.length} points from ${String(first.timestamp)} (${num(first.value)}) to ${String(last.timestamp)} (${num(last.value)}), min ${num(Math.min(...values))}, max ${num(Math.max(...values))}`;
|
|
474
|
+
}
|
|
475
|
+
/** `analyze_metrics` results, by op: an aggregate, breakdown groups, or time series / percentile series. */
|
|
476
|
+
function summarizeMetrics(output) {
|
|
477
|
+
const footer = "The user sees these metrics charted in the observability explorer.";
|
|
478
|
+
if (Array.isArray(output.groups)) {
|
|
479
|
+
const groups = rowsOf(output, "groups");
|
|
480
|
+
return summary(`${groups.length} groups (dimensions | value | cost):`, groups.map((group) => {
|
|
481
|
+
const dimensions = isRow(group.dimensions) ? Object.entries(group.dimensions).map(([key, value]) => `${key}=${String(value)}`).join(", ") : void 0;
|
|
482
|
+
return `- ${cells(dimensions, num(group.value), num(group.estimatedCost) && `${num(group.estimatedCost)} ${group.costUnit ?? ""}`.trim())}`;
|
|
483
|
+
}), output, footer);
|
|
484
|
+
}
|
|
485
|
+
if (Array.isArray(output.series)) {
|
|
486
|
+
const series = rowsOf(output, "series");
|
|
487
|
+
return summary(`${series.length} series:`, series.map((line) => seriesLine(typeof line.name === "string" ? line.name : `p${num(line.percentile)}`, line)), output, footer);
|
|
488
|
+
}
|
|
489
|
+
return [
|
|
490
|
+
`Value: ${num(output.value) ?? "no data"}`,
|
|
491
|
+
...output.previousValue != null ? [`Previous period: ${num(output.previousValue)}`] : [],
|
|
492
|
+
...output.changePercent != null ? [`Change: ${num(output.changePercent)}%`] : [],
|
|
493
|
+
...output.estimatedCost != null ? [`Estimated cost: ${num(output.estimatedCost)} ${output.costUnit ?? ""}`.trim()] : [],
|
|
494
|
+
footer
|
|
495
|
+
].join("\n");
|
|
496
|
+
}
|
|
369
497
|
// src/server/mcp/toolsets/observability.ts
|
|
370
498
|
const COMBINATORS = [
|
|
371
499
|
"anyOf",
|
|
@@ -497,16 +625,27 @@ function analyzeSchema(routes) {
|
|
|
497
625
|
}
|
|
498
626
|
/** Observability (traces, spans, logs) and observability analytics (metrics, scores, feedback). */
|
|
499
627
|
function addObservabilityTools(kit) {
|
|
500
|
-
const { call, addOperation, addCombined, config } = kit;
|
|
628
|
+
const { call, addOperation, addCombined, config, offered } = kit;
|
|
629
|
+
const metricRoutes = {
|
|
630
|
+
aggregate: GET_METRIC_AGGREGATE,
|
|
631
|
+
breakdown: GET_METRIC_BREAKDOWN,
|
|
632
|
+
timeseries: GET_METRIC_TIME_SERIES,
|
|
633
|
+
percentiles: GET_METRIC_PERCENTILES
|
|
634
|
+
};
|
|
635
|
+
const explorer = kit.apps.observabilityExplorer && offered(GET_CAPABILITIES) ? kit.apps.observabilityExplorer : void 0;
|
|
636
|
+
const opensIn = (app, summary) => app ? {
|
|
637
|
+
meta: { ui: { resourceUri: app } },
|
|
638
|
+
summary
|
|
639
|
+
} : void 0;
|
|
501
640
|
if (config.toolsets.has("observability")) {
|
|
502
|
-
const bodyTool = (route, rows, schema = route.bodySchema) => addOperation(route, hoistRepeated(asObjectSchema(toJSONSchema(schema))), async (args, signal) => {
|
|
641
|
+
const bodyTool = (route, rows, schema = route.bodySchema, options) => addOperation(route, hoistRepeated(asObjectSchema(toJSONSchema(schema))), async (args, signal) => {
|
|
503
642
|
const result = await call(route, { body: args }, signal);
|
|
504
643
|
return rows ? fitRows(result, rows, PAGE_LIMIT_HINT, {
|
|
505
644
|
cursors: CURSORS,
|
|
506
645
|
detail: rows === "traces" || rows === "spans" ? "get_span" : void 0
|
|
507
646
|
}) : result;
|
|
508
|
-
});
|
|
509
|
-
bodyTool(QUERY_TRACES, "traces");
|
|
647
|
+
}, options);
|
|
648
|
+
bodyTool(QUERY_TRACES, "traces", void 0, opensIn(explorer, summarizeTraces("traces")));
|
|
510
649
|
bodyTool(AGGREGATE_TRACES);
|
|
511
650
|
bodyTool(QUERY_SPANS, "spans");
|
|
512
651
|
bodyTool(AGGREGATE_SPANS);
|
|
@@ -538,7 +677,7 @@ function addObservabilityTools(kit) {
|
|
|
538
677
|
...result,
|
|
539
678
|
nextOffset: offset + kept
|
|
540
679
|
} : result;
|
|
541
|
-
});
|
|
680
|
+
}, opensIn(kit.apps.traceViewer, summarizeTrace));
|
|
542
681
|
addOperation(GET_SPAN_ROUTE, object({
|
|
543
682
|
traceId,
|
|
544
683
|
spanId: str("Span id.")
|
|
@@ -550,23 +689,50 @@ function addObservabilityTools(kit) {
|
|
|
550
689
|
addOperation(LIST_TRACES_ROUTE, hoistRepeated(listQuerySchema(LIST_TRACES_ROUTE)), async (args, signal) => fitRows(await call(LIST_TRACES_ROUTE, { query: args }, signal), "spans", PER_PAGE_HINT, {
|
|
551
690
|
cursors: CURSORS,
|
|
552
691
|
detail: "get_span"
|
|
553
|
-
}));
|
|
554
|
-
|
|
692
|
+
}), opensIn(explorer, summarizeTraces("spans")));
|
|
693
|
+
if (explorer) {
|
|
694
|
+
const appOnly = { meta: { ui: {
|
|
695
|
+
resourceUri: explorer,
|
|
696
|
+
visibility: ["app"]
|
|
697
|
+
} } };
|
|
698
|
+
addOperation(GET_CAPABILITIES, object({}), async (_args, signal) => ({
|
|
699
|
+
...await call(GET_CAPABILITIES, {}, signal),
|
|
700
|
+
tools: {
|
|
701
|
+
logs: offered(LIST_LOGS),
|
|
702
|
+
metrics: Object.values(metricRoutes).every(offered)
|
|
703
|
+
}
|
|
704
|
+
}), appOnly);
|
|
705
|
+
const values = {
|
|
706
|
+
entityTypes: GET_ENTITY_TYPES,
|
|
707
|
+
entityNames: GET_ENTITY_NAMES,
|
|
708
|
+
serviceNames: GET_SERVICE_NAMES,
|
|
709
|
+
environments: GET_ENVIRONMENTS,
|
|
710
|
+
tags: GET_TAGS
|
|
711
|
+
};
|
|
712
|
+
addCombined(Object.values(values), object({
|
|
713
|
+
kind: {
|
|
714
|
+
type: "string",
|
|
715
|
+
enum: Object.keys(values),
|
|
716
|
+
description: "Which values to list."
|
|
717
|
+
},
|
|
718
|
+
...listQuerySchema(GET_ENTITY_NAMES).properties,
|
|
719
|
+
...listQuerySchema(GET_TAGS).properties
|
|
720
|
+
}, ["kind"]), (args, signal) => {
|
|
721
|
+
const { kind, ...query } = args;
|
|
722
|
+
return call(values[kind], { query }, signal);
|
|
723
|
+
}, appOnly);
|
|
724
|
+
}
|
|
725
|
+
addOperation(LIST_LOGS, hoistRepeated(listQuerySchema(LIST_LOGS)), async (args, signal) => fitRows(await call(LIST_LOGS, { query: args }, signal), "logs", PER_PAGE_HINT, { cursors: CURSORS }), opensIn(explorer, summarizeLogs));
|
|
555
726
|
}
|
|
556
727
|
if (config.toolsets.has("observability_analytics")) {
|
|
557
728
|
for (const [route, key] of [[LIST_SCORES, "scores"], [LIST_FEEDBACK, "feedback"]]) addOperation(route, hoistRepeated(listQuerySchema(route)), async (args, signal) => fitRows(await call(route, { query: args }, signal), key, PER_PAGE_HINT, { cursors: CURSORS }));
|
|
558
|
-
const analyze = (routes) => addCombined(Object.values(routes), hoistRepeated(analyzeSchema(routes)), (args, signal) => {
|
|
729
|
+
const analyze = (routes, options) => addCombined(Object.values(routes), hoistRepeated(analyzeSchema(routes)), (args, signal) => {
|
|
559
730
|
const { op, ...body } = args;
|
|
560
731
|
const route = typeof op === "string" && Object.hasOwn(routes, op) ? routes[op] : void 0;
|
|
561
732
|
if (!route) throw toolError(400, `Unknown op "${String(op)}". Use one of: ${OPS.join(", ")}.`);
|
|
562
733
|
return call(route, { body }, signal);
|
|
563
|
-
});
|
|
564
|
-
analyze(
|
|
565
|
-
aggregate: GET_METRIC_AGGREGATE,
|
|
566
|
-
breakdown: GET_METRIC_BREAKDOWN,
|
|
567
|
-
timeseries: GET_METRIC_TIME_SERIES,
|
|
568
|
-
percentiles: GET_METRIC_PERCENTILES
|
|
569
|
-
});
|
|
734
|
+
}, options);
|
|
735
|
+
analyze(metricRoutes, opensIn(explorer, summarizeMetrics));
|
|
570
736
|
analyze({
|
|
571
737
|
aggregate: GET_SCORE_AGGREGATE,
|
|
572
738
|
breakdown: GET_SCORE_BREAKDOWN,
|
|
@@ -914,6 +1080,11 @@ function addStoredAgentTools(kit) {
|
|
|
914
1080
|
});
|
|
915
1081
|
}
|
|
916
1082
|
// src/server/mcp/catalogue.ts
|
|
1083
|
+
const modelSummaries = /* @__PURE__ */ new WeakMap();
|
|
1084
|
+
/** The summary a tool sends the model when its result is rendered in an MCP App, if it has one. */
|
|
1085
|
+
function modelSummaryOf(tool) {
|
|
1086
|
+
return tool ? modelSummaries.get(tool) : void 0;
|
|
1087
|
+
}
|
|
917
1088
|
const MAX_TOOL_NAME_LENGTH = 64;
|
|
918
1089
|
/** A backing route's permission is a read when every permission it accepts has the `read` action. */
|
|
919
1090
|
function isReadRoute(route) {
|
|
@@ -1096,9 +1267,13 @@ async function buildBuiltinMCPTools(ctx, config) {
|
|
|
1096
1267
|
description,
|
|
1097
1268
|
inputSchema,
|
|
1098
1269
|
outputSchema: options.outputSchema,
|
|
1099
|
-
mcp: {
|
|
1270
|
+
mcp: {
|
|
1271
|
+
annotations: options.annotations ?? annotationsFor(route),
|
|
1272
|
+
...options.meta ? { _meta: options.meta } : {}
|
|
1273
|
+
},
|
|
1100
1274
|
execute: async (args, context) => execute(args ?? {}, context?.abortSignal)
|
|
1101
1275
|
});
|
|
1276
|
+
if (options.summary) modelSummaries.set(tools[name], options.summary);
|
|
1102
1277
|
};
|
|
1103
1278
|
const addOperation = (route, inputSchema, execute, options) => {
|
|
1104
1279
|
if (offered(route)) add(route.mcp.name, route, route.mcp.description, inputSchema, execute, options);
|
|
@@ -1344,13 +1519,14 @@ async function buildBuiltinMCPTools(ctx, config) {
|
|
|
1344
1519
|
requestContext,
|
|
1345
1520
|
config,
|
|
1346
1521
|
capabilities,
|
|
1522
|
+
apps: ctx.apps ?? {},
|
|
1347
1523
|
offered,
|
|
1348
1524
|
permitted,
|
|
1349
1525
|
call,
|
|
1350
1526
|
add,
|
|
1351
1527
|
addOperation,
|
|
1352
|
-
addCombined: (routes, inputSchema, execute) => {
|
|
1353
|
-
if (routes.every(offered)) add(routes[0].mcp.name, routes[0], routes[0].mcp.description, inputSchema, execute);
|
|
1528
|
+
addCombined: (routes, inputSchema, execute, options) => {
|
|
1529
|
+
if (routes.every(offered)) add(routes[0].mcp.name, routes[0], routes[0].mcp.description, inputSchema, execute, options);
|
|
1354
1530
|
},
|
|
1355
1531
|
visibleAgentIds: async () => {
|
|
1356
1532
|
const agents = await listVisibleAgents();
|
|
@@ -1364,6 +1540,6 @@ async function buildBuiltinMCPTools(ctx, config) {
|
|
|
1364
1540
|
if (config.toolsets.has("stored_agents")) addStoredAgentTools(kit);
|
|
1365
1541
|
return tools;
|
|
1366
1542
|
}
|
|
1367
|
-
export { buildBuiltinMCPTools };
|
|
1543
|
+
export { buildBuiltinMCPTools, modelSummaryOf };
|
|
1368
1544
|
|
|
1369
|
-
//# sourceMappingURL=catalogue-
|
|
1545
|
+
//# sourceMappingURL=catalogue-Nzu-ZF0D.js.map
|