@mwillbanks/ast-mcp 0.6.5 → 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/CONTRIBUTING.md +6 -0
- package/dist/ast-mcp.js +358 -337
- package/dist/ast-mcp.js.map +45 -32
- package/dist/workers/sql-postgres-worker.js +5 -0
- package/dist/workers/sql-postgres-worker.js.map +10 -0
- package/package.json +3 -2
- package/src/cli/doctor.ts +103 -0
- package/src/cli/index.ts +9 -1
- package/src/config/index.ts +61 -6
- package/src/config/registry.ts +209 -67
- package/src/config/v2-schema.ts +2 -0
- package/src/helpers/installer.ts +10 -1
- package/src/http/index.ts +12 -5
- package/src/installer/codex.ts +237 -0
- package/src/installer/diagnostics.ts +387 -0
- package/src/installer/directory-ancestry.ts +55 -0
- package/src/installer/index.ts +386 -119
- package/src/installer/ownership.ts +165 -0
- package/src/installer/service-state.ts +151 -0
- package/src/installer/service.ts +131 -7
- package/src/installer/transaction.ts +342 -0
- package/src/installer/transport.ts +22 -31
- package/src/intelligence/mutation/locks.ts +4 -1
- package/src/patch/engine.ts +157 -11
- package/src/runtime/approval.ts +427 -66
- package/src/runtime/config-write.ts +27 -1
- package/src/runtime/diagnostics.ts +115 -0
- package/src/runtime/file-capabilities.ts +2 -0
- package/src/runtime/hosts/codex.ts +16 -0
- package/src/runtime/path-policy.ts +2 -0
- package/src/runtime/release.ts +220 -0
- package/src/runtime/sql-assistance.ts +439 -0
- package/src/runtime/sql-options-schema.ts +31 -0
- package/src/runtime/sql-postgres-worker.ts +72 -0
- package/src/runtime/sql-postgres.ts +245 -0
- package/src/server/index.ts +35 -5
- package/src/server/lifecycle.ts +1 -1
- package/src/tools/configuration.ts +2 -0
- package/src/tools/diagnostics.ts +85 -0
- package/src/tools/files.ts +2 -0
- package/src/tools/index.ts +9 -0
- package/templates/skills/ast-mcp/SKILL.md +20 -1
- package/templates/skills/ast-mcp/evals/evals.json +274 -0
- package/templates/skills/ast-mcp/evals/semantic.ts +2 -0
- package/templates/skills/ast-mcp/evals/trigger-queries.json +4 -1
- package/templates/skills/ast-mcp/references/cli.md +97 -0
- package/templates/skills/ast-mcp/references/configuration.md +11 -3
- package/templates/skills/ast-mcp/references/diagnostics.md +106 -0
- package/templates/skills/ast-mcp/references/host-context.md +85 -0
- package/templates/skills/ast-mcp/references/installation.md +37 -0
- package/templates/skills/ast-mcp/references/issue-reporting.md +80 -0
- package/templates/skills/ast-mcp/references/patch-state-machine.md +10 -0
- package/templates/skills/ast-mcp/references/tool-catalog.md +120 -50
- package/templates/skills/ast-mcp/scripts/check-install.ts +223 -24
- package/templates/skills/ast-mcp/scripts/release.ts +220 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { Worker } from "node:worker_threads";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
SqlAdapter,
|
|
5
|
+
SqlAdapterRequest,
|
|
6
|
+
SqlAdapterResult,
|
|
7
|
+
} from "./sql-assistance";
|
|
8
|
+
|
|
9
|
+
interface PostgresAdapterOptions {
|
|
10
|
+
maxPending?: number;
|
|
11
|
+
maxOutstandingBytes?: number;
|
|
12
|
+
maxSourceBytes?: number;
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
workerFactory?: (url: URL) => Worker;
|
|
15
|
+
workerUrl?: URL;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Task {
|
|
19
|
+
bytes: number;
|
|
20
|
+
request: SqlAdapterRequest;
|
|
21
|
+
settled: boolean;
|
|
22
|
+
released: boolean;
|
|
23
|
+
cleanup(): void;
|
|
24
|
+
resolve(result: SqlAdapterResult): void;
|
|
25
|
+
reject(reason: unknown): void;
|
|
26
|
+
worker?: Worker;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const unavailable = (): SqlAdapterResult => ({
|
|
30
|
+
status: "unavailable",
|
|
31
|
+
complete: false,
|
|
32
|
+
scope: "sql",
|
|
33
|
+
});
|
|
34
|
+
const unsupported = (): SqlAdapterResult => ({
|
|
35
|
+
status: "unsupported",
|
|
36
|
+
complete: false,
|
|
37
|
+
scope: "sql",
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
function positive(value: number): boolean {
|
|
41
|
+
return Number.isSafeInteger(value) && value > 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function response(value: unknown): SqlAdapterResult {
|
|
45
|
+
if (typeof value !== "object" || value === null) return unavailable();
|
|
46
|
+
const raw = value as Partial<SqlAdapterResult>;
|
|
47
|
+
if (
|
|
48
|
+
!["valid", "invalid", "unsupported", "unavailable"].includes(
|
|
49
|
+
raw.status ?? "",
|
|
50
|
+
) ||
|
|
51
|
+
typeof raw.complete !== "boolean" ||
|
|
52
|
+
!["sql", "sql-and-procedural"].includes(raw.scope ?? "") ||
|
|
53
|
+
(raw.diagnostics !== undefined && !Array.isArray(raw.diagnostics)) ||
|
|
54
|
+
((raw.status === "valid" || raw.status === "invalid") && !raw.complete)
|
|
55
|
+
)
|
|
56
|
+
return unavailable();
|
|
57
|
+
return {
|
|
58
|
+
status: raw.status!,
|
|
59
|
+
complete: raw.complete,
|
|
60
|
+
scope: raw.scope!,
|
|
61
|
+
diagnostics: raw.diagnostics?.slice(0, 20).map((diagnostic) => ({
|
|
62
|
+
message: "SQL syntax rejected by the selected validator",
|
|
63
|
+
...(Number.isSafeInteger(diagnostic?.line) && diagnostic.line! >= 0
|
|
64
|
+
? { line: diagnostic.line }
|
|
65
|
+
: {}),
|
|
66
|
+
...(Number.isSafeInteger(diagnostic?.column) && diagnostic.column! >= 0
|
|
67
|
+
? { column: diagnostic.column }
|
|
68
|
+
: {}),
|
|
69
|
+
...(Number.isSafeInteger(diagnostic?.offset) && diagnostic.offset! >= 0
|
|
70
|
+
? { offset: diagnostic.offset }
|
|
71
|
+
: {}),
|
|
72
|
+
})),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Optional parse work uses fresh workers to reclaim each WASM heap.
|
|
78
|
+
* Capacity remains reserved until worker termination is confirmed.
|
|
79
|
+
*/
|
|
80
|
+
export class PostgresSqlAdapter implements SqlAdapter {
|
|
81
|
+
readonly id = "libpg-query";
|
|
82
|
+
readonly version = "18.2.2";
|
|
83
|
+
readonly #queue: Task[] = [];
|
|
84
|
+
readonly #active = new Set<Task>();
|
|
85
|
+
#pending = 0;
|
|
86
|
+
#bytes = 0;
|
|
87
|
+
readonly #limits;
|
|
88
|
+
|
|
89
|
+
constructor(private readonly options: PostgresAdapterOptions = {}) {
|
|
90
|
+
this.#limits = {
|
|
91
|
+
maxPending: options.maxPending ?? 8,
|
|
92
|
+
maxOutstandingBytes: options.maxOutstandingBytes ?? 2 * 1024 * 1024,
|
|
93
|
+
maxSourceBytes: options.maxSourceBytes ?? 512 * 1024,
|
|
94
|
+
timeoutMs: options.timeoutMs ?? 5000,
|
|
95
|
+
};
|
|
96
|
+
if (Object.values(this.#limits).some((value) => !positive(value)))
|
|
97
|
+
throw new TypeError("Invalid PostgreSQL adapter resource limit");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
stats(): { pending: number; active: number; outstandingBytes: number } {
|
|
101
|
+
return {
|
|
102
|
+
pending: this.#pending,
|
|
103
|
+
active: this.#active.size,
|
|
104
|
+
outstandingBytes: this.#bytes,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async validate(request: SqlAdapterRequest): Promise<SqlAdapterResult> {
|
|
109
|
+
request.signal.throwIfAborted();
|
|
110
|
+
if (
|
|
111
|
+
request.dialect !== "postgresql" ||
|
|
112
|
+
(request.version !== undefined && request.version !== "18") ||
|
|
113
|
+
(request.variant !== undefined && request.variant !== "sql")
|
|
114
|
+
)
|
|
115
|
+
return Promise.resolve(unsupported());
|
|
116
|
+
const bytes = Buffer.byteLength(request.source);
|
|
117
|
+
if (
|
|
118
|
+
bytes > this.#limits.maxSourceBytes ||
|
|
119
|
+
this.#pending >= this.#limits.maxPending ||
|
|
120
|
+
this.#bytes + bytes > this.#limits.maxOutstandingBytes
|
|
121
|
+
)
|
|
122
|
+
return Promise.resolve(unavailable());
|
|
123
|
+
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
this.#pending++;
|
|
126
|
+
this.#bytes += bytes;
|
|
127
|
+
const snapshot = { ...request };
|
|
128
|
+
let task: Task;
|
|
129
|
+
const abort = () => {
|
|
130
|
+
void this.#settle(task, unavailable(), snapshot.signal.reason);
|
|
131
|
+
};
|
|
132
|
+
const timer = setTimeout(() => {
|
|
133
|
+
void this.#settle(task, unavailable());
|
|
134
|
+
}, this.#limits.timeoutMs);
|
|
135
|
+
task = {
|
|
136
|
+
bytes,
|
|
137
|
+
request: snapshot,
|
|
138
|
+
settled: false,
|
|
139
|
+
released: false,
|
|
140
|
+
cleanup: () => {
|
|
141
|
+
clearTimeout(timer);
|
|
142
|
+
snapshot.signal.removeEventListener("abort", abort);
|
|
143
|
+
},
|
|
144
|
+
resolve,
|
|
145
|
+
reject,
|
|
146
|
+
};
|
|
147
|
+
snapshot.signal.addEventListener("abort", abort, { once: true });
|
|
148
|
+
this.#queue.push(task);
|
|
149
|
+
if (snapshot.signal.aborted) abort();
|
|
150
|
+
this.#dispatch();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
#release(task: Task): void {
|
|
155
|
+
if (task.released) return;
|
|
156
|
+
task.released = true;
|
|
157
|
+
this.#active.delete(task);
|
|
158
|
+
this.#pending--;
|
|
159
|
+
this.#bytes -= task.bytes;
|
|
160
|
+
this.#dispatch();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async #settle(
|
|
164
|
+
task: Task,
|
|
165
|
+
result: SqlAdapterResult,
|
|
166
|
+
cancellation?: unknown,
|
|
167
|
+
): Promise<void> {
|
|
168
|
+
if (task.settled) return;
|
|
169
|
+
task.settled = true;
|
|
170
|
+
task.cleanup();
|
|
171
|
+
const queued = this.#queue.indexOf(task);
|
|
172
|
+
if (queued >= 0) this.#queue.splice(queued, 1);
|
|
173
|
+
if (task.worker && !task.released) {
|
|
174
|
+
// Retirement has its own bounded budget. Unconfirmed threads retain their
|
|
175
|
+
// capacity reservation even after the caller receives unavailable.
|
|
176
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
177
|
+
let termination: Promise<boolean>;
|
|
178
|
+
try {
|
|
179
|
+
termination = task.worker.terminate().then(
|
|
180
|
+
() => {
|
|
181
|
+
this.#release(task);
|
|
182
|
+
return true;
|
|
183
|
+
},
|
|
184
|
+
() => false,
|
|
185
|
+
);
|
|
186
|
+
} catch {
|
|
187
|
+
termination = Promise.resolve(false);
|
|
188
|
+
}
|
|
189
|
+
const retired = await Promise.race([
|
|
190
|
+
termination,
|
|
191
|
+
new Promise<false>((resolve) => {
|
|
192
|
+
timer = setTimeout(() => resolve(false), this.#limits.timeoutMs);
|
|
193
|
+
}),
|
|
194
|
+
]);
|
|
195
|
+
clearTimeout(timer);
|
|
196
|
+
if (!retired) result = unavailable();
|
|
197
|
+
} else {
|
|
198
|
+
this.#release(task);
|
|
199
|
+
}
|
|
200
|
+
if (cancellation !== undefined) task.reject(cancellation);
|
|
201
|
+
else task.resolve(result);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
#dispatch(): void {
|
|
205
|
+
if (this.#active.size > 0) return;
|
|
206
|
+
const task = this.#queue.shift();
|
|
207
|
+
if (!task) return;
|
|
208
|
+
if (task.settled) {
|
|
209
|
+
this.#dispatch();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
this.#active.add(task);
|
|
213
|
+
try {
|
|
214
|
+
const worker = (this.options.workerFactory ?? ((url) => new Worker(url)))(
|
|
215
|
+
this.options.workerUrl ??
|
|
216
|
+
new URL("./sql-postgres-worker.ts", import.meta.url),
|
|
217
|
+
);
|
|
218
|
+
task.worker = worker;
|
|
219
|
+
worker.unref();
|
|
220
|
+
worker.once("error", () => {
|
|
221
|
+
void this.#settle(task, unavailable());
|
|
222
|
+
});
|
|
223
|
+
worker.once("exit", () => {
|
|
224
|
+
// Exit and terminate confirmation are independent retirement proofs.
|
|
225
|
+
this.#release(task);
|
|
226
|
+
void this.#settle(task, unavailable());
|
|
227
|
+
});
|
|
228
|
+
worker.once("message", (value: unknown) => {
|
|
229
|
+
void this.#settle(task, response(value));
|
|
230
|
+
});
|
|
231
|
+
worker.postMessage({
|
|
232
|
+
source: task.request.source,
|
|
233
|
+
variant: task.request.variant ?? "sql",
|
|
234
|
+
});
|
|
235
|
+
} catch {
|
|
236
|
+
void this.#settle(task, unavailable());
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const adapter = new PostgresSqlAdapter();
|
|
242
|
+
|
|
243
|
+
export async function loadPostgresSqlAdapter(): Promise<SqlAdapter> {
|
|
244
|
+
return adapter;
|
|
245
|
+
}
|
package/src/server/index.ts
CHANGED
|
@@ -5,6 +5,10 @@ import {
|
|
|
5
5
|
|
|
6
6
|
import packageJson from "../../package.json" with { type: "json" };
|
|
7
7
|
import type { IntelligenceRuntimeOptions } from "../intelligence/lifecycle/service.ts";
|
|
8
|
+
import {
|
|
9
|
+
clearSessionApprovals,
|
|
10
|
+
recordApprovalTransportFailure,
|
|
11
|
+
} from "../runtime/approval";
|
|
8
12
|
import { Telemetry, type TelemetryOptions } from "../runtime/telemetry";
|
|
9
13
|
import { registerSkills } from "../skills";
|
|
10
14
|
import tools from "../tools";
|
|
@@ -13,6 +17,8 @@ import { createIntelligenceToolService } from "../tools/intelligence.ts";
|
|
|
13
17
|
|
|
14
18
|
export interface ServerOptions {
|
|
15
19
|
approvalTimeoutMs?: number;
|
|
20
|
+
diagnosticsFetch?: typeof fetch;
|
|
21
|
+
transport?: "stdio" | "http" | "unknown";
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
export function createServer(
|
|
@@ -41,24 +47,47 @@ export function createServer(
|
|
|
41
47
|
const requestOptions = args[optionsIndex] as
|
|
42
48
|
| Parameters<typeof server.server.elicitInput>[1]
|
|
43
49
|
| undefined;
|
|
44
|
-
const
|
|
50
|
+
const probe =
|
|
51
|
+
(args[0] as { params?: { _meta?: Record<string, unknown> } }).params
|
|
52
|
+
?._meta?.["io.ast-mcp/probe"] === true;
|
|
53
|
+
const deadlineMs = probe
|
|
54
|
+
? Math.min(approvalTimeoutMs, 5000)
|
|
55
|
+
: approvalTimeoutMs;
|
|
56
|
+
const timeout = AbortSignal.timeout(deadlineMs);
|
|
45
57
|
args[optionsIndex] = {
|
|
46
58
|
...requestOptions,
|
|
47
59
|
maxTotalTimeout: Math.min(
|
|
48
|
-
requestOptions?.maxTotalTimeout ??
|
|
49
|
-
|
|
60
|
+
requestOptions?.maxTotalTimeout ?? deadlineMs,
|
|
61
|
+
deadlineMs,
|
|
50
62
|
),
|
|
51
63
|
signal: requestOptions?.signal
|
|
52
64
|
? AbortSignal.any([requestOptions.signal, timeout])
|
|
53
65
|
: timeout,
|
|
54
66
|
};
|
|
55
67
|
}
|
|
56
|
-
return Reflect.apply(request, undefined, args)
|
|
68
|
+
return Reflect.apply(request, undefined, args).catch((error: unknown) => {
|
|
69
|
+
if ((args[0] as { method?: string }).method === "elicitation/create")
|
|
70
|
+
recordApprovalTransportFailure(
|
|
71
|
+
server,
|
|
72
|
+
(args[0] as { params?: { _meta?: Record<string, unknown> } }).params
|
|
73
|
+
?._meta?.["io.ast-mcp/approvalChallenge"],
|
|
74
|
+
error,
|
|
75
|
+
);
|
|
76
|
+
throw error;
|
|
77
|
+
});
|
|
57
78
|
}) as typeof server.server.request;
|
|
58
79
|
|
|
59
80
|
const telemetry = new Telemetry(telemetryOptions);
|
|
60
81
|
const intelligence = createIntelligenceToolService(intelligenceOptions);
|
|
61
|
-
tools(server, {
|
|
82
|
+
tools(server, {
|
|
83
|
+
intelligence,
|
|
84
|
+
telemetry,
|
|
85
|
+
execution,
|
|
86
|
+
diagnostics: {
|
|
87
|
+
fetch: options.diagnosticsFetch,
|
|
88
|
+
transport: options.transport,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
62
91
|
registerSkills(server);
|
|
63
92
|
const closeServer = server.close.bind(server);
|
|
64
93
|
let closePromise: Promise<void> | undefined;
|
|
@@ -67,6 +96,7 @@ export function createServer(
|
|
|
67
96
|
try {
|
|
68
97
|
await closeServer();
|
|
69
98
|
} finally {
|
|
99
|
+
clearSessionApprovals(undefined, server);
|
|
70
100
|
try {
|
|
71
101
|
await intelligence.close?.();
|
|
72
102
|
} finally {
|
package/src/server/lifecycle.ts
CHANGED
|
@@ -11,7 +11,7 @@ export {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export function createProcessServer() {
|
|
14
|
-
const server = createServer();
|
|
14
|
+
const server = createServer({}, {}, {}, { transport: "stdio" });
|
|
15
15
|
const close = server.close.bind(server);
|
|
16
16
|
let disposeSignals: (() => void) | undefined;
|
|
17
17
|
let disposeFailures: (() => void) | undefined;
|
|
@@ -28,6 +28,7 @@ import { readWorkspaceRevisionBytes } from "../runtime/file-read.ts";
|
|
|
28
28
|
import { sha256 } from "../runtime/hash";
|
|
29
29
|
import { evaluatePolicyForCheck } from "../runtime/path-policy";
|
|
30
30
|
import { resolveWorkspacePath } from "../runtime/paths";
|
|
31
|
+
import { sqlAssistanceOptionsSchema } from "../runtime/sql-options-schema";
|
|
31
32
|
import { type ConfiguredExecution, localExecution } from "./configured";
|
|
32
33
|
|
|
33
34
|
interface JsonLocationToken {
|
|
@@ -568,6 +569,7 @@ export default function registerConfigurationTools(
|
|
|
568
569
|
)
|
|
569
570
|
.max(4)
|
|
570
571
|
.optional(),
|
|
572
|
+
sql: sqlAssistanceOptionsSchema.optional(),
|
|
571
573
|
strategies: z
|
|
572
574
|
.array(z.enum(["ast", "aider_block"]))
|
|
573
575
|
.max(2)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/server";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
|
|
4
|
+
import packageJson from "../../package.json" with { type: "json" };
|
|
5
|
+
import {
|
|
6
|
+
toolFailure,
|
|
7
|
+
toolOutputSchema,
|
|
8
|
+
toolSuccess,
|
|
9
|
+
} from "../helpers/mcp-schema";
|
|
10
|
+
import { runApprovalProbe, withApprovalContext } from "../runtime/approval";
|
|
11
|
+
import {
|
|
12
|
+
checkLatestVersion,
|
|
13
|
+
collectDiagnostics,
|
|
14
|
+
type DiagnosticsOptions,
|
|
15
|
+
} from "../runtime/diagnostics";
|
|
16
|
+
|
|
17
|
+
export default function registerDiagnosticTools(
|
|
18
|
+
server: McpServer,
|
|
19
|
+
options: Pick<DiagnosticsOptions, "fetch" | "transport"> & {
|
|
20
|
+
requestScoped?: boolean;
|
|
21
|
+
} = {},
|
|
22
|
+
) {
|
|
23
|
+
server.registerTool(
|
|
24
|
+
"diagnostics",
|
|
25
|
+
{
|
|
26
|
+
annotations: {
|
|
27
|
+
destructiveHint: false,
|
|
28
|
+
idempotentHint: true,
|
|
29
|
+
openWorldHint: true,
|
|
30
|
+
readOnlyHint: true,
|
|
31
|
+
},
|
|
32
|
+
description:
|
|
33
|
+
"Reports sanitized runtime, approval, capability and configuration state before filesystem approval. Always checks the public npm latest release with a five-second deadline.",
|
|
34
|
+
inputSchema: z.object({}).strict(),
|
|
35
|
+
outputSchema: toolOutputSchema,
|
|
36
|
+
title: "Diagnose AST MCP",
|
|
37
|
+
},
|
|
38
|
+
async (_, context) => {
|
|
39
|
+
try {
|
|
40
|
+
return toolSuccess(
|
|
41
|
+
await collectDiagnostics({ ...options, server, context }),
|
|
42
|
+
);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return toolFailure(error);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
server.registerTool(
|
|
49
|
+
"approval_probe",
|
|
50
|
+
{
|
|
51
|
+
annotations: {
|
|
52
|
+
destructiveHint: false,
|
|
53
|
+
idempotentHint: true,
|
|
54
|
+
openWorldHint: true,
|
|
55
|
+
readOnlyHint: true,
|
|
56
|
+
},
|
|
57
|
+
description:
|
|
58
|
+
"Explicitly tests a bounded approval form and checks the latest release. Acceptance grants no filesystem permission and persists no configuration.",
|
|
59
|
+
inputSchema: z.object({}).strict(),
|
|
60
|
+
outputSchema: toolOutputSchema,
|
|
61
|
+
title: "Probe Approval Transport",
|
|
62
|
+
},
|
|
63
|
+
async (_, context) => {
|
|
64
|
+
try {
|
|
65
|
+
const versionCheck = checkLatestVersion(packageJson.version, {
|
|
66
|
+
fetch: options.fetch,
|
|
67
|
+
});
|
|
68
|
+
return await withApprovalContext(
|
|
69
|
+
{
|
|
70
|
+
context,
|
|
71
|
+
server,
|
|
72
|
+
tool: "approval_probe",
|
|
73
|
+
requestScoped: options.requestScoped,
|
|
74
|
+
},
|
|
75
|
+
async () => {
|
|
76
|
+
const probe = runApprovalProbe();
|
|
77
|
+
return toolSuccess({ ...probe, versionCheck: await versionCheck });
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
return toolFailure(error);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
);
|
|
85
|
+
}
|
package/src/tools/files.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
inspectWorkspaceFileCapabilitiesSafely,
|
|
23
23
|
readFilesSafely,
|
|
24
24
|
} from "../runtime/file-read";
|
|
25
|
+
import { sqlAssistanceOptionsSchema } from "../runtime/sql-options-schema";
|
|
25
26
|
import { type ConfiguredExecution, localExecution } from "./configured";
|
|
26
27
|
|
|
27
28
|
const failure = toolFailure;
|
|
@@ -253,6 +254,7 @@ export default function registerFileTools(
|
|
|
253
254
|
patchStrategy: z.enum(["ast", "aider_block"]).optional(),
|
|
254
255
|
preview: z.boolean().optional(),
|
|
255
256
|
previewReceipt: z.string().uuid().optional(),
|
|
257
|
+
sql: sqlAssistanceOptionsSchema.optional(),
|
|
256
258
|
})
|
|
257
259
|
.strict()
|
|
258
260
|
.superRefine((value, context) => {
|
package/src/tools/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { Telemetry } from "../runtime/telemetry";
|
|
|
5
5
|
import registerNativeCodeIntelligenceTools from "./code-intelligence";
|
|
6
6
|
import registerConfigurationTools from "./configuration";
|
|
7
7
|
import { configuredExecution, type ExecutionOptions } from "./configured";
|
|
8
|
+
import registerDiagnosticTools from "./diagnostics";
|
|
8
9
|
import registerFileTools from "./files";
|
|
9
10
|
import registerIntelligenceTools, {
|
|
10
11
|
type IntelligenceToolService,
|
|
@@ -17,6 +18,10 @@ export default function (
|
|
|
17
18
|
intelligence?: IntelligenceToolService;
|
|
18
19
|
telemetry?: Telemetry;
|
|
19
20
|
execution?: ExecutionOptions;
|
|
21
|
+
diagnostics?: {
|
|
22
|
+
fetch?: typeof fetch;
|
|
23
|
+
transport?: "stdio" | "http" | "unknown";
|
|
24
|
+
};
|
|
20
25
|
} = {},
|
|
21
26
|
) {
|
|
22
27
|
const execute = configuredExecution(
|
|
@@ -32,6 +37,10 @@ export default function (
|
|
|
32
37
|
registerWorkspaceTools(server, execute);
|
|
33
38
|
registerNativeCodeIntelligenceTools(server, execute);
|
|
34
39
|
registerConfigurationTools(server, execute);
|
|
40
|
+
registerDiagnosticTools(server, {
|
|
41
|
+
...services.diagnostics,
|
|
42
|
+
requestScoped: services.execution?.requestScoped,
|
|
43
|
+
});
|
|
35
44
|
registerFileTools(server, execute);
|
|
36
45
|
registerLifecycleTools(server, execute);
|
|
37
46
|
registerIntelligenceTools(server, execute, services.intelligence);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ast-mcp
|
|
3
|
-
description: Use for local repository exploration, code intelligence, guarded file operations,
|
|
3
|
+
description: Use for local repository exploration, code intelligence, guarded file operations, AST-MCP installation, diagnostics, recovery, and unexpected-behavior reports. Use when tools disconnect, approvals fail, configuration needs migration, or selected manual skills need updates. Do not use for unrelated remote-only research, supplied text, or general AST explanations.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# AST MCP
|
|
@@ -19,10 +19,23 @@ Do not invent a `$ast-mcp/references/...` filesystem path.
|
|
|
19
19
|
Reading a resource does not activate a skill.
|
|
20
20
|
|
|
21
21
|
- Load [tool-catalog.md](references/tool-catalog.md) for tool inputs, workspace selection, indexing, retrieval, and graph operations.
|
|
22
|
+
- Load [cli.md](references/cli.md) for supported CLI commands, subcommands, options, and output.
|
|
23
|
+
- Load [diagnostics.md](references/diagnostics.md) for failures, approval probes, host policy conflicts, and release checks.
|
|
24
|
+
- Load [host-context.md](references/host-context.md) for host permission limits and exact checkout selection.
|
|
25
|
+
- Load [issue-reporting.md](references/issue-reporting.md) before drafting or submitting an unexpected-behavior report.
|
|
22
26
|
- Load [patch-state-machine.md](references/patch-state-machine.md) before file mutations or recovery from rejected patches.
|
|
23
27
|
- Load [installation.md](references/installation.md) for missing tools, disconnections, upgrades, stale instructions, or configuration migration.
|
|
24
28
|
- Load [configuration.md](references/configuration.md) for path rules, approvals, formatting, telemetry, and CLI output.
|
|
25
29
|
|
|
30
|
+
## Diagnose unexpected behavior
|
|
31
|
+
|
|
32
|
+
Use MCP `diagnostics` for the connected server or CLI `doctor` when MCP is unavailable.
|
|
33
|
+
Every diagnostic and issue workflow must attempt a fresh latest stable version check.
|
|
34
|
+
Report unavailable checks explicitly. Never infer the connected version from an installed executable.
|
|
35
|
+
Search open and closed upstream issues before proposing a new report.
|
|
36
|
+
Read likely matches and preserve reporting authorization boundaries.
|
|
37
|
+
Keep Codex-specific recovery separate from Claude, Claude Desktop, Grok, Copilot, and other MCP hosts.
|
|
38
|
+
|
|
26
39
|
## Check availability
|
|
27
40
|
|
|
28
41
|
1. Confirm that file tools and direct intelligence tools are callable.
|
|
@@ -85,4 +98,10 @@ Stop on stale hashes, ambiguous matches, stale receipts, capped reads, permissio
|
|
|
85
98
|
Reinspect the target and rebuild the operation through the supported route.
|
|
86
99
|
Distinguish path policy from OS permissions. Do not broaden access without authorization.
|
|
87
100
|
Change `ast-mcp.toml` through `config_core` and `config_paths`, never whole-file writers.
|
|
101
|
+
|
|
102
|
+
SQL validation is optional. No SQL request means no validator call. A configured dialect alone does not trigger validation.
|
|
103
|
+
Advisory results never block a safe patch. Required validation is opt-in and can be overridden per operation with `sql: { policy: "skip" }`.
|
|
104
|
+
Generic `run` SQL matching is not dialect validation. Select the patch strategy explicitly; AST failure never triggers Aider automatically.
|
|
105
|
+
Read [tool-catalog.md](references/tool-catalog.md), [configuration.md](references/configuration.md), and [patch-state-machine.md](references/patch-state-machine.md) for schemas, limits, and outcomes.
|
|
106
|
+
|
|
88
107
|
Host approval is required by default. Model arguments cannot grant approval.
|