@tellagen/mcp-server 0.5.1 → 0.7.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.
- package/README.md +53 -3
- package/SKILL.md +143 -19
- package/contracts/mcp-protocol.json +64 -3
- package/contracts/runbooks/manifest.json +24 -14
- package/contracts/runbooks/v2/client-protocol.json +65 -2
- package/contracts/runbooks/v2/client-writes.guidance.json +16 -1
- package/contracts/runbooks/v2/fixtures/filesystem-pressure.json +22 -31
- package/contracts/runbooks/v2/fixtures/timeline-event-blocks-rejected.json +15 -1
- package/contracts/runbooks/v2/investigation-window.guidance.json +45 -0
- package/contracts/runbooks/v2/question-checks.guidance.json +49 -0
- package/contracts/runbooks/v2/result-summary.guidance.json +53 -5
- package/contracts/runbooks/v2/timeline-event-blocks.schema.json +66 -3
- package/contracts/tellagen-runbook-contracts.json +3 -3
- package/dist/active-run.d.ts +6 -0
- package/dist/active-run.js +14 -0
- package/dist/active-run.js.map +1 -1
- package/dist/cli/doctor.d.ts +19 -0
- package/dist/cli/doctor.js +179 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/kubernetes.d.ts +47 -0
- package/dist/cli/kubernetes.js +369 -0
- package/dist/cli/kubernetes.js.map +1 -0
- package/dist/cli/main.js +10 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/diagnosis-structure.d.ts +380 -102
- package/dist/diagnosis-structure.js +334 -14
- package/dist/diagnosis-structure.js.map +1 -1
- package/dist/doctor/checks.d.ts +42 -0
- package/dist/doctor/checks.js +181 -0
- package/dist/doctor/checks.js.map +1 -0
- package/dist/doctor/config-files.d.ts +49 -0
- package/dist/doctor/config-files.js +121 -0
- package/dist/doctor/config-files.js.map +1 -0
- package/dist/doctor/k8s-read-only.d.ts +16 -0
- package/dist/doctor/k8s-read-only.js +89 -0
- package/dist/doctor/k8s-read-only.js.map +1 -0
- package/dist/doctor/real-fs.d.ts +3 -0
- package/dist/doctor/real-fs.js +36 -0
- package/dist/doctor/real-fs.js.map +1 -0
- package/dist/doctor/toml.d.ts +13 -0
- package/dist/doctor/toml.js +205 -0
- package/dist/doctor/toml.js.map +1 -0
- package/dist/figures.d.ts +520 -101
- package/dist/figures.js +341 -7
- package/dist/figures.js.map +1 -1
- package/dist/heartbeat.d.ts +3 -0
- package/dist/heartbeat.js +32 -1
- package/dist/heartbeat.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/k8s-safety.d.ts +42 -0
- package/dist/k8s-safety.js +33 -0
- package/dist/k8s-safety.js.map +1 -0
- package/dist/listen-config.d.ts +5 -5
- package/dist/listen-probe.d.ts +14 -1
- package/dist/listen-probe.js +83 -5
- package/dist/listen-probe.js.map +1 -1
- package/dist/listen-settings.d.ts +8 -0
- package/dist/listen-settings.js +29 -0
- package/dist/listen-settings.js.map +1 -1
- package/dist/listener.d.ts +11 -0
- package/dist/listener.js +60 -16
- package/dist/listener.js.map +1 -1
- package/dist/log-lines.d.ts +118 -0
- package/dist/log-lines.js +534 -0
- package/dist/log-lines.js.map +1 -0
- package/dist/redact.d.ts +21 -0
- package/dist/redact.js +212 -5
- package/dist/redact.js.map +1 -1
- package/dist/run-events.js +13 -1
- package/dist/run-events.js.map +1 -1
- package/dist/run-requests.d.ts +16 -0
- package/dist/run-requests.js +56 -0
- package/dist/run-requests.js.map +1 -0
- package/dist/run-window.d.ts +59 -0
- package/dist/run-window.js +141 -0
- package/dist/run-window.js.map +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +11 -9
- package/dist/server.js.map +1 -1
- package/dist/session.d.ts +37 -0
- package/dist/session.js +59 -0
- package/dist/session.js.map +1 -1
- package/dist/tool-report.d.ts +2 -0
- package/dist/tool-report.js +3 -0
- package/dist/tool-report.js.map +1 -0
- package/dist/tools/amendments.d.ts +13 -0
- package/dist/tools/amendments.js +206 -0
- package/dist/tools/amendments.js.map +1 -0
- package/dist/tools/catalog.js +4 -0
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/diagnostics.js +131 -3
- package/dist/tools/diagnostics.js.map +1 -1
- package/dist/tools/figures.d.ts +2 -2
- package/dist/tools/figures.js +37 -9
- package/dist/tools/figures.js.map +1 -1
- package/dist/tools/findings.d.ts +136 -0
- package/dist/tools/findings.js +68 -7
- package/dist/tools/findings.js.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/investigations.d.ts +3223 -5
- package/dist/tools/investigations.js +202 -50
- package/dist/tools/investigations.js.map +1 -1
- package/dist/tools/next.d.ts +16 -0
- package/dist/tools/next.js +49 -1
- package/dist/tools/next.js.map +1 -1
- package/dist/tools/postmortem-runbooks.d.ts +20 -20
- package/dist/tools/requests.d.ts +3 -0
- package/dist/tools/requests.js +62 -0
- package/dist/tools/requests.js.map +1 -0
- package/dist/tools/resume.js +14 -1
- package/dist/tools/resume.js.map +1 -1
- package/dist/tools/source-links.d.ts +7 -0
- package/dist/tools/source-links.js +32 -5
- package/dist/tools/source-links.js.map +1 -1
- package/dist/tools/timeline.js +24 -2
- package/dist/tools/timeline.js.map +1 -1
- package/dist/version.d.ts +4 -2
- package/dist/version.js +6 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/server.json +1 -1
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
"description": "The blocks field of a timeline event: typed widgets that hold the numbers behind a note. Send it with the REST timeline create (POST /api/v1/incidents/{id}/timeline) or update (PATCH /api/v1/timeline/{id}); the MCP tools tellagen_post_timeline_event and tellagen_update_timeline_event pass it through. The server validates every block and answers one bad block with 400 invalid_block, a message, the path of the first bad field in field and up to ten bad fields in details.errors. An update that sends blocks replaces the whole array; [] removes them; leaving the field out keeps them. Strings are trimmed, one line and free of control characters (only source.query may hold line breaks; a diff line's text is the one string that is not trimmed, so it keeps its indentation, and it may hold tabs). The same blocks, except table and changes, are the figure of a Diagnosis chain step (causal_paths[].steps[].figure). Numbers are finite and between -1e12 and 1e12. An event carries at most 12 blocks and 64 KB of block JSON.",
|
|
6
6
|
"x-guidance": [
|
|
7
7
|
"Put the few numbers a responder scans for in one stats block, each with a short label, a value, a caption that says what it is measured on, and a tone. Send at most four when you can: the first four are drawn as tiles in one row, the total first, and colour goes only on the exception. A block may hold up to eight figures, and the web draws the ones after the fourth as plain rows under the tiles. Give the block a title of at most 80 characters when the tiles need a name. A title and more than four figures are optional, and a client that picked up a run sends them only when server_capabilities lists figure_extras_v1. In the figure of a Diagnosis step, a source name such as a test runner summary belongs in a source chip (the step's evidence), not in a tile caption.",
|
|
8
|
-
"Use a compare block for a metric that has a value before, a value after and a threshold (an SLO or alert line). Give the unit, say which direction is better, and put one row per host, route or query.",
|
|
8
|
+
"Use a compare block for a metric that has a value before, a value after and a threshold (an SLO or alert line). Give the unit, say which direction is better, and put one row per host, route or query. Never put a limit, a budget or a threshold in before: before is what the value was earlier. When each row has its own limit (a page length against its budget), give the row a limit and leave before out, so the row reads after against limit. A client that picked up a run sends limit only when server_capabilities lists figure_limits_v1.",
|
|
9
9
|
"Use a trend block for a series over time. Send start and step_seconds together, reduce the range to at most 500 points, add at most three marks for the events that explain the shape, and fill source with the query that produced the series (kind, datasource, query, step, and artifact_id when you have it).",
|
|
10
10
|
"Use a table block for a ranked list (top queries, failing routes), a checks block for a recovery checklist with a result per check, and a changes block for a value that moved from one thing to another.",
|
|
11
11
|
"Use a range_overlap block when the cause is two ranges meeting (layout offsets, a maintenance window against an error spike, memory or port ranges): two to four rows with a from and a to, in one unit. Tellagen computes the overlap and zooms to it; send min and max for the whole range, and a window only to choose the zoom yourself.",
|
|
12
12
|
"Use a histogram block when an average hides a slow tail: bucket edges (3 to 61, increasing) and one count per bucket for before and for after, plus the threshold (an SLO). Tellagen computes p50, p95, p99 and the share over the threshold from the buckets, so send counts, never percentiles.",
|
|
13
13
|
"Use a run_history block for CI builds, scheduled jobs, canaries or deploys: runs oldest first, each with a ref, a result (success, failure, cancelled, pending) and the failing job, repo as owner/name so each run links to its page, marks for the change that introduced and the one that fixed it (between two neighbouring run refs, change_ref regression or fix), and an optional span with a label such as E2E Tests failed. If the history has more than 30 runs, send the 30 that matter (the runs around the break and the fix) and set runs_not_shown to how many you left out, so the strip can say so. A client that picked up a run sends runs_not_shown only when server_capabilities lists figure_extras_v1.",
|
|
14
14
|
"Use a diff block for the change that broke something or fixed it: the file path, the commit ref, the added and removed counts of the whole change (additions and deletions are the size of the whole change, not of the lines you send), and the changed lines in hunks, each with op + or - and the text with its indentation. If the change has 12 or fewer changed lines (in at most 6 hunks), send all of them. If it has more, send the whole hunks the claim cites, in file order, at most 3, and at most 12 changed lines in all; if one hunk alone is longer, cut it after a complete pair of removed and added lines. Never send a changed line without its counterpart: a removed line comes with the line that replaced it, next to it. Add up to 2 unchanged lines (op context) before and after each hunk, and old_no and new_no (1-based) on every line when you know them. Unchanged lines and line numbers are optional, and a client that picked up a run sends them only when server_capabilities lists diff_lines_v1. Never invent a line number: if you do not have the real ones, leave every number out.",
|
|
15
|
+
"Use a log_lines block for log evidence: the lines that prove a claim, or the proof that there are none. Put in matched how many lines the query matched and in scanned how many it looked at, and fill source (kind, datasource, query, from and to) so the page can open the query in Grafana Explore. Send at most 8 lines, the ones that show the event first, each with its time, level and text as the log has them and up to 6 fields. Give every line a relation: matches_event, context, or unrelated, and say in note why an unrelated line is not proof (for example Company 578, 11 hours after the event). A line that looks like proof and is not is the one to mark, never to leave out. When the query found nothing, send matched 0 with scanned, source.from and source.to: 0 of 2,313 lines from 00:26 to 01:26 is proof, an empty list with no range is not. Set event_at to the moment of the event so the page can say how far a line is from it. Never write a line you did not read in a tool result. A client that picked up a run sends log_lines only when server_capabilities lists log_lines_v1.",
|
|
15
16
|
"Set example: true only on a block that stands in for data you did not read from a tool result (a demo or an illustration); a block built from a tool result never sets it.",
|
|
16
17
|
"Tone is a meaning, not decoration: good for a figure that is healthy or recovered, warn for one that needs attention, bad for one that is failing, neutral or no tone for a plain fact. Never use tone to emphasise.",
|
|
17
18
|
"A block owns its numbers. Do not repeat in the note a number that a block already shows; the note says what happened and why, the block says how much.",
|
|
@@ -35,7 +36,8 @@
|
|
|
35
36
|
{"$ref": "#/$defs/range_overlap"},
|
|
36
37
|
{"$ref": "#/$defs/histogram"},
|
|
37
38
|
{"$ref": "#/$defs/run_history"},
|
|
38
|
-
{"$ref": "#/$defs/diff"}
|
|
39
|
+
{"$ref": "#/$defs/diff"},
|
|
40
|
+
{"$ref": "#/$defs/log_lines"}
|
|
39
41
|
]
|
|
40
42
|
},
|
|
41
43
|
"slot": {"const": "summary", "description": "Draws the block above the note. Not together with anchor."},
|
|
@@ -121,12 +123,14 @@
|
|
|
121
123
|
"items": {
|
|
122
124
|
"type": "object",
|
|
123
125
|
"additionalProperties": false,
|
|
124
|
-
"required": ["label", "
|
|
126
|
+
"required": ["label", "after"],
|
|
127
|
+
"anyOf": [{"required": ["before"]}, {"required": ["limit"]}],
|
|
125
128
|
"properties": {
|
|
126
129
|
"label": {"type": "string", "minLength": 1, "maxLength": 80},
|
|
127
130
|
"mono": {"type": "boolean"},
|
|
128
131
|
"before": {"$ref": "#/$defs/number"},
|
|
129
132
|
"after": {"$ref": "#/$defs/number"},
|
|
133
|
+
"limit": {"$ref": "#/$defs/number"},
|
|
130
134
|
"details": {
|
|
131
135
|
"type": "array",
|
|
132
136
|
"maxItems": 3,
|
|
@@ -482,6 +486,65 @@
|
|
|
482
486
|
}
|
|
483
487
|
}
|
|
484
488
|
}
|
|
489
|
+
},
|
|
490
|
+
"log_lines": {
|
|
491
|
+
"type": "object",
|
|
492
|
+
"description": "The log lines that prove a claim, or the proof that there are none: how many lines matched out of how many were scanned, in what range, and up to 8 of the matches, each marked by how it relates to the event. Needs log_lines_v1.",
|
|
493
|
+
"additionalProperties": false,
|
|
494
|
+
"required": ["type", "matched"],
|
|
495
|
+
"x-rules": [
|
|
496
|
+
"lines is empty only when matched is 0, and has at most matched lines",
|
|
497
|
+
"lines and lines_not_shown together are at most matched",
|
|
498
|
+
"scanned is not below matched",
|
|
499
|
+
"matched 0 needs scanned, source.from and source.to"
|
|
500
|
+
],
|
|
501
|
+
"properties": {
|
|
502
|
+
"type": {"const": "log_lines"},
|
|
503
|
+
"slot": {"$ref": "#/$defs/slot"},
|
|
504
|
+
"anchor": {"$ref": "#/$defs/anchor"},
|
|
505
|
+
"postmortem": {"$ref": "#/$defs/postmortem"},
|
|
506
|
+
"example": {"$ref": "#/$defs/example"},
|
|
507
|
+
"title": {"type": "string", "maxLength": 80},
|
|
508
|
+
"source": {
|
|
509
|
+
"type": "object",
|
|
510
|
+
"description": "Where the lines came from and the range that was searched. Provenance only: the page builds the Grafana Explore address from it.",
|
|
511
|
+
"additionalProperties": false,
|
|
512
|
+
"properties": {
|
|
513
|
+
"kind": {"type": "string", "maxLength": 80},
|
|
514
|
+
"datasource": {"type": "string", "maxLength": 80},
|
|
515
|
+
"query": {"type": "string", "maxLength": 2000},
|
|
516
|
+
"from": {"type": "string", "format": "date-time"},
|
|
517
|
+
"to": {"type": "string", "format": "date-time", "description": "Not before from."}
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
"matched": {"type": "integer", "minimum": 0, "maximum": 1000000000, "description": "How many lines matched the query in the range."},
|
|
521
|
+
"scanned": {"type": "integer", "minimum": 0, "maximum": 1000000000, "description": "How many lines the query looked at. Not below matched."},
|
|
522
|
+
"event_at": {"type": "string", "format": "date-time", "description": "The moment of the event the lines are about."},
|
|
523
|
+
"lines": {
|
|
524
|
+
"type": "array",
|
|
525
|
+
"maxItems": 8,
|
|
526
|
+
"items": {
|
|
527
|
+
"type": "object",
|
|
528
|
+
"additionalProperties": false,
|
|
529
|
+
"required": ["time", "level", "text"],
|
|
530
|
+
"properties": {
|
|
531
|
+
"time": {"type": "string", "format": "date-time"},
|
|
532
|
+
"level": {"enum": ["error", "warn", "info", "debug", "other"]},
|
|
533
|
+
"text": {"type": "string", "minLength": 1, "maxLength": 500, "description": "The line as logged. Tabs are allowed, other control characters are not."},
|
|
534
|
+
"fields": {
|
|
535
|
+
"type": "object",
|
|
536
|
+
"maxProperties": 6,
|
|
537
|
+
"propertyNames": {"maxLength": 40},
|
|
538
|
+
"additionalProperties": {"type": "string", "minLength": 1, "maxLength": 200},
|
|
539
|
+
"description": "Labels or parsed fields of the line, such as task or error."
|
|
540
|
+
},
|
|
541
|
+
"relation": {"enum": ["matches_event", "context", "unrelated"], "description": "unrelated marks a line that looks like proof and is not."},
|
|
542
|
+
"note": {"type": "string", "maxLength": 160, "description": "Why the line is what its relation says."}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
"lines_not_shown": {"type": "integer", "minimum": 0, "maximum": 1000000000, "description": "How many matches are not in lines."}
|
|
547
|
+
}
|
|
485
548
|
}
|
|
486
549
|
}
|
|
487
550
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"upstream_repository": "https://github.com/tellagen/tellagen",
|
|
3
|
-
"upstream_commit": "
|
|
3
|
+
"upstream_commit": "8af893562cfb80bed9ad5bacc5844d150feedb0e",
|
|
4
4
|
"upstream_worktree_dirty": false,
|
|
5
|
-
"contract_version": "2026-11-
|
|
6
|
-
"bundle_sha256": "
|
|
5
|
+
"contract_version": "2026-11-17.1",
|
|
6
|
+
"bundle_sha256": "f0c6dbed0bd3e716de808f5cf42553def829864a0c26cb40f3c85cae7ec3fd3e",
|
|
7
7
|
"bundle_path": "contracts/runbooks"
|
|
8
8
|
}
|
package/dist/active-run.d.ts
CHANGED
|
@@ -27,3 +27,9 @@ export declare function otherLiveSession(client: TellagenClient, state: RunState
|
|
|
27
27
|
* question for the person, or what the model must do, never both in one text.
|
|
28
28
|
*/
|
|
29
29
|
export declare function joinFact(state: RunState): string;
|
|
30
|
+
/**
|
|
31
|
+
* The run an addition is about: the id it was given, else the finished
|
|
32
|
+
* run this session remembers that still takes additions (the one a write
|
|
33
|
+
* answered about last). Never the open run: it is not finished.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveAmendRunId(client: TellagenClient, given?: string): string;
|
package/dist/active-run.js
CHANGED
|
@@ -64,4 +64,18 @@ export function joinFact(state) {
|
|
|
64
64
|
const who = state.client_name ? `${state.client_name}${state.client_version ? ` ${state.client_version}` : ""}` : "Another client";
|
|
65
65
|
return `${who} on this computer is working on run ${state.run_id} (picked up at ${state.picked_up_at}). Two clients on one run write over each other.`;
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The run an addition is about: the id it was given, else the finished
|
|
69
|
+
* run this session remembers that still takes additions (the one a write
|
|
70
|
+
* answered about last). Never the open run: it is not finished.
|
|
71
|
+
*/
|
|
72
|
+
export function resolveAmendRunId(client, given) {
|
|
73
|
+
const id = given?.trim();
|
|
74
|
+
if (id)
|
|
75
|
+
return checkedRunId(id);
|
|
76
|
+
const finished = client.session.latestAmendable();
|
|
77
|
+
if (finished)
|
|
78
|
+
return finished.runId;
|
|
79
|
+
throw new NoActiveRunError("No finished run is remembered in this session. Pass investigation_run_id: the run you completed, or the run the person names.");
|
|
80
|
+
}
|
|
67
81
|
//# sourceMappingURL=active-run.js.map
|
package/dist/active-run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-run.js","sourceRoot":"","sources":["../src/active-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAiB,MAAM,gBAAgB,CAAC;AAE7D,uFAAuF;AACvF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,QAAQ,EAAE;KACV,QAAQ,CAAC,2EAA2E,CAAC,CAAC;AAEzF;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO,EAAE,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,IAAI,GAAG,IAAI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,GAAG;QAAE,OAAO,SAAS,CAAC;IAChD,OAAO,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAe;IACtC,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACnI,OAAO,GAAG,GAAG,uCAAuC,KAAK,CAAC,MAAM,kBAAkB,KAAK,CAAC,YAAY,kDAAkD,CAAC;AACzJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAsB,EAAE,KAAc;IACtE,MAAM,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,IAAI,EAAE;QAAE,OAAO,YAAY,CAAC,EAAE,CAAC,CAAC;IAChC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;IAClD,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC,KAAK,CAAC;IACpC,MAAM,IAAI,gBAAgB,CACxB,+HAA+H,CAChI,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TellagenClient } from "../client.js";
|
|
2
|
+
import { type CheckDeps, type ToolResult } from "../doctor/checks.js";
|
|
3
|
+
import { type DoctorFs } from "../doctor/config-files.js";
|
|
4
|
+
import { realDoctorFs } from "../doctor/real-fs.js";
|
|
5
|
+
import { type CliIo } from "./io.js";
|
|
6
|
+
export declare const DOCTOR_USAGE = "Usage: tellagen-mcp-server doctor [--client claude-code|claude-desktop|codex|cursor] [--tool grafana|kubernetes|github|docs] [--fix] [--report]\n";
|
|
7
|
+
export { realDoctorFs };
|
|
8
|
+
export interface DoctorDeps {
|
|
9
|
+
fs?: DoctorFs;
|
|
10
|
+
shellPath?: string;
|
|
11
|
+
fetch?: CheckDeps["fetch"];
|
|
12
|
+
/** The client that posts the report. Left out, one is built from the environment and the sign-in. */
|
|
13
|
+
reportClient?: () => Promise<TellagenClient>;
|
|
14
|
+
}
|
|
15
|
+
export declare function safeArgs(args: readonly string[]): string[];
|
|
16
|
+
/** The sentence --report sends. A fixed word list: no name, path, value or file text. */
|
|
17
|
+
export declare function reportDetail(result: ToolResult): string;
|
|
18
|
+
/** `doctor`: find why a client cannot see a tool, from the config files of the clients on this computer. */
|
|
19
|
+
export declare function doctorCommand(args: readonly string[], io: CliIo, deps?: DoctorDeps): Promise<number>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { createRuntime } from "../bootstrap.js";
|
|
2
|
+
import { checkEntry, DOCTOR_TOOLS, toolOfEntry } from "../doctor/checks.js";
|
|
3
|
+
import { CLIENT_LABELS, DOCTOR_CLIENTS, scanClient, } from "../doctor/config-files.js";
|
|
4
|
+
import { realDoctorFs } from "../doctor/real-fs.js";
|
|
5
|
+
import { formatError, TellagenAPIError } from "../errors.js";
|
|
6
|
+
import { TOOL_REPORT_PATH } from "../tool-report.js";
|
|
7
|
+
import { MCP_SERVER_VERSION } from "../version.js";
|
|
8
|
+
import { parseArgs } from "./io.js";
|
|
9
|
+
export const DOCTOR_USAGE = "Usage: tellagen-mcp-server doctor [--client claude-code|claude-desktop|codex|cursor] [--tool grafana|kubernetes|github|docs] [--fix] [--report]\n";
|
|
10
|
+
export { realDoctorFs };
|
|
11
|
+
/** One line of what a person does to read the result: the status word first. */
|
|
12
|
+
function statusWord(status) {
|
|
13
|
+
return status === "ok" ? "ok " : status === "failed" ? "FAIL" : "warn";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Args the doctor prints: flags that take no value and names of programs and
|
|
17
|
+
* packages it recognises. Anything else, including any value that follows a
|
|
18
|
+
* flag, prints as a placeholder, because the output may be pasted.
|
|
19
|
+
*/
|
|
20
|
+
const SAFE_ARGS = new Set([
|
|
21
|
+
"-y", "--yes", "-q", "--quiet", "--stdio", "stdio", "server", "run", "-i", "--rm",
|
|
22
|
+
"npx", "uvx", "node", "mcp-grafana", "kubernetes-mcp-server", "mcp-server-kubernetes",
|
|
23
|
+
"github-mcp-server", "@modelcontextprotocol/server-github", "@tellagen/mcp-server", "docs-mcp",
|
|
24
|
+
]);
|
|
25
|
+
export function safeArgs(args) {
|
|
26
|
+
return args.map((arg) => (SAFE_ARGS.has(arg) ? arg : "<keep your arg>"));
|
|
27
|
+
}
|
|
28
|
+
/** A corrected entry for the person to paste. Env values are never printed, only their names. */
|
|
29
|
+
function correctedEntry(result, fixCommand) {
|
|
30
|
+
const entry = result.entry;
|
|
31
|
+
const envNames = Object.keys(entry.env);
|
|
32
|
+
const args = safeArgs(entry.args);
|
|
33
|
+
if (entry.client === "codex") {
|
|
34
|
+
const lines = [`[mcp_servers.${JSON.stringify(entry.name).slice(1, -1)}]`, `command = ${JSON.stringify(fixCommand)}`];
|
|
35
|
+
if (args.length > 0)
|
|
36
|
+
lines.push(`args = [${args.map((a) => JSON.stringify(a)).join(", ")}]`);
|
|
37
|
+
if (envNames.length > 0)
|
|
38
|
+
lines.push(`env = { ${envNames.map((n) => `${n} = "<keep your value>"`).join(", ")} }`);
|
|
39
|
+
return lines.join("\n");
|
|
40
|
+
}
|
|
41
|
+
const body = { command: fixCommand };
|
|
42
|
+
if (args.length > 0)
|
|
43
|
+
body.args = args;
|
|
44
|
+
if (envNames.length > 0)
|
|
45
|
+
body.env = Object.fromEntries(envNames.map((n) => [n, "<keep your value>"]));
|
|
46
|
+
return JSON.stringify({ [entry.name]: body }, null, 2);
|
|
47
|
+
}
|
|
48
|
+
function printReport(io, reports, wanted, fix) {
|
|
49
|
+
let problems = false;
|
|
50
|
+
for (const { scan, results } of reports) {
|
|
51
|
+
const label = CLIENT_LABELS[scan.client];
|
|
52
|
+
if (scan.filesRead.length === 0 && scan.unreadable.length === 0) {
|
|
53
|
+
io.stdout(`${label}: no config file found.\n`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
io.stdout(`${label} (read: ${scan.filesRead.join(", ") || "nothing"})\n`);
|
|
57
|
+
for (const name of scan.unreadable)
|
|
58
|
+
io.stdout(` Could not read ${name} as a config file. Open it and check that it is valid.\n`);
|
|
59
|
+
if (results.length === 0) {
|
|
60
|
+
io.stdout(wanted ? ` No ${wanted} server in this client's config.\n` : " No grafana, kubernetes, github or docs server in this client's config.\n");
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
for (const result of results) {
|
|
64
|
+
io.stdout(` ${result.tool}: server "${result.serverName}" (${result.source})\n`);
|
|
65
|
+
for (const check of result.checks) {
|
|
66
|
+
io.stdout(` ${statusWord(check.status)} ${check.summary}\n`);
|
|
67
|
+
if (fix && check.fixCommand)
|
|
68
|
+
io.stdout(`\n Corrected entry (print only; nothing was changed):\n${correctedEntry(result, check.fixCommand).replace(/^/gm, " ")}\n\n`);
|
|
69
|
+
}
|
|
70
|
+
if (result.checks.length === 0)
|
|
71
|
+
io.stdout(" Nothing to check for this entry.\n");
|
|
72
|
+
if (result.problem)
|
|
73
|
+
problems = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return problems;
|
|
77
|
+
}
|
|
78
|
+
/** A tool has a problem only when every server of the client that is this tool has one. */
|
|
79
|
+
function problemsByTool(results) {
|
|
80
|
+
const out = new Map();
|
|
81
|
+
for (const tool of DOCTOR_TOOLS) {
|
|
82
|
+
const mine = results.filter((r) => r.tool === tool);
|
|
83
|
+
if (mine.length > 0 && mine.every((r) => r.problem))
|
|
84
|
+
out.set(tool, mine[0]);
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
/** The sentence --report sends. A fixed word list: no name, path, value or file text. */
|
|
89
|
+
export function reportDetail(result) {
|
|
90
|
+
const failed = result.checks.find((check) => check.status === "failed");
|
|
91
|
+
return (failed?.reportSummary ?? "The doctor found a problem in the client config.").slice(0, 200);
|
|
92
|
+
}
|
|
93
|
+
async function sendReports(io, reports, deps) {
|
|
94
|
+
const sent = [];
|
|
95
|
+
const client = await (deps.reportClient ?? (async () => (await createRuntime(io.env)).client))();
|
|
96
|
+
for (const { scan, results } of reports) {
|
|
97
|
+
const problems = problemsByTool(results);
|
|
98
|
+
if (problems.size === 0)
|
|
99
|
+
continue;
|
|
100
|
+
client.session.identity = { name: scan.client, label: CLIENT_LABELS[scan.client], version: "" };
|
|
101
|
+
const sources = [...problems.entries()].map(([tool, result]) => ({ key: tool, state: "not_found", access_status: result.problem ?? "missing_tool", detail: reportDetail(result) }));
|
|
102
|
+
try {
|
|
103
|
+
await client.post(TOOL_REPORT_PATH, { available_sources: sources }, { safeToRepeat: true });
|
|
104
|
+
sent.push(`${CLIENT_LABELS[scan.client]}: ${[...problems.keys()].join(", ")}`);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
if (err instanceof TellagenAPIError && (err.status === 404 || err.status === 405)) {
|
|
108
|
+
io.stderr("This Tellagen does not take a tool report without a check yet. Run the doctor without --report, or ask an admin to update Tellagen.\n");
|
|
109
|
+
return 1;
|
|
110
|
+
}
|
|
111
|
+
const text = formatError(err);
|
|
112
|
+
let message = text;
|
|
113
|
+
try {
|
|
114
|
+
message = JSON.parse(text).message ?? text;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
/* keep the text */
|
|
118
|
+
}
|
|
119
|
+
io.stderr(`Could not report ${CLIENT_LABELS[scan.client]}: ${message}\n`);
|
|
120
|
+
return 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (sent.length === 0)
|
|
124
|
+
io.stdout("Nothing was reported: the doctor found no problem. It never reports a tool as found, because only a running session can show that.\n");
|
|
125
|
+
else
|
|
126
|
+
io.stdout(`Reported to Tellagen (names and statuses only, no paths, values or file text): ${sent.join("; ")}.\n`);
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
/** `doctor`: find why a client cannot see a tool, from the config files of the clients on this computer. */
|
|
130
|
+
export async function doctorCommand(args, io, deps = {}) {
|
|
131
|
+
const parsed = parseArgs(args, ["client", "tool"], ["fix", "report", "help"]);
|
|
132
|
+
if (parsed.unknown.length > 0 || parsed.positional.length > 0 || parsed.flags.has("help")) {
|
|
133
|
+
io.stderr(DOCTOR_USAGE);
|
|
134
|
+
return parsed.flags.has("help") ? 0 : 2;
|
|
135
|
+
}
|
|
136
|
+
const clientArg = parsed.values.client;
|
|
137
|
+
if (clientArg !== undefined && !DOCTOR_CLIENTS.includes(clientArg)) {
|
|
138
|
+
io.stderr(`Unknown client "${clientArg.slice(0, 40)}". Use one of: ${DOCTOR_CLIENTS.join(", ")}.\n`);
|
|
139
|
+
return 2;
|
|
140
|
+
}
|
|
141
|
+
const toolArg = parsed.values.tool;
|
|
142
|
+
if (toolArg !== undefined && !DOCTOR_TOOLS.includes(toolArg)) {
|
|
143
|
+
io.stderr(`Unknown tool "${toolArg.slice(0, 40)}". Use one of: ${DOCTOR_TOOLS.join(", ")}.\n`);
|
|
144
|
+
return 2;
|
|
145
|
+
}
|
|
146
|
+
const wanted = toolArg;
|
|
147
|
+
const fs = deps.fs ?? realDoctorFs();
|
|
148
|
+
const checkDeps = {
|
|
149
|
+
fs,
|
|
150
|
+
shellPath: deps.shellPath ?? io.env.PATH ?? io.env.Path ?? "",
|
|
151
|
+
fetch: deps.fetch ?? ((url, init) => fetch(url, { ...init, redirect: "manual" })),
|
|
152
|
+
};
|
|
153
|
+
io.stdout(`Tellagen doctor ${MCP_SERVER_VERSION}\n`);
|
|
154
|
+
io.stdout("It reads the MCP config files of the AI clients on this computer, because you ran it. It never changes them");
|
|
155
|
+
io.stdout(parsed.flags.has("report") ? " and sends only names and statuses to Tellagen.\n\n" : " and sends nothing to Tellagen.\n\n");
|
|
156
|
+
const reports = [];
|
|
157
|
+
for (const client of (clientArg ? [clientArg] : DOCTOR_CLIENTS)) {
|
|
158
|
+
const scan = scanClient(client, fs);
|
|
159
|
+
const results = [];
|
|
160
|
+
for (const entry of scan.entries) {
|
|
161
|
+
const tool = toolOfEntry(entry);
|
|
162
|
+
if (!tool || (wanted && tool !== wanted))
|
|
163
|
+
continue;
|
|
164
|
+
results.push(await checkEntry(entry, tool, checkDeps));
|
|
165
|
+
}
|
|
166
|
+
reports.push({ scan, results });
|
|
167
|
+
}
|
|
168
|
+
const problems = printReport(io, reports, wanted, parsed.flags.has("fix"));
|
|
169
|
+
io.stdout("\nThe doctor cannot see a running session: it reads config files only. The model check (Recheck in Tellagen settings, or /tellagen:check-tools) is still the truth for a session.\n");
|
|
170
|
+
if (!wanted || wanted === "kubernetes")
|
|
171
|
+
io.stdout("It does not test what a Kubernetes identity can change. The model check reports that.\n");
|
|
172
|
+
if (parsed.flags.has("report")) {
|
|
173
|
+
const code = await sendReports(io, reports, deps);
|
|
174
|
+
if (code !== 0)
|
|
175
|
+
return code;
|
|
176
|
+
}
|
|
177
|
+
return problems ? 1 : 0;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAoD,MAAM,qBAAqB,CAAC;AAC9H,OAAO,EACL,aAAa,EACb,cAAc,EACd,UAAU,GAIX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,E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I,CAAC,MAAM,IAAI,MAAM,KAAK,YAAY;QAAE,EAAE,CAAC,MAAM,CAAC,yFAAyF,CAAC,CAAC;IAE7I,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QAClD,IAAI,IAAI,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;IAC9B,CAAC;IACD,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { TellagenClient } from "../client.js";
|
|
2
|
+
import { type DoctorFs } from "../doctor/config-files.js";
|
|
3
|
+
import { type CliIo } from "./io.js";
|
|
4
|
+
export declare const KUBERNETES_USAGE = "Usage: tellagen-mcp-server kubernetes setup [--client claude-code|claude-desktop|codex|cursor] [--context NAME]\n [--service-account NAME [-n NAMESPACE] [--duration 8h]] [--yes] [--no-report]\n\nSets up a read-only Kubernetes server for diagnosis: writes its settings file, adds the server to your AI client\n(it asks first), runs four access checks and reports them to Tellagen.\n";
|
|
5
|
+
export declare const SETUP_DIR_PARTS: readonly [".config", "tellagen"];
|
|
6
|
+
export interface RunResult {
|
|
7
|
+
code: number;
|
|
8
|
+
stdout: string;
|
|
9
|
+
stderr: string;
|
|
10
|
+
}
|
|
11
|
+
/** What the setup writes, so a test can run it on a fake computer. */
|
|
12
|
+
export interface SetupFiles {
|
|
13
|
+
/** Writes a file with mode 600 (a private file), creating its folder. */
|
|
14
|
+
writePrivate(path: string, text: string): void;
|
|
15
|
+
/** Writes a file that holds no secret. */
|
|
16
|
+
write(path: string, text: string): void;
|
|
17
|
+
}
|
|
18
|
+
export interface KubernetesSetupDeps {
|
|
19
|
+
fs?: DoctorFs;
|
|
20
|
+
files?: SetupFiles;
|
|
21
|
+
/** Runs a program with no shell. */
|
|
22
|
+
run?: (command: string, args: string[], env?: Record<string, string>) => Promise<RunResult>;
|
|
23
|
+
confirm?: (question: string) => Promise<boolean>;
|
|
24
|
+
reportClient?: () => Promise<TellagenClient>;
|
|
25
|
+
now?: () => Date;
|
|
26
|
+
}
|
|
27
|
+
export declare const nodeFiles: SetupFiles;
|
|
28
|
+
/** A path as a person reads it: the home folder is `~`, so no user name is printed. */
|
|
29
|
+
export declare function shortPath(path: string, home: string): string;
|
|
30
|
+
/** The settings file of the server: read tools only, a few write-side guards, and secrets denied. */
|
|
31
|
+
export declare function kubernetesServerConfig(kubeconfigPath?: string): string;
|
|
32
|
+
/** The program and arguments a client starts for the server. */
|
|
33
|
+
export declare function serverCommand(configPath: string): {
|
|
34
|
+
command: string;
|
|
35
|
+
args: string[];
|
|
36
|
+
};
|
|
37
|
+
/** A kubeconfig for one service account token. JSON strings are valid YAML, so values are quoted safely. */
|
|
38
|
+
export declare function serviceAccountKubeconfig(name: string, cluster: {
|
|
39
|
+
server: string;
|
|
40
|
+
ca?: {
|
|
41
|
+
data?: string;
|
|
42
|
+
file?: string;
|
|
43
|
+
};
|
|
44
|
+
insecure?: boolean;
|
|
45
|
+
}, token: string): string;
|
|
46
|
+
/** `kubernetes setup`: one command for the computer side of the Kubernetes setup. */
|
|
47
|
+
export declare function kubernetesCommand(args: readonly string[], io: CliIo, deps?: KubernetesSetupDeps): Promise<number>;
|