Skip to main content
Glama
mmarqueti

ActiveCampaign MCP Server

by mmarqueti

get_contact_by_id

Retrieve a specific contact's details from ActiveCampaign using the contact's unique ID. Access essential contact information for efficient management and analysis.

Instructions

Busca um contato no ActiveCampaign pelo ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contactIdYesID do contato a ser buscado

Implementation Reference

  • The primary handler function that performs the API request to retrieve the contact by ID, calls the format helper, and structures the tool response.
    private async getContactById(contactId: string) {
      try {
        const response = await this.apiClient.get(`/api/3/contacts/${contactId}`, {
          params: {
            include: 'fieldValues,tags,contactLists',
          },
        });
    
        const contact = await this.formatContactData(response.data.contact);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(contact, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new Error(`Erro ao buscar contato por ID: ${error instanceof Error ? error.message : 'Erro desconhecido'}`);
      }
    }
  • Tool definition including name, description, and input schema for parameter validation.
    {
      name: 'get_contact_by_id',
      description: 'Busca um contato no ActiveCampaign pelo ID',
      inputSchema: {
        type: 'object',
        properties: {
          contactId: {
            type: 'string',
            description: 'ID do contato a ser buscado',
          },
        },
        required: ['contactId'],
      },
    },
  • src/index.ts:62-65 (registration)
    Tool registration in the MCP server's CallToolRequest handler by checking name against contactToolNames and delegating to ContactTools.
    const contactToolNames = ['get_contact_by_email', 'get_contact_by_id', 'search_contacts'];
    if (contactToolNames.includes(name)) {
      return await this.contactTools.executeTool(name, args);
    }
  • Internal registration/dispatch in ContactTools.executeTool via switch case that routes 'get_contact_by_id' to the handler.
    // Executar ferramenta de contato
    async executeTool(name: string, args: any) {
      switch (name) {
        case 'get_contact_by_email':
          return await this.getContactByEmail(args?.email as string);
        case 'get_contact_by_id':
          return await this.getContactById(args?.contactId as string);
        case 'search_contacts':
          return await this.searchContacts(args?.query as string, args?.limit as number);
        default:
          throw new Error(`Ferramenta de contato desconhecida: ${name}`);
      }
    }
  • Supporting helper that enriches raw contact data with human-readable field names, tags, and list information via additional API calls.
    private async formatContactData(rawContact: any): Promise<ActiveCampaignContact> {
      const contact: ActiveCampaignContact = {
        id: rawContact.id,
        email: rawContact.email,
        firstName: rawContact.firstName || '',
        lastName: rawContact.lastName || '',
        phone: rawContact.phone || '',
        cdate: rawContact.cdate,
        udate: rawContact.udate,
      };
    
      // Buscar valores de campos customizados
      if (rawContact.fieldValues) {
        try {
          const fieldsResponse = await this.apiClient.get('/api/3/fields');
          const fields = fieldsResponse.data.fields || [];
          
          contact.fieldValues = rawContact.fieldValues.map((fv: any) => {
            const field = fields.find((f: any) => f.id === fv.field);
            return {
              field: field ? field.title : fv.field,
              value: fv.value,
            };
          });
        } catch (error) {
          console.error('Erro ao buscar campos customizados:', error);
        }
      }
    
      // Buscar tags
      if (rawContact.tags) {
        try {
          const tagsResponse = await this.apiClient.get('/api/3/tags');
          const allTags = tagsResponse.data.tags || [];
          
          contact.tags = rawContact.tags.map((tagId: string) => {
            const tag = allTags.find((t: any) => t.id === tagId);
            return tag ? tag.tag : tagId;
          });
        } catch (error) {
          console.error('Erro ao buscar tags:', error);
        }
      }
    
      // Buscar listas
      if (rawContact.contactLists) {
        try {
          const listsResponse = await this.apiClient.get('/api/3/lists');
          const allLists = listsResponse.data.lists || [];
          
          contact.lists = rawContact.contactLists.map((cl: any) => {
            const list = allLists.find((l: any) => l.id === cl.list);
            return {
              list: list ? list.name : cl.list,
              status: cl.status,
            };
          });
        } catch (error) {
          console.error('Erro ao buscar listas:', error);
        }
      }
    
      return contact;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states this is a search operation, implying it's read-only and non-destructive, but doesn't confirm this explicitly. It lacks details on error handling (e.g., what happens if the ID is invalid), rate limits, authentication requirements, or return format. For a tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Portuguese that directly states the tool's function. It's front-loaded with the core purpose and wastes no words, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (single parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks behavioral details and usage guidance. For a simple lookup tool, this might suffice, but it doesn't provide a complete picture for optimal agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal value beyond the input schema. It mentions 'pelo ID' (by ID), which aligns with the schema's 'contactId' parameter, but doesn't provide additional context like ID format or examples. With 100% schema description coverage (the schema fully documents the single parameter), the baseline is 3, as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Busca um contato no ActiveCampaign pelo ID' (Search for a contact in ActiveCampaign by ID). It specifies the verb (search), resource (contact), and method (by ID). However, it doesn't explicitly differentiate from sibling tools like get_contact_by_email, which is a similar lookup by different identifier.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like get_contact_by_email (for email-based lookup) or search_contacts (for broader searches), nor does it specify prerequisites or exclusions. The agent must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/mmarqueti/activecampaign-mcp-server'

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