vexp-mcp 2.7.0 → 3.1.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 ADDED
@@ -0,0 +1,31 @@
1
+ # vexp-mcp — MCP Server for AI Coding Agents (Claude Code, Cursor, Codex)
2
+
3
+ **The [Model Context Protocol](https://modelcontextprotocol.io) server behind [vexp](https://vexp.dev), the local-first context engine for AI coding agents.**
4
+
5
+ `vexp-mcp` exposes your codebase's dependency graph to any MCP-capable agent — Claude Code, Cursor, Windsurf, OpenAI Codex, Zed, Cline and more — as a small, deliberately slim set of tools. Ranked pivot files with line ranges and blast radius in one call, compact file skeletons at 70–90% token savings, and a mechanical completion check when the agent says it's done. Everything runs on your machine: no cloud indexing, no API key, and your source never leaves your laptop.
6
+
7
+ > **You normally don't install this package directly.** Install [`vexp-cli`](https://www.npmjs.com/package/vexp-cli) (or the [VS Code extension](https://marketplace.visualstudio.com/items?itemName=vexp.vexp-vscode)) and run `vexp setup` — it wires this server into every agent it detects.
8
+
9
+ ## Tools your agent gets
10
+
11
+ | Tool | What it does |
12
+ |---|---|
13
+ | `run_pipeline` | Ranked pivot files + line ranges + blast radius for a task, in one call |
14
+ | `get_skeleton` | File structure at 70–90% token savings, for files the agent only needs to understand |
15
+ | `verify_done` | Mechanical completion check: parse errors, broken imports, untouched dependents, impacted tests |
16
+ | `expand_vexp_ref` | Full body of any referenced symbol, on demand |
17
+
18
+ The catalog is kept deliberately small — 3.0 trimmed it to roughly a third of its former token footprint — because every listed schema rides along on every request your agent makes.
19
+
20
+ ## Why teams use vexp
21
+
22
+ - **Sessions cost less, measured.** vexp 3.0 was tuned on full agent sessions paired against the same agent without vexp: more tasks resolved, 13% less context replay, 8% lower session cost — 20% lower on long sessions.
23
+ - **87% fewer tokens per call** than reading whole files, on real usage.
24
+ - **100% local.** Zero network calls, zero cloud indexing, works offline.
25
+ - **14 agents, 34 languages**, one `vexp setup`.
26
+
27
+ → [vexp.dev](https://vexp.dev) · [Docs](https://vexp.dev/docs) · [`vexp-cli` on npm](https://www.npmjs.com/package/vexp-cli)
28
+
29
+ ---
30
+
31
+ <sub><strong>Keywords:</strong> MCP server · Model Context Protocol · AI coding agent · Claude Code MCP · Cursor MCP · code context · token savings · dependency graph · tree-sitter · local-first · code verification</sub>
package/dist/index.js CHANGED
@@ -72,6 +72,58 @@ const ESSENTIAL_TOOL_DEFINITIONS = [
72
72
  * keep working whether or not it is listed.
73
73
  * VEXP_ALL_TOOLS=1 restores the full surface.
74
74
  */
75
+ /**
76
+ * Trim a definition down to what `tools/list` has to carry.
77
+ *
78
+ * The advertised catalog is resident in the agent's context on EVERY turn; a
79
+ * call happens at most once. Measured on a 13-instance bench run: 41.6 API
80
+ * turns per session against a 65,521-token transcript, and this surface's
81
+ * three listed schemas were ~1,078 tokens of that, re-sent every turn. The
82
+ * models called them 5 times in ~10,000 tool calls.
83
+ *
84
+ * So the listing keeps the decision rule (when to call me) and drops the
85
+ * explanation plus every advanced parameter no model has been observed to
86
+ * set. Dispatch and Zod validation still use the full definitions: this
87
+ * narrows the shop window, not the shop.
88
+ */
89
+ const LISTING_OVERRIDES = {
90
+ run_pipeline: {
91
+ description: "Ranked pivot files with line ranges plus blast radius for this repo, in one call. " +
92
+ "Use at task start when the task does NOT already name the files to touch; skip it when it does.",
93
+ inputSchema: {
94
+ type: "object",
95
+ properties: {
96
+ task: { type: "string", description: "The task, anchored on real identifiers or paths" },
97
+ preset: { type: "string", enum: ["auto", "explore", "modify", "debug", "refactor"] },
98
+ },
99
+ required: ["task"],
100
+ },
101
+ },
102
+ get_skeleton: {
103
+ description: "File structure (signatures, classes, types) at ~85% fewer tokens than Read. " +
104
+ "For files you need to understand, not edit.",
105
+ inputSchema: {
106
+ type: "object",
107
+ properties: {
108
+ files: { type: "array", items: { type: "string" } },
109
+ detail: { type: "string", enum: ["minimal", "standard", "detailed"] },
110
+ },
111
+ required: ["files"],
112
+ },
113
+ },
114
+ verify_done: {
115
+ // The one tool bench models actually reached for. Trimmed, not gutted:
116
+ // its description is what earns the call.
117
+ description: "Call BEFORE declaring a multi-file task complete: returns files that no longer parse, " +
118
+ "imports of names that no longer exist, dependents you left untouched (file:line), and " +
119
+ "the impacted tests. Run those tests. No parameters.",
120
+ inputSchema: { type: "object", properties: {} },
121
+ },
122
+ };
123
+ export function slimForListing(def) {
124
+ const o = LISTING_OVERRIDES[def.name];
125
+ return o ? { ...def, description: o.description, inputSchema: o.inputSchema } : def;
126
+ }
75
127
  const MINIMAL_TOOL_DEFINITIONS = [
76
128
  RUN_PIPELINE_DEFINITION,
77
129
  GET_SKELETON_DEFINITION,
@@ -95,24 +147,26 @@ function allToolsEnabled() {
95
147
  // ~/.vexp/daemons.json on all platforms, which is the authoritative
96
148
  // lookup when an agent spawns the MCP server from an unrelated cwd.
97
149
  export function createMcpServer(daemon) {
98
- const server = new Server({ name: "vexp-mcp", version: "1.0.0" }, { capabilities: { tools: { listChanged: true } } });
99
- // Once any response carries a [V-REF:...] placeholder, expand_vexp_ref
100
- // becomes relevant: expose it and tell the client the list changed.
101
- let vrefSeen = false;
102
- const noteVref = (text) => {
103
- if (vrefSeen || !text.includes("[V-REF:"))
104
- return;
105
- vrefSeen = true;
106
- server.sendToolListChanged().catch(() => {
107
- /* client may not support notifications — fallback is in-band */
108
- });
109
- };
150
+ const server = new Server({ name: "vexp-mcp", version: "1.0.0" }, { capabilities: { tools: {} } });
151
+ // This surface used to publish expand_vexp_ref mid-session, the first time a
152
+ // response carried a [V-REF:...] placeholder, via tools/list_changed. It was
153
+ // meant to save the schema's weight until the tool became relevant. The
154
+ // arithmetic says it did the opposite.
155
+ //
156
+ // The tools array is the FIRST thing in the request, so it is the prefix of
157
+ // the prompt cache. Changing it mid-session invalidates the cache for tools,
158
+ // system and every message after them: the whole ~23,000-token prefix is
159
+ // re-created at the 1.25x write price. Carrying the schema instead costs
160
+ // ~60 tokens on each remaining turn at the 0.1x cache-read price — roughly
161
+ // 1,200 tokens over a typical tail. Publishing the change is ~24x worse
162
+ // than never hiding the tool.
163
+ //
164
+ // So the listing is now static, and the in-band fallback every V-REF
165
+ // response already carries ("or Read the file") covers the rest.
110
166
  server.setRequestHandler(ListToolsRequestSchema, () => ({
111
167
  tools: allToolsEnabled()
112
168
  ? ALL_TOOL_DEFINITIONS
113
- : vrefSeen
114
- ? [...MINIMAL_TOOL_DEFINITIONS, EXPAND_VEXP_REF_DEFINITION]
115
- : MINIMAL_TOOL_DEFINITIONS,
169
+ : MINIMAL_TOOL_DEFINITIONS.map(slimForListing),
116
170
  }));
117
171
  server.setRequestHandler(CallToolRequestSchema, async (req) => {
118
172
  const { name, arguments: args } = req.params;
@@ -161,7 +215,6 @@ export function createMcpServer(daemon) {
161
215
  content: [{ type: "text", text: `Unknown tool: ${name}` }],
162
216
  };
163
217
  }
164
- noteVref(text);
165
218
  return {
166
219
  content: [{ type: "text", text }],
167
220
  };
@@ -56,21 +56,25 @@ function formatSkeletonsAsText(nodes) {
56
56
  lines.push(`# File Skeletons`);
57
57
  lines.push(`> ${byFile.size} file(s), ${nodes.length} symbol(s)`);
58
58
  lines.push("");
59
+ // One heading and one fence per FILE, not per symbol.
60
+ //
61
+ // This emitted six lines of chrome around every symbol — a heading, the
62
+ // fully-qualified name, a blank line, two fence markers and another blank.
63
+ // On a file with four hundred symbols that is two thousand four hundred
64
+ // lines of decoration wrapped around the thing we are here to make smaller.
65
+ // The same mistake sat in the CLI, where a header box per symbol made a
66
+ // Rust skeleton LARGER than the file it summarised.
67
+ //
68
+ // Nothing is lost: the file path is the heading, the symbol name is the
69
+ // first line of its own skeleton, and the per-symbol reduction percentage
70
+ // is arithmetic the reader did not ask for.
59
71
  for (const [filePath, fileNodes] of byFile) {
60
- lines.push(`## \`${filePath}\``);
72
+ lines.push(`## \`${filePath}\` — ${fileNodes.length} symbol(s)`);
73
+ lines.push("");
74
+ lines.push("```");
75
+ lines.push(fileNodes.map((n) => n.skeleton).join("\n\n"));
76
+ lines.push("```");
61
77
  lines.push("");
62
- for (const n of fileNodes) {
63
- const reduction = n.token_reduction_pct > 0
64
- ? ` *(${n.token_reduction_pct.toFixed(0)}% token reduction)*`
65
- : "";
66
- lines.push(`### ${n.node}${reduction}`);
67
- lines.push(`*\`${n.fqn}\`*`);
68
- lines.push("");
69
- lines.push("```");
70
- lines.push(n.skeleton);
71
- lines.push("```");
72
- lines.push("");
73
- }
74
78
  }
75
79
  return lines.join("\n");
76
80
  }
@@ -97,6 +97,27 @@ function formatStatusAsText(status, targeting) {
97
97
  "Restart the daemon (`vexp daemon-cmd restart`) or re-run `vexp setup-llm` — until then, results are NOT LLM-compressed.");
98
98
  lines.push("");
99
99
  }
100
+ // Coverage gaps (3.1). Files over max_file_size_kb were skipped with an
101
+ // INFO log line and nothing else; this surface said HEALTHY over a graph
102
+ // missing 21% of the bytes of a user's lib/ (tier-4 field report, 2026-08).
103
+ if (status.coverage) {
104
+ const c = status.coverage;
105
+ const gaps = [];
106
+ if ((c.skipped_oversized ?? 0) > 0) {
107
+ const ex = c.skipped_examples?.length ? ` — e.g. ${c.skipped_examples.join(", ")}` : "";
108
+ gaps.push(`- ⚠️ ${c.skipped_oversized} file(s) over max_file_size_kb = ${c.max_file_size_kb ?? "?"} are NOT indexed${ex}. ` +
109
+ `Their symbols and callers are invisible to impact, search and run_pipeline. Full list: .vexp/coverage.json; raise the cap in .vexp/vexp.toml to include them.`);
110
+ }
111
+ if (c.unparsed_code_files?.length) {
112
+ gaps.push(`- Unparsed file types (no parser yet): ${c.unparsed_code_files.map((u) => `${u.count} .${u.ext}`).join(", ")}`);
113
+ }
114
+ if (gaps.length > 0) {
115
+ lines.push("## Coverage gaps");
116
+ lines.push("");
117
+ lines.push(...gaps);
118
+ lines.push("");
119
+ }
120
+ }
100
121
  // Savings Ledger (2.3.3) — the one savings surface, on every agent.
101
122
  // Replaces the old per-call counter as the headline: zero tool calls is
102
123
  // not "not working" — silence on oriented prompts is a logged decision.
@@ -47,5 +47,9 @@ export async function handleVerifyDone(params, daemon) {
47
47
  const rendered = result?.output;
48
48
  if (typeof rendered === "string")
49
49
  return rendered;
50
- return JSON.stringify(result, null, 2);
50
+ // Without the indentation: measured over 32 real vexp tool responses from
51
+ // the campaign, 76.1k tokens of indented JSON is 50.6k compact — the same
52
+ // answer, a third less to read. Whitespace is for humans, and no human reads
53
+ // a tool result.
54
+ return JSON.stringify(result);
51
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vexp-mcp",
3
- "version": "2.7.0",
3
+ "version": "3.1.0",
4
4
  "license": "UNLICENSED",
5
5
  "description": "vexp MCP server — AI context tools for coding agents",
6
6
  "type": "module",
@@ -32,5 +32,31 @@
32
32
  "@types/uuid": "^9.0.7",
33
33
  "typescript": "^5.4.0",
34
34
  "tsx": "^4.7.0"
35
- }
35
+ },
36
+ "keywords": [
37
+ "mcp",
38
+ "mcp-server",
39
+ "model-context-protocol",
40
+ "ai-context",
41
+ "context-engine",
42
+ "code-context",
43
+ "claude-code",
44
+ "claude",
45
+ "cursor",
46
+ "windsurf",
47
+ "codex",
48
+ "zed",
49
+ "cline",
50
+ "save-tokens",
51
+ "token-optimization",
52
+ "code-intelligence",
53
+ "dependency-graph",
54
+ "tree-sitter",
55
+ "code-verification",
56
+ "ai-agent",
57
+ "coding-agent",
58
+ "local-first",
59
+ "offline",
60
+ "privacy"
61
+ ]
36
62
  }