contract-risk-analyzer
合同风险分析器
合同风险分析器是一个结合了 FastMCP 服务器和 LangGraph 工作流的工具,用于摄取金融合同 PDF,提取关键条款和义务,标记具有严重性的已知风险术语,比较合同版本,并将所有内容综合成结构化的风险摘要,供需要快速、可解释的合同分类的律师、风险团队和运营人员使用。
MCP 工具接受本地 file_path 或远程 pdf_url。对于 Railway 等托管部署,请使用 pdf_url,以便服务器在分析前将 PDF 下载到临时存储中。
架构(高层级)
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.serverMCP 端点:
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/healthMCP 端点:
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"
]
}
}
}工具调用示例
输入源规则
对于单合同工具,请提供以下其中之一:
{
"file_path": "/app/samples/contract.pdf"
}或者:
{
"pdf_url": "https://example.com/contracts/contract.pdf"
}对于 compare_contracts,请为每一方提供一个源:
{
"pdf_url_a": "https://example.com/contracts/v1.pdf",
"pdf_url_b": "https://example.com/contracts/v2.pdf"
}远程 PDF 会被下载到临时存储中,每个 PDF 上限为 50 MB,并在每次工具调用后删除。
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 (通过
openaiSDK)PyMuPDF (
pymupdf)Pydantic
LangGraph
Docker
Railway
This server cannot be installed
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