Search for companies
search_companyFind UK companies by name to retrieve company numbers, status, type, and registered addresses for business verification and research.
Instructions
Search for UK companies by name. Returns a list of matching companies with their company number, status, type, and registered address. Use this first when you only have a company name and need its company number.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Company name or keywords to search for | |
| limit | No | Maximum number of results to return (default 10) |
Implementation Reference
- src/server.ts:77-86 (handler)The handler function for search_company tool. Takes query and optional limit parameters, constructs URL search params, calls the API endpoint /search, and returns the results as text or error.
async ({ query, limit }) => { try { const params = new URLSearchParams({ q: query }); if (limit) params.set("limit", String(limit)); const data = await api(`/search?${params}`); return text(data); } catch (e) { return err(String(e)); } } - src/server.ts:66-75 (schema)Input schema for search_company tool using Zod. Defines 'query' as a required string (min 1 char) and 'limit' as an optional integer (1-20) with descriptions.
inputSchema: { query: z.string().min(1).describe("Company name or keywords to search for"), limit: z .number() .int() .min(1) .max(20) .optional() .describe("Maximum number of results to return (default 10)"), }, - src/server.ts:58-87 (registration)Complete registration of search_company tool with McpServer. Includes title, description, inputSchema, and handler function.
server.registerTool( "search_company", { title: "Search for companies", description: "Search for UK companies by name. Returns a list of matching companies with " + "their company number, status, type, and registered address. Use this first " + "when you only have a company name and need its company number.", inputSchema: { query: z.string().min(1).describe("Company name or keywords to search for"), limit: z .number() .int() .min(1) .max(20) .optional() .describe("Maximum number of results to return (default 10)"), }, }, async ({ query, limit }) => { try { const params = new URLSearchParams({ q: query }); if (limit) params.set("limit", String(limit)); const data = await api(`/search?${params}`); return text(data); } catch (e) { return err(String(e)); } } ); - src/server.ts:7-25 (helper)The callApi helper function used by all tools to make authenticated API requests to the registrum.co.uk API with X-API-Key header.
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() used by tool handlers to format successful responses and error responses in MCP 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 }], }; }