Skip to main content
Glama

Healthcare Revenue Cycle Management (RCM) Multi-Agent MCP Server

AIネイティブなマルチエージェントRevenue Cycle Management (RCM) MCPサーバーで、適格性確認、事前承認、および共有推論トレースを実装し、Supabaseとpgvectorをバックエンドとしています。


アーキテクチャ概要

                          ┌────────────────────────────┐
                          │    RCM Multi-Agent System  │
                          │   (Eligibility / PriorAuth)│
                          └─────────────┬──────────────┘
                                        │ (SSE / HTTP / stdio)
                          ┌─────────────▼──────────────┐
                          │   FastMCP Server (Port 8000)│
                          │  trace.* | eligibility.*   │
                          │        priorauth.*         │
                          └─────────────┬──────────────┘
                                        │
                 ┌──────────────────────┴──────────────────────┐
                 ▼                                             ▼
     ┌────────────────────────┐                   ┌────────────────────────┐
     │  Supabase Relational   │                   │  pgvector / Semantic   │
     │  (Payers, Coverage,    │                   │  (Historical Clinical  │
     │   Rules, Traces)       │                   │   Precedents & Cases)  │
     └────────────────────────┘                   └────────────────────────┘

Related MCP server: mymedi-ai-mcp-server

1. Supabaseデータベースのセットアップ

ステップ1.1: Supabaseプロジェクトを作成する

  1. Supabaseにログインし、新しいプロジェクトを作成します。

  2. プロジェクト設定 -> データベースで、プロジェクトURLとAPIキー(anonまたはservice_role)を確認します。

ステップ1.2: pgvectorを有効にしてスキーマを適用する

  1. SupabaseダッシュボードでSQLエディタを開きます。

  2. supabase/schema.sqlの内容をコピーして貼り付け、実行します:

    • vector拡張機能を有効にします(CREATE EXTENSION IF NOT EXISTS vector;)。

    • テーブルを作成します: payers、appointments、patient_coverage、benefit_accumulators、payer_pa_rules、pa_requests、agent_trace(追記専用)、およびescalations。

    • match_pa_casesコサイン類似度ベクトル検索関数を作成します。

ステップ1.3: シードデータを読み込む

以下のいずれかの方法で、Supabaseに合成データをシードできます。

オプションA(Pythonシーダースクリプト): .envにSUPABASE_URLとSUPABASE_KEYを設定したら:

python seed_data.py

オプションB(SQLエディタ): SQLエディタで、supabase/seed.sqlの内容をコピーして貼り付け、実行します。

これにより、以下がシードされます:

  • 5つの支払者: Aetna Commercial、Blue Cross Blue Shield、UnitedHealthcare、Medicare Part B、Cigna。

  • 5つの予約: 対象サービス日(DOS)を含む予定された訪問。

  • 適用範囲レコード: エッジケーステスト用の有効なポリシーと終了したポリシー。

  • 給付累積: 特定のCPTコードに対する控除額、自己負担金、共同保険。

  • PAルールと先例: 事前承認ガイドラインと、埋め込みを含む過去のケース。


2. 環境設定

.env.exampleを.envにコピーします:

cp .env.example .env

.envファイルを自分の認証情報で更新します:

# Supabase Configuration
SUPABASE_URL=https://<your-project-ref>.supabase.co
SUPABASE_KEY=<your-supabase-service-role-or-anon-key>

# Server Configuration
MCP_SERVER_HOST=0.0.0.0
MCP_SERVER_PORT=8000

# Optional Embedding Key
OPENAI_API_KEY=

3. インストール

プロジェクトの依存関係をインストールします:

pip install -r requirements.txt

4. MCPツールリファレンス

A. 共有トレースツール(trace.*)

すべてのエージェントで使用され、追記専用で監査可能な意思決定ログを維持します。

ツール名

説明

主な入力

出力

trace_write_decision

トレースログに意思決定レコードを追加します

entity_id, agent_name, decision_type, decision_payload, confidence, evidence_refs

status, trace_id

trace_query

エンカウンターの時系列の意思決定履歴を取得します

entity_id

count、トレースエントリのリスト

trace_escalate_to_human

人間の監督者によるレビューのためにケースをキューに入れます

entity_id, agent_name, reason, context

escalation_id, status

B. 適格性ツール(eligibility.*)

実際の予約サービス日(DOS)における患者の適用範囲を検証し、患者の費用を見積もります。

ツール名

説明

主な入力

出力

eligibility_check_coverage

対象サービス日に対して有効なポリシー期間を検証します

patient_id, payer_id, service_type, service_date

coverage_status, is_valid_on_service_date, deductible_met_pct

eligibility_get_benefit_details

累積残高を取得します

patient_id, payer_id, cpt_code

copay, coinsurance_pct, deductible_remaining, estimated_patient_responsibility

eligibility_flag_coverage_gap

検出された適用範囲のギャップをトレースに記録します

patient_id, gap_reason, confidence

status, trace_id

C. 事前承認ツール(priorauth.*)

手順ルールの検索、先例の検索、および臨床的正当性の提出を自動化します。

ツール名

説明

主な入力

出力

priorauth_check_requirement

手順コードが事前承認を必要とするかどうかを確認します

payer_id, cpt_code

requires_pa, rule_text

priorauth_submit_request

臨床的正当性を提出し、ステータスを受け取ります

patient_id, payer_id, cpt_code, clinical_summary

id, status (approved/denied/pending), payer_notes

priorauth_check_status

提出された承認ステータスをポーリングします

pa_request_id

id, status, payer_notes

priorauth_search_similar_cases

過去のPAケースに対するセマンティックベクトル検索

cpt_code, clinical_summary, top_k

match_count、類似度スコア付きのランク付けされたprecedents


5. MCPサーバーの実行

オプションA: SSEトランスポート(デフォルト)

Server-Sent Events(SSE)を介してFastMCPサーバーを起動します:

python run_server.py
  • SSEエンドポイントは http://localhost:8000/sse で利用可能になります。

オプションB: カスタムホスト/ポートまたはStdio

トランスポートパラメータを直接カスタマイズできます:

# Run over stdio (e.g. for Claude Desktop / CLI clients)
python src/mcp_server/server.py --transport stdio

# Run over SSE on custom port
python src/mcp_server/server.py --transport sse --port 8080

6. テストと検証

pytestでテストスイートを実行します:

pytest tests/

期待される出力:

tests\test_mcp_tools.py ..........                                       [100%]
============================= 10 passed in 0.07s ==============================

7. エージェントクライアントへの接続

Claude Desktopの設定

claude_desktop_config.jsonに以下を追加します:

{
  "mcpServers": {
    "rcm-server": {
      "command": "python",
      "args": ["<path-to-repo>/src/mcp_server/server.py", "--transport", "stdio"]
    }
  }
}

Related MCP Connectors

Related MCP Servers