The official UK Companies House REST API is straightforward for single-user scripts. Once multiple workflows, teammates, or AI agents start sharing one wrapper service, a couple of practical constraints show up.
First, Companies House applies a 600 requests per 5 minutes rate limit per API key. Second, allowing callers to pass their own API key in a header (BYOK) has an easy concurrency trap. Mutating client.auth on a shared httpx.AsyncClient can leak one caller's key onto another caller's request.
Store incoming keys inside an async ContextVar (resetting in finally:) and pass auth explicitly per request:
resp = await client.get( f"https://api.company-information.service.gov.uk/company/{company_number}", auth=httpx.BasicAuth(resolved_key, ""), ) Beyond key isolation, a lightweight wrapper adds a few small quality-of-life improvements over hitting the upstream endpoints directly. Hashing each resolved key with SHA-256 lets you enforce independent 600 / 300s token buckets per key so heavy users don't slow down BYOK callers. Zero-padding short company numbers (48839 to 00048839) keeps cache keys consistent, and a 5-minute TTL cache avoids spending upstream quota on repeat profile or filing checks.
This kind of setup is mainly useful for UK KYB onboarding flows, accounting and compliance teams pulling officer histories, and n8n or MCP automations that need predictable rate handling. If you'd rather connect to an existing hosted instance with these guards built in, it is live here: uk-companies-house-registry-mcp.

