77 lines
2.7 KiB
Markdown
77 lines
2.7 KiB
Markdown
# pmda-drug-info — Claude Code MCP plugin
|
||
|
||
PMDA 添付文書ベース医薬指導 Q&A の MCP plugin(hu-sandbox/pmda v2e 98/100 baseline)。
|
||
|
||
## アーキテクチャ
|
||
|
||
```
|
||
Claude Code (agent) → MCP stdio → pmda_server.py
|
||
├─ PG queries (drug_master / interaction / restriction / dosing)
|
||
└─ OS search (pmda_sections, sudachi C-mode)
|
||
```
|
||
|
||
10 tools: `search_drugs`, `list_categories`, `list_drugs_in_category`,
|
||
`get_drug_master`, `get_drug_interactions`, `get_drug_restrictions`,
|
||
`get_drug_dosing`, `search_section_text`, `list_drug_chapters`,
|
||
`read_drug_chapter`.
|
||
|
||
4 sub-agents(`agents/*.md`): `single_drug`, `interaction`,
|
||
`patient_specific`, `adverse_event`.
|
||
|
||
## Plugin は独立配布
|
||
|
||
`mygpt.*` への依存なし。PG/OS への接続情報を環境変数で渡すだけで動く。
|
||
`queries.py` / `db.py` / `os_client.py` / `taxonomy.py` / `drug_category.md`
|
||
は hu-sandbox/pmda からコピーした自己完結セット。
|
||
|
||
## 環境変数
|
||
|
||
```
|
||
PMDA_PG_HOST Postgres ホスト (例: tunnel / pg.example.com)
|
||
PMDA_PG_PORT Postgres ポート (default 5432)
|
||
PMDA_PG_DB Postgres DB (例: gptbase)
|
||
PMDA_PG_USER Postgres ユーザ
|
||
PMDA_PG_PASSWORD Postgres パスワード
|
||
|
||
PMDA_OPENSEARCH_URL OpenSearch URL (例: http://admin:admin@tunnel:9200)
|
||
PMDA_OS_INDEX OS index 名(default: pmda_sections)
|
||
```
|
||
|
||
## インストール
|
||
|
||
```bash
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
Claude Code:
|
||
|
||
```bash
|
||
# Plugin ディレクトリを Claude Code に登録(PROJECT 単位で)
|
||
/plugin install path/to/pmda-drug-info
|
||
```
|
||
|
||
`.claude-plugin/plugin.json` の `mcpServers.pmda_drug_info` が
|
||
`python ./pmda_server.py` を stdio MCP サーバとして起動する。
|
||
|
||
## データ準備
|
||
|
||
Plugin は読み取り専用。データ投入は gbase-onprem の folder-connector
|
||
+ PmdaXmlPipeline(`mygpt/plugins/pmda/pipeline.py`)が一括管理する。
|
||
|
||
- PG: aerich migration `migrations/models/263_*_add_pmda_tables.py` で 4 表作成
|
||
- OS: `pmda_sections` index は `mygpt/plugins/pmda/os_index.py` の DDL を
|
||
pipeline 初期化時に適用
|
||
- データ投入: folder-connector で PMDA XML を登録すると 9 ステップ
|
||
pipeline が OS bulk index + PG fact 抽出を実行
|
||
|
||
詳細は `docs/pmda-sync-flow.md` を参照。
|
||
|
||
## 動作確認
|
||
|
||
```bash
|
||
# stdio MCP リクエストを手動で投げる
|
||
echo '{"jsonrpc":"2.0","id":1,"method":"initialize"}' | python pmda_server.py
|
||
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list"}' | python pmda_server.py
|
||
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"search_drugs","arguments":{"query":"ロサルタン"}}}' | python pmda_server.py
|
||
```
|