get_contact_by_email
Retrieve contact details from ActiveCampaign using an email address. This tool integrates with the ActiveCampaign MCP Server to simplify contact lookup and management.
Instructions
Busca um contato no ActiveCampaign pelo email
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | Email do contato a ser buscado |
Implementation Reference
- src/tools/contacts.ts:75-110 (handler)Core handler function that performs the API request to ActiveCampaign to retrieve contact by email, handles empty results and errors, formats the contact data, and returns the response in MCP tool format.private async getContactByEmail(email: string) { try { const response = await this.apiClient.get('/api/3/contacts', { params: { email: email, include: 'fieldValues,tags,contactLists', }, }); const contacts = response.data.contacts; if (!contacts || contacts.length === 0) { return { content: [ { type: 'text', text: `Nenhum contato encontrado com o email: ${email}`, }, ], }; } const contact = await this.formatContactData(contacts[0]); return { content: [ { type: 'text', text: JSON.stringify(contact, null, 2), }, ], }; } catch (error) { throw new Error(`Erro ao buscar contato por email: ${error instanceof Error ? error.message : 'Erro desconhecido'}`); } }
- src/tools/contacts.ts:11-24 (schema)Defines the tool metadata: name, description, and input schema requiring an 'email' string parameter.{ name: 'get_contact_by_email', description: 'Busca um contato no ActiveCampaign pelo email', inputSchema: { type: 'object', properties: { email: { type: 'string', description: 'Email do contato a ser buscado', }, }, required: ['email'], }, },
- src/index.ts:47-54 (registration)Registers the get_contact_by_email tool (via contactTools.getTools()) in the MCP server's listTools request handler.this.server.setRequestHandler(ListToolsRequestSchema, async () => { const contactTools = this.contactTools.getTools(); const trackingTools = this.trackingTools.getTools(); return { tools: [...contactTools, ...trackingTools] as Tool[], }; });
- src/index.ts:62-65 (registration)Routes calls to 'get_contact_by_email' to the ContactTools.executeTool method in the MCP server's callTool request handler.const contactToolNames = ['get_contact_by_email', 'get_contact_by_id', 'search_contacts']; if (contactToolNames.includes(name)) { return await this.contactTools.executeTool(name, args); }
- src/tools/contacts.ts:64-65 (handler)Internal dispatch in ContactTools.executeTool that invokes the getContactByEmail handler.case 'get_contact_by_email': return await this.getContactByEmail(args?.email as string);