deleteCompany
Delete a company and all its associated data from Teamwork. Requires the company ID.
Instructions
This tool allows you to delete a company, be careful with this tool as it will delete the company and all associated data. It requires the following parameters: companyId.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companyId | Yes | Path parameter: companyId |
Implementation Reference
- The tool handler function that validates input, calls the service, and returns the result or error response.
export async function handleDeleteCompany(input: any) { logger.info('Calling teamworkService.deleteCompany()'); logger.info(`Company ID: ${input?.companyId}`); try { const companyId = input.companyId; if (!companyId) { throw new Error("Company ID is required"); } const result = await teamworkService.deleteCompany(companyId); logger.info(`Company deleted successfully with ID: ${companyId}`); return { content: [{ type: "text", text: JSON.stringify({ success: result }, null, 2) }] }; } catch (error: any) { return createErrorResponse(error, 'Deleting company'); } } - The tool definition/schema including name, description, inputSchema (requiring companyId integer), and annotations marking it as destructive.
export const deleteCompanyDefinition = { name: "deleteCompany", description: "This tool allows you to delete a company, be careful with this tool as it will delete the company and all associated data. It requires the following parameters: companyId.", inputSchema: { type: 'object', properties: { companyId: { type: 'integer', description: 'Path parameter: companyId' } }, required: [ 'companyId' ] }, annotations: { title: "Delete Company", readOnlyHint: false, destructiveHint: true, openWorldHint: false } }; - The service layer function that performs the actual API call to delete a company via Teamwork's REST API.
export const deleteCompany = async (companyId: number) => { try { logger.info(`Deleting company with ID ${companyId}`); const api = ensureApiClient(); await api.delete(`companies/${companyId}.json`); logger.info(`Successfully deleted company with ID ${companyId}`); return true; } catch (error: any) { logger.error(`Error deleting company with ID ${companyId}: ${error.message}`); throw new Error(`Failed to delete company with ID ${companyId}: ${error.message}`); } }; - src/tools/index.ts:91-91 (registration)Registration of the deleteCompany tool in the toolPairs array, pairing its definition with its handler function.
{ definition: deleteCompany, handler: handleDeleteCompany }, - src/utils/config.ts:256-256 (registration)Registration of deleteCompany in the Companies tool group within the configuration file for permission/feature grouping.
'Companies': ['createCompany', 'updateCompany', 'deleteCompany', 'getCompanies', 'getCompanyById']