error-broker
Classifies agent errors and provides clear recovery actions (retry, escalate) with configurable categories and strategies, plus MCP tools for direct agent use.
README
error-broker
Classify agent errors and get a clear recovery action.
Agents hit rate limits, auth failures, timeouts, and bad JSON all the time. Most stacks treat every failure the same. error-broker maps the raw error to a category and tells you what to do next: wait and retry, or stop and escalate.
Free and open source (MIT). No account. No API key.
Why it helps
- Same rules for Cursor agents, scripts, and app code
- Useful defaults out of the box
- Optional YAML if you want custom categories or strategies
- MCP tools so agents can call it directly
- Repeat failures escalate instead of looping forever
Install (Cursor MCP)
Add this to .cursor/mcp.json or ~/.cursor/mcp.json:
{
"mcpServers": {
"error-broker": {
"command": "npx",
"args": ["-y", "github:amsultan2010/error-broker", "mcp"]
}
}
}
Reload Cursor. The agent gets tools like handle_error and classify_error.
If you clone this repo locally, you can point Cursor at the built CLI instead:
{
"mcpServers": {
"error-broker": {
"command": "node",
"args": ["/absolute/path/to/error-broker/dist/cli.js", "mcp"]
}
}
}
Install (npm)
npm i error-broker
import { handle, classifyError, createBroker } from "error-broker";
const decision = handle({
status: 429,
message: "Rate limit exceeded",
context: { run_id: "job-1", tool: "openai" },
});
console.log(decision.instructions);
// RETRY [rate_limit]: wait 60s, then retry (attempt 1/3). ...
CLI
npx error-broker classify '{"status":429,"message":"Rate limit exceeded"}'
npx error-broker handle '{"status":401,"message":"Invalid API key"}'
npx error-broker categories
npx error-broker strategies
What you get back
handle returns JSON like:
{
"category": "rate_limit",
"action": "retry",
"wait_seconds": 60,
"max_attempts": 3,
"attempt": 1,
"should_retry": true,
"escalate": false,
"reason": "Rate limited. Wait, then retry.",
"instructions": "RETRY [rate_limit]: wait 60s, then retry (attempt 1/3). Rate limited. Wait, then retry."
}
Pass the same context.run_id on later failures so attempt counting and escalation work.
Default categories
rate_limit, quota, auth, timeout, network, overloaded, context_overflow, invalid_response, not_found, tool_failure, unknown
Custom config (optional)
npx error-broker handle --config-dir ./my-config '{"status":429,"message":"slow down"}'
Put taxonomy.yaml and strategies.yaml in that folder. Examples live in defaults/.
MCP tools
classify_error: map an error to a categoryhandle_error: classify plus recovery advicelist_categories: show taxonomylist_strategies: show recovery rulesreset_attempts: clear counters for a run
SDK
The npm package is the SDK. Import it in your agent code:
import { createBroker, handle, classifyError } from "error-broker";
const broker = createBroker();
const result = broker.handle({
status: 503,
message: "service unavailable",
context: { run_id: "batch-9", tool: "search" },
});
if (result.should_retry) {
// wait result.wait_seconds, then retry your call
}
See examples/sdk-usage.mjs.
Until the package is on npm, install from GitHub:
npm i github:amsultan2010/error-broker
Development
npm install
npm test
npm run build
node dist/cli.js classify '{"status":429,"message":"rate limit"}'
node examples/sdk-usage.mjs
Cursor Marketplace
This repo is packaged as a Cursor plugin (.cursor-plugin/plugin.json + mcp.json).
Submit it at: https://cursor.com/marketplace/publish
Cursor reviews marketplace plugins manually. Use this repo URL:
https://github.com/amsultan2010/error-broker
License
MIT. See LICENSE.
The MIT license is fully set up: LICENSE file in the repo root and "license": "MIT" in package.json.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。