agda-mcp-server 0.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.
- package/LICENSE +23 -0
- package/README.md +472 -0
- package/dist/agda/advanced-queries.d.ts +52 -0
- package/dist/agda/advanced-queries.js +249 -0
- package/dist/agda/advanced-queries.js.map +1 -0
- package/dist/agda/batch.d.ts +6 -0
- package/dist/agda/batch.js +59 -0
- package/dist/agda/batch.js.map +1 -0
- package/dist/agda/expression-operations.d.ts +17 -0
- package/dist/agda/expression-operations.js +86 -0
- package/dist/agda/expression-operations.js.map +1 -0
- package/dist/agda/goal-operations.d.ts +29 -0
- package/dist/agda/goal-operations.js +156 -0
- package/dist/agda/goal-operations.js.map +1 -0
- package/dist/agda/response-parsing.d.ts +4 -0
- package/dist/agda/response-parsing.js +44 -0
- package/dist/agda/response-parsing.js.map +1 -0
- package/dist/agda/session.d.ts +88 -0
- package/dist/agda/session.js +340 -0
- package/dist/agda/session.js.map +1 -0
- package/dist/agda/types.d.ts +99 -0
- package/dist/agda/types.js +5 -0
- package/dist/agda/types.js.map +1 -0
- package/dist/agda-process.d.ts +4 -0
- package/dist/agda-process.js +14 -0
- package/dist/agda-process.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/navigation.d.ts +3 -0
- package/dist/tools/navigation.js +192 -0
- package/dist/tools/navigation.js.map +1 -0
- package/dist/tools/proof.d.ts +3 -0
- package/dist/tools/proof.js +250 -0
- package/dist/tools/proof.js.map +1 -0
- package/dist/tools/session.d.ts +3 -0
- package/dist/tools/session.js +108 -0
- package/dist/tools/session.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// MIT License — see LICENSE
|
|
2
|
+
//
|
|
3
|
+
// Session management tools: agda_load, agda_session_status, agda_typecheck
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { resolve, relative } from "node:path";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { typeCheckBatch } from "../agda-process.js";
|
|
8
|
+
export function register(server, session, repoRoot) {
|
|
9
|
+
// ── agda_load ─────────────────────────────────────────────────────
|
|
10
|
+
server.tool("agda_load", "Load and type-check an Agda file. This establishes the interactive session — subsequent commands (goal_type, case_split, give, refine, auto) operate on the loaded file's goals. Returns errors, warnings, and a list of unsolved goals with their IDs.", {
|
|
11
|
+
file: z.string().describe("Path to the .agda file (relative to repo root or absolute)"),
|
|
12
|
+
}, async ({ file }) => {
|
|
13
|
+
const filePath = resolve(repoRoot, file);
|
|
14
|
+
if (!existsSync(filePath)) {
|
|
15
|
+
return { content: [{ type: "text", text: `File not found: ${filePath}` }] };
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const result = await session.load(filePath);
|
|
19
|
+
const relPath = relative(repoRoot, filePath);
|
|
20
|
+
let output = `## Loaded: ${relPath}\n\n`;
|
|
21
|
+
output += `**Status:** ${result.success ? "OK" : "FAILED"}\n`;
|
|
22
|
+
output += `**Goals:** ${result.goals.length} unsolved\n\n`;
|
|
23
|
+
if (result.errors.length > 0) {
|
|
24
|
+
output += `### Errors\n`;
|
|
25
|
+
for (const err of result.errors) {
|
|
26
|
+
output += `\`\`\`\n${err}\n\`\`\`\n`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (result.allGoalsText) {
|
|
30
|
+
output += `### Goals & Warnings\n\`\`\`\n${result.allGoalsText}\n\`\`\`\n`;
|
|
31
|
+
}
|
|
32
|
+
if (result.goals.length > 0) {
|
|
33
|
+
output += `\n### Goal IDs\n`;
|
|
34
|
+
output += `Use these IDs with \`agda_goal_type\`, \`agda_case_split\`, \`agda_give\`, \`agda_refine\`, \`agda_auto\`, \`agda_compute\`, \`agda_infer\`.\n\n`;
|
|
35
|
+
for (const goal of result.goals) {
|
|
36
|
+
output += `- **?${goal.goalId}**\n`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { content: [{ type: "text", text: output }] };
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
return {
|
|
43
|
+
content: [{ type: "text", text: `Agda load failed: ${err instanceof Error ? err.message : String(err)}` }],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
// ── agda_session_status ───────────────────────────────────────────
|
|
48
|
+
server.tool("agda_session_status", "Show the current Agda session status: loaded file and available goal IDs.", {}, async () => {
|
|
49
|
+
const loadedFile = session.getLoadedFile();
|
|
50
|
+
const goalIds = session.getGoalIds();
|
|
51
|
+
let output = `## Agda Session Status\n\n`;
|
|
52
|
+
output += `**Loaded file:** ${loadedFile ? relative(repoRoot, loadedFile) : "(none)"}\n`;
|
|
53
|
+
output += `**Goal IDs:** ${goalIds.length > 0 ? goalIds.map((id) => `?${id}`).join(", ") : "(none)"}\n\n`;
|
|
54
|
+
if (!loadedFile) {
|
|
55
|
+
output += `Use \`agda_load\` to load a file and start an interactive session.\n`;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
output += `### Available commands\n`;
|
|
59
|
+
output += `- \`agda_goal_type\` — show type/context for a goal\n`;
|
|
60
|
+
output += `- \`agda_case_split\` — case-split on a variable\n`;
|
|
61
|
+
output += `- \`agda_give\` — fill a goal with an expression\n`;
|
|
62
|
+
output += `- \`agda_refine\` — refine a goal\n`;
|
|
63
|
+
output += `- \`agda_auto\` — auto-solve a goal\n`;
|
|
64
|
+
output += `- \`agda_auto_all\` — auto-solve all goals\n`;
|
|
65
|
+
output += `- \`agda_solve_all\` — solve all uniquely-solvable goals\n`;
|
|
66
|
+
output += `- \`agda_compute\` — normalize an expression\n`;
|
|
67
|
+
output += `- \`agda_infer\` — infer the type of an expression\n`;
|
|
68
|
+
output += `- \`agda_elaborate\` — elaborate an expression\n`;
|
|
69
|
+
output += `- \`agda_constraints\` — show constraints\n`;
|
|
70
|
+
output += `- \`agda_why_in_scope\` — explain why a name is in scope\n`;
|
|
71
|
+
output += `- \`agda_show_module\` — show module contents\n`;
|
|
72
|
+
output += `- \`agda_search_about\` — search definitions by type signature\n`;
|
|
73
|
+
}
|
|
74
|
+
return { content: [{ type: "text", text: output }] };
|
|
75
|
+
});
|
|
76
|
+
// ── agda_typecheck ────────────────────────────────────────────────
|
|
77
|
+
server.tool("agda_typecheck", "Quick batch type-check of an Agda file (stateless — does not establish an interactive session). Use agda_load for interactive proof work.", {
|
|
78
|
+
file: z.string().describe("Path to the .agda file"),
|
|
79
|
+
}, async ({ file }) => {
|
|
80
|
+
const filePath = resolve(repoRoot, file);
|
|
81
|
+
if (!existsSync(filePath)) {
|
|
82
|
+
return { content: [{ type: "text", text: `File not found: ${filePath}` }] };
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const result = await typeCheckBatch(filePath, repoRoot);
|
|
86
|
+
const relPath = relative(repoRoot, filePath);
|
|
87
|
+
let output = `## Type-check: ${relPath}\n\n`;
|
|
88
|
+
output += `**Status:** ${result.success ? "OK" : "FAILED"}\n\n`;
|
|
89
|
+
if (result.errors.length > 0) {
|
|
90
|
+
output += `### Errors (${result.errors.length})\n`;
|
|
91
|
+
for (const err of result.errors)
|
|
92
|
+
output += `- ${err}\n`;
|
|
93
|
+
}
|
|
94
|
+
if (result.warnings.length > 0) {
|
|
95
|
+
output += `### Warnings (${result.warnings.length})\n`;
|
|
96
|
+
for (const warn of result.warnings)
|
|
97
|
+
output += `- ${warn}\n`;
|
|
98
|
+
}
|
|
99
|
+
return { content: [{ type: "text", text: output }] };
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
return {
|
|
103
|
+
content: [{ type: "text", text: `Agda invocation failed: ${err instanceof Error ? err.message : String(err)}` }],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/tools/session.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;YACb,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,2BAA2B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;aAC1H,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agda-mcp-server",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "MCP server for interactive Agda proof development — type-checking, goal inspection, case splitting, proof search, and more via the Model Context Protocol",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"agda-mcp-server": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"start": "node dist/index.js",
|
|
25
|
+
"dev": "tsx src/index.ts",
|
|
26
|
+
"pretest": "npm run build",
|
|
27
|
+
"test": "node --test test/**/*.test.js",
|
|
28
|
+
"test:integration": "node --test test/integration/**/*.test.js",
|
|
29
|
+
"verify": "npm test && npm pack --dry-run",
|
|
30
|
+
"prepublishOnly": "npm run verify"
|
|
31
|
+
},
|
|
32
|
+
"packageManager": "npm@11.11.0",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/LionOfJewdah/agda-mcp-server.git"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/LionOfJewdah/agda-mcp-server#readme",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/LionOfJewdah/agda-mcp-server/issues"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"agda",
|
|
43
|
+
"mcp",
|
|
44
|
+
"model-context-protocol",
|
|
45
|
+
"proof-assistant",
|
|
46
|
+
"type-theory",
|
|
47
|
+
"interactive-theorem-proving"
|
|
48
|
+
],
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
54
|
+
"zod": "^3.25 || ^4.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/node": "^24.5.2",
|
|
58
|
+
"tsx": "^4.0.0",
|
|
59
|
+
"typescript": "^5.9.3"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=24"
|
|
63
|
+
},
|
|
64
|
+
"license": "MIT"
|
|
65
|
+
}
|