fachwerk-mcp
An MCP server for Python projects. What a coding agent writes is checked before it reaches your files.
Every edit passes your strict checks first: black, isort, ruff, flake8, pylint, bandit, mypy and ty. A failed check writes nothing.
Why
A coding agent writes code that looks right and sometimes is not: an invented API, a forgotten import, an unhandled None, a shell command built from input. Reading every diff is the
only safeguard most setups have, and it does not scale. fachwerk-mcp moves the checks in front of the write. The strict chain you would run in CI runs on every edit, the agent gets the
findings back at once and fixes them, and what reaches your files has already passed.
How it keeps the code safe
- Checked before it is written. An edit goes through the write gate in the same call: syntax, structure, safe fixes, format, lint (ruff, flake8, pylint, bandit) and types (ty, mypy).
All or nothing: if one check fails, nothing is written and the agent gets every finding. It catches what models get wrong, including
# ... rest unchangedplaceholders. - Strict by default, and your project cannot quietly weaken it. The default profile
recommendedruns the chain with a strict policy that ships with the server and ignores the rule selections and ignore lists of the project. If your project checks with other linters, results can differ, and the server says so. You choose once per project, with a question in your client orfachwerk-mcp gate set:recommended,project(your tools with your settings; the server can then no longer ensure that its strict rules are kept) orcustom. A tool of the chain that cannot run blocks the write and is named; nothing passes unchecked by accident. - Only what the agent causes. Existing code is not clean, and an agent should not drown in findings it did not write. Findings a file had before the work (git HEAD) are counted, not listed; only new ones block. The strict rules apply to new code, so a project can move toward them without a clean-up first.
- Least privilege. Three levels:
read,write,run(default). Tests and commands run only inside a sandbox (bubblewrap, no network,.gitand credential files protected); if the sandbox cannot start, commands are refused. A model cannot change its own rights: it may propose a few settings (interpreter, test command, ...), and only you confirm them. Anything that widens its access or weakens the checks can never be proposed. - You can see what happened. Settings live outside your project, every change is in an audit log,
server_infosays what is active and what is degraded, and the call log shows what the agent did.
What it does not do
- It is not a proof of security. Linters find known patterns; they do not replace a review of what matters.
- New suppression comments (
# nosec,# noqa,# type: ignore) are not checked yet. This is a known, accepted gap of 0.1.0 (see the changelog). - Only the recommended chain is tested and measured. Other combinations work, but are not verified.
- Commands and tests need bubblewrap, so they run on Linux only; reading and editing do not depend on the sandbox.
Why this approach should work
The idea, putting the findings of static analysis back in front of the model until the code is clean, is not new, and it has been measured:
- Security and quality improve with a feedback loop. Blyth, Licorish, Treude and Wagner fed the findings of Bandit (security) and Pylint (quality) back to GPT-4o and asked it to fix them. Within ten iterations the share of generated code with security issues fell from over 40% to 13%, and the share with reliability warnings from over 50% to 11%. (Static Analysis as a Feedback Loop: Enhancing LLM-Generated Code Beyond Correctness, 2025)
- But an agent can clear a finding the wrong way. Wynter found that external checker feedback lets cheaper coding agents repair many more rule violations, and also that agents often cleared a defect by deleting the newly added files. fachwerk-mcp shows every removal in its report ("Removed, not just changed") for that reason. (Fixed or Deleted? External Feedback Lets Cheaper AI Coding Agents Repair Rule Violations, 2026)
These studies support the approach. They do not measure fachwerk-mcp itself.
How well does it agree with your own checks?
The conformance harness (python -m tests.conformance) changes a project through the real tools and compares the verdict of the gate with the same chain run as plain commands. On five
Python projects, 10 changes each, the verdicts agreed in all but one case (a false block after a rename, fixed since and covered by a test). That is a small sample, and the harness is
there so you can run more on your own project.
More
- Made for Python. Works on symbols, not lines; uses your virtual environment and your
pyproject.toml; runs your tests with pytest. - Read little, write once. Symbol index and reference search instead of whole files; one call per change.
- One server for all your projects and clients. OpenCode, Claude Code, Codex, Cursor, VS Code, Zed, ...
- Little setup. One command, no configuration file, all checking tools included. Nothing is written into your projects.
Quick start
Run this inside your Python project.
OpenCode: put this into opencode.jsonc in the project:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"fachwerk": { "type": "local", "command": ["uvx", "fachwerk-mcp", "stdio"] }
}
}
}
Claude Code:
claude mcp add fachwerk -- uvx fachwerk-mcp stdio
That is all. The project you are in is the root; nothing else to install or configure.
Other clients: fachwerk-mcp print-config <client> prints the entry for OpenCode, Claude Code,
Codex, Cursor, VS Code and Zed. Prefer pip? pip install fachwerk-mcp, then use
fachwerk-mcp stdio as the command.
Several projects or several clients? Run one shared server instead; it prints the line that connects your client:
fachwerk-mcp serve --root ~/projects/app --root ~/projects/lib --level write
Requires Python 3.12 or newer.
Connect your agent
fachwerk-mcp print-config <client> prints the exact entry for each client
(opencode, claude-code, codex, cursor, vscode, zed); add --level read|write to
write a lower access level into it. The two agents below in detail.
OpenCode
Put the entry into opencode.jsonc in your project, or into your global OpenCode config. OpenCode's
current configuration keeps servers under mcp.servers:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"fachwerk": {
"type": "local",
"command": ["uvx", "fachwerk-mcp", "stdio"]
}
}
}
}
| You want | Change |
|---|---|
| Edits but no commands, or read-only | append "--level", "write" (or "read") to command |
| A fixed project, whatever folder you start in | append "--root", "/home/you/projects/app" to command |
The shared server (fachwerk-mcp serve) |
use {"type": "remote", "url": "http://127.0.0.1:8808/mcp", "oauth": false, "headers": {"Authorization": "Bearer <token>"}} instead of the local entry |
| To switch it off for a while | add "disabled": true to the server entry |
| The server in every project | opencode mcp add --global; without --global it writes to the project configuration |
OpenCode names the tools fachwerk_code_* (server name, underscore, tool name). To make the
write gate the only way to change files, deny OpenCode's own edit and write tools in its
permission settings; the OpenCode MCP documentation
has the current rules.
Claude Code
Run this inside your project; it registers the server for you (user scope, stored in ~/.claude.json):
claude mcp add fachwerk -- uvx fachwerk-mcp stdio
| You want | Command |
|---|---|
The server only for this project, shared with your team through .mcp.json |
claude mcp add --scope project fachwerk -- uvx fachwerk-mcp stdio |
| Edits but no commands | claude mcp add fachwerk -- uvx fachwerk-mcp stdio --level write |
| Read-only | claude mcp add fachwerk -- uvx fachwerk-mcp stdio --level read |
| A fixed project, whatever folder you start in | claude mcp add fachwerk -- uvx fachwerk-mcp stdio --root ~/projects/app |
The shared server (fachwerk-mcp serve) |
claude mcp add --transport http fachwerk http://127.0.0.1:8808/mcp --header "Authorization: Bearer <token>" |
Check with claude mcp list, or /mcp inside Claude Code. The tools show up as
mcp__fachwerk__code_*. Claude Code keeps its own Edit and Write tools next to them; to make
the write gate the only way to change files, deny those two in your permission settings
("permissions": {"deny": ["Edit", "Write"]} in .claude/settings.json), so every edit has to
pass the checks. Run /mcp to reconnect after you update fachwerk-mcp.
Learn more
Quick start in detail · The write gate · How the gate checks · Made for Python · Tools and access levels · Projects, caches, language servers · Architecture · Security
Built on the official MCP Python SDK. MIT licensed.
Metadata
Release files for fachwerk-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fachwerk_mcp-0.1.0.tar.gz | 630.4 kB | With provenance | Details for fachwerk_mcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fachwerk_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for fachwerk_mcp-0.1.0-py3-none-any.whl |
Total release size: 1.1 MB
Release files / fachwerk_mcp-0.1.0.tar.gz
| Download URL | fachwerk_mcp-0.1.0.tar.gz |
|---|---|
| Size | 630.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d472e53373aacf5eaeb34055ecdc699232bdf214477eb31846ac49197b535408
|
|
BLAKE2b-256 checksum How to use checksums |
1d166472594e6664312fcea72ec230b62a53b316735d90e1dedb98029d309c11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logRelease files / fachwerk_mcp-0.1.0-py3-none-any.whl
| Download URL | fachwerk_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 423.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91b5392cfe414abd1dda5a084388ebf328806ee8625801f3eca31e098b097134
|
|
BLAKE2b-256 checksum How to use checksums |
0a56e548d65bb6c6eeb0abbfa31b67d953086bd9b189f99416630a48ae44b1ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logSecurity for fachwerk-mcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for fachwerk_mcp-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.