mcp-server
v1.1.1MCP server for the cognium-dev checking engine: deterministic static-analysis tools for coding agents (Claude Code, Cursor, Claude Desktop)
MCP server for the cognium-dev checking engine: deterministic static-analysis (SAST) tools and reference resources for coding agents (Claude Code, Cursor, Claude Desktop). The engine is the open-source checking engine behind Cognium Autonomous Loop; its core library is circle-ir. Ships every deterministic capability of circle-ir — polyglot taint analysis, cross-file taint paths, entry-point enumeration, CWE metadata, sanitizer lookups — as MCP tool calls that an LLM can chain without ever guessing at the SAST engine's internal state. Or run in place from a clone of this repository:
Summary extracted from the README.
@cognium/mcp-server
MCP server for the cognium-dev checking engine: deterministic static-analysis (SAST) tools and reference resources for coding agents (Claude Code, Cursor, Claude Desktop). The engine is the open-source checking engine behind Cognium Autonomous Loop; its core library is circle-ir.
Ships every deterministic capability of circle-ir — polyglot taint analysis, cross-file taint paths, entry-point enumeration, CWE metadata, sanitizer lookups — as MCP tool calls that an LLM can chain without ever guessing at the SAST engine's internal state.
- Zero LLM in the analysis path. Every finding this server returns comes from the deterministic circle-ir pipeline. LLM-side reasoning is fed by these tools; it does not decide them.
- Cache-first. The server holds up to 3 recent project analyses in memory, keyed by option-set and invalidated by file
mtime. Repeated tool calls on the same project reuse the cached analysis. - Size-bounded output. Findings, taint paths, and snippets are truncated at safe defaults so a single tool call cannot blow past a client context window.
Install
npm install -g @cognium/mcp-server
Or run in place from a clone of this repository:
npm install
npm run build
node packages/mcp-server/dist/bin.js
Client configuration
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"cognium": {
"command": "npx",
"args": ["-y", "@cognium/mcp-server"]
}
}
}
Claude Code
claude mcp add cognium -- npx -y @cognium/mcp-server
Cursor
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"cognium": {
"command": "npx",
"args": ["-y", "@cognium/mcp-server"]
}
}
}
The same stdio config is bundled in the cognium-dev plugin for Cursor (mcp.json) and Claude Code (.mcp.json). That plugin also ships skills, rules, commands, and a SAST reviewer agent.
Tools
| Tool | Purpose |
|---|---|
scan |
Run the full polyglot SAST pipeline on a file or directory. Returns SastFindings + per-file taint flows + cross-file taint paths. |
explain_finding |
Enrich a single finding id with CWE metadata, remediation, CVSS-like score, and sanitizer suggestions. |
taint_paths |
List cross-file taint flows filtered by source file, sink file, or sink type. |
list_entry_points |
Enumerate every attacker-reachable handler (HTTP routes, middlewares, event listeners) grouped by framework. |
list_reachable_sinks |
List every sink of a given category that has a real taint flow reaching it (excludes lexical-only matches). |
attack_surface_summary |
Roll-up: entry points × sinks × cross-file taint paths + top files by finding count. |
check_sanitizer |
Deterministic yes/no on whether a function is a recognized sanitizer for a sink category. |
describe_sink |
CWE, remediation, CVSS-like severity, and sanitizer list for a sink category. |
describe_source |
Every framework API pattern circle-ir treats as a source of a given category. |
find_similar |
Given a finding id, return other findings sharing the same rule_id and/or sink_type. |
find_callers |
Who calls a method, with a resolution tier on every answer and a reason on every site it could not resolve. Java. |
find_callees |
What a method calls, with the same tiers and reasons. Java. |
dependency_calls |
For a Maven dependency bump: every call into the artifact, the tests that reach each one, and the sites that cannot be ruled in or out. Java. Computed by @cognium/code-facts 0.1.0, installed with the server. |
find_dead_code |
Per declaration, the engine's dead-code@0.1 fact (live, may-be-live with reasons, or dead, with the paths from an entry and the first test that reaches it), and a decision under the rule "no inferred edge decides", against the roots listed in entrySet. TypeScript, JavaScript, Java, Python, Go. |
removal_reach |
For two checked-out trees, every removed declaration with what reached it at the base (removal-reach@0.1; moves and renames listed apart), each with the same decision, and allUnreachable over the change. TypeScript, JavaScript, Java, Python, Go. |
analyze_dependencies |
Known advisories in a project's resolved dependencies (Maven, Gradle; npm, pnpm, Yarn), matched against the OSV advisory snapshot you supply per ecosystem; with baseline_root, what a change removed and added. See below. |
refresh |
Manually invalidate the cache for one project or every project. |
analyze_dependencies
Resolves each manifest directory to its dependency set from the best input
present, and says which: a caller-named file (resolved), gradle.lockfile,
the dependency-tree.txt / dependency-list.txt a build writes
(mvn dependency:tree -DoutputFile=dependency-tree.txt), or else the build
file itself (kind: "declared", direct dependencies only). It then matches
every coordinate against the advisory snapshot at advisory_db — a directory
of OSV records, as unzip Maven/all.zip from OSV.dev leaves it; default
<project_root>/.cognium/advisory/osv-maven.
npm projects (ecosystems: ["npm"], or by default when the tree has npm
manifests and an npm snapshot is present) resolve per directory holding a
package.json, best input first: a caller-named file (resolved with kind
npm-package-lock, pnpm-lock or yarn-lock); a pnpm-lock.yaml, read as
one manifest per workspace importer, each with only the packages that importer
reaches; package-lock.json; yarn.lock; else package.json itself (direct,
declared). A range, dist-tag or unknown version is counted as unresolved and
never matched, and node_modules/ is never read. The npm snapshot is
advisory_dbs.npm (unzip npm/all.zip; default
<project_root>/.cognium/advisory/osv-npm), and npm versions compare by
SemVer. With npm in the answer, advisoryDb lists one entry per ecosystem; a
Maven-only answer is unchanged.
It never downloads a snapshot and never runs a build: the answer depends only
on the tree, the snapshot and this version, and carries the snapshot's
digest and snapshotDate (the newest record in it) so the caller can pin
both. Each match gives the advisory id and aliases (CVE), the affected ranges,
the later fixed versions, the record's own severity fields (copied, never
ranked), the dependency's path from a direct dependency, and the version the
POMs declare for it with where that comes from (direct, property,
dependencyManagement, a parent's, a BOM, an external parent). Withdrawn
records are listed by id and never matched. Test-only dependencies are left
out unless include_dev is true.
With baseline_root (the same project at an earlier commit), the answer adds
delta — advisories removed, added and persisting, each with the
versions seen on both sides, and the dependency drift — and the baseline's
resolution, both under the one snapshot.
Resources
| URI | Content |
|---|---|
cognium://sast-finding-schema |
JSON Schema for SastFinding |
cognium://sink-catalog |
Every taint sink pattern known to circle-ir |
cognium://source-catalog |
Every taint source pattern |
cognium://sanitizer-catalog |
Every sanitizer entry, indexed by sink type |
cognium://passes |
Contents of circle-ir docs/PASSES.md — canonical pass registry |
Suggested tool-call flow
scanon the project root to prime the cache and get a summary.attack_surface_summaryfor a security-posture overview.- Iterate over the highest-severity findings with
explain_findingfor CWE context. find_similarto catch the same pattern elsewhere.- Before proposing a fix,
check_sanitizerany proposed wrapper against the target sink type. - Before changing a method,
find_callerson it to see what depends on it.
The Claude Code plugin's find_callers suggestion
This repository also ships a Claude Code plugin (plugins/cognium-dev). With it
enabled, a Read or Grep whose output names a Java method declaration adds
one line of context suggesting find_callers for that method, with the
symbol filled in — once per method per session.
It only suggests. It calls no tool, runs no analysis, reads no file and
changes nothing; calling the tool stays the agent's decision. Turn it off with
the plugin's Suggest find_callers after reading Java option in /config, or
COGNIUM_SUGGEST_FIND_CALLERS=off outside the plugin. It is a plugin feature and
changes nothing about the server: the tools, their schemas and their answers are
the same with it and without it.
Calls into a dependency
dependency_calls takes project_root (the tree after the bump) and
artifact (groupId:artifactId[:version]). The artifact's packages come from
jar_path, else the jar in the local Maven repository (maven_repo_dir,
$MAVEN_REPO_LOCAL or ~/.m2/repository) for a versioned coordinate, else a
built-in table of common artifacts; packageSource says which, and an
artifact none resolves is refused rather than answered as "0 calls". The
answer is the object cognium depcalls -f json (formerly cognium-dev depcalls) prints: calls[] with the
tests reaching each (covered when tests[0].class is strong), covered,
uncovered, unattributedSites[] and partial[], plus engine, facts,
counts and truncation. The contract is C4 0.5.0 §11c.
It is computed by @cognium/code-facts 0.1.0, an exact dependency of the
server since 0.8.1, on the same circle-ir (4.23.0) the server pins, so one
circle-ir is installed. If the package cannot be loaded, the tool answers
with one line saying so, and every other tool keeps serving.
Dead code and removals
find_dead_code takes project_root; removal_reach takes project_root
(the head) and baseline_root (the base), two separate checkouts. Both take
language (typescript · javascript · java · python · go; by default
the one family present), root_kinds (default every entry kind except test)
and limit. The engine's answer is passed through unchanged; the contract is
C4 0.3.0 §11, with language from 0.4.0.
Each declaration also carries a decision under one rule,
no-inferred-edge-decides@0.1. An inferred edge neither proves code live nor
proves it dead:
decision.outcome |
When | because |
|---|---|---|
reachable |
a strong path: from a declared or conventional entry over exact or polymorphic calls |
strong-path |
unreachable |
no path of any kind from any root, no unresolved site that could bind to it, no unparsed file that could reach it | all four of no-strong-path, no-weak-path, no-unresolved-site, no-partial-file |
undecided |
anything else: a person decides | any of inferred-entry, inferred-call, reference, unresolved-site, partial-file, partial-at-head (its file did not parse at the head, so it may not be removed at all), no-entries |
Read a decision against the evidence next to it:
entrySetlists the roots the walk started from: their kinds, their certainty, where they are, and a digest.scopegives how many files were read, and which directories were skipped.
With no roots, nothing is unreachable. removal_reach sums the change up in
decisions.allUnreachable:
truewhen something was removed and every removal isunreachable;falsewhen any removal isreachable;nullotherwise.
The tools refuse these with one line:
- an empty
root_kinds; - a language with no files under a root;
- two roots that are the same directory or overlap;
- a tree of 50,000 files or more, since an answer over part of a tree could call live code dead.
Reading a navigation answer
find_callers and find_callees report a tier on every answer and a
reason on every call site they could not resolve, because a caller list is
only useful if you know whether it is complete.
| Tier | What it means |
|---|---|
exact |
The receiver's static type was known and the target was unique in it. Act on these. |
polymorphic |
Dispatch is open. candidates lists every implementation that could run, and target is the declaring member. |
inferred |
Bound by the method name alone, with no receiver type to confirm it. A lead to check, never a caller. |
inferred is a floor and is never promoted. It is also never produced when a
receiver's type is known and lacks the method: on a 405-file Java
repository, 78 of 147 name-only "callers" of one method had a receiver whose
own declared type could not have had it, so that case is now no answer plus a
reason rather than a weak answer.
Every non-answer carries one of external (the target is outside the searched
tree — the JDK, a framework), dynamic (reflection), generated (the member
only exists after annotation processing, such as a Lombok accessor),
parse-error, unsupported-language, or unknown (in the tree, and the call
graph could not bind it). A large external count usually means the name is a
common one, not that the answer is poor.
scope states what was searched and what was skipped, so a count can be read
against its denominator, and truncated appears whenever a list was cut.
What the tiers measure
The navigation tools resolve Java. A file in another language is reported
as unsupported-language and is not counted in scope.searched, so an answer
never implies a language was searched when it was not.
These numbers come from an independent evaluation against compiler-backed ground truth — a sample of call sites in WebGoat, each site's callee resolved by the Eclipse JDT compiler, with a pinned ripgrep answering the same queries as a baseline. Every figure carries its denominator, and the baseline is on the same line so the comparison is visible rather than asserted.
| this server | ripgrep baseline | |
|---|---|---|
exact precision |
100 % — 142 of 142 answers that landed on a resolved site | — (it claims no exact) |
| recall, all sampled sites | 34.1 % | 92.3 % |
| recall, targets declared in the repository | 79.6 % | — |
| precision of a plain name match | — | 60.6 % |
Two of those rows need reading together rather than separately. Recall over all sampled sites is capped at 39.8 % for any tool that answers from an index, because only 186 of the 467 sampled sites have a target declared inside the repository at all; the rest are in the JDK or a library. A text search answers about a name wherever it is declared, so the two columns of that row are answering different questions. The row below it — targets declared in the repository — is the one where both columns answer the same question.
An inferred hit is not evidence of a call. It is a method name that
matched, with no receiver type to confirm it — and the baseline row above is
the measure of what a bare name match is worth: right 60.6 % of the time on
this sample. Treat an inferred hit as a lead to check by opening the site,
never as a caller. That is why it is a separate tier rather than a weaker
exact: the label is the warning, and the tool will not promote it.
What exact is worth is the other half of the same point: of the 142 exact
answers that landed on a site the compiler had resolved, 142 named the
compiler's callee and none contradicted it.
Using it as a library
The package is side-effect free to import: nothing is built, read or connected until you ask for it. The stdio binary is a separate file, so mounting the server over your own transport does not spawn a subprocess.
Over HTTP, mount the handler. It is web-standard — a Request in, a Response
out — builds a fresh server per request, and serves both protocol eras:
import { createHandler } from '@cognium/mcp-server';
const handler = createHandler();
// Hono, Workers, Deno, Bun: hand it the request.
app.all('/mcp', (c) => handler.fetch(c.req.raw));
To inspect what the install loaded, or to connect a transport of your own:
import { createServer } from '@cognium/mcp-server';
// Floor plus whatever optional modules this install has.
const { server, discovery } = await createServer();
console.error(discovery.enablement.state); // 'floor' | 'extended' | 'commercial'
await server.connect(myTransport); // serves the 2025-era protocol only
buildServer(options) is the synchronous form: it registers exactly what you
pass and resolves nothing.
Which directories a tool may read
Every path argument of every tool — scan.path, every project_root,
dependency_calls' jar_path and maven_repo_dir, nested paths such as
site.file and analyze_dependencies' resolved[].path and
resolved[].applies_to, and the path arguments of an optional module's tools
— is confined to the allowed roots before the tool runs (0.9.0, #37, S5):
- a path with a
..segment is refused, wherever it would land; - on a POSIX host a Windows-style path (backslashes,
C:) is refused; on Windows a UNC path (\\server\share) is; - everything else is resolved with
realpath, so a symlink is judged by where it points, and refused unless that lies inside a root. A tree argument inside a root reaches the tool as its real path; a nested relative path is checked against every tree of the call.
The files a tool then finds on its own inside a tree — a build file, a
lockfile, dependency-tree.txt, effective-pom.xml, an advisory record — are
read only when their real path is still inside that tree, so a symlink planted
in a project cannot lead a read out of it either.
The allowed roots are:
- the client's MCP roots, when the client declares the
rootscapability (asked for on every call, so a folder the user opens counts from the next call). On the stdio binary they are the roots by themselves; wherever roots are also configured, they only narrow them — a tool may read the part of the client's roots that lies inside a configured root; - the configured roots:
allowedRootspassed tobuildServer(),createServer()orcreateHandler(), elseCOGNIUM_MCP_ALLOWED_ROOTS(directories separated by:, or;on Windows); - nothing else. With no configured root and no client roots, every path is
refused, with one line naming
COGNIUM_MCP_ALLOWED_ROOTS. The working directory is never a root: clients start servers in/(Claude Desktop on macOS) or in$HOME.
The opt-out is explicit: allowedRoots: '*' or COGNIUM_MCP_ALLOWED_ROOTS=*
(the client's roots, if it sends any, still narrow it). The stdio binary says
on stderr which applies.
A client that sends no MCP roots — or declares the capability and does not
answer roots/list — needs COGNIUM_MCP_ALLOWED_ROOTS in its env:
"cognium": {
"command": "npx",
"args": ["-y", "@cognium/mcp-server"],
"env": { "COGNIUM_MCP_ALLOWED_ROOTS": "/Users/me/src" }
}
Over HTTP, a client's MCP roots name directories on the client's machine, so
on createHandler() they can only narrow the roots the host configures, never
stand in for them: a host that names no roots serves no path. A host that
connects buildServer() to a transport of its own gets the same rule unless it
passes clientRoots: 'establish'. On the 2026-07-28 revision, where a server
cannot send a request to the client, a client that declares roots is asked
for them with an input_required result (inputRequests["cognium/roots"], a
roots/list request) and the call goes on when it retries with the answer.
dependency_calls reads the local Maven repository (~/.m2/repository) only
when it lies inside a root; otherwise the artifact's packages come from the
built-in table and the answer's note says so. Add the repository to
COGNIUM_MCP_ALLOWED_ROOTS, or pass jar_path, to have the jar read.
Optional tool modules
The seventeen tools above are always present. A separate package may add more by
exporting a ToolModule:
export default {
id: 'example/mcp',
version: '1.0.0',
licence: 'MIT',
circleIrRange: '4.9', // the circle-ir major.minor it was built against
register(server, ctx) {
// ctx.cache — the server's analysis cache, shared with every tool
// ctx.enablement — what this install may offer; the module decides what
// to register, and checks again at call time
// ctx.allowedRoots — the real paths tools may read in the call in
// progress (read it at call time: it follows the
// client's MCP roots). The server has already checked
// the tool's path arguments; hold any further path the
// module reads to the same roots
},
};
Set COGNIUM_MCP_MODULES to a comma-separated list of specifiers to control
what is looked for, or to none to look for nothing.
The server comes up either way. A module that is absent, broken, wrongly
shaped or built against a different circle-ir minor is refused on one line of
stderr, and the seventeen built-in tools serve as normal.
A refusal is also visible to the MCP client, on both protocol eras (the
initialize result and server/discover):
capabilities.experimental["cognium/modules"]is always present:{ circleIr, loaded: [{ id, version, licence, circleIrRange }], refused: [{ specifier, reason, id?, version?, builtAgainst?, installed? }] }. On a version-skew refusal,builtAgainstis thecircle-irthe module declares andinstalledthe one this server pins.instructionscarries the same facts as one paragraph when, and only when, something was refused.
A module that throws while registering is reported the same way.
| Variable | Effect |
|---|---|
COGNIUM_MCP_MODULES |
Which module specifiers to look for. none disables. |
COGNIUM_MCP_ALLOWED_ROOTS |
The directories tools may read, :-separated (; on Windows), narrowed to the client's MCP roots when it sends them. Unset: only the client's MCP roots, and with none every path is refused (never the working directory). * turns confinement off. |
COGNIUM_ENDPOINT |
An opaque endpoint passed through to modules. The server never parses or connects to it. |
COGNIUM_LICENSE |
A licence token, verified offline. Also read from $COGNIUM_CONFIG_DIR/license, default ~/.cognium/license. |
COGNIUM_LICENSE_PUBKEY |
Extra verification keys as kid=key[,kid=key], base64url raw Ed25519, merged over the published ones. A bare key with no kid= matches any token, which is a development convenience and not for production. |
A token is cognium-lic-v1.<base64url payload>.<base64url Ed25519 signature>.
The payload is { kid, org, tier, iat, expiry, entitlements? } and the
signature covers its canonical form (RFC 8785), so a token survives being
re-encoded in transit. kid names the signing key, so keys rotate without
invalidating tokens already issued: a verifier holds the old key as long as
tokens signed by it are still in date. An expiry given as a bare date is good
through the whole of that UTC day. A field the verifier does not know is still
covered by the signature; a known field of the wrong shape is malformed.
Verification is offline — a published key, no network, nothing cached or
written. No key is baked in yet, so tokens currently report no-key.
No telemetry, no phone-home, and no feature is locked behind a token: the state decides what is listed, and the terms carry the grant.
What a response and a tool tell you
provenanceis the last field of every successful response:"deterministic"for all seventeen built-in tools. A tool from an optional module that used a model saysllm: <model>.outputSchemaandstructuredContent. Every built-in tool declares anoutputSchemaintools/list, and every successful response carriesstructuredContent: the same object as the JSON incontent[0].text. The schema pins the top-level envelope; nested engine objects are open, so the engine may add a field inside them in a minor. AnisErrorresult carries text only.- Annotations are declared on every tool in
tools/list. Sixteen of the seventeen arereadOnlyHint: true; none reaches the network (openWorldHint: false) or deletes anything (destructiveHint: false).refreshis not read-only: it writes no file, but it clears the server's in-memory cache. - Errors. A malformed request gets a JSON-RPC error:
-32602for bad parameters or a tool that does not exist,-32601for an unknown method. A well-formed call a tool cannot serve — an unknown sink type, a missing path — is a normal result withisError: trueand a message that says what to do. - Protocol revisions. The server speaks MCP 2026-07-28 and the 2025-era
revisions before it, from the same binary and the same HTTP handler. A client
that opens with
initializeand one that opens withserver/discoverare both served; nothing has to be configured.
Development
npm run build # tsc + chmod +x dist/bin.js
npm run typecheck # tsc --noEmit
npm test # vitest run (unit, three-state matrix, one answer, stdio smoke)
Two suites drive the built binary, so build before testing. From the repository
root, npm run check:pins checks the circle-ir pin and
node scripts/verify-install.mjs <tarball> installs a packed build into an
empty directory and checks what it serves.
License
MIT