coc_status
Get current status and statistics of the Chain of Consciousness, including chain length, timestamps, event counts, and agent counts.
Instructions
Get current status and statistics of the Chain of Consciousness.
Returns:
JSON with chain length, genesis/latest timestamps, event type counts,
agent counts, and chain file pathInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- Tool handler for coc_status: reads the chain from chain.jsonl, counts event types and agents, returns JSON stats including chain length, genesis/latest timestamps, event type counts, agent counts, and chain file path.
@mcp.tool() def coc_status() -> str: """Get current status and statistics of the Chain of Consciousness. Returns: JSON with chain length, genesis/latest timestamps, event type counts, agent counts, and chain file path """ chain = _read_chain() if not chain: return json.dumps({"status": "not_initialized", "message": "No chain found. Call coc_init first."}) types: dict[str, int] = {} agents: dict[str, int] = {} for e in chain: types[e["type"]] = types.get(e["type"], 0) + 1 agents[e["agent"]] = agents.get(e["agent"], 0) + 1 return json.dumps({ "status": "active", "chain_length": len(chain), "genesis_ts": chain[0]["ts"], "latest_ts": chain[-1]["ts"], "latest_seq": chain[-1]["seq"], "event_types": types, "agents": agents, "chain_file": CHAIN_FILE, }) - Helper that reads all entries from chain.jsonl, used by coc_status to load chain data.
def _read_chain() -> list: if not os.path.exists(CHAIN_FILE): return [] entries = [] with open(CHAIN_FILE, "r", encoding="utf-8") as f: for line in f: line = line.strip() if line: entries.append(json.loads(line)) return entries - src/agent_trust_stack_mcp/server.py:538-539 (registration)Decorator @mcp.tool() registers coc_status as an MCP tool.
@mcp.tool() def coc_status() -> str: - Configuration constants defining chain file paths used by coc_status.
CHAIN_DIR = os.environ.get("COC_CHAIN_DIR", os.path.join(os.getcwd(), "chain")) CHAIN_FILE = os.path.join(CHAIN_DIR, "chain.jsonl") META_FILE = os.path.join(CHAIN_DIR, "chain_meta.json") RATINGS_DIR = os.environ.get("ARP_RATINGS_DIR", os.path.join(os.getcwd(), "ratings"))