deleteCompany
Remove a company and all associated data using the companyId parameter. This tool ensures complete deletion from the Teamwork MCP server.
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
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companyId | Yes | Path parameter: companyId |
Implementation Reference
- The handler function for the deleteCompany MCP tool. It validates input, calls the teamwork service to delete the company, and returns a formatted MCP 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) { logger.error(`Error in deleteCompany handler: ${error.message}`); return { content: [{ type: "text", text: `Error deleting company: ${error.message}` }] }; } }
- The schema definition for the deleteCompany tool, including name, description, inputSchema, and annotations.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 } };
- src/tools/index.ts:91-91 (registration)Registration of the deleteCompany tool in the toolPairs array, associating its definition with the handler function.{ definition: deleteCompany, handler: handleDeleteCompany },
- src/tools/index.ts:40-40 (registration)Import statement for deleteCompany tool definition and handler in the tools index.import { deleteCompanyDefinition as deleteCompany, handleDeleteCompany } from './companies/deleteCompany.js';
- The service-level helper function that performs the actual API deletion of the company.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}`); } };