gbizinfo-mcp
# gbizinfo-mcp
Gビズインフォ REST API v2の現行18エンドポイントを、MCP・CLI・Pythonから利用できます。MCPはstdioで動作し、APIのJSONレスポンスをそのまま返します。
[MCP登録](#mcpクライアントに登録する) · [CLI](#cliで使う) · [Pythonライブラリ](#pythonライブラリとして使う)
## MCPクライアントに登録する
Python 3.11以上、[uv](https://docs.astral.sh/uv/) と Git、Gビズインフォで発行したAPIトークンが必要です。 設定例の `your_token` は手元で差し替えてください。
### Codex
```sh
codex mcp add gbizinfo --env "GBIZINFO_API_TOKEN=your_token" -- uvx --python 3.12 --from git+https://github.com/koizumikento/gbizinfo-mcp.git@master gbizinfo-mcp
codex mcp list
```
新しいセッションの `/mcp` で接続を確認します。デスクトップ版では設定の「MCP servers」でSTDIOを選び、下のJSONと同じコマンド・引数を入力して保存し、再起動します。 環境変数も設定してください。 [OpenAI公式のMCP設定](https://learn.chatgpt.com/docs/extend/mcp)
### Claude Desktop / Cursor
- Claude Desktop(Windows) `%APPDATA%/Claude/claude_desktop_config.json`
- Claude Desktop(macOS) `~/Library/Application Support/Claude/claude_desktop_config.json`
- Cursor `.cursor/mcp.json`(プロジェクト内)
既存の `mcpServers` に項目を追加し、保存後にクライアントを再起動します。`uvx` が見つからない場合は `command` に実行ファイルの絶対パスを指定してください。
```json
{
"mcpServers": {
"gbizinfo": {
"command": "uvx",
"args": [
"--python",
"3.12",
"--from",
"git+https://github.com/koizumikento/gbizinfo-mcp.git@master",
"gbizinfo-mcp"
],
"env": {
"GBIZINFO_API_TOKEN": "your_token"
}
}
}
}
```
## CLIで使う
CLIとPythonを実行するシェルでトークンを設定します。
```powershell
$env:GBIZINFO_API_TOKEN = "your_token"
```
macOSやLinuxでは `export GBIZINFO_API_TOKEN="your_token"` を使います。
クローンせずに実行できます。結果は標準出力に出ます。
引数はJSONオブジェクトで渡します。例の法人番号は照会したい13桁の番号に置き換えてください。次の例はPowerShell 7.3以降またはmacOS・Linuxのシェルで実行できます。
```sh
uvx --python 3.12 --from git+https://github.com/koizumikento/gbizinfo-mcp.git@master gbizinfo-mcp hojin_get_basic --args '{"corporate_number":"1234567890123"}'
```
## Pythonライブラリとして使う
自分のPythonプロジェクト(`pyproject.toml` があるディレクトリ)で依存関係に追加します。[CLIで使う](#cliで使う)と同様に、実行するシェルで `GBIZINFO_API_TOKEN` を設定してください。
```sh
uv add "git+https://github.com/koizumikento/gbizinfo-mcp.git@master"
```
次のコードを `example.py` に保存し、同じディレクトリで `uv run python example.py` を実行します。
`create_toolset()` で作ったクライアントで、MCPと同名の非同期メソッドを呼び出せます。
```python
import asyncio
from gbizinfo_mcp import create_toolset
gbizinfo = create_toolset()
print(asyncio.run(gbizinfo.hojin_get_basic(corporate_number="1234567890123")))
```
## ツール
法人を探すには `hojin_search` を使います。更新情報を期間で絞り込むツールと、法人番号で情報を取得するツールは次のとおりです。
| 情報 | 期間で更新情報を取得 | 法人番号で取得 |
| --- | --- | --- |
| 基本情報 | `hojin_update_info_basic` | `hojin_get_basic` |
| 届出・認定 | `hojin_update_info_certification` | `hojin_get_certification` |
| 表彰 | `hojin_update_info_commendation` | `hojin_get_commendation` |
| 財務 | `hojin_update_info_finance` | `hojin_get_finance` |
| 特許 | `hojin_update_info_patent` | `hojin_get_patent` |
| 調達 | `hojin_update_info_procurement` | `hojin_get_procurement` |
| 補助金 | `hojin_update_info_subsidy` | `hojin_get_subsidy` |
| 職場情報 | `hojin_update_info_workplace` | `hojin_get_workplace` |
法人ごとの事業所情報は `hojin_get_corporation` で照会できます。一括取得には公式サイトのデータダウンロードを使ってください。`hojin_update_info_corporation` を呼ぶと、期間指定のAPIには接続せず、代わりの取得方法を案内します。[公式のお知らせ](https://help.info.gbiz.go.jp/hc/ja/articles/5543677736734)
## データ出典・利用条件
本サーバーはGビズインフォの情報提供REST APIを利用します。API利用前に、公式の[APIページ](https://content.info.gbiz.go.jp/api/index.html)、[API・データダウンロード利用規約](https://help.info.gbiz.go.jp/hc/ja/articles/4999421139102-API-%E3%83%87%E3%83%BC%E3%82%BF%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89%E5%88%A9%E7%94%A8%E8%A6%8F%E7%B4%84)、[Gビズインフォ利用規約](https://help.info.gbiz.go.jp/hc/ja/articles/4795140981406-%E5%88%A9%E7%94%A8%E8%A6%8F%E7%B4%84)を確認してください。取得データの権利・利用条件は提供元に従います。
## 開発
SitesのWorkerで実行する場合は [Sites用adapterと配備手順](docs/sites.md) を参照してください。
```bash
uv sync --frozen
uv run ruff check .
uv run ty check
uv run pytest
uv build
```
## License
[MIT](LICENSE)
TDQS
Scored across 19 tools
The get_* and update_info_* families are cleanly separated by resource type (patent, subsidy, finance, workplace, etc.), so an agent can pick by data domain. However, hojin_get_corporation vs hojin_get_basic (basic corporate info vs corporation registry info) is a subtle distinction, and the deprecated hojin_update_info_corporation overlaps confusingly with both.
All tools share a hojin_ prefix and follow predictable patterns: hojin_get_<resource>, hojin_update_info_<resource>, plus hojin_search. Minor deviations exist — hojin_get_basic drops the resource noun used everywhere else, and hojin_search has no object noun — but the schema is easy to infer.
19 tools is on the heavy side but is justified by the systematic pairing of 9 resource families across two access modes (get-by-corporate-number and update-feed-by-date). The only dead weight is the deprecated hojin_update_info_corporation tool, which could be removed.
Coverage is strong: search, per-resource retrieval, and date-range update feeds for basic, certification, commendation, finance, patent, procurement, subsidy, and workplace info. Gaps are minor — no reference/list tool for filter values (prefecture, industry codes) and no bulk/composite fetch, plus the suspended establishment-update path leaves one lifecycle hole.