How I built an MCP tab that refuses to run what you didn't approve: a pinned command, a 16-char hash, and 0 silent executions
Ankita AI is a desktop AI assistant by Krish Verma, and the newest way to extend it is also the easiest way to shoot yourself in the foot: MCP servers. An MCP server is arbitrary code that your assistant runs on your machine, with your files and your credentials in reach. The official MCP registry lists thousands of them. The normal install flow is: copy a command from the internet, paste it into a config file, run it. That is a supply-chain attack with a copy button.
So when I built the MCP tab for Ankita — Plugins now has an MCP page beside Apps and Skills, shipped in v2.7.6 — I gave it one rule: the registry is a marketplace of typed metadata, never a source of commands. The app builds the command itself, from fields it validates, and nothing executes until you approve the exact command it built. The full project lives at ankita-sable.vercel.app.
The registry never names the binary
The core of the design is in src/integrations/mcp-registry.mjs, and it starts with a two-entry table:
const RUNNABLE = {
npm: { runtime: "npx", spec: (id, version) => `${id}@${version}` },
pypi: { runtime: "uvx", spec: (id, version) => `${id}==${version}` },
};
The executable comes from this table, never from the registry payload. A server entry does not get to name the binary Ankita runs. If it declares a runtimeHint, it has to be the one this table already uses for that package type — npx for npm, uvx for PyPI — or the install is refused with a sentence explaining why. Same for the package itself: the identifier must match a strict regex (no whitespace, no shell metacharacters, no leading dash), and the version must match a digits-and-dots pin. A range like ^1.0.0 or 1.x cannot pass as a pin, because the approval system depends on the version being exact — more on that below.
A server that only publishes a remote HTTP endpoint is refused too, with the reason shown in the UI instead of a broken command: Ankita only launches stdio servers. Remote-only entries appear in search results marked unusable, with the explanation attached, rather than silently failing later or — worse — silently working through a URL you never inspected.
Search is bounded, then collapsed to one entry per server
Search hits registry.modelcontextprotocol.io with a 15-second timeout, at most 3 pages of 50 results, and an abort signal even if the caller passed none — the comment in the code says a review tool must never fire-and-forget. A search returns every published version of every match, so collapseToLatest() reduces it to one entry per server name: the one the registry flags as latest, or the highest version if no flag is set. The desktop shows at most 40 candidates, usable ones first, and the search box itself caps queries at 100 characters before anything touches the network. A registry outage reaches you as a sentence ("the MCP registry returned 503…"), not a stack trace.
Approval is granted to a command, not a name
This is the part I care most about, in src/integrations/mcp-store.mjs:
export function commandHash(command, args = []) {
const blob = JSON.stringify({ command: String(command || ""), args: args.map(String) });
return crypto.createHash("sha256").update(blob, "utf8").digest("hex").slice(0, 16);
}
Approval is granted to a command, not to a name. Approving npx -y pkg@1.2.3 must not silently authorise npx -y pkg@9.9.9 later, so the 16-character hash of the exact command plus its arguments is what gets remembered. A new install records approvedAt: null and approvedHash: null. Nothing runs until you press start in the window, after the window has shown you the exact command — and start() is what calls markApproved(). If the command changes afterwards, isApproved() compares the stored hash against the fresh one and fails, so the server needs approval again. The version pin and the hash are the same mechanism viewed twice: the pin makes the command exact, the hash makes the approval exact.
The desktop side adds its own bounds. Environment variables are capped at 40, each value at 4,096 characters, names must match ^[A-Za-z_][A-Za-z0-9_]*$, and installing from the registry reports which required variables are still missing instead of starting a server that will crash on its first tool call. The three servers Ankita configures itself — the Chrome browser server, the browser-extension server, and Computer Use — are hidden from the page entirely, so the MCP tab never offers to remove something another settings section owns. A manual install path exists for servers that aren't in the registry at all, and it goes through the same store, the same hash, and the same start-time approval.
What this does not do
Pinning a version is not auditing a package. pkg@1.2.3 is still whatever the publisher uploaded as 1.2.3, and npx still fetches it from npm at launch time — the tab guarantees you run exactly what you approved, not that what you approved is safe. The registry's own metadata (descriptions, repository links) is treated as display text, never as instructions, but a convincing description on a malicious package is still a convincing description. And the approval hash covers the command and its arguments, not the environment variables: rotating an API key doesn't invalidate the approval, which is convenient and possibly a hole.
The verification is 26 tests for the registry module and 10 for the desktop page (counts from the test files, not a local run): pinned npx and uvx commands, remote-only refusals, shell metacharacters in identifiers, non-pinned versions, a name that isn't in the registry suggesting near misses instead of silently substituting one, and a failed start recording the error instead of claiming success.
The question
Tell me I'm wrong: the approval hash covers the command and its args, but not the environment variables. A changed API key or a swapped endpoint URL sails through on an old approval. Is that the right line — env values change too often to re-approve every rotation — or should any env change invalidate the approval the same way a version bump does? I'd rather hear the break in the design here than find it in a postmortem.
Krish Verma, creator of Ankita AI — an open-source desktop AI assistant. The MCP tab ships in Ankita v2.7.6; the code is in src/integrations/mcp-registry.mjs, src/integrations/mcp-store.mjs, and desktop/electron/mcp.mjs.
Top comments (4)
I'd invalidate on env var names, not values. If every key rotation asks for approval again, people learn to click yes without reading. A new variable name is the change worth a prompt, since that's how a server starts reaching for a token it never needed before.
You're pointing at the right gap, but the premise is slightly off — today env changes don't invalidate approval at all, in either direction. commandHash() in src/integrations/mcp-store.mjs hashes only the command and args, and isApproved() just compares the stored approvedHash against that. A rotated key value already costs zero prompts, which is the behaviour you want to keep. But a brand-new variable name slips through silently too, which is exactly the hole you describe — a server reaching for a token it never needed. Your rule is the fix I'd take: fold the sorted env var names into the hash and keep the values out, so a name change re-prompts and a value rotation doesn't. The honest caveat: env is edited as config on the stored record, so I'd also need the hash recomputed whenever env is edited, or the name check would only bite at install time.
Thanks for checking the code instead of taking my word for it. Recomputing on every env edit sounds right. Otherwise someone adds a variable through the config editor and the approval keeps showing as current until the next install.
Good instinct to check the editor path — I went looking for it, and it doesn't exist. McpStore in src/integrations/mcp-store.mjs has no update method at all: add, remove, setEnabled, markApproved, that's it. The desktop MCP tab (desktop/electron/mcp.mjs) and the mcp_manage tool only add, remove, enable, disable or reload. So the only way to change a server's env today is remove + re-add, and add() creates a fresh record with approvedHash: null — approval gets asked again, and reconcile() in src/integrations/mcp-manager.mjs won't start an unapproved server. The stale-approval window you're picturing can't happen through any shipped path.
Two honest caveats. First, that env-names fix isn't in the code yet — commandHash() still hashes only command and args, so this is about the shape of the fix, not something already shipped. Second, the hash is only computed in add(), so the check trusts the stored file: someone hand-editing mcp.json directly could change env — or the command — without the stored commandHash moving, and isApproved() would still pass. That's a text-editor hole, not a UI one. When the env-names fold lands I'll recompute the hash on load too, so a hand-edited file can't stay approved.