> For the complete documentation index, see [llms.txt](https://modelmesh.gitbook.io/cline-zhong-wen-ban-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://modelmesh.gitbook.io/cline-zhong-wen-ban-docs/pei-zhi-mcp-fu-wu-qi.md).

# 配置 MCP 服务器

#### 全局 MCP 服务器包含模式 <a href="#enabling-or-disabling-mcp-servers" id="enabling-or-disabling-mcp-servers"></a>

使用 MCP 服务器可以增加您的代币使用量。Cline-胜算云增强版 提供根据需要限制或禁用 MCP 服务器功能的功能。

1. 单击 Cline-胜算云增强版 扩展顶部导航栏中的“MCP 服务器”图标。
2. 选择“已安装”选项卡，然后单击该窗格底部的“高级 MCP 设置”链接。
3. Cline 将打开一个新的设置窗口。找到 `Cline>Mcp:Mode` 并从下拉菜单中进行选择。

![](https://docs.cline.bot/~gitbook/image?url=https%3A%2F%2F3321249260-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Ff8Oh1Lcy6yWYq1caYESV%252Fuploads%252FTWRfm1Wth2QUo4btcR61%252FMCP-settings-edit.png%3Falt%3Dmedia%26token%3D0b47f297-3f72-41a2-b199-eb3f5bb9072b\&width=768\&dpr=4\&quality=100\&sign=45772f0d\&sv=2)

#### 管理单个 MCP[ 服务器](https://docs.roocode.com/features/mcp/using-mcp-in-roo#managing-individual-mcp-servers) <a href="#managing-individual-mcp-servers" id="managing-individual-mcp-servers"></a>

每个 MCP 服务器都有自己的配置面​​板，您可以在其中修改设置、管理工具并控制其运行。要访问这些设置：

1. 单击 Cline-胜算云增强版 扩展顶部导航栏中的“MCP 服务器”图标。
2. 在列表中找到您要管理的 MCP 服务器，然后单击其名称将其打开。

![](https://docs.cline.bot/~gitbook/image?url=https%3A%2F%2F3321249260-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Ff8Oh1Lcy6yWYq1caYESV%252Fuploads%252FXsVB1jLVbAtvGCbCdVeP%252FMCP-settings-individual.png%3Falt%3Dmedia%26token%3D85b24101-8fcd-4387-b267-a8083f9f68ca\&width=768\&dpr=4\&quality=100\&sign=7554284f\&sv=2)

**删除**[**服务器**](https://docs.roocode.com/features/mcp/using-mcp-in-roo#deleting-a-server)

1. 单击要删除的 MCP 服务器旁边的垃圾桶图标，或单击 MCP 服务器配置框底部的红色删除服务器按钮。

注意：没有删除确认对话框

**重启**[**服务器**](https://docs.roocode.com/features/mcp/using-mcp-in-roo#restarting-a-server)

1. 单击要重新启动的 MCP 服务器旁边的“重新启动”按钮，或单击 MCP 服务器配置框底部的灰色“重新启动服务器”按钮。

**启用或禁用**[**服务器**](https://docs.roocode.com/features/mcp/using-mcp-in-roo#enabling-or-disabling-a-server)

1. 单击 MCP 服务器旁边的切换开关可单独启用/禁用服务器。

**网络**[**超时**](https://docs.roocode.com/features/mcp/using-mcp-in-roo#network-timeout)

要设置工具调用 MCP 服务器后等待响应的最长时间：

1. 点击单个 MCP 服务器配置框底部的 `Network Timeout` 下拉菜单，更改时间。默认值为 1 分钟，但可以设置为 30 秒到 1 小时之间。

![](https://docs.cline.bot/~gitbook/image?url=https%3A%2F%2Fdocs.roocode.com%2Fimg%2Fusing-mcp-in-roo%2Fusing-mcp-in-roo-6.png\&width=300\&dpr=4\&quality=100\&sign=aa027d96\&sv=2)

#### 编辑 MCP 设置[文件](https://docs.roocode.com/features/mcp/using-mcp-in-roo#editing-mcp-settings-files) <a href="#editing-mcp-settings-files" id="editing-mcp-settings-files"></a>

所有已安装的 MCP 服务器的设置都位于 `cline_mcp_settings.json` 文件中：

1. 单击 Cline-胜算云增强版 窗格顶部导航栏上的 MCP 服务器图标。
2. 选择“已安装”选项卡。
3. 单击窗格底部的“配置 MCP 服务器”按钮。

该文件使用 JSON 格式，其中的 `mcpServers` 对象包含命名的服务器配置：

复制

```
{
  "mcpServers": {
    "server1": {
      "command": "python",
      "args": ["/path/to/server.py"],
      "env": {
        "API_KEY": "your_api_key"
      },
      "alwaysAllow": ["tool1", "tool2"],
      "disabled": false
    }
  }
}
```

*Cline-胜算云增强版 中的 MCP 服务器配置示例（STDIO 传输）*

***

#### 了解运输[类型](https://docs.roocode.com/features/mcp/using-mcp-in-roo#understanding-transport-types) <a href="#understanding-transport-types" id="understanding-transport-types"></a>

MCP 支持两种服务器通信传输类型：

#### STDIO 传输 <a href="#stdio-transport" id="stdio-transport"></a>

用于在您的机器上运行的本地服务器：

* 通过标准输入/输出流进行通信
* 更低的延迟（无网络开销）
* 更好的安全性（无网络暴露）
* 设置更简单（无需 HTTP 服务器）
* 在您的机器上作为子进程运行

有关 STDIO 传输如何工作的更多详细信息，请参阅 [MCP 传输机制。](https://docs.cline.bot/mcp-servers/mcp-transport-mechanisms)

STDIO 配置示例：

复制

```
{
  "mcpServers": {
    "local-server": {
      "command": "node",
      "args": ["/path/to/server.js"],
      "env": {
        "API_KEY": "your_api_key"
      },
      "alwaysAllow": ["tool1", "tool2"],
      "disabled": false
    }
  }
}
```

#### 上交所运输 <a href="#sse-transport" id="sse-transport"></a>

用于通过 HTTP/HTTPS 访问的远程服务器：

* 通过服务器发送事件协议进行通信
* 可以托管在不同的机器上
* 支持多个客户端连接
* 需要网络访问
* 允许集中部署和管理

有关 SSE 传输如何工作的更多深入信息，请参阅 [MCP 传输机制。](https://docs.cline.bot/mcp-servers/mcp-transport-mechanisms)

SSE 配置示例：

复制

```
{
  "mcpServers": {
    "remote-server": {
      "url": "https://your-server-url.com/mcp",
      "headers": {
        "Authorization": "Bearer your-token"
      },
      "alwaysAllow": ["tool3"],
      "disabled": false
    }
  }
}
```

***

#### 在您的[工作流程](https://docs.roocode.com/features/mcp/using-mcp-in-roo#using-mcp-tools-in-your-workflow)中使用 MCP 工具 <a href="#using-mcp-tools-in-your-workflow" id="using-mcp-tools-in-your-workflow"></a>

配置 MCP 服务器后，Cline 将自动检测可用的工具和资源。使用方法如下：

1. 在 Cline-胜算云增强版 的对话窗口中输入您的请求
2. Cline-胜算云增强版将确定 MCP 工具何时可以帮助您完成任务
3. 出现提示时批准使用工具（或使用自动批准）

示例：“分析我的 API 的性能”可能会使用测试 API 端点的 MCP 工具。

#### MCP[ 服务器](https://docs.roocode.com/features/mcp/using-mcp-in-roo#troubleshooting-mcp-servers)故障排除 <a href="#troubleshooting-mcp-servers" id="troubleshooting-mcp-servers"></a>

常见问题及解决方案：

* **服务器无响应：** 检查服务器进程是否正在运行并验证网络连接
* **权限错误：** 确保在 `mcp_settings.json` 文件中配置了正确的 API 密钥和凭据。
* **工具不可用：** 确认服务器正确实施该工具，并且未在设置中禁用该工具
* **性能缓慢：** 尝试调整特定 MCP 服务器的网络超时值

[Edit this page](https://github.com/RooVetGit/Roo-Code-Docs/edit/main/docs/features/mcp/using-mcp-in-roo.md)
