Skip to main content
Glama

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)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
unread_onlyNo

Implementation Reference

  • 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
            ],
        }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/The-Nexus-Guard/aip-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server