forge
Forge schema-bound, sandboxed tools at runtime. Paired with the cowork `forge` persona for chat-driven use in the voice-skill bridge. Use when you would otherwise write the same Bash snippet ≥3× with different parameters, when you need precise numerical results over a dataset, or when the user wants reproducible/deterministic output written to a file.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 25
- Forks
- 4
01 前言 Front Matter
- name
- forge
- version
- 0.2.0
- mcp_server
- forge
- description
- Forge schema-bound, sandboxed tools at runtime. Paired with the cowork `forge` persona for chat-driven use in the voice-skill bridge. Use when you would otherwise write the same Bash snippet ≥3× with different parameters, when you need precise numerical results over a dataset, or when the user wants reproducible/deterministic output written to a file.
- promoted_from
- forge
02 资源文件 104
- 脚本examples/voice_demo.sh4.1 KB
- 参考文档forge-mcp.service.yaml689 B
- 脚本forge.py13.6 KB
- 脚本forge/__init__.py742 B
- 脚本forge/_compute_discovery.py4.8 KB
- 脚本forge/_wincompat.py9.8 KB
- 脚本forge/_winproc.py9.4 KB
- 脚本forge/artifacts.py23.1 KB
- 脚本forge/breakers.py5.8 KB
- 脚本forge/cache.py4.1 KB
- 脚本forge/chain_dna.py12.4 KB
- 脚本forge/chain_loss.py7.7 KB
- 脚本forge/clag.py46.1 KB
- 脚本forge/corvin_data/__init__.py4.3 KB
- 脚本forge/corvin_data/data_policy.py11.2 KB
- 脚本forge/corvin_data/data_registry.py8.5 KB
- 脚本forge/corvin_data/format_sniffer.py5.2 KB
- 脚本forge/corvin_data/mcp_handlers.py29.5 KB
- 脚本forge/corvin_data/pii_detector.py13.6 KB
- 脚本forge/corvin_data/pii_presidio.py4.0 KB
- 脚本forge/corvin_data/pseudonymize.py3.0 KB
- 脚本forge/corvin_data/redactor.py13.8 KB
- 脚本forge/corvin_data/schema_extension.py9.8 KB
- 脚本forge/corvin_data/snapshot.py29.4 KB
- 脚本forge/corvin_data/strict_anonymizer.py12.9 KB
- 脚本forge/mcp_server.py148.8 KB
- 脚本forge/multi_registry.py6.2 KB
- 脚本forge/paths.py22.5 KB
- 脚本forge/permissions.py4.6 KB
- 参考文档forge/policy.json1.4 KB
- 脚本forge/policy.py16.0 KB
- 脚本forge/registry.py18.9 KB
- 脚本forge/runner.py49.5 KB
- 脚本forge/runs.py9.3 KB
- 脚本forge/sandbox_helpers/sitecustomize.py8.6 KB
- 脚本forge/sandbox_helpers/test_sitecustomize_imds.py846 B
- 脚本forge/sandbox_provider.py3.7 KB
- 脚本forge/sandbox.py10.5 KB
- 脚本forge/scope.py6.3 KB
- 脚本forge/secret_vault.py10.9 KB
- 脚本forge/security_events.py438.4 KB
- 脚本forge/static_check.py3.4 KB
- 脚本forge/sync.py2.3 KB
- 脚本forge/tenant_migrate.py10.9 KB
- 脚本forge/tenants.py4.0 KB
- 脚本forge/test_chain_dna.py10.8 KB
- 脚本forge/test_clag.py24.6 KB
- 脚本scripts/forge_cleanup.py3.4 KB
- 脚本tests/_licence_pin.py1.8 KB
- 脚本tests/conftest.py2.9 KB
- 脚本tests/test_artifact_e2e.py13.4 KB
- 脚本tests/test_artifacts.py15.9 KB
- 脚本tests/test_audit_detail_floor.py23.9 KB
- 脚本tests/test_cache.py9.0 KB
- 脚本tests/test_cleanup.py4.7 KB
- 脚本tests/test_compute_engine_tools.py10.1 KB
- 脚本tests/test_corvin_data_e2e.py11.6 KB
- 脚本tests/test_corvin_data_mcp.py22.6 KB
- 脚本tests/test_corvin_data_pii.py13.9 KB
- 脚本tests/test_corvin_data_pseudonymize.py7.9 KB
- 脚本tests/test_corvin_data_redactor.py19.2 KB
- 脚本tests/test_corvin_data_schema.py13.0 KB
- 脚本tests/test_corvin_data_snapshot.py20.0 KB
- 脚本tests/test_corvin_data_strict_anonymizer.py17.6 KB
- 脚本tests/test_data_register_connection_containment.py2.7 KB
- 脚本tests/test_datasource_connect.py8.4 KB
- 脚本tests/test_datasource_query_rag_query.py14.7 KB
- 脚本tests/test_envelope.py7.1 KB
- 脚本tests/test_forge_list.py6.9 KB
- 脚本tests/test_forge.py13.9 KB
- 脚本tests/test_loopback_shim.py1.8 KB
- 脚本tests/test_mandatory_mac.py8.0 KB
- 脚本tests/test_mcp_server_audit_chain.py6.6 KB
- 脚本tests/test_mcp.py25.5 KB
- 脚本tests/test_multi_scope.py4.6 KB
- 脚本tests/test_namespace_gate.py12.2 KB
- 脚本tests/test_output_streaming.py5.5 KB
- 脚本tests/test_paths_compat.py11.3 KB
- 脚本tests/test_paths_tenant.py7.8 KB
- 脚本tests/test_persona_sandbox.py13.3 KB
- 脚本tests/test_redact.py6.5 KB
- 脚本tests/test_requirements.py11.4 KB
- 脚本tests/test_round4_registry_cli_paths.py2.7 KB
- 脚本tests/test_run_workspace.py9.4 KB
- 脚本tests/test_runner_winjob_close.py3.1 KB
- 脚本tests/test_scope_compat.py12.4 KB
- 脚本tests/test_scope_detection.py8.0 KB
- 脚本tests/test_secret_injection.py22.4 KB
- 脚本tests/test_secret_vault_paths.py4.1 KB
- 脚本tests/test_security_audit.py19.9 KB
- 脚本tests/test_security_breakers.py13.6 KB
- 脚本tests/test_security_budget.py16.3 KB
- 脚本tests/test_security_events_windows_lock.py14.1 KB
- 脚本tests/test_security_policy.py8.0 KB
- 脚本tests/test_security_static_check.py10.2 KB
- 脚本tests/test_subcommands.py9.3 KB
- 脚本tests/test_tenant_migrate.py14.8 KB
- 脚本tests/test_tenant_migration_roundtrip.py13.6 KB
- 脚本tests/test_tenants.py8.2 KB
- 脚本tests/test_voice_persona_acl.py10.3 KB
- 脚本tests/test_voice_policy_hotreload.py8.4 KB
- 脚本tests/test_windows_import.py6.0 KB
- 脚本tests/test_winproc.py5.1 KB
- 脚本tests/test_xbind_guard.py1.6 KB
03 SKILL.md 正文
forge — runtime tool factory for Claude Code
You (Claude) can register a new tool at runtime via the forge MCP server.
The new tool is callable as mcp__forge__<name> from the next tools/list
onward, in the current session and in any future session that sees the same
~/.config/corvin-voice/forge/ workspace.
When this plugin runs inside the voice-skill repo (the normal case), the
cowork forge persona auto-routes user phrases like "forge mir ein tool",
"build me a tool that …", or "I need a deterministic tool" onto this MCP
server — the persona ships restrictively (no Bash/Edit/Write) so generated
tools cannot inherit the owner's bypassPermissions privilege.
When to use forge
Reach for forge_tool when at least one of these holds:
- You would otherwise write the same Bash/Python snippet ≥3 times with different parameters (paths, columns, thresholds)
- You need precise numerical results over a dataset (statistics, regression, aggregation, filtering, splitting)
- The user wants the answer written to a file (CSV, JSON, PNG)
- The user uses the words "deterministic", "reproducible", "save as", "compute exactly", "audit trail"
- The result of one computation is used multiple times later — caching it in a forged tool gets you reuse for free
When NOT to use forge
- One-off shell commands (
wc -l,git status) — Bash is fine - LLM-shaped work (code review, translation, design discussion)
- An existing forged tool already does this — call it instead
- The data lives only in your conversation context — Bash + a heredoc is cheaper than codifying a tool
Calling sequence
mcp__forge__forge_tool({name, description, input_schema, impl, runtime?, meta?})- The server emits
notifications/tools/list_changed— wait one tick - Call
mcp__forge__<name>with the input you wanted - (optional)
mcp__forge__forge_promote({name})to make it durable
Schema conventions
The input_schema is JSON-Schema. Three forge-specific extensions:
| Annotation | Meaning |
|---|---|
"x-bind": "ro" |
Path is read-only-mounted into the sandbox at exec time |
"x-bind": "rw" |
Path (or its parent) is read-write-mounted into the sandbox |
"x-redact": true |
Field is replaced with <redacted> in the run manifest |
Use "x-redact": true on api keys, bearer tokens, secrets — the tool still
sees the real value, but it never appears in runs/<id>/run_manifest.json.
Output convention (every forged tool follows this)
A tool prints one JSON object to stdout. Either form is accepted:
Plain form — server auto-wraps:
{"sum": 42, "summary": "sum=42"}
Full envelope form — server passes through:
{ "ok": true, "status": 200,
"data": {"sum": 42, "summary": "sum=42"},
"error": null,
"meta": {"deterministic": true, "side_effects": false} }
Either way, the MCP structuredContent you receive looks like:
{ "ok": true, "data": {...}, "envelope": {...},
"artifacts": [...], "run_id": "2026-...", "sandbox": "bwrap",
"duration_s": 0.024 }
artifacts is the list of files the tool wrote into _artifacts_dir,
auto-discovered by the server (the tool can't fake the list).
meta hints
When you forge a tool, set meta to declare its character. The flags
change runtime behaviour:
| Flag | Effect |
|---|---|
deterministic: true |
Result cache: identical real inputs return the cached envelope, |
with meta.replayed_from = <old_run_id>. Sandbox = "cache". |
|
side_effects: false |
Documentation only (used by promote-to-skill flow); does not |
| currently change runtime behaviour. |
Set deterministic: true only when the tool's output is a pure function
of its inputs — no clock reads, no RNG without an explicit seed parameter,
no network calls. If unsure, leave it unset.
Output paths — where artifacts land
Every call has its own runs/<ts>_<id>/artifacts/ directory. The server
injects its absolute path into the payload as _artifacts_dir. Your tool
can write any number of files there:
adir = json.loads(sys.stdin.read())["_artifacts_dir"]
with open(f"{adir}/result.csv", "w") as fh:
...
The server scans that directory after the tool exits and reports the files
back as artifacts: [{path, rel, bytes, kind, preview?}, ...].
If the user named an output path explicitly (~/Desktop/report.csv),
pass it as a regular schema field with "x-bind": "rw" so the sandbox can
write there too.
Workspace layout
~/.config/corvin-voice/forge/ (override via $FORGE_ROOT)
├── registry.json tool manifest (one row per forged tool)
├── tools/<name>.{py,sh} tool implementations on disk
├── skills/<name>/ promoted tools (durable across sessions)
├── runs/<ts>_<id>/ one folder per call:
│ ├── run_manifest.json input + tool_sha + start time
│ ├── run_completion.json status + duration + sandbox + artifacts
│ ├── RUN_SUMMARY.md human-readable digest
│ ├── stdout.json full envelope the tool returned
│ └── artifacts/ files the tool wrote
├── cache/<key>.json deterministic-tool cache entries
├── memory/<date>.md free-form notes (append-only)
└── audit.jsonl create / delete / promote events
Useful CLI subcommands
(For when you want to inspect from the host shell — Claude doesn't run these directly, but mention them to the user.)
| Command | What it does |
|---|---|
forge.py run-list |
Recent runs, newest first |
forge.py run-show [--id <id>] |
RUN_SUMMARY.md of a run |
forge.py cleanup --keep N |
Keep last N runs, delete the rest |
forge.py cleanup --keep N --purge-cache |
…and wipe the deterministic cache |
forge.py sync [--target <dir>] |
Copy promoted skills to ~/.claude/skills/ |
Examples
1. Group statistics on a CSV the user dropped in
mcp__forge__forge_tool({
"name": "csv_group_stats",
"description": "mean + pop-stddev of a numeric column grouped by another",
"input_schema": {
"type": "object",
"required": ["file", "group_by", "value_col"],
"properties": {
"file": {"type": "string", "x-bind": "ro"},
"group_by": {"type": "string"},
"value_col": {"type": "string"}
}
},
"impl": "...python that reads stdin JSON, prints {data: {groups: {...}}}...",
"meta": {"deterministic": true, "side_effects": false}
})
Then call mcp__forge__csv_group_stats({file, group_by, value_col}). The
result is in data; the full envelope is in runs/<id>/stdout.json.
Calling it twice with the same file path → cache hit, ~0ms second time.
2. Synthesize a CSV the user can download
mcp__forge__forge_tool({
"name": "synth_sales_csv",
"description": "synthesize a deterministic sales CSV from a seed",
"input_schema": {
"type": "object",
"required": ["n_rows", "seed"],
"properties": {
"n_rows": {"type": "integer"},
"seed": {"type": "integer"}
}
},
"impl": "...writes CSV into open(_artifacts_dir + '/sales.csv', 'w')...",
"meta": {"deterministic": true}
})
The MCP response will include artifacts[0].path — that's the absolute
path of the generated CSV. Mention it to the user; they can cat / open
it directly.
3. Tool with a secret
mcp__forge__forge_tool({
"name": "fetch_user",
"description": "fetch a user record",
"input_schema": {
"type": "object",
"required": ["api_key", "user_id"],
"properties": {
"api_key": {"type": "string", "x-redact": true},
"user_id": {"type": "string"}
}
},
"impl": "..."
})
api_key is sent verbatim to the tool but written as <redacted> in
runs/<id>/run_manifest.json and never lands in audit logs.
Security policy — the safety envelope
The operator's policy.json (next to registry.json in the workspace)
is the safety envelope nothing in meta can widen. If absent, strict
built-in defaults apply.
{
"default_budget": { "cpu_seconds": 10, "wall_seconds": 30,
"output_bytes": 4194304, "artifact_bytes": 67108864 },
"max_budget": { "cpu_seconds": 60, "wall_seconds": 300,
"output_bytes": 16777216, "artifact_bytes": 268435456 },
"forbidden_imports": ["socket", "subprocess", "ctypes", "multiprocessing"],
"forbidden_tool_names": ["shell.*", "system.*"],
"allowed_namespaces": null, // null = all OK (subject to deny)
"rate_limit": { "default_calls_per_minute": 60,
"per_tool": { "csv.heavy": 10 } },
"circuit_breaker": { "enabled": true, "failure_threshold": 5,
"reset_timeout": 60, "half_open_max": 2 },
"network": { "default": false },
"audit": { "hash_chain": true }
}
What gets enforced when:
| Phase | Check | On violation |
|---|---|---|
forge_tool |
name_allowed(name) (forbidden globs + namespace) |
reject + policy.namespace_denied event |
forge_tool |
AST static check vs. forbidden_imports |
reject + policy.import_denied event |
| Pre-call | rate limiter token-bucket consume | reject + rate_limit.exceeded event |
| Pre-call | circuit breaker can_execute() (CLOSED/OPEN/HALF_OPEN) |
reject + circuit_breaker.rejected event |
| Spawn | meta.budget clamped by max_budget → applied as rlimits + timeout + output_cap |
clamp_info surfaces in envelope.meta.policy_clamped |
| Post-run | artifacts dir total bytes vs. budget.artifact_bytes |
error + budget.exceeded |
| Post-run (success) | breaker record_success() (resets counter / closes HALF_OPEN) |
circuit_breaker.closed event on transition |
| Post-run (ToolError) | breaker record_failure() (may trip OPEN) |
circuit_breaker.opened event on transition |
SchemaError, PermissionDenied, and TamperError do not count
against the breaker — those are caller- or security-side problems, not
"the tool is broken." Tamper writes its own tool.tamper_detected event.
Audit & integrity
Every security-relevant action appends a structured event to
<workspace>/audit.jsonl. With audit.hash_chain: true (default), each
record carries prev_hash and hash (sha256 of prev_hash || canonical_record).
The CLI exposes verification:
python3 forge.py audit-verify
# audit OK (.../audit.jsonl) ← rc 0
# audit INTEGRITY VIOLATION ... ← rc 1, lists offending lines
Tampering with any field re-localizes to a tampered issue at that line;
deleting a record produces a broken_chain at the next record's line.
Anti-patterns to avoid
- Don't forge inside a single Bash one-liner's worth of work — the forge step itself costs ~50 tokens of schema. Pay for it only when you'll reuse the tool ≥3 times or you need its sandbox/audit guarantees.
- Don't put one-off paths into the impl source — pass them as schema fields. Otherwise the tool's sha changes with every call and no cache ever hits.
- Don't write outside
_artifacts_dirunless anx-bind: rwfield explicitly tells the runner to mount that path. The sandbox will block the write and you'll get a confusing exit code. - Don't claim
deterministic: trueif your impl reads the clock or callsrandom.random()without a seed parameter — the cache will lock in stale answers.
04 同仓库更多 Skills
voice
Voice mode for Claude Code — automatically reads assistant replies aloud via TTS, with German/English auto-detection and optional summarization for long responses. Trigger when the user mentions voice, vorlesen, sprachausgabe, TTS, "speak", "say it out loud", or asks about /voice-* commands.
paper-generator-orchestrator
暂无简介
academic-paper-generation
暂无简介
cowork
暂无简介
quality-layer-control
Toggle quality disciplines (ADR Gate, docs-as-definition-of-done, etc.) on or off globally
using-ldd
Use at the start of any conversation, and whenever the user mentions LDD, loss-driven development, loss, gradient, SGD on code, drift, refinement loop, outer loop, inner loop, method evolution, or says "LDD:" / "apply LDD". Establishes how to dispatch the ten LDD skills and when each fires. Must be the first skill considered in any coding task where LDD is available.