Portable MCP server for agent handoff state and review tracking.
Project description
Agent Handoff MCP
Portable MCP server for agent handoff state, review findings, exports, close checks, and lane-scoped worker/orchestrator coordination.
Scope
This package owns handoff state and related workflow primitives:
- task state, decisions, blockers, and next actions
- review findings and review runs
- generated
CURRENT_TASK.jsonsnapshots - lane registration, lane activity, worker reports, and lane messages
- artifact indexing and derived metrics snapshots
It does not include unrelated repo-intel or UI helpers.
Runtime State
By default, runtime state lives under the workspace you point the CLI at:
- SQLite DB:
.task-state/handoff.db - exports:
.task-state/exports/ - generated markdown:
CURRENT_TASK.json
Override these with CLI flags or AGENT_HANDOFF_* environment variables.
Installation
From PyPI (recommended)
pip install mcp-agent-handoff
# or, as an isolated tool:
uv tool install mcp-agent-handoff
# or, ad-hoc without installing:
uvx mcp-agent-handoff --workspace-root /path/to/workspace serve-stdio
From the monorepo source tree (development)
From this package root inside agentic-protocol-monorepo:
cd packages/mcp-agent-handoff
python -m pip install -e ".[dev]"
Development
All package-local development commands are intended to run from the package root:
make lint-handoff
make fix-lint-handoff
make format-handoff
make mypy-handoff
make test-handoff
make check-handoff
Prefer the package-local Make targets when running checks from editors or agent sessions. Workspace-level interpreter discovery can point at a minimal environment that lacks this package's dev extras such as pytest, while make test-handoff and make check-handoff keep execution anchored to the package root and honor PYTHON=/path/to/python3 overrides when you need to pin a specific interpreter.
The Makefile automatically adds a sibling ../codex-subagent-bridge/src to PYTHONPATH when that checkout exists. In a fully extracted repo, that fallback is unnecessary once dependencies are installed normally.
Direct commands also work:
PYTHONPATH=src python -m ruff check src tests
PYTHONPATH=src python -m mypy src
PYTHONPATH=src python -m pytest tests -q
Python API
The package can be used directly as a library — this is the primary fallback when MCP tool calls are unavailable.
Always import from the package root (agent_handoff_mcp), never from submodules like .config, .decisions, or .core. Submodules are internal and may change.
from pathlib import Path
from agent_handoff_mcp import (
RuntimeConfig,
configure_runtime,
get_handoff_state,
search_handoff,
record_event,
review_findings,
list_review_findings,
set_handoff_state,
update_task_status,
get_verified_tests,
render_handoff,
record_file_touch,
get_touched_files,
)
# Configure runtime before any read/write call
configure_runtime(RuntimeConfig.for_repo(Path("/path/to/workspace")))
# Read state
state = get_handoff_state(sections="identity")
# Search decisions
results = search_handoff(queries=["slice_complete"], record_types=["decision"], limit=5)
# List open findings
findings = list_review_findings(status="open")
Without installation (monorepo source tree):
PYTHONPATH=packages/mcp-agent-handoff/src python3 -c "
from pathlib import Path
from agent_handoff_mcp import RuntimeConfig, configure_runtime, get_handoff_state
configure_runtime(RuntimeConfig.for_repo(Path('.')))
state = get_handoff_state(sections='identity')
print(state['data']['active']['task_ref'])
"
CLI Usage
Run the MCP server over stdio:
mcp-agent-handoff --workspace-root /path/to/workspace serve-stdio
Run the MCP server over HTTP:
mcp-agent-handoff --workspace-root /path/to/workspace serve-http
FastMCP's current HTTP defaults are:
- host:
127.0.0.1 - port:
8000 - path:
/mcp
Useful CLI checks:
mcp-agent-handoff --workspace-root /path/to/workspace doctor
mcp-agent-handoff --workspace-root /path/to/workspace state
mcp-agent-handoff --workspace-root /path/to/workspace review-findings --operation list
mcp-agent-handoff --workspace-root /path/to/workspace handoff-close-check
Review Intake
Preferred path when agent-orchestrator-mcp is available:
get_latest_slice_review_packetget_review_findings_summaryorreview_findings --operation listas needed
Handoff-only fallback:
load_sessionsearch_handoff(queries=["slice_complete"], record_types=["decision"], limit=1)get_verified_tests(task_ref=..., commit_sha=...)review_findings(review={"operation":"list","status":"open"})
Use the MCP read surfaces above before inspecting .task-state/handoff.db directly. Drop to raw SQLite or filesystem inspection only when the required MCP tool is unavailable or when you are debugging MCP transport or serialization failures.
Source-tree execution without installation:
PYTHONPATH=src python -m agent_handoff_mcp --workspace-root /path/to/workspace serve-stdio
Token-Efficient Usage
The v2 envelope is already compact, but callers still save the most tokens by shaping read responses deliberately:
- Use
get_handoff_state(sections="identity")for routine task checks instead of a full state fetch. - Use
detail="summary"on read surfaces such asget_handoff_state,load_session,review_findings,search_handoff, andartifactswhen truncated text is acceptable. - Use
top_n_*,limit=, andfields=to cap read size instead of trimming large payloads client-side.load_sessionacceptstop_n_touched_files(default 20, max 200) to bound the additivetouched_fileslist. - Read from the canonical
datablock —result["data"]["active"]etc. The legacy top-level mirror was removed in 0.3.0 and never returns.
Package-local guidance and examples live in docs/guides/token-efficient-usage.md.
Wire format note (≥0.3.0)
Starting in agent-handoff-mcp 0.3.0, MCP tool responses are native JSON
objects on the wire, not JSON strings inside structured_content.result.
Every handler is annotated -> dict and returns a real dict via
_envelope(); FastMCP serialises it once. If you previously did
json.loads(handoff_tool(...)) to parse a JSON string return value, drop
the json.loads — the call returns a dict directly. If you previously
read result.content[0].text from the MCP wire payload and parsed it,
read result.structured_content directly instead.
The envelope field set is unchanged (ok, schema_version, tool,
scope, data, mutation, artifacts, warnings, task_ref) and
schema_version stays at 2. Only the wire-encoding moved from
JSON-string-inside-JSON to a native nested object. See
CHANGELOG.md for the full migration notice.
Client Adapter Shape
Installed console-script adapter:
{
"name": "altcontext-mcp",
"command": "mcp-agent-handoff",
"args": ["--workspace-root", "/path/to/workspace", "serve-stdio"]
}
Source checkout adapter:
{
"name": "altcontext-mcp",
"command": "python3",
"args": [
"-m",
"agent_handoff_mcp",
"--workspace-root",
"/path/to/workspace",
"serve-stdio"
],
"cwd": "/path/to/mcp-agent-handoff",
"env": {
"PYTHONPATH": "/path/to/mcp-agent-handoff/src"
}
}
Tool Surface
mcp-agent-handoff now exposes a single 22-tool MCP surface.
Legacy --tool-profile all|core|extended inputs are still accepted for compatibility, but they all expose the same tool set:
mcp-agent-handoff --workspace-root /path/to/workspace --tool-profile core serve-stdio
Unified surface (22 tools)
| CLI name | MCP tool |
|---|---|
state |
get_handoff_state |
set |
set_handoff_state |
event |
record_event |
next-actions |
next_actions |
review-findings |
review_findings |
review-runs |
review_runs |
handoff-close-check |
handoff_close_check |
render-handoff |
render_handoff (kind=current_task/dashboard) |
| (no CLI) | load_session |
| (no CLI) | close_slice |
audit-decisions |
audit_decision_ids |
export |
export_handoff_state |
import |
import_handoff_state |
archive |
archive_task_state |
task-status |
update_task_status |
artifacts |
artifacts |
handoff-search |
search_handoff |
get-verified-tests |
get_verified_tests |
get-archived-task |
get_archived_task |
record-file-touch |
record_file_touch |
get-touched-files |
get_touched_files |
record_event uses a typed event payload with event_kind="decision" | "test_result" | "blocker" so each variant keeps its own required fields.
next_actions uses operation="list" | "add" | "update" | "complete" | "skip".
review_findings uses operation="record" | "batch_record" | "update" | "list".
review_runs uses operation="record" | "list" | "coverage".
Branch/worktree drift is surfaced through warnings on write responses. If you
set AGENT_HANDOFF_ENFORCE_BRANCH=1, branch mismatches against the active
task's target_branch fail before mutation on enforceable branches. Direct
Python callers see BranchMismatchError; MCP clients receive the standard v2
error envelope with data.expected_branch and data.actual_branch.
CLI-only extras (not part of MCP registry): artifact-list, artifact-terms.
Surface classes:
action: mutates canonical state; do not blind-retryquery: read-only inspection of canonical state; usually safe to retrygenerator: derived output such as close checks, markdown renders, and metrics summaries
Troubleshooting
The fastest first check is still:
mcp-agent-handoff --workspace-root /path/to/workspace doctor
If startup succeeds but calls fail, check the workspace paths first: --workspace-root, --state-dir, --current-task-path, and --exports-dir must all point at the same workspace state.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_agent_handoff-0.5.1.tar.gz.
File metadata
- Download URL: mcp_agent_handoff-0.5.1.tar.gz
- Upload date:
- Size: 244.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7db324b409afaf82c08f7c43bec186e17eac62f8937911151a871479726a1a18
|
|
| MD5 |
563d28dccde4dffcb337f60dcdc26fe4
|
|
| BLAKE2b-256 |
74c1008249d3a2aea7649739ad9fb18cf86e6de1931e9bf59e9045e2a87e4a7d
|
File details
Details for the file mcp_agent_handoff-0.5.1-py3-none-any.whl.
File metadata
- Download URL: mcp_agent_handoff-0.5.1-py3-none-any.whl
- Upload date:
- Size: 143.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4c15c166e5173191e3fb15272f5b432e974fbf7dae65388b66e3e6fd19a4067
|
|
| MD5 |
90e5857f97060addec2d5cf38cbe4964
|
|
| BLAKE2b-256 |
61e9d1197fec13e953918e4bfa58103d2fdce6449e3dc646900bec87de100761
|