用途:通过 Mastra 开发服务器 API 调试智能体(agent)、查看对话线程、列出与检查工具及工作流、访问可观测性数据,适合在 UI 无法清晰显示错误时定位问题。
主要能力:获取最新对话线程、调试智能体错误、查看线程消息、列出全部工具与工作流、获取工作流详情与运行历史、查看工具与工作流 schema、获取 traces 与 logs。
使用方式:脚本需在 skills/mastra-api/ 目录运行,从仓库根目录运行需加该前缀。常用命令:scripts/get_latest_thread.sh <agent-id> [port]、scripts/debug_agent_error.sh <agent-id> [port]、scripts/list_tools.sh [port]、scripts/list_workflows.sh [port]、scripts/get_workflow_details.sh <workflow-name> [port]、scripts/get_workflow_runs.sh <workflow-name> [port] [page] [perPage]。也可直接调用 API,如 curl -sS http://localhost:4111/api/agents | jq 'keys',以及 /api/tools、/api/workflows、/api/observability/traces、/api/logs 等端点。查看线程消息示例:curl --globoff -sS "http://localhost:4111/api/memory/threads/THREAD_ID/messages?page=0&perPage=50&agentId=my-agent&orderBy[field]=createdAt&orderBy[direction]=DESC" | jq '.'。
限制与注意:查询参数含方括号时必须使用 curl --globoff,否则会被当作字符范围。完整交互式文档见 http://localhost:4111/swagger-ui。更完整的端点、分页排序、错误处理及项目特定配置见 references/api_endpoints.md 与 references/tools_and_workflows.md。