
Lens Mcp
io.github.mrhpython由 GitHub 帳號 mrhpython 發布v1.1.1更新於 Nov 10, 2026
Outside-in validation gate for AI-generated text; a separate model checks LLM output, fail-closed.
概覽
透過託管的 Lens API 對 AI 生成的文字執行外部驗證閘門,回傳通過/失敗評分並清理 PII。
- 可以做什麼
- 將託管的 Soulfield Lens API 包裝成 stdio MCP 伺服器。閘門層提供 validate_content,由另一個模型對文字執行固定閘門,回傳通過/失敗、評分、各維度結果與違規詳情;scrub_pii 是基於模式的伺服器端掃描,把結構化 PII 與憑證模式替換為類型標記;lens_health 是無需金鑰的狀態檢查。可選的驗證器層增加六個本機工具,用於跨檔案一致性檢查與缺陷記憶,但僅在本機安裝 lens-kit CLI 後可用。
- 適用情境
- 適合在助手生成的文字即將發布或交付時使用,希望由獨立模型檢查,而不是讓產生答案的模型自我評分。閘門是失敗關閉的,邊界情況回傳 UNKNOWN 而不是默默通過。可選的驗證器層適合檢查磁碟上的檔案,找出禁用詞、沒有依據的數字與遺失的證據標記。
- 執行需求
- 透過 npx 或全域安裝 @soulfield/lens-mcp 在本機執行,需要 Node.js。validate_content 與 scrub_pii 需要 SOULFIELD_API_KEY,SOULFIELD_API_BASE 應指向託管服務或你自己的部署。lens_health 不需要金鑰。可選的驗證器層需要在本機安裝 lens-kit CLI,或設定 LENS_KIT_BIN 指向其路徑。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Lens Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
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.
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:
Install
Or run without installing: npx @soulfield/lens-mcp.
Claude Code
Any MCP client (JSON config)
Production calls need an API key — request one at [email protected]. lens_health works without one.
Tools
Gate tier — hosted API, works out of the box
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.
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:
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)
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.)
來源:README.md,提交 c1acaf8
工具
0版本歷史
1- v1.1.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分