aip_check_messages
Retrieve messages sent to your AI agent, with options to filter for unread messages only.
Instructions
Check for messages sent to your agent.
Args: unread_only: If True, only return unread messages (default: True)
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "aip_check_messages"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| unread_only | No |
Implementation Reference
- aip_mcp_server/server.py:231-282 (handler)The implementation of the aip_check_messages MCP tool, which authenticates with the service and retrieves messages.
@mcp.tool() def aip_check_messages(unread_only: bool = True) -> dict: """Check for messages sent to your agent. Args: unread_only: If True, only return unread messages (default: True) """ import requests client = _load_client() # Get challenge ch_resp = requests.post( f"{client.service_url}/challenge", json={"did": client.did}, timeout=10, ) if not ch_resp.ok: return {"error": f"Challenge failed: {ch_resp.text}"} challenge = ch_resp.json().get("challenge") # Sign challenge signature = client.sign(challenge.encode()) # Retrieve messages msg_resp = requests.post( f"{client.service_url}/messages", json={ "did": client.did, "challenge": challenge, "signature": signature, "unread_only": unread_only, }, timeout=15, ) if not msg_resp.ok: return {"error": f"Failed to retrieve messages: {msg_resp.text}"} data = msg_resp.json() messages = data.get("messages", []) return { "count": data.get("count", len(messages)), "messages": [ { "id": m.get("id"), "from": m.get("sender_did"), "timestamp": m.get("created_at", m.get("timestamp")), "encrypted": bool(m.get("encrypted_content")), } for m in messages ], }