Brex MCP服务器
用于Brex API的模型上下文协议(MCP)服务器。针对具有投影和批处理功能的安全、小型、只读响应进行了优化。
安装
克劳德代码
# Install the package
npm install -g mcp-brex
# Add to Claude Code with your API key
claude mcp add brex --env BREX_API_KEY=your_brex_api_key -- npx mcp-brex克劳德桌面
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"brex": {
"command": "npx",
"args": ["mcp-brex"],
"env": {
"BREX_API_KEY": "your_brex_api_key"
}
}
}
}手动设置(开发)
git clone https://github.com/dennisonbertram/mcp-brex.git
cd mcp-brex
npm install
npm run build
claude mcp add brex --env BREX_API_KEY=your_key -- node build/index.js资源
brex://expenses|brex://expenses/{id}|brex://expenses/card|brex://expenses/card/{id}brex://budgets|brex://budgets/{id}brex://spend_limits|brex://spend_limits/{id}brex://budget_programs|brex://budget_programs/{id}brex://transactions/card/primary|brex://transactions/cash/{id}brex://docs/usage(代理的紧凑使用指南)
笔记:
- 资源接受
?summary_only=true&fields=id,status,...以控制有效载荷大小。 - 费用资源自动扩展
merchant和budget为了可读性。
工具(除非另有说明,否则为只读)
- 预算:
get_budgets,get_budget - 支出限额:
get_spend_limits,get_spend_limit - 预算方案:
get_budget_programs,get_budget_program - 费用(单页):
get_expenses - 费用(分页):
get_all_expenses,get_all_card_expenses - 按ID列出的费用:
get_expense,get_card_expense - 卡对账单:
get_card_statements_primary - 交易:
get_card_transactions,get_cash_transactions - 现金报表:
get_cash_account_statements - 账户:
get_all_accounts,get_account_details - 收据(手写):
match_receipt,upload_receipt - 更新(写入):
update_expense
如何调用工具
始终在以下位置发送参数 arguments (不是 input).通过分页和过滤保持有效载荷较小。
常用参数:
- 分页:
page_size(\<=50),max_items(建议\<=200) - 日期筛选:
start_date,end_date,window_days - 状态筛选:
status支出/交易数组 - 金额过滤:
min_amount,max_amount费用 - 商户过滤:
merchant_name费用 - 扩展控制:
expand数组以包括嵌套对象(例如。,["merchant", "budget"])
推荐示例:
{
"name": "get_all_card_expenses",
"arguments": {
"page_size": 10,
"max_items": 20,
"start_date": "2025-08-25T00:00:00Z",
"end_date": "2025-08-26T00:00:00Z",
"status": ["APPROVED"],
"min_amount": 100
}
}{
"name": "get_expenses",
"arguments": {
"limit": 5,
"status": "APPROVED"
}
}{
"name": "get_card_transactions",
"arguments": {
"limit": 10,
"posted_at_start": "2025-08-25T00:00:00Z"
}
}{
"name": "get_all_accounts",
"arguments": {
"page_size": 10,
"max_items": 20,
"status": "ACTIVE"
}
}{
"name": "get_transactions",
"arguments": {
"accountId": "acc_123456789",
"limit": 10
}
}{
"name": "get_expenses",
"arguments": {
"limit": 5,
"expand": ["merchant", "user"]
}
}分页和过滤最佳实践
重要:使用分页、筛选和排序来控制响应大小,而不是依赖摘要。
数据控制的关键参数:
page_size: number--每页项目数(建议:≤50)max_items: number--所有页面的最大总项目数(建议:≤200)start_date/end_date: string--ISO日期范围过滤window_days: number--将较大的日期范围拆分为较小的批次status: string[]--按状态筛选(例如,\[“已批准”、“待处理”\])min_amount/max_amount: number--基于金额的费用过滤
最佳实践:
- 始终使用日期范围 用于批量请求,以避免巨大的响应
- 使用小页面大小 (≤50)和合理的max_items(≤200)
- 应用状态筛选器 只获取您需要的数据
- 使用窗口_天 (例如,7)批量处理大日期范围
- 控制嵌套对象扩展 随着
expand参数:
- 默认: expand: [] 返回精益对象(每个对象约500-1000个令牌) - 随着扩张: expand: ["merchant", "budget"] 返回完整对象(每个对象约15K+个令牌) - 可用的扩展选项: merchant, budget, user, department, location, receipts
- 先进行小范围测试 在扩大规模之前
- 现金端点需要额外的Brex示波器;优雅地处理403秒
出版
仅 build/, README.md,以及 LICENSE 出版。
许可证
麻省理工学院——见 LICENSE.
