get_company
Fetch detailed company information from Tracxn using a unique company identifier to access comprehensive business data and insights.
Instructions
Fetch detailed information about a company from Tracxn
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companyId | Yes | The unique identifier of the company |
Implementation Reference
- src/handlers/tools.ts:89-131 (handler)Executes the get_company tool: parses arguments, validates companyId, calls Tracxn API to fetch company details, handles errors, and returns JSON response.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; if (!args) { throw new Error('No arguments provided'); } if (name !== 'get_company') { throw new Error(`Unknown tool: ${name}`); } // Check if API key is available if (!process.env.TRACXN_API_KEY) { throw new Error('TRACXN_API_KEY environment variable is not set'); } const toolArgs = args as unknown as ToolArgs; if (!toolArgs.companyId) { throw new Error('companyId is required'); } try { const response = await tracxnClient.get(`/companies/${toolArgs.companyId}`); // Check if response is HTML (login page) if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) { throw new Error('Received HTML response instead of JSON. This usually means authentication failed. Please check your API key.'); } return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2) }], isError: false }; } catch (error: any) { if (error.response?.status === 401) { throw new Error('Authentication failed. Please check your API key.'); } else if (error.response?.status === 403) { throw new Error('Access forbidden. Please check your API key permissions.'); } else if (error.response?.status === 404) { throw new Error(`Company with ID ${toolArgs.companyId} not found.`); } else { throw new Error(`API request failed: ${error.message}`); } } });
- src/handlers/tools.ts:58-80 (schema)Defines the tool schema including input (companyId string) and output (id, name, description).const getCompanyTool: Tool = { name: 'get_company', description: 'Fetch detailed information about a company from Tracxn', inputSchema: { type: 'object', properties: { companyId: { type: 'string', description: 'The unique identifier of the company' } }, required: ['companyId'] }, outputSchema: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' }, description: { type: 'string' } }, required: ['id', 'name'] } };
- src/handlers/tools.ts:83-87 (registration)Registers get_company tool to be discoverable via ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async (request) => { return { tools: [getCompanyTool] }; });
- src/index.ts:42-42 (registration)Invokes registration of tools including get_company on the main MCP server instance.await registerTracxnTools(server);