kya_sign_card
Sign KYA cards with Ed25519 private keys to create secure audit trails for agent safety verification.
Instructions
Sign an existing KYA card with the session's Ed25519 private key.
Args: agent_id: The agent_id of the card to sign. Must call kya_create_card first.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes |
Implementation Reference
- src/agent_safety_mcp/server.py:432-459 (handler)The kya_sign_card function implements the logic to sign an existing KYA card using the Ed25519 private key.
@mcp.tool() def kya_sign_card(agent_id: str) -> dict: """Sign an existing KYA card with the session's Ed25519 private key. Args: agent_id: The agent_id of the card to sign. Must call kya_create_card first. """ if agent_id not in _kya_cards: return {"error": f"No card found for agent_id '{agent_id}'. Create one first."} if _kya_key_name is None: return {"error": "No keypair generated. Call kya_generate_keypair first."} from kya.signer import KEY_DIR priv_path = str(KEY_DIR / f"{_kya_key_name}.key") if not os.path.exists(priv_path): return {"error": f"Private key not found at {priv_path}"} try: signed = sign_card(_kya_cards[agent_id], priv_path) _kya_cards[agent_id] = signed return { "status": "signed", "agent_id": agent_id, "has_signature": "_signature" in signed or "signature" in signed, } except Exception as e: return {"error": str(e)}