v1.2.0-rc.2
Release date: 2026-06-26
PyPI: https://pypi.org/project/madcop/1.2.0rc2/
Full diff: v1.1.0rc.1...v1.2.0rc.2
What is this?
v1.2.0 closes the local-first loop. madcop can now talk to external tool
servers (MCP), trace what it did (JSONL), and remember what it
learned (knowledge brain). Together they make a multi-session agent that
can grow without re-explaining itself.
This is rc.2, a pure fix release over rc.1 (same code + a 1-line
import fix; PyPI does not allow re-uploading the same version).
New in v1.2.0
1. MCP client (stdio transport)
Talk to external tool servers via JSON-RPC 2.0 over the server's
stdin/stdout. Surface mcp://server/... as a tool namespace, mix with
local tools.
import asyncio
from madcop.tools import MCPClient
async def main():
client = MCPClient(command=["python3", "my_mcp_server.py"])
await client.start()
tools = await client.list_tools()
result = await client.call_tool("search_docs", {"query": "madcop"})
await client.stop()
asyncio.run(main())Stdio only in v1.2.0; HTTP/SSE on the v1.3.0 roadmap.
2. Tracing (JSONL dump + viewer)
Every plan-execute run can write a JSONL trace. Each event
(plan_start, step_start, step_end, llm_call, tool_call,
directive, halt, error, plan_end) is one line. Tracer is
thread-safe (lock + per-line flush).
from pathlib import Path
from madcop.agent import Tracer, TraceMiddleware, MiddlewareChain, QianControlMiddleware
chain = MiddlewareChain([
QianControlMiddleware(),
TraceMiddleware(Tracer(Path("~/.madcop/trace.jsonl").expanduser())),
])For a single-run summary, print_summary(read_traces(path)) gives event
counts, duration, and step order.
3. Knowledge brain (PageDB + Dream consolidation)
Long-term memory in a single SQLite file: 8 tables, FTS5 indexed, versioned,
audit-logged, full-text searchable.
from madcop.brain import PageDB, parse, scan
db = PageDB("~/.madcop/brain.db")
parsed = parse("---\ntitle: My lesson\ntype: skill\n---\n\n## Body\nX")
db.save(slug=parsed.slug, title=parsed.title, page_type=parsed.type,
compiled_truth=parsed.compiled_truth, timeline=parsed.timeline,
frontmatter=parsed.frontmatter)
# Search later
hits = db.search("lesson")
# Pre-screen before saving (catches API keys, JWTs, PEM blocks, etc.)
if scan(body):
print("sensitive content — needs human review")Prescreen (sensitive-content guard)
18 regex patterns catch the secrets we never want in the brain: AWS
keys, OpenAI / Anthropic / GitHub / PyPI / HuggingFace tokens, JWTs,
PEM private keys, database connection strings, internal IPs, Chinese
mobile numbers, and .env-style KEY=VALUE pairs. Hits route to
review_queue instead of pages.
Dream consolidation
A Dream pass periodically:
- dedups pages by content hash (older is the survivor; tags and
timeline entries are merged in; links are repointed) - prunes orphan links (defensive; CASCADE handles most)
- marks pages stale by
last_accessed_at
It's a report, not a silent mutator. dry_run=True shows what
would have happened; real runs write one ingest_log row with
operation='consolidate' and a JSON detail blob for audit.
BrainMiddleware
BrainMiddleware plugs into the v1.0 middleware chain. The agent
opts in to memory by writing learn:-prefixed notes in a step
outcome — the middleware parses them, slugifies, and writes to the
brain.
Stats
- Tests: 825/825 pass (was 674 in v1.1.0, +151)
- New modules: 7 in
madcop/brain/, 1 inmadcop/agent/(tracing),
1 inmadcop/tools/(MCP client) - Public surface added:
madcop.brainpackage,Tracer/
TraceMiddlewareinmadcop.agent,MCPClientinmadcop.tools
What's changed since v1.2.0-rc.1
madcop/agent/tracing.py: changedfrom .middleware import ...to
absolutefrom madcop.agent.middleware import ...so that
pip install --no-depsworks without langgraph being installed
(real users were unaffected). Same fix already used in
madcop/brain/middleware.py.
Install
pip install madcop[all]==1.2.0rc2What's not in this release
- HTTP/SSE MCP transport (v1.3.0)
- Vector search in brain (FTS5 is enough at single-user scale)
- Dream auto-merge of non-identical content (we deliberately don't
auto-merge; dedup is safe, merge is dangerous)