Brex MCP 服务器
一个用于Brex API的模型上下文协议(MCP)服务器。该服务器针对安全、小型、只读的响应进行了优化,支持投影和批处理。
新功能(0.3.2)
- 修复:工具现在包含一个宽松的(或允许性的)选项
inputSchema在工具列表中,这样客户如Claude Code就能正确显示并允许调用工具。处理程序的行为没有变化。
安装
克劳德·科德
# 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-brexClaude Desktop(可译为“Claude桌面版”或根据具体语境简化为“Claude桌面”)
添加到你的 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 (not 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,
"summary_only": true,
"fields": ["id", "posted_at", "amount.amount", "amount.currency", "merchant.raw_descriptor"]
}
}{
"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) 且合理的最大项目数 (≤200)
- 应用状态过滤器 只获取您需要的数据
- 使用 window_days (例如,7)以批量处理大日期范围
- 控制嵌套对象展开 (与)……一起,带着
expand参数:
- 默认: expand: [] 返回简洁的对象(每个对象约500-1000个标记) - 随着扩张: expand: ["merchant", "budget"] 返回完整对象(每个约15K+个标记) - 可用的扩展选项: merchant, budget, user, department, location, receipts
- 先用小范围进行测试 在扩大规模之前
- 现金终端需要额外的Brex权限范围;优雅地处理403错误
注:Brex交易端点(卡和现金)不支持 posted_at_start 或者 expand检索交易,并在需要时在客户端进行过滤 posted_at/posted_at_date。
金钱与单位
Brex上的所有金额均以分为单位。此服务器默认在工具输出中标注货币字段,以防止单位错误:
- amount_cents: 整数(例如,100000)
- 金额(美元):以美元为单位的数字(例如,1000.0)
- amount_formatted:用户友好的字符串(例如,“$1,000.00”)
示例(费用 购买金额):
{
"purchased_amount": {
"amount_cents": 100000,
"amount_dollars": 1000.0,
"amount_formatted": "$1,000.00",
"currency": "USD"
}
}控制键:
format_amounts:"cents" | "dollars" | "both"(默认:"both")include_formatted布尔值(默认:true)include_summary布尔值(默认:true)添加meta.summary总计/平均值
出版
仅 build/, README.md,和 LICENSE 已发布。
许可证
MIT —— 参见 LICENSE.
