hailab-japan-company-data
by HOTAgithub
README.md
# hai Lab — Japan Company Data (Bazaar / x402)
Search Japanese company basic info, financials, subsidies, and procurement directly from AI agents — paid per request via x402 on Bazaar.
Powered by [gBizINFO](https://info.gbiz.go.jp/) (Ministry of Economy, Trade and Industry) public data.
## What it does
AI agents (Claude, Cursor, ChatGPT, Copilot, etc.) can look up Japanese companies by corporate number or name, and retrieve financial, subsidy, and procurement information. Each call costs **$0.01 USDC** and is settled automatically via the **CDP Facilitator** on **Base Sepolia**. No accounts, no API keys for buyers — just pay-per-call.
## Architecture (current, working)
This is the **production deployment** that is indexed on the x402 Bazaar.
| Layer | Tech | Detail |
|---|---|---|
| **Payment gate** | Node.js server + CDP SDK + `@x402/core` | `node/server.ts` |
| **Exposure** | Cloudflare Tunnel (`cloudflared`) | Public HTTPS URL |
| **Settlement** | CDP Facilitator | Base Sepolia, USDC, `$0.01`/call |
| **Data API** | Cloudflare Worker (`hailab-japan-company-api`) | gBizINFO + D1 cache |
| **MCP server** | Cloudflare Worker (`/mcp`) | Streamable HTTP |
> **Important:** The CDP SDK (`createX402Server`) does **not** run on Cloudflare Workers (JWT/crypto incompatibility). It runs on a Node.js server exposed through a Cloudflare Tunnel. See `node/server.ts`.
## Paid endpoints (Bazaar-indexed)
| Route | Description |
|---|---|
| `GET /v1/company/:cn` | Get a Japanese company's basic info by 13-digit corporate number |
| `GET /v1/search?name=X&en=1` | Search Japanese companies by name (Japanese or English) |
| `GET /v1/company/:cn/finance` | Get a company's financial information |
| `GET /v1/company/:cn/subsidy` | Get a company's subsidy/award information |
| `GET /v1/company/:cn/procurement` | Get a company's government procurement info |
All routes return **English field names** when `?en=1` is passed (e.g. `company_name`, `address` instead of 法人名, 所在地). Addresses are converted to English format via the [jp-postal-code-api](https://github.com/ttskch/jp-postal-code-api) (Japan Post official romanized data), e.g. `東京都港区赤坂9丁目6番35号` → `9-6-35 Akasaka, Minato-ku, Tokyo`.
## Run the Bazaar server locally
```bash
cd node
npm install
# CDP API keys (see CDP Portal)
export CDP_API_KEY_ID="..."
export CDP_API_KEY_SECRET="..."
npx tsx server.ts # listens on http://localhost:8787
```
Expose it publicly (needs `cloudflared`):
```bash
./cloudflared tunnel --url http://localhost:8787
# → prints a https://<random>.trycloudflare.com URL
```
Verify Bazaar acceptance:
```bash
curl -X POST https://api.cdp.coinbase.com/platform/v2/x402/validate \
-H "Content-Type: application/json" \
-d '{"resource":"<YOUR_PUBLIC_URL>/v1/company/9010401014127","method":"GET"}'
# expect: "valid": true, simulation.outcome: "accepted"
```
## Trigger indexing (paid settle)
Each route is indexed on the Bazaar after a successful settle through the CDP Facilitator:
```bash
npx tsx node/pay-all.ts # pays $0.01 per route, triggers indexing
```
## MCP Server
- **Endpoint**: `https://hailab-japan-company-api.pickaxe.workers.dev/mcp`
- **Transport**: Streamable HTTP
- **Registry**: `io.github.HOTAgithub/hailab-japan-company-data`
| Tool | Description |
|---|---|
| `get_company` | Get a Japanese company's basic info by 13-digit corporate number |
| `search_companies` | Search Japanese companies by name (Japanese or English) |
| `get_finance` | Get a company's financial information |
| `get_subsidy` | Get a company's subsidy/award information |
| `get_procurement` | Get a company's government procurement info |
## Data source
- Source: gBizINFO (Ministry of Economy, Trade and Industry)
- Commercial use permitted (per gBizINFO terms)
- Data accuracy is not guaranteed. Verify primary sources before critical decisions.
## Repository layout
```
src/index.js # Cloudflare Worker: data API + MCP server (+ English `en=1`)
node/server.ts # Node.js Bazaar payment-gate server (CDP SDK) — PRODUCTION
node/english.ts # Japanese → English translation (address via jp-postal-code-api)
node/pay-all.ts # Trigger indexing on all routes via paid settle
```
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues