get_company
Retrieve comprehensive company data by providing the unique company ID, enabling access to detailed information through the Tracxn MCP Server.
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)Handler for executing the 'get_company' tool: validates arguments, checks API key, fetches company data from Tracxn API using axios, 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)Tool definition including name, description, input schema (requires companyId string), and output schema (id, name required).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 the get_company tool in the MCP tools/list response.server.setRequestHandler(ListToolsRequestSchema, async (request) => { return { tools: [getCompanyTool] }; });
- src/index.ts:42-42 (registration)Top-level call to register all Tracxn tools, including get_company, on the MCP server.await registerTracxnTools(server);