read_conversation
Read the full message history of a social media DM or comment thread by providing conversation and account IDs.
Instructions
Read messages in a social media conversation.
Get the full message history of a DM or comment thread.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conversation_id | Yes | Conversation ID (from list_inbox results) | |
| account_id | Yes | Social account ID that received the messages | |
| org_id | No | Organization ID (uses YAPARAI_ORG_ID env var if not provided) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/yaparai/tools/social.py:203-223 (handler)The main handler function for the 'read_conversation' tool. It takes conversation_id, account_id, and optional org_id, resolves org_id, and calls client.social_get_conversation() to fetch full message history of a DM or comment thread.
async def read_conversation( conversation_id: str, account_id: str, org_id: str | None = None, ) -> dict: """ Read messages in a social media conversation. Get the full message history of a DM or comment thread. Args: conversation_id: Conversation ID (from list_inbox results) account_id: Social account ID that received the messages org_id: Organization ID (uses YAPARAI_ORG_ID env var if not provided) Returns: Dict with conversation messages, sender info, and timestamps. """ oid = resolve_org_id(org_id) client = YaparAIClient() return await client.social_get_conversation(oid, conversation_id, account_id) - src/yaparai/server.py:164-164 (registration)The tool registration line where 'read_conversation' is registered with the MCP server via mcp.tool().
mcp.tool(read_conversation) - src/yaparai/client.py:243-249 (helper)The underlying API client method (social_get_conversation) that sends the actual HTTP GET request to the conversation endpoint with the account_id parameter.
async def social_get_conversation(self, org_id: str, conv_id: str, account_id: str) -> dict: """Get conversation messages.""" return await self._request( "GET", f"/api/enterprise/orgs/{org_id}/social/inbox/{conv_id}", params={"account_id": account_id}, ) - src/yaparai/tools/_org.py:6-18 (helper)Helper utility that resolves the org_id parameter (uses YAPARAI_ORG_ID env var as fallback). Used by the read_conversation handler.
def resolve_org_id(org_id: str | None = None) -> str: """Return the org_id from parameter or YAPARAI_ORG_ID env var. Raises ValueError if neither is set. """ oid = org_id or YAPARAI_ORG_ID if not oid: raise ValueError( "Organization ID is required. Either pass org_id parameter " "or set the YAPARAI_ORG_ID environment variable. " "Use list_organizations() to find your org ID." ) return oid