Skip to main content
Glama
Lipika118

credit-risk-mcp

by Lipika118

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 提供三个工具:

工具

功能

get_company_financials

获取任何股票代码的实时资产负债表和损益表数据(通过 yfinance

calculate_altman_zscore

计算 Altman Z-Score——一种结合 5 个财务比率的经典破产风险公式——针对上市公司

predict_loan_default_risk

使用逻辑回归模型预测个人贷款申请人的违约概率

向 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.pklscaler.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_riskcalculate_altman_zscore 都是只读的——它们不修改任何数据,也不进行除获取公开市场数据之外的外部调用。

许可证

MIT

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

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides 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
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables financial calculations such as compound interest, loan EMI, and savings goal projections through natural language.
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables natural language portfolio monitoring, risk analysis, and compliance checking with tools for real-time portfolio status, risk metrics, anomaly detection, SEC filings search, market KPIs, and compliance validation.
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

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/Lipika118/credit-risk-mcp'

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