lens-mcp
Use Soulfield Lens over MCP to independently validate AI-generated text, scrub sensitive identifiers, and run local consistency and defect-memory checks.
Validate content: Run a hosted 10-lens gate with optional domain and audience/purpose context; receive a deterministic 0–10 score, per-lens results, and violation reasoning. Borderline or incomplete checks fail closed rather than silently passing.
Scrub PII and secrets: Redact structured identifiers such as emails, phone numbers, card numbers, SSNs, UK NI/UTR numbers, connection strings, and credentials, with findings returned. Names and free-form PII are not reliably detected.
Check service health: Query Lens API status and version without authentication.
Run local consistency checks: Scan files for case-insensitive forbidden strings, verify summary numbers appear in their source body, and check case-sensitive evidence markers survive into rendered outputs.
Maintain defect memory: Read prior catches, record named defects and prevention rules, and view recurrence statistics with suggestions to promote recurring patterns into deterministic checks.
Handle long validations: Large inputs automatically use asynchronous submission and polling; optional local receipts can record gate results.
Hosted validation and scrubbing require an API key. Local consistency and defect tools use lens-kit without an LLM call; their matches are tripwires that require adjudication, not automatic proof of a defect.
Soulfield Lens — MCP server
Long jobs can use validation_submit followed by validation_receipt on a
fresh MCP connection. Save the returned job ID with the candidate SHA-256 locally.
Retrieve that ID after a polling timeout; do not submit the content again.
Pending, failed, expired and incomplete jobs confer no clearance. An uncertain
submission without a returned ID must not be automatically retried. The existing
validate_content tool is unchanged. See test/validation-jobs.test.cjs for
offline recovery and Rights-preservation fixtures.
Outside-in validation for AI-generated text, as an MCP tool.
Every AI tool asks the same model that wrote the answer whether it's any good. It says yes. The Soulfield Lens is outside-in: a separate model runs a fixed gate over your output. It checks text — it doesn't write it. This package puts that gate inside Claude Code, Cursor, and any other MCP-compatible agent, so output can be validated on the path where it's generated.
The gate is fail-closed: a borderline case returns UNKNOWN, never a silent pass. There is no generation step, so it can't fabricate claims of its own — only check. It can still be wrong about a judgment; that is exactly why borderline cases return UNKNOWN instead of a confident yes.
This is a local stdio boundary around the hosted Lens API (api.soulfield.one). It keeps repository access on the caller's machine and sends only the finished artifact text to the API gate. A scrub also sends the lines of your own identity file (LENS_PUBLIC_IDENTITY_FILE) that occur in that text, so they are not redacted.
It exposes two tiers. The gate tier (3 tools) needs nothing but an API key. The validator tier (7 tools) adds one local orchestration entry point plus the optional lens-kit cross-file checks and defect memory that the single-document gate cannot see. Skip local evidence inputs and the gate tier works exactly as before.
Try it before you install anything
The keyless demo endpoint runs the same gate — a few runs a day per IP, no signup:
curl -s https://api.soulfield.one/v1/demo \
-H 'content-type: application/json' \
-d '{"text": "<paste the AI output you are about to ship>"}'Related MCP server: Arkheia Hallucination Detection MCP
Install
npm install -g @soulfield/lens-mcpOr run without installing: npx @soulfield/lens-mcp.
Claude Code
claude mcp add soulfield-lens \
-e SOULFIELD_API_BASE=https://api.soulfield.one \
-e SOULFIELD_API_KEY=<your-key> \
-- npx @soulfield/lens-mcpAny MCP client (JSON config)
{
"mcpServers": {
"soulfield-lens": {
"command": "npx",
"args": ["@soulfield/lens-mcp"],
"env": {
"SOULFIELD_API_BASE": "https://api.soulfield.one",
"SOULFIELD_API_KEY": "<your-key>"
}
}
}
}Production calls need an API key — request one at hello@soulfield.one. lens_health works without one.
Tools
Gate tier — hosted API, works out of the box
Tool | What it does | Auth |
| Runs the outside-in gate over text. Returns pass/fail, score, per-dimension results, and violation details with reasoning. Optional | key |
| Server-side scan for structured PII and secrets — emails, UK/US phone numbers, credit-card numbers, US SSNs, UK NI/UTR numbers, database connection strings, and common API-key/credential patterns. Returns scrubbed text (each match replaced by a type marker) plus findings. Pattern-based, no LLM call. Targets structured identifiers — it does not detect personal names or free-form PII, and structured-format coverage is best-effort, not exhaustive. | key |
| Checks the Lens API is up. Returns status and version. | none |
Validator tier — local; consistency checks require lens-kit
Version note: the validator tier lands in 1.1.0. If
npm view @soulfield/lens-mcp versionstill reports1.0.0, the registry has not caught up with this repo yet andnpx @soulfield/lens-mcpwill give you the three gate-tier tools only. Install from source in the meantime.
Artifact orchestration:
validate_artifactlands in 1.2.0. Its bounded local evidence search is built into this MCP package. Requested consistency checks still requirelens-kit.
Side effect worth knowing: every validator-tier call appends a row to
RUNS.mdin its working directory — that is the kit's run ledger, by design. The directory is thecwdargument, or the server's own cwd if you omit it, so passcwdexplicitly if you care where the ledger lives. Sensitive flag values are redacted in the row (--deny <redacted>), so deny terms do not land on disk.
Prerequisite: pip install lens_kit (Apache-2.0, github.com/mrhpython/lens-kit), or set LENS_KIT_BIN to its path. Without it these six tools return UNKNOWN with an error — never a silent pass. No API key needed: they run locally and make no LLM call.
Why they run locally and not on the hosted API: they take file paths off your disk. A hosted endpoint that accepted arbitrary local paths would be a file-disclosure vector, not a feature. On stdio the paths are your own machine, so the capability is safe here and only here — and for that reason it will not be added to the hosted API.
Tool | What it does | Exit semantics |
| Reads one local artifact, searches only explicitly permitted evidence roots, runs requested consistency checks, and sends only the artifact text to the API gate. It labels the result | consistency violation → |
| Scans files for deny-list terms (case-insensitive literal). Run on every customer-facing file before an irreversible publish: catches a real client name, an internal codename or a banned absolute surviving into shipped copy. A credential scanner will not find these, because nothing here is a credential. Negation-blind: a banned phrase quoted in order to disclaim it matches identically to the same phrase asserted. | hit proves the string is present — adjudicate the verdict |
| Checks every numeric literal in a summary actually appears in the body it summarizes. Catches the invented figure. Tripwire: literal matching only, no derived arithmetic, and a figure cited as superseded ("supersedes the ~471 estimate") flags exactly like a stale one. Review, don't auto-trust. | violation / clean |
| Checks evidence markers in a source survive into every rendered output — the caveat or citation dropped between formats. Case-SENSITIVE, unlike | violation / clean |
Choosing deny terms and markers. These three are tripwires, not oracles — on a live run over this project's own copy they produced six flags and zero true defects, across three distinct false-positive classes (negation, superseded-figure, casing). That is the designed behaviour, and it is why the doctrine is adjudicate, never auto-apply. Deny terms work best as strings that are wrong in every context — a real client name, an internal codename — rather than claims you do not make, which legitimately appear inside disclaimers. Markers work best when their casing is stable across source and render.
| lens_catches_relevant | Reads the defect bank before you validate: prior named defects for an artifact type, most-recurrent first. Patterns at threshold are marked [PROMOTE] — they recur often enough to deserve a fixed check. | — |
| lens_catches_add | Records a named defect so it is caught next time: what was wrong, the general pattern, the forward rule. Routine passes are rejected by design — only real defects. | — |
| lens_catches_stats | Per-pattern recurrence counts with promote suggestions. Tells you what to harden next. | — |
The two tiers are complementary, not alternatives. The gate has no tools and no file access — that is precisely what makes it an independent check, and it is also why it cannot see a contradiction spread across two files. The validator tier sees the disk; the gate owns the score. Pair them: gather substrate evidence with the local tools, hand the text to the gate, and never argue a gate FAIL into a PASS. Full protocol: docs/VALIDATOR-AGENT.md.
One local entry point
validate_artifact makes the boundary explicit in one call:
{
"artifact_path": "output/candidate.md",
"evidence_roots": ["reports", "output/proof"],
"evidence_queries": [
{
"claim": "measured-result",
"query": "113/113 rows scored",
"case_sensitive": true
}
],
"domain": "agency",
"context": "Internal technical handoff"
}The response includes evidence_scope, files_read, searches_and_commands, claims_verified, and claims_unverified. claims_verified is deliberately empty: grep proves that text exists at a source location, not that the claim is true. The separate validator agent must read the located evidence, reason across the files, and attach the final full-validator receipt.
Evidence file contents and local absolute paths are never added to the API request. Directory searches skip .git, node_modules, symlinks, and binary files and fail closed when configured safety limits are exceeded.
What you get per run: receipts — what was checked, what passed, what was held, and why. Machine-readable, not a badge. We won't hand you a guaranteed accuracy number for your data: scores don't transfer across models, datasets, and runtimes, and a tool that promises a fixed figure on data it has never seen is making the exact claim this gate exists to catch.
Long inputs
Inputs of ~4,000 characters and up are submitted as an async job and polled to completion automatically, so a single long validation never dies on a request timeout. Short inputs use the fast synchronous path. No configuration needed.
Configuration (env vars)
Variable | Default | Purpose |
|
| Lens API base URL. Use |
| — | Required for |
|
| Per-request timeout for the sync path. |
|
| Total wall-clock budget for the async poll loop. |
|
| Input length at which the async path kicks in. |
|
| Path to the |
|
| Timeout for a validator-tier command. On timeout the verdict is UNKNOWN, never a pass. |
|
| Default working directory for the three |
|
| Your own published details (name, postal address, contact email, phone), one per line. |
| unset | When set, each gate result from |
The rest of the product
This wrapper is one of several surfaces on the same engine:
Free one-output audit — api.soulfield.one/audit. The audit is the demo.
Wire it in (SDK stop-hook and middleware) — api.soulfield.one/developers.
Own it — the kit: lenses, compiler, self-improve loop, validator agent, Apache-2.0. Train it on your own data. Public repo: github.com/mrhpython/lens-kit — clone it,
pip install -e ".[dev]", and the test suite runs offline with no key. Installing it is also what activates the validator tier above.
We hold our own marketing copy to the same gate this package exposes.
License
MIT — see LICENSE. (The lens-kit product is licensed separately under Apache-2.0.)
Available Tools
9 toolslens_catches_addRecord a Catch (append to defect memory)A
Append a NAMED DEFECT to the defect bank so it is caught next time. Record what was WRONG, the general pattern it is an instance of, and the forward rule that prevents it — doctrine REJECTS routine passes, so only log actual defects. Set self_catch=true when the defect was a failure of your own validation discipline. This is the write half of the improvement loop: enough recurrences of a pattern promote it to a deterministic check.
Inputs: rule (required), catch (required), domain (required), pattern (required), +3 more.
lens_catches_relevantPrior Catches (institutional defect memory)A
Read the defect bank BEFORE validating: prior named defects for an artifact type, most-recurrent patterns first. This is the institutional memory that makes the gate improve over time — the recurring traps tell you where this class of artifact has failed before. Any pattern at threshold is marked [PROMOTE], meaning it recurs often enough to deserve a deterministic check. Runs the local lens-kit CLI, no LLM call. Omit artifact_type and pass all=true when the type has no history yet.
Inputs: all, cwd, domain, format, +2 more.
lens_catches_statsCatch Recurrence StatsA
Per-pattern recurrence counts across the defect bank. Any pattern at or above the threshold gets a PROMOTE-to-deterministic-check suggestion — that is the signal a recurring judgment call should become a cheap fixed check instead. Use this to decide what to harden next.
Inputs: cwd.
lens_consistency_leaksForbidden-String Leak ScanA
Scan customer-facing files for deny-list terms (CASE-INSENSITIVE literal match — note lens_consistency_markers is case-SENSITIVE, they differ). Deterministic, no LLM. Exit 6 on a hit. Run this on EVERY customer-facing file before any irreversible publish: it is the check that catches a real client name, an internal codename or a banned absolute surviving into shipped copy. A credential scanner will not find these, because nothing here is a credential. IMPORTANT — a hit proves the STRING IS PRESENT, which is authoritative; it does not by itself prove a violation, because the match is NEGATION-BLIND: a banned phrase quoted in order to disclaim it ('we will not give you a guaranteed accuracy number') looks identical to the same phrase asserted. Adjudicate before acting. Deny terms should therefore be strings that are wrong in EVERY context (a real client name, an internal codename), not claims-you-do-not-make — those belong in a lens prompt.
Inputs: files (required), cwd, deny, profile.
lens_consistency_markersMarker Parity (source vs rendered)A
Check that evidence markers counted in a source artifact survive into every rendered output. Deterministic, no LLM, exit 6 on a violation. Catches the caveat, citation or hedge that gets dropped between formats — the source says 'as-of 2026-04' and the rendered deck quietly does not. Matching is CASE-SENSITIVE (unlike lens_consistency_leaks, which is case-insensitive), so pick markers whose casing is stable across source and render: 'TRIPWIRE' in the source will NOT match 'Tripwire' in the render and will read as dropped when nothing was. TRIPWIRE: a deliberate subset render also under-counts legitimately. Before treating a hit as a removed caveat, grep the rendered file case-insensitively.
Inputs: source (required), rendered (required), cwd, markers, +1 more.
lens_consistency_numbersNumber Parity (summary vs body)A
Check that every numeric literal in a summary actually appears in the body it summarizes. Deterministic, no LLM, exit 6 on a violation. Catches the invented figure — the number a summary asserts that its source never stated. TRIPWIRE, not an oracle: literal matching only, no semantic or derived arithmetic, so a legitimately computed total will flag. Review a hit, do not auto-trust it.
Inputs: body (required), summary (required), cwd.
lens_healthLens API Health CheckA
Check if the Soulfield Lens API service is running and responsive. Returns status and version. No auth required.
Inputs: no named parameters.
scrub_piiScrub PIIA
Scan text for structured PII and secrets (emails, UK/US phone numbers, credit-card numbers, US SSNs, UK NI/UTR numbers, database connection strings, and common API-key/credential patterns) via the hosted Lens API. Returns scrubbed text with each match replaced by a generic [REDACTED] marker (the finding TYPE — email, phone_uk, ni_number, etc. — appears only in the findings list, not in the replacement), plus that findings list. It scrubs structured identifiers only: personal NAMES survive, so scrubbed output is not anonymized. Pattern-based server-side scan, no LLM call. Targets structured identifiers — it does not detect personal names or free-form PII, and coverage of structured formats is best-effort, not exhaustive. Requires SOULFIELD_API_KEY.
Inputs: text (required).
validate_contentValidate ContentA
Run the 10-lens validation gate on AI-generated content. Returns pass/fail, per-lens results, violation details, and a deterministic 0-10 score derived from violation counts (10 = clean, floors at 0; computed by the API tier layer, not by the LLM — the LLM-emitted 0-100 score was removed 2026-07-30). Requires SOULFIELD_API_KEY. Supports domains: general, finance, marketing, legal, seo, agency. WIRE CONTRACT (since 2026-08-10): each lens carries status (ran|skipped|error) and passed is null whenever no verdict was produced — parse passed===false as the violation signal, never !passed. HALT SEMANTICS: Rights runs first and halts the run on a critical violation; in a halted response downstream judged lenses read passed:null/status:skipped (unknown, not clean — consciousScan is non-blocking and keeps passed:true, its status:skipped is the never-ran signal).
Inputs: text (required), domain, context.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool has a distinct function: main validation, PII scrubbing, health check, three deterministic consistency checks, and defect-bank operations. The main confusion risk is lens_consistency_leaks vs lens_consistency_markers, which sound alike but are clearly separated by case-sensitivity and purpose.
The set mixes verb-initial names like validate_content and scrub_pii with a lens_-prefixed family like lens_consistency_* and lens_catches_*. Within the lens_ families naming is consistent, but the overall convention is not uniform enough for a single predictable pattern.
Nine tools is well-scoped for a validation-focused server covering gate validation, PII scrubbing, consistency checks, health, and defect-bank memory. Each tool has a clear role and none feels redundant or extraneous.
Core workflows are covered: validate content, scrub PII, run deterministic consistency checks, check service health, and read/add to the defect bank. Minor gaps include no update/delete for defect-bank entries and no tool to manage the deny-list used by lens_consistency_leaks, but these are workable limitations.
Maintenance
Related MCP Connectors
Cutting AI slop is real productivity. Editorial and artifact linter for docs, web UI & slides.
Free mechanical checks for AI text: unnamed counts, dangling references, bad arithmetic, misquotes.
Multi-model AI fact-checker (Community Notes for AI) and second opinion across LLM families.
Multi-model AI fact-checker (Community Notes for AI) and second opinion across LLM families.
Related MCP Servers
- AlicenseAqualityCmaintenanceAdversarial AI review API — independent AI reviews another AI's output. Stop LLMs from grading their own homework. Provides automated quality assurance for AI-generated code, content, and other outputs through independent review pipelines.45 npm3MIT

Arkheia Hallucinationofficial
AlicenseNot gradedqualityCmaintenanceDetect fabrication and hallucination in any LLM output. Score responses from GPT-4o, Claude, Gemini, Llama and 30+ models. Free tier included.MIT
perf-mcpofficial
AlicenseAqualityDmaintenanceFact-checks and fixes AI outputs by catching hallucinations, repairing broken JSON, and correcting errors before they reach users, with tools for verification, validation, and correction.452 npmMIT- AlicenseAqualityDmaintenanceA private, open-source AI-text checker. Get a read on whether text looks AI-written, the exact AI-tell spans to fix, a reuse check, and a grammar pass.4MIT