credit-risk-mcp
Credit Risk Analytics MCP Server
A Python MCP (Model Context Protocol) server that exposes credit-risk analytics as callable tools for Claude Desktop — turning natural-language questions into real financial risk calculations.
功能
该服务器为 Claude 提供三个工具:
工具 | 功能 |
| 获取任何股票代码的实时资产负债表和损益表数据(通过 |
| 计算 Altman Z-Score——一种结合 5 个财务比率的经典破产风险公式——针对上市公司 |
| 使用逻辑回归模型预测个人贷款申请人的违约概率 |
向 Claude Desktop 提问,例如 “TCS.NS 的 Altman Z-Score 是多少?” 或者提供贷款申请人的收入、债务比率和信用历史,它会调用正确的工具,执行真实计算,并解释结果。
Related MCP server: Finance MCP Server
为什么选择 MCP
没有 MCP,这些只是你需要自己运行的 Python 函数。MCP 将它们变成 AI 客户端可以直接调用的工具:Claude Desktop 向此服务器发送结构化的 JSON-RPC 请求,服务器执行实际计算,并将结果返回——这样你得到的是实时、可验证的答案,而不是模型训练数据中的猜测。
项目结构
credit-risk-mcp/
├── server.py # The MCP server — defines all 3 tools
├── train_model.py # Generates synthetic credit data + trains the logistic regression model
├── requirements.txt # Python dependencies
├── model.pkl # Trained logistic regression model
├── scaler.pkl # StandardScaler used to preprocess model inputs
└── .gitignore设置
git clone https://github.com/Lipika118/credit-risk-mcp.git
cd credit-risk-mcp
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt已包含训练好的模型(model.pkl、scaler.pkl),因此你可以直接运行服务器。如果你想自己重新训练:
python3 train_model.py这会生成一个合成但逼真的申请人数据集(收入、债务比率、信用历史、逾期付款、贷款金额、年龄),训练一个逻辑回归模型,并打印测试 AUC。
独立测试
在连接 Claude Desktop 之前,使用 MCP Inspector 直接测试工具:
pip install "mcp[cli]"
mcp dev server.py这会打开一个浏览器界面,你可以在其中手动调用每个工具,并查看每个工具的 JSON-RPC 请求/响应。
连接到 Claude Desktop
将此添加到你的 claude_desktop_config.json(Windows 上为 %APPDATA%\Claude\claude_desktop_config.json,Mac 上为 ~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"credit-risk": {
"command": "/full/path/to/venv/Scripts/python.exe",
"args": ["/full/path/to/credit-risk-mcp/server.py"]
}
}
}完全退出并重新打开 Claude Desktop,然后在聊天输入菜单中检查 连接器——credit-risk 应列出并已开启。
示例用法
公司风险:
“TCS.NS 的 Altman Z-Score 是多少?”
Ticker: TCS.NS
Altman Z-Score: 10.69
Risk Zone: Safe zone (low bankruptcy risk)
Component ratios:
Working Capital / Total Assets: 0.410
Retained Earnings / Total Assets: 0.548
EBIT / Total Assets: 0.366
Market Cap / Total Liabilities: 11.271
Revenue / Total Assets: ...个人风险:
“一位贷款申请人月收入 40000,债务收入比 0.5,信用历史 3 年,去年逾期付款 2 次,希望贷款 250000,年龄 27——他们的违约风险是多少?”
Default probability: 78.0%
Risk band: High risk关于模型的说明
贷款违约模型基于合成数据训练,而非真实申请人记录——这避免了隐私/许可问题,同时仍能学习真实、可解释的关系(较高的债务收入比和较多的逾期付款都会增加预测的违约风险)。它旨在演示 MCP 集成模式,而非用于实际贷款决策。
安全性
predict_loan_default_risk 和 calculate_altman_zscore 都是只读的——它们不修改任何数据,也不进行除获取公开市场数据之外的外部调用。
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Altman Z-Score bankruptcy-risk screen for a US-listed ticker, inputs looked up automatically.
Loan & mortgage calculator, compound interest, ROI, crypto prices, FX conversion for AI agents.
Connect AI agents to financial institution origination, analytics, and compliance workflows.
Ask data questions in natural language. Get SQL, insights, and charts from your databases.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with natural language access to WRDS financial data for credit and equity analysis through 29 specialized tools. It enables users to query bond history, credit ratings, financial metrics, and syndicated loans using simple conversational prompts.MIT
- FlicenseNot gradedqualityDmaintenanceEnables financial calculations such as compound interest, loan EMI, and savings goal projections through natural language.-
- FlicenseBqualityCmaintenanceEnables SEC EDGAR financial research, analysis, valuation, and chart data generation through natural language.24-
- AlicenseNot gradedqualityBmaintenanceEnables querying of SEC EDGAR filings and financial data via natural language, offering tools for company lookup, filing retrieval, XBRL data, and full-text search.91 npmMIT