Skip to main content
Glama

AgentMail

by agentmail-to
wrapper.ts1.08 kB
import { AgentMailClient } from 'agentmail' export class Wrapper { constructor(private readonly client = new AgentMailClient()) {} public async call(method: string, args: Record<string, any>) { const parts = method.split('.') const methodKey = parts.pop() if (!methodKey) throw new Error('Method name empty') let parent: any = this.client for (const part of parts) parent = parent[part] const { inbox_id, thread_id, message_id, draft_id, attachment_id, ...options } = args const methodArgs = [inbox_id, thread_id, message_id, draft_id, attachment_id, options].filter(Boolean) return await parent[methodKey].call(parent, ...methodArgs) } public async safeCall(method: string, args: Record<string, any>) { try { return { isError: false, result: await this.call(method, args) } } catch (error) { if (error instanceof Error) return { isError: true, result: error.message } else return { isError: true, result: 'Unknown error' } } } }

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/agentmail-to/agentmail-toolkit'

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