Skip to main content
Glama
lkm1developer

Apollo.io MCP Server

employees_of_company

Find employees of a company by entering the company name, website URL, or LinkedIn URL to access contact information and organizational details.

Instructions

Find employees of a company using company name or website/LinkedIn URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
companyYesCompany name
website_urlNoCompany website URL
linkedin_urlNoCompany LinkedIn URL

Implementation Reference

  • Core implementation of the employees_of_company tool: searches for the company by name (optionally filtering by URL), retrieves company ID, then searches for people/employees in that organization.
    async employeesOfCompany(query: EmployeesOfCompanyQuery): Promise<any> {
      try {
        const { company, website_url, linkedin_url } = query;
        
        if (!company) {
          throw new Error('Company name is required');
        }
    
        const strippedWebsiteUrl = stripUrl(website_url);
        const strippedLinkedinUrl = stripUrl(linkedin_url);
        
        // First search for the company
        const companySearchPayload = {
          q_organization_name: company,
          page: 1,
          limit: 100
        };
        
        const mixedCompaniesResponse = await axios.post(
          'https://api.apollo.io/v1/mixed_companies/search', 
          companySearchPayload, 
          {
            headers: {
              'Content-Type': 'application/json',
              'X-Api-Key': this.apiKey
            }
          }
        );
        
        if (!mixedCompaniesResponse.data) {
          throw new Error('No data received from Apollo API');
        }
        
        let organizations = mixedCompaniesResponse.data.organizations;
        if (organizations.length === 0) {
          throw new Error('No organizations found');
        }
        
        // Filter companies by website or LinkedIn URL if provided
        const companyObjs = organizations.filter((item: any) => {
          const companyLinkedin = stripUrl(item.linkedin_url);
          const companyWebsite = stripUrl(item.website_url);
          
          if (strippedLinkedinUrl && companyLinkedin && companyLinkedin === strippedLinkedinUrl) {
            return true;
          } else if (strippedWebsiteUrl && companyWebsite && companyWebsite === strippedWebsiteUrl) {
            return true;
          }
          return false;
        });
        
        // If we have filtered results, use the first one, otherwise use the first from the original search
        const companyObj = companyObjs.length > 0 ? companyObjs[0] : organizations[0];
        const companyId = companyObj.id;
        
        if (!companyId) {
          throw new Error('Could not determine company ID');
        }
        
        // Now search for employees
        const peopleSearchPayload: any = {
          organization_ids: [companyId],
          page: 1,
          limit: 100
        };
        
        // Add optional filters if provided in the tool config
        if (query.person_seniorities) {
          peopleSearchPayload.person_titles = (query.person_seniorities ?? '').split(',').map((item: string) => item.trim());
        }
        
        if (query.contact_email_status) {
          peopleSearchPayload.contact_email_status_v2 = (query.contact_email_status ?? '').split(',').map((item: string) => item.trim());
        }
        
        const peopleResponse = await axios.post(
          'https://api.apollo.io/v1/mixed_people/search', 
          peopleSearchPayload, 
          {
            headers: {
              'Content-Type': 'application/json',
              'X-Api-Key': this.apiKey
            }
          }
        );
        
        if (!peopleResponse.data) {
          throw new Error('No data received from Apollo API');
        }
        
        return peopleResponse.data.people || [];
      } catch (error: any) {
        console.error(`Error finding employees: ${error.message}`);
        return null;
      }
    }
  • src/index.ts:200-221 (registration)
    MCP tool registration in the list of available tools, including name, description, and input schema.
    {
      name: 'employees_of_company',
      description: 'Find employees of a company using company name or website/LinkedIn URL',
      inputSchema: {
        type: 'object',
        properties: {
          company: {
            type: 'string',
            description: 'Company name'
          },
          website_url: {
            type: 'string',
            description: 'Company website URL'
          },
          linkedin_url: {
            type: 'string',
            description: 'Company LinkedIn URL'
          }
        },
        required: ['company']
      }
    }
  • TypeScript interface defining the input parameters for the employeesOfCompany method.
    export interface EmployeesOfCompanyQuery {
      company: string;
      website_url?: string;
      linkedin_url?: string;
      [key: string]: any;
    }
  • MCP server request handler for call_tool requests, which delegates execution to ApolloClient.employeesOfCompany.
    case 'employees_of_company': {
      const result = await this.apollo.employeesOfCompany(args as any);
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(result, null, 2)
        }]
      };
    }
  • Utility function to normalize (strip protocol, www, trailing slash, lowercase) URLs for matching company website and LinkedIn URLs.
    const stripUrl = (url?: string): string | undefined => {
      if (!url) return undefined;
      
      try {
        // Remove protocol (http://, https://)
        let stripped = url.replace(/^https?:\/\//, '');
        
        // Remove www.
        stripped = stripped.replace(/^www\./, '');
        
        // Remove trailing slash
        stripped = stripped.replace(/\/$/, '');
        
        // Convert to lowercase
        stripped = stripped.toLowerCase();
        
        return stripped;
      } catch (error) {
        console.error('Error stripping URL:', error);
        return url;
      }

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/lkm1developer/apollo-io-mcp-server'

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