Skip to main content
Glama

getPersonById

Retrieve specific person details by their ID using the Teamwork MCP server. Simplifies access to individual data within Teamwork projects and tasks.

Instructions

Get a specific person by ID from Teamwork

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
personIdYesThe ID of the person to retrieve

Implementation Reference

  • The async handler function that implements the core logic of the getPersonById tool, including input validation, calling the teamworkService.getPersonById helper, error handling, JSON formatting, and returning a text content response.
    export async function handleGetPersonById(input: any) { logger.info('=== getPersonById tool called ==='); logger.info(`Input parameters: ${JSON.stringify(input || {})}`); try { if (!input.personId) { logger.error('Missing required parameter: personId'); return { content: [{ type: "text", text: "Error: Missing required parameter 'personId'" }] }; } const personId = parseInt(input.personId, 10); if (isNaN(personId)) { logger.error(`Invalid personId: ${input.personId}`); return { content: [{ type: "text", text: `Error: Invalid personId. Must be a number.` }] }; } logger.info(`Calling teamworkService.getPersonById(${personId})`); const person = await teamworkService.getPersonById(personId); // Debug the response logger.info(`Person response type: ${typeof person}`); if (person === null || person === undefined) { logger.warn(`Person with ID ${personId} not found or API returned empty response`); return { content: [{ type: "text", text: `No person found with ID ${personId} or API returned empty response.` }] }; } try { const jsonString = JSON.stringify(person, null, 2); logger.info(`Successfully stringified person response`); logger.info('=== getPersonById tool completed successfully ==='); return { content: [{ type: "text", text: jsonString }] }; } catch (jsonError: any) { logger.error(`JSON stringify error: ${jsonError.message}`); return { content: [{ type: "text", text: `Error formatting response: ${jsonError.message}` }] }; } } catch (error: any) { logger.error(`Error in getPersonById tool: ${error.message}`); return { content: [{ type: "text", text: `Error: ${error.message}` }] }; }
  • The tool definition object including name, description, inputSchema (requiring personId as integer), and annotations for the getPersonById tool.
    export const getPersonByIdDefinition = { name: "getPersonById", description: "Get a specific person by ID from Teamwork", inputSchema: { type: "object", properties: { personId: { type: "integer", description: "The ID of the person to retrieve" } }, required: ["personId"] }, annotations: { title: "Get a Person by their ID", readOnlyHint: false, destructiveHint: false, openWorldHint: false } };
  • Registration of the getPersonById tool by pairing its definition and handler in the toolPairs array, which populates toolDefinitions and toolHandlersMap for MCP tool exposure.
    { definition: getPersonById, handler: handleGetPersonById },
  • Supporting service function that performs the actual API call to retrieve person data from Teamwork (/people/{id}.json), used by the tool handler via teamworkService.getPersonById.
    export const getPersonById = async (personId: number, params?: Omit<PeopleQueryParams, 'personId'>) => { try { logger.info(`Fetching person with ID ${personId} from Teamwork API`); const api = ensureApiClient(); const response = await api.get(`/people/${personId}.json`, { params }); logger.info(`Successfully fetched person with ID ${personId}`); return response.data; } catch (error: any) { logger.error(`Teamwork API error: ${error.message}`); throw new Error(`Failed to fetch person with ID ${personId} from Teamwork API`); } };

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