Kritisi Solidity Audit
v1.1.0MCP server for Solidity security audits, NatSpec documentation, and import merging.
A Model Context Protocol stdio server that exposes the kritisi Solidity security toolkit to MCP-compatible clients. It audits local Solidity files and folders, fetches verified contracts from Etherscan, produces designed PDF or Markdown reports, adds NatSpec documentation, merges imports, and inspects provider configuration. Everything runs locally over stdio; no hosted backend is required. mcp-kritisi is a thin wrapper around the published kritisi package.
Summary extracted from the README.
mcp-kritisi
A Model Context Protocol stdio server that exposes the kritisi Solidity security toolkit to MCP-compatible clients. It audits local Solidity files and folders, fetches verified contracts from Etherscan, produces designed PDF or Markdown reports, adds NatSpec documentation, merges imports, and inspects provider configuration. Everything runs locally over stdio; no hosted backend is required.
mcp-kritisi is a thin wrapper around the published kritisi package. Provider access, report parsing, PDF/Markdown generation, and file-safety rules all come from that library; this project only adds the MCP transport, source acquisition, and tool schemas.
Features
security_auditreturns high/medium/low findings for a Solidity file and can write a PDF or Markdown report.audit_projectscans a folder of Solidity files, resolves entrypoints and imports, and audits the project.audit_contractfetches a verified contract from Etherscan V2 by chain ID and address, resolves proxies, and audits it.natspec_documentgenerates NatSpec comments and never writes files unless asked.merge_importsflattens a Solidity file and its imports withsol-merger.show_configreports effective provider settings with API keys redacted.- Supports OpenRouter (default), OpenAI, Claude/Anthropic, and DeepSeek.
- Works over stdio with any MCP client, including Claude Desktop, Cursor, and Qoder.
- Refuses non-
.solinputs and protects existing files unlessoverwriteis set. - API keys are read from environment variables or the user's kritisi config, never from tool arguments.
Requirements
- Node.js 18 or newer.
- The published
kritisipackage (^2.5.0), installed from npm duringnpm install. - An API key for the provider you intend to use.
- An
ETHERSCAN_API_KEYwhen usingaudit_contract. The key stays in the client environment; it is never passed as a tool argument.
Install
From npm
Install the server globally:
npm install --global mcp-kritisi
mcp-kritisi --help
Or run it on demand without a global install:
npx -y mcp-kritisi --help
From source
git clone https://github.com/zororaka00/mcp-kritisi.git
cd mcp-kritisi
npm ci
npm run build
node dist/index.js --version
The build output is written to dist/. The package depends on kritisi from npm.
Client configuration
Add the server to your MCP client configuration. The example below uses npx so no global install is required:
{
"mcpServers": {
"kritisi": {
"command": "npx",
"args": ["-y", "mcp-kritisi"],
"env": {
"OPENROUTER_API_KEY": "<your-api-key>",
"ETHERSCAN_API_KEY": "<your-etherscan-key>"
}
}
}
}
Optional provider settings can be added to env, for example OPENROUTER_MODEL, OPENAI_API_KEY, or ANTHROPIC_API_KEY.
If the package is installed globally, use "command": "mcp-kritisi" with no arguments. When running from a source checkout, use "command": "node" and the absolute path to dist/index.js in args.
Programmatic usage
The package root also exposes a side-effect-free library entrypoint for embedding the tools in another MCP server:
const { McpServer } = require('@modelcontextprotocol/sdk/server/mcp.js');
const { registerKritisiTools, version } = require('mcp-kritisi');
const server = new McpServer({ name: 'my-server', version });
registerKritisiTools(server);
registerKritisiTools adds all available tools to an existing server; version is the installed package version. Importing the package does not start a server or open stdio.
Configuration
Environment variables take precedence over the user-local kritisi config at ~/.config/kritisi/config.json (or $XDG_CONFIG_HOME/kritisi/config.json). Set KRITISI_CONFIG_PATH to use a different file.
| Variable | Purpose | Default |
|---|---|---|
OPENROUTER_API_KEY |
OpenRouter API key | none |
OPENROUTER_MODEL |
OpenRouter model | openai/gpt-5.6-sol |
OPENROUTER_BASE_URL |
OpenRouter endpoint override | https://openrouter.ai/api/v1/chat/completions |
OPENAI_API_KEY |
OpenAI API key | none |
OPENAI_MODEL |
OpenAI model | gpt-5.6-sol |
ANTHROPIC_API_KEY / CLAUDE_API_KEY |
Claude API key | none |
ANTHROPIC_MODEL / CLAUDE_MODEL |
Claude model | claude-opus-5 |
DEEPSEEK_API_KEY |
DeepSeek API key | none |
DEEPSEEK_MODEL |
DeepSeek model | deepseek-v4-pro |
KRITISI_TIMEOUT_MS |
Per-request timeout in milliseconds | 120000 |
KRITISI_RETRIES |
Retries for network errors and HTTP 429/5xx | 2 |
KRITISI_RETRY_DELAY_MS |
Base backoff delay; doubles per retry | 500 |
ANTHROPIC_MAX_TOKENS / CLAUDE_MAX_TOKENS |
Claude output token cap | 8192 |
ETHERSCAN_API_KEY |
Etherscan V2 API key used by audit_contract |
none |
ETHERSCAN_BASE_URL |
Etherscan API endpoint override (testing or compatible proxies) | https://api.etherscan.io/v2/api |
ETHERSCAN_TIMEOUT_MS |
Etherscan request timeout | 20000 |
KRITISI_ALLOWED_ROOTS |
Optional path-delimited allowlist for project folders | unset |
KRITISI_MAX_PROJECT_FILES |
Maximum Solidity files scanned per project | 200 |
KRITISI_MAX_PROJECT_BYTES |
Maximum total Solidity source bytes per project | 5000000 |
KRITISI_MAX_FILE_BYTES |
Maximum size of a single Solidity file | 1000000 |
KRITISI_MAX_SOURCE_CHARS |
Maximum merged source sent to the model | 400000 |
Provider-specific *_BASE_URL variables are also supported. show_config displays the effective configuration and reports keys only as set or unset.
Tools
All tools return JSON text content. Failures are returned as MCP tool errors (isError: true); the server stays running.
Audit tools write a report only when reportPath (or legacy outputPdf) is set. The file extension selects the format: .pdf produces the designed PDF report, .md/.markdown produces a Markdown report. Responses include reportFile (format, path, or null); pdf is retained for compatibility and is set only for PDF output.
| Tool | Purpose | Writes files |
|---|---|---|
security_audit |
Audit a Solidity file with optional PDF/Markdown report | Only when reportPath or outputPdf is set |
audit_project |
Audit a folder of Solidity files | Only when reportPath or outputPdf is set |
audit_contract |
Audit a verified Etherscan contract by chain ID and address | Only when reportPath or outputPdf is set |
natspec_document |
Add NatSpec documentation | Only with write: true or output |
merge_imports |
Merge imports into one file | Only when output is set |
show_config |
Inspect effective provider configuration | Never |
security_audit
| Input | Type | Default | Meaning |
|---|---|---|---|
path |
string | required | Path to a .sol file |
provider |
enum | openrouter |
openrouter, openai, claude, anthropic, or deepseek |
outputPdf |
string | none | Legacy PDF output path; prefer reportPath |
reportPath |
string | none | Report path; .pdf, .md, or .markdown selects the format |
overwrite |
boolean | false |
Replace an existing report |
includeReport |
boolean | true |
Include the full findings JSON in the response |
Response: provider, model, usage, summary (high/medium/low counts), reportFile (format, path, or null), pdf (PDF path or null), and report unless includeReport is false.
{
"path": "contracts/Vault.sol",
"reportPath": "reports/Vault.md"
}
Relative paths are resolved against the MCP server process working directory; prefer absolute paths in client configuration for predictable results.
audit_project
Scans a local directory recursively for .sol files, ignores dependency/build directories (node_modules, lib, out, cache, tests, scripts), computes contracts and entrypoints, and audits the project. If one entrypoint is found it is flattened with imports; otherwise a bundle of project files is audited. Set entry to select a specific entry file.
| Input | Type | Default | Meaning |
|---|---|---|---|
path |
string | required | Directory containing Solidity files |
provider |
enum | openrouter |
AI provider |
entry |
string | auto | Entry .sol path relative to the folder |
outputPdf |
string | none | Legacy PDF output path; prefer reportPath |
reportPath |
string | none | Report path; .pdf, .md, or .markdown selects the format |
overwrite |
boolean | false |
Replace an existing report |
includeReport |
boolean | false |
Include the full findings JSON in the response (off by default to keep context small) |
Response: project inventory (root, files, totalBytes, contractCount, truncated contracts, entrypointCount, truncated entrypoints, truncated warnings, auditMode, entry, sourceCharacters, auditWarning), provider/model/usage, summary, reportFile, and report when includeReport is true.
audit_contract
Fetches verified source from Etherscan API V2 using ETHERSCAN_API_KEY, resolves a proxy to its implementation when reported, and audits the source. Unverified contracts are rejected with an explanatory error. The API key is never a tool argument.
| Input | Type | Default | Meaning |
|---|---|---|---|
chainId |
number | required | EVM chain ID, for example 1 or 42161 |
address |
string | required | Verified contract address |
provider |
enum | openrouter |
AI provider |
outputPdf |
string | none | Legacy PDF output path; prefer reportPath |
reportPath |
string | none | Report path; .pdf, .md, or .markdown selects the format |
overwrite |
boolean | false |
Replace an existing report |
includeReport |
boolean | false |
Include the full findings JSON in the response (off by default to keep context small) |
Response: target metadata (chainId, address, contractName, compiler settings, proxy, implementation, file count, warnings), provider/model/usage, summary, reportFile, and report when includeReport is true.
Etherscan supports many EVM chains through chainId; source and ABI endpoints are available on its Free tier, though some chains require a paid Etherscan plan. Chains not covered by Etherscan are not supported by this tool yet.
natspec_document
| Input | Type | Default | Meaning |
|---|---|---|---|
path |
string | required | Path to a .sol file |
provider |
enum | openrouter |
AI provider |
write |
boolean | false |
Update the source in place and keep a .sol.bak backup |
output |
string | none | Write the documented source to this path (implies writing) |
overwrite |
boolean | false |
Replace an existing output file |
By default the documented source is returned and no file is touched. Markdown code fences are stripped, and responses that do not look like Solidity are rejected without modifying files.
merge_imports
| Input | Type | Default | Meaning |
|---|---|---|---|
path |
string | required | Path to a .sol file |
output |
string | none | Write the merged source to this path |
overwrite |
boolean | false |
Replace an existing output file |
Response: source, written (path or null), and merged (source text).
show_config
Returns configPath, whether the config file exists, the installed kritisi libraryVersion and libraryPath, Etherscan key status/base URL, and the effective provider configuration with keys redacted.
Safety
- Inputs must end in
.sol; other paths are rejected before any provider request. audit_projectrefuses folders outsideKRITISI_ALLOWED_ROOTSwhen that variable is set, skips symlinks, and enforces file/size limits.audit_contractrequires a verified Etherscan source; unverified contracts and unverified proxy implementations are rejected instead of guessed.- Files are written only when a tool argument requests it. Existing outputs require
overwrite: true. - In-place NatSpec updates always create a
<file>.sol.bakbackup first. - PDF and Markdown reports include target/provider/model metadata and an AI-assistance disclaimer; PDFs add the designed cover, risk badge, finding blocks, code panels, and page numbers.
- API keys are never accepted as tool parameters. They are redacted from provider and Etherscan errors and reported only as
set/unset.
Development
npm ci
npm run lint
npm run format:check
npm test
npm audit
npm pack --dry-run
npm test builds the server and runs MCP protocol tests with the official SDK client, a local mock provider, and a mock Etherscan API. The suite is network-free and covers tool discovery, configuration redaction, file guards, folder scanning and root restrictions, Etherscan plain/standard-JSON/proxy handling, unverified contracts, PDF/Markdown reports, and error handling.
A live provider smoke test is not part of the automated suite. Run one only with credentials supplied intentionally through the environment.
Publishing
prepublishOnly runs lint and tests. Before publishing:
npm run lint
npm test
npm pack --dry-run
npm publish --access public
Review the package contents with npm pack --dry-run and never commit API keys or local configuration files.
Publishing to the MCP Registry
This repository is prepared for the official MCP Registry under the name io.github.zororaka00/mcp-kritisi. The registry entry is described by server.json, and the mcpName field in package.json must match the name in that file.
Publish the npm package first, then use the official mcp-publisher CLI installed from its releases or Homebrew (do not install it from npm):
mcp-publisher validate
mcp-publisher login github
mcp-publisher publish
The registry is currently in preview, so metadata or API behavior may change. See the official publishing quickstart for platform-specific installation commands and current requirements. Keep package.json, server.json, and the npm version aligned when releasing updates.
Limitations
- Audit output is AI-assisted and not a substitute for a professional security review. Verify findings independently.
audit_contractandaudit_projectare source-level reviews. They do not execute transactions, simulate buy/sell behavior, or verify current token tax, liquidity locks, blacklists, or honeypot status on-chain.audit_contractonly supports chains covered by Etherscan V2 and contracts whose source (or proxy implementation source) is verified.audit_projectignores common dependency/build directories; projects that rely on Foundry remappings may fall back to a bundled source audit when flattening fails.- Contract source is sent to the configured third-party provider.
- Model output is untrusted; instructions embedded in audited code can attempt prompt injection.
- Very large contracts or projects may exceed the configured source limit or the model context window. Split them or raise the documented limits deliberately.
License
MIT; see LICENSE.