updatePerson
Modify user details in Teamwork, including timezone, name, email, job title, and permissions, using the person ID to identify and update specific records.
Instructions
Update a person in Teamwork. This endpoint allows you to modify user information like timezone, name, email, etc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| administrator | No | Make this person an administrator | |
| company-id | No | ID of the company the person belongs to | |
| email-address | No | Email address of the person | |
| first-name | No | First name of the person | |
| last-name | No | Last name of the person | |
| personId | Yes | The ID of the person to update | |
| phone-number-office | No | Office phone number | |
| timezoneId | No | Timezone ID for the person | |
| title | No | Job title or position of the person | |
| user-type | No | User type (account, collaborator, contact) |
Implementation Reference
- src/tools/people/updatePerson.ts:69-117 (handler)The handler function that implements the core logic of the 'updatePerson' tool, processing input, validating, calling the service, and formatting the response.export async function handleUpdatePerson(input: any) { logger.info('Calling teamworkService.updatePerson()'); logger.info(`Person ID: ${input.personId}`); try { const personId = input.personId; if (!personId) { throw new Error("Person ID is required"); } // Create update data object with the person wrapper const updateData: { person: Record<string, any> } = { person: {} }; // Copy all fields from input to updateData.person // except personId which is used for the API path Object.keys(input).forEach(key => { if (key !== 'personId') { updateData.person[key] = input[key]; } }); // Make sure we're not sending an empty update if (Object.keys(updateData.person).length === 0) { throw new Error("At least one field to update must be provided"); } logger.info(`Sending update data: ${JSON.stringify(updateData)}`); const result = await teamworkService.updatePerson(personId, updateData); logger.info(`Successfully updated person with ID: ${personId}`); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { logger.error(`Error in updatePerson handler: ${error.message}`); return { content: [{ type: "text", text: `Error updating person: ${error.message}` }] }; } }
- The tool definition including name, description, input schema, and annotations for the 'updatePerson' tool.export const updatePersonDefinition = { name: "updatePerson", description: "Update a person in Teamwork. This endpoint allows you to modify user information like timezone, name, email, etc.", inputSchema: { type: 'object', properties: { personId: { type: 'integer', description: 'The ID of the person to update' }, // Field names match the Swagger definition "first-name": { type: 'string', description: 'First name of the person' }, "last-name": { type: 'string', description: 'Last name of the person' }, "email-address": { type: 'string', description: 'Email address of the person' }, "title": { type: 'string', description: 'Job title or position of the person' }, "phone-number-office": { type: 'string', description: 'Office phone number' }, "timezoneId": { type: 'integer', description: 'Timezone ID for the person' }, "administrator": { type: 'boolean', description: 'Make this person an administrator' }, "user-type": { type: 'string', description: 'User type (account, collaborator, contact)' }, "company-id": { type: 'integer', description: 'ID of the company the person belongs to' } }, required: ['personId'] }, annotations: { title: "Update a Person", readOnlyHint: false, destructiveHint: false, openWorldHint: false } };
- src/tools/index.ts:88-88 (registration)Registration of the 'updatePerson' tool in the toolPairs array, pairing its definition and handler.{ definition: updatePerson, handler: handleUpdatePerson },
- Helper service function that performs the actual API call to update a person in Teamwork.export const updatePerson = async (personId: number, updateData: any) => { try { logger.info(`Updating person with ID ${personId}`); logger.info(`Update data: ${JSON.stringify(updateData)}`); const api = getApiClientForVersion('v1'); // Note: We use put because this is a v1 API endpoint (the base path is handled by the API client) const response = await api.put(`people/${personId}.json`, updateData); logger.info(`Successfully updated person with ID ${personId}`); return response.data; } catch (error: any) { logger.error(`Error updating person with ID ${personId}: ${error.message}`); throw new Error(`Failed to update person with ID ${personId}: ${error.message}`); } };