# MCP 服务

Source: https://langbot.app/docs/zh/deploy/mcp-server

在 Claude、Cursor 或其他 MCP 客户端里管理 LangBot 工作区：地址、鉴权和工具。

LangBot 自带 MCP 服务。外部的 AI 助手或 Agent 连上之后，可以管理一个工作区：机器人、处理器、工作流、知识库、定时任务和监控。（想让机器人使用其他 MCP 服务的工具，请看 [MCP](https://langbot.app/docs/zh/usage/mcp/readme.md)。）

## 连接

| 项目   | 值                                                  |
| ---- | -------------------------------------------------- |
| 传输方式 | Streamable HTTP                                    |
| 地址   | `http://<你的 LangBot>:5300/mcp`                     |
| 鉴权   | `X-API-Key: <key>` 或 `Authorization: Bearer <key>` |

在侧边栏的 **API 集成** 里创建密钥。一个密钥只属于一个工作区，只能访问授权范围内的内容。只有一个工作区的自部署实例，也可以使用 `config.yaml` 里的全局密钥 `api.global_api_key`。请像保管密码一样保管密钥：有写权限的密钥可以修改你的机器人。

## 工具

工具使用和 WebUI 相同的操作、权限与校验，返回内容里的密钥会被隐藏。

| 分类                                                    | 工具                                                                                                                                                                                           |
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 机器人                                                   | `list_bots`、`get_bot`、`create_bot`、`update_bot`、`delete_bot`、`list_bot_event_route_statuses` 等                                                                                               |
| Agent 和其他处理器                                          | `list_processors`、`create_processor`、`update_processor`、`debug_agent`、`list_processor_runs` 等                                                                                                |
| 聊天（流水线）                                               | `list_pipelines`、`create_pipeline`、`update_pipeline`、`run_pipeline` 等                                                                                                                        |
| [工作流](https://langbot.app/docs/zh/usage/workflows.md) | `list_workflows`、`get_workflow`、`get_workflow_options`、`create_workflow`、`update_workflow`、`test_workflow`、`copy_workflow`、`delete_workflow`                                                 |
| 工作流运行记录和历史版本                                          | `list_workflow_runs`、`get_workflow_run`、`list_workflow_versions`、`get_workflow_version`、`restore_workflow_version`                                                                           |
| 工作流数据表                                                | `list_workflow_data_tables`、`create_workflow_data_table`、`list_workflow_data_table_rows`、`add_workflow_data_table_row`、`update_workflow_data_table_rows`、`delete_workflow_data_table_rows` 等 |
| 定时任务                                                  | `list_schedules`、`create_schedule`、`pause_schedule`、`trigger_schedule`、`list_schedule_runs` 等                                                                                                |
| 知识库、模型、插件、技能                                          | `list_knowledge_bases`、`retrieve_knowledge_base`、`list_llm_models`、`list_plugins`、`list_skills` 等                                                                                            |
| 监控                                                    | `get_monitoring_executions`、`get_inflight_executions`、`get_monitoring_errors`、`get_monitoring_llm_calls` 等                                                                                   |
| 工作区和沙箱                                                | `get_system_info`、`get_workspace_timezone`、`get_sandbox_status` 等                                                                                                                            |

工作流的图结构、步骤类型和触发方式写在技能 [`langbot-mcp-ops`](https://github.com/langbot-app/LangBot/blob/master/skills/skills/langbot-mcp-ops/SKILL.md) 里，让 Agent 搭建工作流之前先读它。`get_workflow_options` 会返回当前实例可用的步骤类型和操作。

## 相关

- [`lbctl`](https://langbot.app/docs/zh/deploy/lbctl.md)：在终端里管理同一个工作区。
- [配置文件](https://langbot.app/docs/zh/deploy/settings.md)：`api.global_api_key`。
