Get company profile
get_companyRetrieve an enriched UK company profile using its Companies House number, providing detailed business information beyond basic API data.
Instructions
Get an enriched profile for a UK company by its Companies House number. Returns name, status, type, incorporation date, registered address, SIC codes with descriptions, accounts status, confirmation statement status, and derived fields like company_age_years and accounts.overdue that are not available from the raw Companies House API.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| company_number | Yes | Companies House company number, e.g. '00445790' for Tesco PLC. Numeric-only numbers should be zero-padded to 8 digits. |
Implementation Reference
- src/server.ts:109-116 (handler)Handler function for get_company tool that takes a company_number parameter, calls the API endpoint /company/{company_number}, and returns the company profile data or error
async ({ company_number }) => { try { const data = await api(`/company/${company_number}`); return text(data); } catch (e) { return err(String(e)); } } - src/server.ts:99-107 (schema)Input schema for get_company tool defining company_number parameter with Zod validation (must be 1-8 alphanumeric characters, regex pattern /^[A-Z0-9]{1,8}$/)
inputSchema: { company_number: z .string() .regex(/^[A-Z0-9]{1,8}$/, "Must be 1–8 alphanumeric characters") .describe( "Companies House company number, e.g. '00445790' for Tesco PLC. " + "Numeric-only numbers should be zero-padded to 8 digits." ), }, - src/server.ts:89-117 (registration)Registration of get_company tool with McpServer, including title, description, inputSchema, and handler function
server.registerTool( "get_company", { title: "Get company profile", description: "Get an enriched profile for a UK company by its Companies House number. " + "Returns name, status, type, incorporation date, registered address, SIC codes " + "with descriptions, accounts status, confirmation statement status, and derived " + "fields like company_age_years and accounts.overdue that are not available from " + "the raw Companies House API.", inputSchema: { company_number: z .string() .regex(/^[A-Z0-9]{1,8}$/, "Must be 1–8 alphanumeric characters") .describe( "Companies House company number, e.g. '00445790' for Tesco PLC. " + "Numeric-only numbers should be zero-padded to 8 digits." ), }, }, async ({ company_number }) => { try { const data = await api(`/company/${company_number}`); return text(data); } catch (e) { return err(String(e)); } } ); - src/server.ts:7-25 (helper)callApi helper function that makes authenticated API requests to the registrum API with API key header and error handling
export async function callApi( path: string, apiKey: string, baseUrl: string = API_BASE ): Promise<unknown> { if (!apiKey) { throw new Error( "REGISTRUM_API_KEY is not set. Get a free key at https://registrum.co.uk and set it in your MCP client config." ); } const res = await fetch(`${baseUrl}${path}`, { headers: { "X-API-Key": apiKey }, }); if (!res.ok) { const body = await res.text(); throw new Error(`API error ${res.status}: ${body}`); } return res.json(); } - src/server.ts:27-38 (helper)Helper functions text() and err() for formatting successful and error responses in MCP tool format
function text(content: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(content, null, 2) }], }; } function err(message: string) { return { isError: true as const, content: [{ type: "text" as const, text: message }], }; }