Skip to main content
Glama

getCompanies

Retrieve and filter companies from Teamwork using parameters like search terms, tags, and custom fields to manage business relationships.

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

  • The main handler function for the 'getCompanies' tool. It processes input parameters, calls the underlying teamwork service, formats the response as text content, and handles errors.
    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');
      }
    } 
  • The tool definition including name, description, input schema for parameters like searchTerm, page, etc., and annotations.
    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 the 'getCompanies' tool in the toolPairs array, which is used to generate toolDefinitions and toolHandlersMap for MCP tool exposure.
    { definition: getCompanies, handler: handleGetCompanies },
  • Helper service function that performs the actual API call to Teamwork to fetch companies based on params, used by the tool handler.
    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}`);
      }
    };
  • Import statement for the getCompanies tool definition and handler in the central tools index.
    import { getCompaniesDefinition as getCompanies, handleGetCompanies } from './companies/getCompanies.js';
Behavior3/5

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

Annotations indicate readOnlyHint=false, destructiveHint=false, and openWorldHint=false, suggesting this is a non-destructive read operation with closed-world assumptions. The description adds context about filtering capabilities (custom fields, tags, search terms) and implies pagination support, which is useful. However, it doesn't disclose rate limits, authentication needs, or response format details, leaving behavioral gaps.

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

Conciseness4/5

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

The description is concise at two sentences, with the first stating the core purpose and the second elaborating on filtering capabilities. It's front-loaded with the main action. However, the second sentence could be slightly more structured (e.g., listing filter types more clearly), and there's some redundancy ('Get a list' and 'retrieve all').

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 moderate complexity (9 parameters, no output schema), the description is adequate but incomplete. It covers the purpose and filtering scope but lacks details on response format, pagination behavior, error handling, or usage examples. With annotations providing safety hints, it's minimally viable but could better support agent decision-making.

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 all 9 parameters are documented in the schema. The description mentions filtering by 'various parameters including custom fields, tags, search terms, and more,' which adds some high-level context but doesn't provide additional semantics beyond what the schema already specifies. This meets the baseline for high schema coverage.

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: 'Get a list of companies' and 'retrieve all companies for the provided filters.' It specifies the resource (companies) and action (get/retrieve with filtering). However, it doesn't explicitly differentiate from sibling tools like getCompanyById, which retrieves a single company by ID rather than a filtered list.

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 mentions filtering capabilities but doesn't compare to sibling tools like getCompanyById (for single companies) or getPeople (for different resources). There's no mention of prerequisites, exclusions, or typical use cases beyond filtering.

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