ndl-search-mcp
# ndl-search-mcp
国立国会図書館サーチの公式APIを参照する読み取り専用のMCPサーバーです。Python 3.12以上とuv(0.13.4で検証)を使います。上流APIのキー設定は不要です。
## MCPクライアント設定
GitHubリポジトリへのアクセス権がある環境でクローンします。
```sh
git clone https://github.com/koizumikento/ndl-search-mcp.git
cd ndl-search-mcp
uv sync --locked
```
クライアントの設定に、クローン先の絶対パスを指定します。
```json
{
"mcpServers": {
"ndl-search-mcp": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/ndl-search-mcp", "run", "--locked", "ndl-search-mcp"]
}
}
}
```
## ツール
| ツール | 用途 |
| --- | --- |
| `search_bibliography` | タイトル・著者で書誌を検索 |
OpenSearchで公開されている書誌メタデータを検索します。利用目的と提供元に応じて申請や許諾が必要な場合があります。
## CLI
```sh
uv run ndl-search-mcp search-bibliography --title "源氏物語" --limit 1
```
結果は標準出力にUTF-8のJSONで出力します。コマンドの引数は `uv run ndl-search-mcp search-bibliography --help` で確認できます。
## Pythonライブラリ
パッケージをインストールしたPython環境で、下記の非同期関数を直接呼び出せます。
```python
import asyncio
from ndl_search_mcp import search_bibliography
result = asyncio.run(search_bibliography(title="源氏物語", limit=1))
print(result)
```
公開関数 `search_bibliography` を利用できます。イベントループがある環境では、関数を直接 `await` します。
## 出典と利用条件
コードはMIT Licenseです。取得するデータの権利と利用条件は、API提供元と各データ提供機関の定めに従います。[公式API仕様](https://ndlsearch.ndl.go.jp/help/api/specifications) · [利用案内](https://ndlsearch.ndl.go.jp/help/api)
## 開発
```sh
uv sync --locked
uv run ruff check .
uv run ty check
uv run pytest
uv build
```
TDQS
Scored across 1 tool
With only one tool, there is no possibility of confusion or misselection between tools. Any search request maps unambiguously to search_bibliography.
The single name follows a clear verb_noun snake_case pattern (search_bibliography), matching the convention implied by its description. No competing conventions exist to conflict.
A one-tool server is too thin for a bibliographic search service; only a single lookup operation is exposed. Reasonable scope would include at least record retrieval or listing tools.
The surface covers only search by title/author, with no way to fetch a full record by identifier, list available fields, or page results beyond a numeric Start. Agents hitting a record will have no follow-up operation to retrieve details.