Skip to main content
Glama

getCompanies

Retrieve a filtered list of companies using search terms, tags, custom fields, and pagination. Supports sorting and detailed profiles.

Instructions

Get a list of companies, retrieve all companies for the provided filters. This endpoint allows you to filter companies by various parameters including custom fields, tags, search terms, and more.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchTermNoFilter by company name and description
pageNoPage number for pagination
pageSizeNoNumber of items per page
orderByNoField to order results by (e.g., name, dateadded, etc.)
orderModeNoSort order (asc or desc)
tagIdsNoFilter by tag IDs
includeCustomFieldsNoInclude custom fields in the response
fullProfileNoInclude full profile information
getStatsNoInclude stats of company tasks and projects

Implementation Reference

  • Tool handler for 'getCompanies'. Calls teamworkService.getCompanies() with input params and returns the result as text content.
    export async function handleGetCompanies(input: any) {
      logger.info('Calling teamworkService.getCompanies()');
      
      try {
        // Prepare query parameters
        const params = { ...input };
        logger.info(`Query parameters: ${JSON.stringify(params)}`);
        
        const result = await teamworkService.getCompanies(params);
        logger.info(`Successfully retrieved companies. Count: ${result?.companies?.length || 0}`);
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify(result, null, 2)
          }]
        };
      } catch (error: any) {
        return createErrorResponse(error, 'Retrieving companies');
      }
    } 
  • Tool definition/schema for 'getCompanies', including name, description, inputSchema with properties like searchTerm, page, pageSize, orderBy, orderMode, tagIds, includeCustomFields, fullProfile, getStats.
    export const getCompaniesDefinition = {
      name: "getCompanies",
      description: "Get a list of companies, retrieve all companies for the provided filters. This endpoint allows you to filter companies by various parameters including custom fields, tags, search terms, and more.",
      inputSchema: {
        type: 'object',
        properties: {
          searchTerm: {
            type: 'string',
            description: 'Filter by company name and description'
          },
          page: {
            type: 'integer',
            description: 'Page number for pagination'
          },
          pageSize: {
            type: 'integer',
            description: 'Number of items per page'
          },
          orderBy: {
            type: 'string',
            description: 'Field to order results by (e.g., name, dateadded, etc.)'
          },
          orderMode: {
            type: 'string',
            description: 'Sort order (asc or desc)',
            enum: ['asc', 'desc']
          },
          tagIds: {
            type: 'array',
            items: {
              type: 'string'
            },
            description: 'Filter by tag IDs'
          },
          includeCustomFields: {
            type: 'boolean',
            description: 'Include custom fields in the response'
          },
          fullProfile: {
            type: 'boolean',
            description: 'Include full profile information'
          },
          getStats: {
            type: 'boolean',
            description: 'Include stats of company tasks and projects'
          }
        }
      },
      annotations: {
        title: "Get Companies",
        readOnlyHint: false,
        destructiveHint: false,
        openWorldHint: false
      }
    };
  • Registration of getCompanies in the tools array: { definition: getCompanies, handler: handleGetCompanies }.
    { definition: getCompanies, handler: handleGetCompanies },
  • Import of getCompaniesDefinition (aliased as getCompanies) and handleGetCompanies from './companies/getCompanies.js'.
    import { getCompaniesDefinition as getCompanies, handleGetCompanies } from './companies/getCompanies.js';
  • Service function that makes an API GET request to 'companies.json' with optional query params and returns the response data.
    export const getCompanies = async (params: any = {}) => {
      try {
        logger.info('Fetching all companies from Teamwork API');
        
        const api = ensureApiClient();
        const response = await api.get('companies.json', { params });
        
        logger.info(`Successfully retrieved companies. Count: ${response.data?.companies?.length || 0}`);
        return response.data;
      } catch (error: any) {
        logger.error(`Error fetching companies: ${error.message}`);
        throw new Error(`Failed to fetch companies: ${error.message}`);
      }
    };
Behavior1/5

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

The description states 'Get' indicating a read-only operation, but annotations set readOnlyHint=false, contradicting the description. No additional behavioral context is provided beyond the schema.

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?

Two concise sentences with no wasted words, front-loaded with the main purpose.

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?

The description covers basic purpose and filtering but lacks details on pagination, ordering, and optionality of parameters. Adequate for a list endpoint but could be more complete.

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?

Schema description coverage is 100%, so the description adds minimal value. It highlights some filter types (custom fields, tags, search terms) but does not clarify behavior beyond schema.

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

Purpose5/5

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

The description uses specific verb 'Get' and resource 'companies', and mentions filtering capabilities. It clearly distinguishes from sibling getCompanyById by implying list vs single company.

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

Usage Guidelines3/5

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

The description implies when to use (when a filtered list of companies is needed) but does not explicitly state exclusions or alternatives like getCompanyById for single company retrieval.

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

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/Vizioz/Teamwork-MCP'

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