companies.js•4.07 kB
export const companyTools = [
{
name: "list_companies",
description: "List companies with optional filtering and pagination",
inputSchema: {
type: "object",
properties: {
filter: { type: "string", description: "Filter query (JSON string)" },
orderBy: { type: "string", description: "Order by field" },
limit: { type: "number", description: "Number of results (max 100)" },
depth: { type: "number", description: "Query depth for relations" },
startingAfter: { type: "string", description: "Cursor for pagination" },
endingBefore: { type: "string", description: "Cursor for pagination" }
}
}
},
{
name: "create_company",
description: "Create a new company in Twenty CRM",
inputSchema: {
type: "object",
properties: {
name: { type: "string", description: "Company name" },
razaoSocial: { type: "string", description: "Razão Social" },
cnpj: { type: "string", description: "CNPJ" },
domainName: { type: "string", description: "Domain name" },
address: { type: "string", description: "Address" },
employees: { type: "number", description: "Number of employees" },
annualRecurringRevenue: {
type: "object",
properties: {
amountMicros: { type: "number" },
currencyCode: { type: "string" }
},
description: "Annual recurring revenue"
},
idealCustomerProfile: { type: "boolean", description: "Ideal customer profile flag" },
accountOwnerId: { type: "string", format: "uuid", description: "Account owner ID" },
linkedinLink: { type: "object", description: "LinkedIn link" },
xLink: { type: "object", description: "X/Twitter link" },
position: { type: "number", description: "Position" }
},
required: ["name"]
}
},
{
name: "get_company",
description: "Get details of a specific company by ID",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Company ID" },
depth: { type: "number", description: "Query depth for relations" }
},
required: ["id"]
}
},
{
name: "update_company",
description: "Update an existing company's information",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Company ID" },
name: { type: "string" },
razaoSocial: { type: "string" },
cnpj: { type: "string" },
domainName: { type: "string" },
address: { type: "string" },
employees: { type: "number" },
annualRecurringRevenue: { type: "object" },
idealCustomerProfile: { type: "boolean" },
accountOwnerId: { type: "string", format: "uuid" },
linkedinLink: { type: "object" },
xLink: { type: "object" },
position: { type: "number" }
},
required: ["id"]
}
},
{
name: "delete_company",
description: "Delete a company from Twenty CRM",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Company ID" }
},
required: ["id"]
}
}
];
export async function executeCompanyTool(toolName, params, apiClient) {
switch (toolName) {
case "list_companies":
return await apiClient.makeRequest("/companies", "GET", null, params);
case "create_company":
return await apiClient.makeRequest("/companies", "POST", params);
case "get_company":
return await apiClient.makeRequest(`/companies/${params.id}`, "GET", null, { depth: params.depth });
case "update_company":
const { id: companyId, ...companyData } = params;
return await apiClient.makeRequest(`/companies/${companyId}`, "PUT", companyData);
case "delete_company":
return await apiClient.makeRequest(`/companies/${params.id}`, "DELETE");
default:
throw new Error(`Unknown company tool: ${toolName}`);
}
}