
ChainWeaver
io.github.dgenioPublished by GitHub account dgeniov0.12.1Updated Oct 24, 2026
Expose deterministic ChainWeaver flows as MCP tools without LLM calls between steps.
The publisher's own server: Agent.chain.tokyo Address Contracts
Overview
ChainWeaver exposes reviewed deterministic tool flows as MCP tools, letting an assistant run a whole flow in one call with no model calls between steps.
- What you can do
- Expose reviewed deterministic flows as MCP tools so the assistant calls a whole flow as one tool. Validate each step's input and output against Pydantic schemas and record structured step logs. Load and validate flow files, and render flow structure as ASCII, DOT or Mermaid. Attest determinism, fuzz flows with property tests, check schema drift and produce cost-avoided estimates. Compose basic flows from a bundled deterministic-only utility tool library.
- When to use it
- Use it when you already have a proven, reviewed, fully deterministic tool path and want the assistant to run it as one tool call instead of inserting model reasoning between steps. The authors themselves suggest a plain function or existing framework first when the workflow is already fixed.
- Requirements
- Runs locally as a Python package, installed with uvx or pip. Exposing flows over MCP needs the mcp extra; reading and writing .flow.yaml files needs the yaml extra. The tools used by a flow must be supplied as a Python module.
Installation
In SourceWeft
- Open ChainWeaver in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
ChainWeaver
Find where your agent no longer needs to reason. Review the evidence. Turn the accepted path into a governed deterministic capability.
[PyPI] [CI] [Python] [License] [Open in Colab] [Read the Weaver Stack overview on Towards AI]
[ChainWeaver quick start: pip install, run a flow, and see the LLM-free step log]
Product thesis under validation — observe → prove → review → compile. ChainWeaver can inspect repeated tool behavior, surface candidates, and execute reviewed deterministic paths with typed contracts. Deterministic execution by itself is not the moat: if you already know the exact workflow, a normal Python function, LangGraph node, or provider-native tool may be simpler. The hypothesis being tested is that trace-derived evidence, useful rejection, governed promotion, security-boundary preservation, and drift detection make ChainWeaver worth adopting. See Product validation & adoption gates and #553.
Remove reasoning boundaries, never security boundaries. Compiling several tool calls into one capability must not silently aggregate privileges or erase child approval requirements. That invariant is tracked explicitly in #554.
Governance for deterministic tool paths. Typed I/O at every step, file-serializable flows, schema-drift detection, determinism attestation, property fuzzing, and structured audit traces provide a disciplined execution substrate for paths that have actually earned deterministic promotion.
Benchmarks are evidence about the executor, not proof of product-market fit. The repo's benchmark report is reproducible — regenerate it yourself with
python benchmarks/report.py— and shows the deterministic core avoiding model-mediated transitions in its synthetic comparison. It does not establish that every repeated path should be compiled, or that ChainWeaver beats the obvious plain-Python implementation. The independent validation program requires that manual baseline explicitly.
See the full example below or run
python examples/simple_linear_flow.py
Installation · Why ChainWeaver? · Is this for me? · Product validation · Quick Start · Architecture · Docs site · Roadmap
See it in 30 seconds
The deterministic executor solves a simple problem: once a path has been shown to need no intermediate reasoning, stop paying a model to re-decide the same plumbing on every run.
Before — a model-mediated path:
After review — the accepted path can run deterministically:
The agent still decides which capability to invoke. The deterministic steps inside it run with strict Pydantic validation and no LLM involvement.
The harder product question comes before this diagram: should this path be compiled at all? A useful ChainWeaver analysis must be able to show why a candidate is recurrent and structurally safe and reject paths where semantic judgment, side effects, authorization, or approval boundaries still matter. That claim is currently being tested on independent traces in #553.
Copy-paste executor path:
The summary below is a condensed view of the real ExecutionResult the script
produces:
Why ChainWeaver?
Why not just write a Python function?
Often, you should.
If your team already knows the workflow is fixed, a normal function or the workflow primitives in your existing framework are usually the lowest-complexity answer. ChainWeaver should earn another dependency only when its lifecycle adds meaningful value—for example:
- discovering non-obvious repeated model-mediated paths from real traces;
- showing evidence for recurrence, dataflow compatibility, and counterexamples;
- rejecting tempting paths that still require semantic judgment;
- preserving approval and authorization constraints during promotion;
- producing reproducible review evidence and artifact identity;
- detecting schema/safety/policy drift after promotion;
- exporting or executing the accepted capability without pretending that fewer model calls automatically means greater correctness.
Whether those advantages are strong enough in real teams is a falsifiable product hypothesis, not a README assumption. See docs/product-validation.md.
When an LLM-powered agent routes tools together — fetch_data → transform → store — a
common pattern is to insert an LLM call between steps so the model can decide
what to do next. For a path that has been demonstrated and reviewed as fully
deterministic, those intermediate calls can add latency, cost, and variability
without adding useful judgment.
ChainWeaver's executor can run an accepted deterministic path without any LLM involvement between steps:
How is this different from LangChain / LangGraph / Prefect / Dagster / Temporal?
Those frameworks can also execute deterministic code. ChainWeaver should not be selected because deterministic execution is impossible elsewhere. Its current product thesis is narrower: start from observed agent/tool behavior, establish which regions no longer need reasoning, make the evidence and rejections reviewable, then promote accepted paths into governed deterministic capabilities.
The execution substrate remains deliberately small and LLM-free between steps, but the project is testing whether the evidence/governance lifecycle—not the mere existence of another workflow runtime—is the part users value.
See docs/comparisons.md for the detailed, versioned comparison and docs/product-validation.md for the criteria that can falsify this positioning.
Is this for me?
ChainWeaver is built for one specific shape of problem. The full fit/non-fit page covers the nuances; the short version:
Use ChainWeaver when
- You have real agent/tool traces and suspect parts of the path are repeated plumbing rather than useful model judgment.
- You want evidence and review around which paths deserve deterministic promotion, not only a runtime for a workflow you already know.
- Determinism, strict schemas, auditability, and drift detection matter once a path is promoted.
- You are prepared to keep security and approval boundaries explicit rather than treating a macro-tool invocation as blanket child authorization.
Don't use ChainWeaver when
- You already know the workflow and a normal Python function or your existing framework expresses it clearly enough.
- Every step requires open-ended reasoning to pick the next one (use an agent framework: LangGraph, the OpenAI / Anthropic SDK tool-use loops).
- You need a general workflow engine for scheduled / durable jobs across time (use Prefect, Dagster, or Temporal).
- You expect the executor to call an LLM. It deliberately doesn't.
- You cannot preserve the authorization/approval semantics of a side-effecting path during compilation.
The product thesis, validation protocol, and kill/pivot criteria are public in docs/product-validation.md.
For the correctness argument behind the deterministic execution design, see docs/data-integrity.md.
Part of the Weaver Stack
ChainWeaver is the deterministic multi-step tool execution layer of the
Weaver Stack — a family of small,
composable SDKs that share weaver-spec's SelectableItem routing contract.
On the request path a router picks which capability to invoke, ChainWeaver
runs the deterministic tool path behind it, and downstream layers gate and
guard the call:
Use standalone or together. Each layer stands on its own — ChainWeaver's
base install has no hard dependency on any sibling and works fully
standalone. Real interop runs through the chainweaver[weaver-stack] extra,
which pins the published weaver-contracts
package: ChainWeaver consumes its SelectableItem / RoutingDecision /
CapabilityToken types directly, so a router can hand a routing decision
straight to resolve_flow_from_routing_decision() for deterministic
execution. See the runnable
Weaver Stack golden path (issue #234).
ChainWeaver does not replace an agent framework. It is meant to be called from one — see the LangGraph recipe (issue #205) and the OpenAI Agents SDK recipe (issue #206) for the canonical integration patterns.
For host-level expectations (when to invoke, how to store traces, side-effect tools, MCP parity), see the Runtime responsibilities page.
Installation
The base install pulls only five runtime dependencies (deepdiff,
packaging, pydantic, tenacity, typer) and has no transitive LLM
SDK pinned. Pick extras for the integrations you actually use:
Maintainer tooling (pytest, ruff, mypy, nbmake, ...) is not a published
extra: it lives in PEP 735 dependency groups, installed with
pip install -e ".[integrations]" --group dev (#550). The [dev] extra no
longer exists.
Package metadata (pyproject.toml) publishes URLs for the
documentation, the
source, the
changelog,
and the
issue tracker, so pip show chainweaver and the PyPI sidebar point users to the right place.
Quick Start
Define tools, build a flow, and execute it
You can also run the bundled examples directly:
The hosted docs also include a cookbook with paired
scripts under examples/cookbook/, plus framework recipes and workflow
templates (LangGraph, OpenAI Agents SDK, release-readiness, policy evaluation).
With the @tool decorator
The @tool decorator eliminates boilerplate by introspecting type hints to
auto-generate input schemas:
Decorated tools are also directly callable:
See examples/decorator_tool.py for a runnable before/after comparison.
With FlowBuilder
FlowBuilder provides a fluent, chainable API as a more Pythonic alternative
to constructing Flow objects directly. It produces an identical Flow — it
is syntax sugar, not a replacement:
.step(tool_name, **mapping)— adds a step; string values are context-key lookups, non-string values are literal constants, no kwargs = full-context passthrough..step_from(flow_step)— appends a pre-builtFlowStepfor interop..with_input_schema(Model)/.with_output_schema(Model)— optional flow-level Pydantic schema declarations..with_trigger(conditions)— optional free-form trigger metadata..build()— returns a validatedFlow; raisesFlowBuilderErrorifnameordescriptionis missing.
Interactive playground
Want to try ChainWeaver without installing anything locally? The
playground/ directory ships a Streamlit app that lets you pick
a pre-loaded flow, edit its JSON input, run it, and watch the step-by-step,
LLM-free execution trace with a Mermaid diagram — the same FlowExecutor
the library ships.
It ships three example flows (arithmetic, a data flow, and an MCP-style
search), produces shareable ?share=<token> links that round-trip a run through
the URL, and is fully stateless so it deploys to Streamlit Community Cloud with
no backend. See playground/README.md for local-run and
deployment instructions.
Architecture
Core abstractions
Tool
A tool wraps a plain Python callable together with Pydantic models for strict input/output validation.
FlowStep
input_mapping maps keys from the accumulated execution context into the
tool's input schema. String values are looked up in the context — a plain key
is a top-level lookup, and a string starting with / is an RFC-6901 JSON
pointer into the nested context (#387) — while non-string values are literal
constants.
output_mapping (#386) optionally renames and prunes a tool's outputs before
they merge into the context: {context_key: output_key} keeps only the listed
output keys, each renamed. Omit it to merge every output key verbatim.
To inject per-request secrets that must never appear in a model-visible schema
(auth tokens, account numbers), pass them at execute-time instead of in
initial_input:
Flow
An ordered sequence of steps. See AGENTS.md §5 for the full
field table (status, tool_schema_hashes, and the input_schema_ref /
output_schema_ref string fields with their resolved-property accessors).
A FlowStep runs either a tool (tool_name) or a registered
sub-flow (flow_name) — exactly one, never both. Referencing a sub-flow lets
you compose reusable flows (issue #75):
The executor runs the sub-flow with the step's resolved inputs, merges its
output back into the parent context, and attaches the sub-flow's
ExecutionResult to the parent StepRecord.sub_result. Sub-flow references
are checked for cycles and a configurable max nesting depth
(FlowExecutor(max_composition_depth=...), default 10) before execution,
raising FlowCompositionError otherwise.
A deadline or CancellationToken passed to execute_flow is forwarded into
composed sub-flows, so cancellation and the wall-clock budget are observed at
the step boundaries inside a sub-flow — a long sub-flow stops between its own
steps rather than only at the parent boundary. The cost report's
steps_executed counts the tool invocations a composed step actually drove
(recursively), so llm_calls_avoided reflects every tool that ran across the
composition.
FlowRegistry
An in-memory catalogue of flows.
FlowExecutor
Runs a flow step-by-step with full schema validation and structured logging. No LLM calls are made at any point.
ChainAnalyzer
Discovers schema-compatible tool combinations offline, before any flow is
registered or executed. compatibility_matrix() checks that every required
input field of a consumer tool appears in the output of the producer with a
matching type. suggest_flows() auto-wires input_mapping by name-matching
and returns Flow objects ready for FlowRegistry.register_flow().
Data flow
MCP Integration Concept
ChainWeaver can sit between agent/tool observation and deterministic execution:
MCP is an interoperability surface, not the product category. The current runtime can expose reviewed flows as MCP tools, while #555 explores whether portable outputs should let the same approved capability execute through other hosts without requiring ChainWeaver to own the runtime.
ChainWeaver is a library you embed, not the runtime that owns your trace
store, identity system, or enterprise authorization control plane. Host authors
should read docs/runtime-responsibilities.md.
Integrations
ChainWeaver plugs into the MCP ecosystem and major agent frameworks. Existing integrations remain supported; new adapter breadth is deliberately lower priority than independent product validation.
Install the extra you need: pip install 'chainweaver[mcp]' (or langgraph,
openai-agents, langchain, llamaindex). Importing any integration without its
extra raises a clear ImportError.
Looking to publish or list ChainWeaver in the MCP registry / awesome-lists / framework
directories? See docs/distribution.md. Broad distribution
is intentionally gated behind the naming decision (#556) and validation evidence
(#553).
Error Handling
All errors are typed and traceable:
All exceptions inherit from ChainWeaverError and carry a stable diagnostic
code (e.g. CW-E006); the CLI prefixes it on error output and failing
StepRecords expose it as error_code. See the full code table in
docs/reference/error-table.md.
Standard tool library
chainweaver.contrib.tools ships a curated set of deterministic
utility tools so that a new user can compose a meaningful flow on the
first afternoon without writing any Tool boilerplate.
The library is deterministic-only: no HTTP, file I/O, database
access, RNG, or clocks. Anything stateful belongs in user code.
Install with pip install 'chainweaver[contrib]'.
Runnable examples: examples/contrib_pluck_and_set.py,
examples/contrib_map_filter.py.
Cost-avoided reporting
Every inter-step transition a naive agent delegates to an LLM is a routing
call ChainWeaver eliminates. CostProfile / CostReport turn that into a
dollar estimate, and the maintained PROVIDER_PRICES table (dated snapshots,
no live HTTP lookup) lets you price it against a real model:
Every report built from the table carries the snapshot's as_of date so
stale prices are visible. Unknown (provider, model) pairs raise
CostProfileError rather than guessing. Pass an explicit
profile=CostProfile(...) when you have better per-call numbers, or set
cost_profile= on FlowExecutor to attach a report to every
ExecutionResult. Prices are refreshed by a maintainer-reviewed PR
(.github/workflows/update-prices.yml) — never auto-merged.
These reports are estimates unless their inputs come from observed trace measurements. They must not be presented as evidence that a candidate should be compiled; #377 tracks calibration of assumed versus measured model mediation.
Export adapters
Hand a compiled flow off to any external agent framework via
chainweaver.export:
flow_to_openai_function emits the
{"type": "function", "function": {…}} shape OpenAI's chat / responses
APIs expect. flow_to_anthropic_tool emits Anthropic's tool_use
shape. flow_to_callable wraps the flow as a Callable[[dict], dict]
suitable for any framework that accepts arbitrary Python callables.
None of these adapters imports openai or anthropic — they emit
dicts and callables only. Runtime integration with those clients is
the caller's job.
Runnable example: examples/export_openai_anthropic.py.
Ecosystem bridges (LangChain, LlamaIndex)
chainweaver.integrations.langchain and
chainweaver.integrations.llamaindex ship thin bidirectional adapters
so existing LangChain BaseTool / LlamaIndex FunctionTool
instances can be pulled into ChainWeaver, and ChainWeaver Tool
instances can be pushed back out.
Install with pip install 'chainweaver[langchain]' /
'chainweaver[llamaindex]'. Importing either module without the
relevant extra raises a clear ImportError.
Plugin discovery
For third-party packages — chainweaver-aws, chainweaver-stripe,
… — ChainWeaver follows the same entry-point convention used by
pytest, Sphinx, MkDocs, and friends.
Publisher (pyproject.toml):
Consumer:
Discovery is opt-in — importing chainweaver does not trigger
plugin imports. Misbehaving plugins (raise on import, return the
wrong type) are logged at WARNING and skipped; pass
strict=True to discover_tools() / discover_flows() for the loud
form.
Runnable example: examples/plugin_discovery.py.
Runtime learning
ChainWeaver can watch what an agent does and propose deterministic-flow candidates for repeated paths. A repeated sequence is not proof that the path is safe or valuable to compile; proposals require review, and the product validation program is explicitly measuring false positives, false negatives, and useful rejections.
ChainObserver(#78) mines repeated tool sequences from runtime traces and emits rankedFlowSuggestions — never auto-registered.chainweaver record(#226) mines recorded JSONL traces and writes candidate flow files for explicit review/promotion.ChainWeaverService(#101) ties observation, static analysis, and optional offline proposals into an analyze → propose → govern → promote loop.
See Product validation & adoption gates before interpreting a suggestion as proof that a path should become deterministic.
Roadmap
The current roadmap is validation-first, not feature-count-first. The latest
published release is v0.14.1; newer work on main remains unreleased until a
subsequent release is cut.
Broad directory submissions, hosted-playground investment, and additional framework-adapter breadth are deliberately lower priority until these gates produce evidence.
v1.0.0 is also evidence-gated: independent workloads/adopters, a manual
baseline, an external security review, repeated use, a downstream integration,
and a 30-day RC compatibility soak are required by
docs/v1-release-criteria.md.
Command-line interface
ChainWeaver ships a chainweaver console script with the following subcommands.
Reading .flow.yaml files needs the YAML extra
(pip install 'chainweaver[yaml]' — also listed in Installation).
The run example below uses a flow shipped under examples/, so it should be
invoked from the repository root.
run is the fastest path from a fresh install to seeing a flow execute:
point it at a .flow.yaml/.flow.json file, pass --tools <module> (the
import path of a Python module that exposes Tool instances at top
level), and supply the initial input as JSON. Hand-authored flow files must
declare a type: Flow (or type: DAGFlow) discriminator at the top — see
the flow file format reference. Most
reporting subcommands also accept --format json for machine consumption
(inspect, validate, check, run, profile, diff, attest,
suggest, doctor); the exceptions are viz, which uses
--format ascii|dot|mermaid, explain, which uses --format md|text, and
dump-schema, which writes a raw JSON Schema and has no --format flag. The result-producing commands (inspect,
validate, check, profile, diff, attest) wrap their --format json
output in a stable, versioned envelope
({"schema_version", "status", "data", "errors"}) so automation can branch on
status / error codes — see
machine-readable output.
All subcommands share the same exit-code contract (0 success, 1
business-logic error, 2 file-not-found / argument error), and the CLI ships
tab-completion (chainweaver --install-completion).
inspect and viz resolve flows from disk or a registry.
Pass --file <path>, --discover-dir <dir>, or --discover-entry-points to
resolve a flow without writing any Python (issue #381); chainweaver flows list previews what is discoverable. With no discovery flag they fall back to a
process-scoped, in-memory registry installed programmatically — running
chainweaver inspect my_flow with neither a flag nor a configured registry
exits 1 with No registry configured. Call chainweaver.cli.set_default_registry(...) before invoking the CLI.. To wire
the default-registry path, use a small entry script:
See docs/cli.md § Programmatic registration
for the full pattern, including why the split exists (file-oriented
commands stay zero-config, registry-oriented commands stay
introspection-friendly).
Development
New contributors: see Your first contribution
in CONTRIBUTING.md for the good-first-issue / good-first-ai-issue onramp
and the step-by-step path to your first PR.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Source: README.md at commit 08be8da
Tools
0Version history
1- v0.12.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts
Other Chain integrations
Agent.chain.tokyo Address Contracts
tokyo.chain.agentOfficial publisher
Lets an assistant rent a Japan mailing address for an agent: browse locations and floors, create a 55 USDC payment intent, and track contracts and events.

Zovo Countdown Chain
Published by GitHub account theluckystrike
Generates a printable countdown calendar to one event — month pages, paper-chain strips or tear-off cards — plus an ICS reminder file.

DeviceChain
io.devicechain
Read-only MCP tools for a self-hosted DeviceChain IoT instance, letting an assistant inspect devices, telemetry and alarms.

BridgePilot — cross-chain route quotes
Published by GitHub account ert1981
BridgePilot — cross-chain route quotes's hosted MCP server; no sign-in required; Streamable HTTP; 1 tool.
BrainChain
com.usebrainchain
Lets an assistant hand a task brief to a frontier model hired and graded by an AI agent, paying in USDG or USDC only for work that passes the quality levels…