不动产金融MCP服务器
连接的远程MCP(模型上下文协议)服务器 克劳德 到 不朽金融REST API.公开20个列入白名单的金融工具——没有代理,没有任意端点,没有前端。
堆栈
- 运行时:Node.js 20+
- 语言:TypeScript(严格)
- 框架:Next.js 16应用路由器(仅后端)
- 主控程序:
mcp-handler(流式HTTP+SSE) - 验证:Zod(严格模式,无额外属性)
- HTTP 客户端:本地
fetch通过超时AbortController - 部署:Vercel(无服务器)
项目结构
immoral-finance-mcp/
├── app/
│ ├── api/
│ │ ├── mcp/[transport]/route.ts # MCP endpoint (main)
│ │ └── health/route.ts # Health check
│ ├── layout.tsx # Minimal layout (required by Next.js)
│ └── page.tsx # Status page
├── src/
│ ├── config/
│ │ └── env.ts # Environment config with validation
│ ├── lib/
│ │ ├── api.ts # HTTP client for Finance API
│ │ ├── errors.ts # Structured error classes
│ │ ├── logging.ts # JSON structured logger
│ │ └── response.ts # Response builder (success/error)
│ ├── schemas/
│ │ └── index.ts # Zod schemas for all 20 tools
│ ├── tools/
│ │ ├── register.ts # MCP server tool registration
│ │ ├── executor.ts # Tool execution orchestrator
│ │ ├── billing.ts # Billing tools (2)
│ │ ├── clients.ts # Client tools (3)
│ │ ├── commissions.ts # Commission tools (3)
│ │ ├── dashboard.ts # Dashboard tools (1)
│ │ ├── expenses.ts # Expense tools (1)
│ │ ├── payments.ts # Payment tools (3)
│ │ ├── payroll.ts # Payroll tools (3)
│ │ ├── pl.ts # P&L tools (3)
│ │ ├── users.ts # User tools (1)
│ │ └── index.ts # Barrel exports
│ └── types/
│ └── index.ts # Shared TypeScript types
├── .env.example # Environment variables template
├── vercel.json # Vercel configuration
├── next.config.ts # Next.js configuration
├── tsconfig.json # TypeScript configuration
└── package.json环境变量
| 变量 | 必填 | 默认 | 描述 |
|---|---|---|---|
FINANCE_API_BASE_URL | ✅ | — | 财务API的基本URL(无尾随斜杠) |
FINANCE_API_KEY | ✅ | — | API密钥(ig_live_ 格式) |
NODE_ENV | ❌ | development | 环境模式 |
REQUEST_TIMEOUT_MS | ❌ | 15000 | 上游请求超时(毫秒) |
LOG_LEVEL | ❌ | info | 日志级别: debug, info, warn, error |
本地开发
1.安装依赖项
npm install2.配置环境
cp .env.example .env.local编辑 .env.local 与你的真实价值观:
FINANCE_API_BASE_URL=https://your-finance-app.vercel.app
FINANCE_API_KEY=ig_live_your_actual_key3.运行开发服务器
npm run devMCP服务器将在以下地点提供:
- MCP端点:
http://localhost:3000/api/mcp - 健康检查:
http://localhost:3000/api/health
4.验证类型
npm run typecheck部署到Vercel
1.推送到GitHub
git init
git add .
git commit -m "Initial commit: Immoral Finance MCP Server v1.0.0"
git remote add origin https://github.com/YOUR_USER/immoral-finance-mcp.git
git push -u origin main2.在Vercel进口
- 首选 vercel.com/new
- 导入您的GitHub存储库
- 框架: Next.js (自动检测)
- 添加环境变量:
- FINANCE_API_BASE_URL =您的财务API URL - FINANCE_API_KEY =您的API密钥
- 点击 部署
3.启用流体计算(推荐)
在Vercel项目设置中→ 函数→ 启用 流体计算 以便更好地处理MCP连接。
4.获取您的公共URL
部署后,您的MCP服务器URL将是:
https://immoral-finance-mcp.vercel.app/api/mcp(或Vercel分配的任何子域)
联系克劳德
克劳德桌面(自定义连接器)
- 打开 克劳德桌面版 → 设置 → 连接器
- 点击 “添加自定义连接器”
- 输入您的MCP服务器URL:
https://your-project.vercel.app/api/mcp- 保存并重新启动Claude
- Claude现在应该能检测到所有20个工具
克劳德代码(CLI)
claude mcp add --transport http immoral-finance https://your-project.vercel.app/api/mcp验证克劳德是否看到了工具
问克劳德:
“你有什么不道德的金融工具?”
克劳德应该列出所有20个工具。
工具(共20个)
账单(2)
| 工具 | 说明 | 参数 |
|---|---|---|
get_billing_matrix | 获取一个月的计费矩阵 | year, month |
get_billing_records | 获取一个月的账单记录 | year, month |
客户(3)
| 工具 | 说明 | 参数 |
|---|---|---|
list_clients | 列出所有客户端 | -- |
list_client_verticals | 列出所有垂直行业 | -- |
get_client_by_id | 通过UUID获取客户端 | id |
仪表板(1)
| 工具 | 说明 | 参数 |
|---|---|---|
get_dashboard_kpis | 获取一年的关键绩效指标 | year |
费用(1)
| 工具 | 说明 | 参数 |
|---|---|---|
get_expenses_by_month | 获得一个月的费用 | year, month |
损益表(3)
| 工具 | 说明 | 参数 |
|---|---|---|
get_pl_summary | 获取一年的损益表摘要 | year |
get_pl_matrix | 获取损益矩阵数据 | year, type (实际/预算) |
get_cost_per_hour | 获取每小时成本指标 | year, dept (伊米迪亚/内容/不道德) |
付款(3)
| 工具 | 说明 | 参数 |
|---|---|---|
get_payment_schedule | 获取付款计划 | year, month |
list_payment_beneficiaries | 列出受益人 | -- |
get_payment_summary | 获取付款摘要 | year, month |
工资单(3)
| 工具 | 说明 | 参数 |
|---|---|---|
get_payroll_by_month | 获取工资数据 | year, month |
list_employees | 列出所有员工 | -- |
get_employee_by_id | 按UUID获取员工 | id |
委员会(3)
| 工具 | 说明 | 参数 |
|---|---|---|
list_partners | 列出所有合作伙伴 | -- |
get_partner_commissions_by_month | 获得每月佣金 | year, month |
get_partner_commissions_annual | 获得年度佣金 | year |
用户(1)
| 工具 | 说明 | 参数 |
|---|---|---|
list_users | 列出所有系统用户 | -- |
输入验证规则
year--4位整数(1000–9999)month--整数1–12id--有效的UUIDtype--枚举:real|budgetdept--枚举:immedia|imcontent|immoralia- 所有模式都使用
.strict()--多余的属性被拒绝 - 必填字段不能为空
- 类型不匹配(字符串中需要数字)被拒绝
安全
- ✅ 仅限白名单端点-无任意API访问
- ✅ API密钥存储在环境变量中,从未公开
- ✅ 生产响应中没有堆栈痕迹
- ✅ 山宁泰错误响应
- ✅ 可配置的请求超时
- ✅ 没有文件系统访问权限
- ✅ 无代码执行
- ✅ 仅后端——没有前端,没有UI组件
响应格式
成功
{
"ok": true,
"tool": "get_billing_matrix",
"source": "/billing/matrix?year=2025&month=3",
"params": { "year": 2025, "month": 3 },
"data": { ... },
"meta": {
"timestamp": "2025-03-15T10:30:00.000Z",
"apiVersion": "v1",
"durationMs": 245
}
}错误
{
"ok": false,
"tool": "get_billing_matrix",
"error": {
"code": "VALIDATION_ERROR",
"message": "\"month\" must be an integer between 1 and 12",
"type": "validation",
"retryable": false
},
"meta": {
"timestamp": "2025-03-15T10:30:00.000Z"
}
}v1限制
- 无OAuth-使用内部API密钥身份验证
- 只读——所有工具都是GET操作
- 无MCP资源或提示
- 不需要自定义域--使用Vercel公共URL
- MCP侧无速率限制(取决于上游API)
许可证
私人——仅供内部使用。
