Skip to main content
Glama
himnishpersonal

contract-risk-analyzer

contract-risk-analyzer

Contract Risk Analyzerは、FastMCPサーバーとLangGraphワークフローを組み合わせたツールです。金融契約のPDFを取り込み、主要な条項や義務を抽出し、既知のリスク用語を重要度とともにフラグ立てし、契約バージョンを比較します。そして、迅速かつ説明可能な契約トリアージを必要とする弁護士、リスク管理チーム、運用担当者のために、すべてを構造化されたリスク概要にまとめます。

MCPツールは、ローカルの file_path またはリモートの pdf_url のいずれかを受け付けます。Railwayなどのホスト型デプロイメントの場合は、サーバーが分析前にPDFを一時ストレージにダウンロードできるよう pdf_url を使用してください。

アーキテクチャ(概要)

PDF
  |
  v
FastMCP_Server
  |
  +--> extract_clauses
  +--> flag_risk_terms
  +--> summarize_obligations
  +--> compare_contracts
  |
  v
LangGraph_Agent (orchestrates tools)
  |
  v
RiskBrief (Pydantic structured output)

セットアップ(ローカル)

cd contract-risk-analyzer
cp .env.example .env
source .venv/bin/activate  # if you already created the project virtualenv
pip install -e ".[dev]"
python -m contract_risk_analyzer.server
  • MCPエンドポイント: http://localhost:8000/mcp

  • ヘルスチェック: http://localhost:8000/health

  • .env ファイルには OPENAI_API_KEY が含まれている必要があります。

Claude Desktop(MCPクライアント)からの接続

オプションA: ローカルのSTDIOサーバーとして実行(Claude Desktopが起動)

Claude Desktopで、以下のようなMCPサーバーエントリを追加します:

{
  "mcpServers": {
    "contract-risk-analyzer": {
      "command": "python",
      "args": ["-m", "contract_risk_analyzer.server"],
      "env": {
        "OPENAI_API_KEY": "YOUR_KEY_HERE"
      }
    }
  }
}

オプションB: ローカルのHTTPサーバーに接続

サーバーを自身で実行している場合(python -m contract_risk_analyzer.server)、mcp-remote を使用してClaude DesktopをローカルのMCP HTTPエンドポイントにブリッジします:

{
  "mcpServers": {
    "contract-risk-analyzer": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://127.0.0.1:8000/mcp",
        "--allow-http"
      ]
    }
  }
}

オプションC: デプロイ済みのRailwayサーバーに接続

デプロイ済みのサーバーは以下から利用可能です:

  • ヘルスチェック: https://contract-risk-analyzer-production-410a.up.railway.app/health

  • MCPエンドポイント: https://contract-risk-analyzer-production-410a.up.railway.app/mcp

Claude Desktopの設定:

{
  "mcpServers": {
    "contract-risk-analyzer": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://contract-risk-analyzer-production-410a.up.railway.app/mcp"
      ]
    }
  }
}

ツール呼び出しの例

入力ソースのルール

単一契約ツールの場合、以下のいずれかを正確に1つ指定してください:

{
  "file_path": "/app/samples/contract.pdf"
}

または:

{
  "pdf_url": "https://example.com/contracts/contract.pdf"
}

compare_contracts の場合、各側に対してソースを1つずつ指定してください:

{
  "pdf_url_a": "https://example.com/contracts/v1.pdf",
  "pdf_url_b": "https://example.com/contracts/v2.pdf"
}

リモートPDFは一時ストレージにダウンロードされます(PDFあたり最大50MB)。各ツール呼び出し後に削除されます。

extract_clauses

入力:

{
  "pdf_url": "https://example.com/contracts/isda.pdf",
  "clause_type": "termination events"
}

出力例:

[
  {
    "section_name": "ARTICLE_VII TERMINATION",
    "clause_type": "termination events",
    "raw_text": "…",
    "plain_english": "…",
    "page_references": [12, 13]
  }
]

flag_risk_terms

入力:

{ "pdf_url": "https://example.com/contracts/isda.pdf" }

出力例:

[
  {
    "term": "cross-default",
    "context": "…",
    "risk_explanation": "…",
    "severity": "high",
    "page_reference": 9
  }
]

summarize_obligations

入力:

{ "pdf_url": "https://example.com/contracts/isda.pdf" }

出力例:

[
  {
    "party": "Borrower",
    "obligations": ["Deliver monthly financial statements…"],
    "key_deadlines": ["Within 30 days after month-end…"],
    "conditions": ["So long as no Event of Default has occurred…"]
  }
]

compare_contracts

入力:

{
  "pdf_url_a": "https://example.com/contracts/v1.pdf",
  "pdf_url_b": "https://example.com/contracts/v2.pdf"
}

出力例:

{
  "added_clauses": ["New collateral top-up requirement…"],
  "removed_clauses": ["Removed cure period for payment default…"],
  "materially_changed_clauses": [
    {
      "section_name": "ARTICLE_IV EVENTS_OF_DEFAULT",
      "change_summary": "Acceleration now triggers immediately…",
      "risk_note": "Increases lender leverage; reduces borrower flexibility."
    }
  ],
  "risk_delta": "Overall risk increased for Borrower due to tighter default/acceleration terms."
}

デプロイメント(Railway)

  • ビルド: Railwayは Dockerfile からコンテナをビルドします。

  • 実行: コンテナは python -m contract_risk_analyzer.server を実行し、$PORT(デフォルトは 8000)にバインドします。

  • ヘルスチェック: GET /health{"status":"ok"} を返します。

  • 環境変数: Railwayのサービス変数に OPENAI_API_KEY を設定してください。

  • 現在のデプロイメント: https://contract-risk-analyzer-production-410a.up.railway.app

技術スタック

  • FastMCP

  • OpenAI GPT-4o (openai SDK経由)

  • PyMuPDF (pymupdf)

  • Pydantic

  • LangGraph

  • Docker

  • Railway

F
license - not found
-
quality - not tested
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/himnishpersonal/contract-risk-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server