get_trust_evidence
Provides trust evidence package with chain statistics, anchor counts, and verification result for evaluating agent trustworthiness.
Instructions
Return structured trust evidence for this agent.
Provides a comprehensive trust evidence package including Chain of Consciousness
statistics, anchor counts, latest hash, verification status, and protocol
information. This data can be used by other agents to assess trustworthiness.
No arguments required — reads from the local chain.
Returns:
JSON with chain stats, anchor data, verification result, and protocol metadataInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The MCP tool handler for get_trust_evidence. Decorated with @mcp.tool(). Returns a JSON string with chain stats, anchoring data, identity, verification endpoints, and protocol metadata. Reads the chain file via _read_chain(), verifies integrity via _verify_chain(), counts OTS/TSA anchor proofs, and calculates chain age. Returns a 'no_chain' status if no chain exists.
@mcp.tool() def get_trust_evidence() -> str: """Return structured trust evidence for this agent. Provides a comprehensive trust evidence package including Chain of Consciousness statistics, anchor counts, latest hash, verification status, and protocol information. This data can be used by other agents to assess trustworthiness. No arguments required — reads from the local chain. Returns: JSON with chain stats, anchor data, verification result, and protocol metadata """ chain = _read_chain() if not chain: return json.dumps({ "status": "no_chain", "message": "No Chain of Consciousness initialized. Call coc_init first.", "trust_level": "none", }) report = _verify_chain(chain) # Count anchor proofs anchor_dir = os.path.join(CHAIN_DIR, "anchors") ots_count = 0 tsa_count = 0 if os.path.isdir(anchor_dir): for f in os.listdir(anchor_dir): if f.endswith(".ots"): ots_count += 1 elif f.endswith(".tsr"): tsa_count += 1 # Calculate chain age in days chain_age_days = 0 if chain: try: genesis_dt = datetime.fromisoformat(chain[0]["ts"]) now = datetime.now(timezone.utc) chain_age_days = (now - genesis_dt).days except (ValueError, KeyError): pass evidence = { "status": "active", "trust_level": "verified" if report["is_valid"] else "unverified", "chain": { "length": len(chain), "age_days": chain_age_days, "genesis_timestamp": chain[0]["ts"] if chain else None, "latest_timestamp": chain[-1]["ts"] if chain else None, "genesis_hash": chain[0]["entry_hash"] if chain else None, "head_hash": chain[-1]["entry_hash"] if chain else None, "schema_version": SCHEMA_VERSION, "integrity_verified": report["is_valid"], "verification_error": report.get("error"), "agents": report.get("agents", {}), "event_types": report.get("types", {}), "session_bridges": report.get("session_bridges", 0), "session_mismatches": report.get("session_mismatches", 0), }, "anchoring": { "chain_anchor_events": len(report.get("anchors", [])), "ots_proofs": ots_count, "tsa_proofs": tsa_count, "anchor_types": ["OpenTimestamps/Bitcoin", "RFC3161/TSA"], "latest_anchor": report["anchors"][-1] if report.get("anchors") else None, }, "identity": { "did": "did:web:vibeagentmaking.com", "agent_card": "https://vibeagentmaking.com/.well-known/agent-card.json", "did_document": "https://vibeagentmaking.com/.well-known/did.json", }, "verification_endpoints": { "chain_data": "https://vibeagentmaking.com/chain/chain.jsonl", "chain_verify": "https://vibeagentmaking.com/verify/", "anchor_proofs": "https://vibeagentmaking.com/chain/anchors/", }, "protocols": { "name": "Agent Trust Stack", "website": "https://vibeagentmaking.com", "count": 7, "mcp_server": "pip install agent-trust-stack-mcp", "full_stack": "pip install agent-trust-stack", }, } return json.dumps(evidence) - src/agent_trust_stack_mcp/server.py:1119-1119 (registration)The tool is registered via the @mcp.tool() decorator on line 1119, where 'mcp' is a FastMCP instance created on line 53.
@mcp.tool() - Helper function called by get_trust_evidence to read the chain from the JSONL file.
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 - Helper function called by get_trust_evidence to verify chain integrity (hash linkage, sequence, data hashes).
def _verify_chain(chain: list) -> dict: report = { "is_valid": False, "error": None, "genesis_ts": None, "latest_ts": None, "entry_count": len(chain), "agents": {}, "types": {}, "anchors": [], "session_bridges": 0, "session_mismatches": 0, "schema_versions": {}, } if not chain: report["error"] = "Chain is empty" return report if chain[0]["type"] != "genesis": report["error"] = f"Entry 0 is not genesis (type={chain[0]['type']})" return report if chain[0]["prev_hash"] != "0" * 64: report["error"] = "Genesis prev_hash is not zeros" return report report["genesis_ts"] = chain[0]["ts"] for i, entry in enumerate(chain): if entry["seq"] != i: report["error"] = f"Entry {i}: sequence mismatch (expected {i}, got {entry['seq']})" return report expected_data_hash = _sha256(entry["data"]) if entry["data_hash"] != expected_data_hash: report["error"] = f"Entry {i}: data_hash mismatch" return report if i > 0 and entry["prev_hash"] != chain[i - 1]["entry_hash"]: report["error"] = f"Entry {i}: prev_hash doesn't match entry {i-1} hash" return report payload = f"{entry['seq']}|{entry['ts']}|{entry['type']}|{entry['agent']}|{entry['data_hash']}|{entry['prev_hash']}" expected_hash = _sha256(payload) if entry["entry_hash"] != expected_hash: report["error"] = f"Entry {i}: entry_hash mismatch" return report etype = entry["type"] report["types"][etype] = report["types"].get(etype, 0) + 1 agent = entry["agent"] report["agents"][agent] = report["agents"].get(agent, 0) + 1 if etype == "anchor": report["anchors"].append(entry["ts"]) sv = entry.get("schema_version", "1.0") if sv not in report["schema_versions"]: report["schema_versions"][sv] = {"first": i, "last": i} else: report["schema_versions"][sv]["last"] = i if etype == "session_start" and entry.get("verification"): report["session_bridges"] += 1 if entry.get("commitment_match") is False: report["session_mismatches"] += 1 report["latest_ts"] = chain[-1]["ts"] report["is_valid"] = True return report