get-threads
Retrieve email threads from Gmail using search queries to filter and organize messages for AI meme generation workflows.
Instructions
Get email threads
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | Maximum number of threads to retrieve | |
| query | No | Gmail search query to filter threads |
Implementation Reference
- src/tools.ts:447-486 (handler)The core handler function for the 'get-threads' tool. It uses the VercelAIToolSet (Composio) to execute the 'GMAIL_GET_THREADS' action with the provided parameters, processes the returned threads into a formatted list, and returns a text response with success or error details.}, async (args, extra) => { try { const userAddress = "default-user"; const result = await toolset.executeAction({ action: "GMAIL_GET_THREADS", entityId: userAddress, params: args }); if (result.successful) { const threads = result.data?.response_data as any; const threadList = threads.threads?.map((thread: any) => `• Thread ${thread.id} (${thread.snippet})` ).join('\n') || 'No threads found'; return { content: [{ type: "text", text: `🧵 Threads retrieved successfully!\n\n${threadList}\n\nTotal: ${threads.threads?.length || 0} threads` }], }; } else { return { content: [{ type: "text", text: `❌ Failed to get threads: ${result.error || 'Unknown error'}` }], }; } } catch (error) { console.error('Error getting threads:', error); return { content: [{ type: "text", text: `Error getting threads: ${error instanceof Error ? error.message : String(error)}` }], }; } });
- src/tools.ts:444-447 (schema)Input schema definition for the 'get-threads' tool using Zod. Defines optional parameters: maxResults (number) and query (string). Provided during tool registration.server.tool("get-threads", "Get email threads", { maxResults: z.number().optional().describe("Maximum number of threads to retrieve"), query: z.string().optional().describe("Gmail search query to filter threads"), }, async (args, extra) => {
- src/tools.ts:444-486 (registration)Registration of the 'get-threads' tool using server.tool() inside the registerTools function. Includes name, description, schema, and inline handler.server.tool("get-threads", "Get email threads", { maxResults: z.number().optional().describe("Maximum number of threads to retrieve"), query: z.string().optional().describe("Gmail search query to filter threads"), }, async (args, extra) => { try { const userAddress = "default-user"; const result = await toolset.executeAction({ action: "GMAIL_GET_THREADS", entityId: userAddress, params: args }); if (result.successful) { const threads = result.data?.response_data as any; const threadList = threads.threads?.map((thread: any) => `• Thread ${thread.id} (${thread.snippet})` ).join('\n') || 'No threads found'; return { content: [{ type: "text", text: `🧵 Threads retrieved successfully!\n\n${threadList}\n\nTotal: ${threads.threads?.length || 0} threads` }], }; } else { return { content: [{ type: "text", text: `❌ Failed to get threads: ${result.error || 'Unknown error'}` }], }; } } catch (error) { console.error('Error getting threads:', error); return { content: [{ type: "text", text: `Error getting threads: ${error instanceof Error ? error.message : String(error)}` }], }; } });