Skip to main content
Glama

getCompanyById

Retrieve detailed company information by ID from the Teamwork MCP server. Use this tool to access company data, custom fields, profiles, and task statistics.

Instructions

Get a specific company by ID. Retrieves detailed information about a company identified by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
companyIdYesThe ID of the company to retrieve
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 'getCompanyById' MCP tool. It processes the input, calls the underlying teamwork service, handles errors, and returns a formatted response.
    export async function handleGetCompanyById(input: any) { logger.info('Calling teamworkService.getCompanyById()'); logger.info(`Company ID: ${input?.companyId}`); try { const companyId = input.companyId; if (!companyId) { throw new Error("Company ID is required"); } // Prepare query parameters const params = { ...input }; delete params.companyId; // Remove companyId from params as it's used in the path const result = await teamworkService.getCompanyById(companyId, params); logger.info(`Successfully retrieved company with ID: ${companyId}`); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { return createErrorResponse(error, 'Retrieving company'); } }
  • The schema/definition for the 'getCompanyById' tool, including name, description, input schema with properties like companyId, and annotations.
    export const getCompanyByIdDefinition = { name: "getCompanyById", description: "Get a specific company by ID. Retrieves detailed information about a company identified by its ID.", inputSchema: { type: 'object', properties: { companyId: { type: 'integer', description: 'The ID of the company to retrieve' }, 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' } }, required: ['companyId'] }, annotations: { title: "Get Company by ID", readOnlyHint: false, destructiveHint: false, openWorldHint: false } };
  • Registration of the getCompanyById tool in the central toolPairs array, associating its definition and handler for use in the MCP tools system.
    { definition: getCompanyById, handler: handleGetCompanyById },
  • The helper service function that performs the actual API call to retrieve the company by ID from Teamwork, used by the tool handler.
    export const getCompanyById = async (companyId: number, params: any = {}) => { try { logger.info(`Fetching company with ID ${companyId} from Teamwork API`); const api = ensureApiClient(); const response = await api.get(`companies/${companyId}.json`, { params }); logger.info(`Successfully retrieved company with ID ${companyId}`); return response.data; } catch (error: any) { logger.error(`Error fetching company with ID ${companyId}: ${error.message}`); throw new Error(`Failed to fetch company with ID ${companyId}: ${error.message}`); } };

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