---
orphan: true
---
# 探测 MCP 连接

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

探测 MCP 服务并返回可发现的工具；探测不会保存连接。

```text
POST https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/connections/actions/probe-mcp
```

## 调用前准备

准备具有目标工作区访问权限的个人访问令牌和目标工作区 ID。

## 请求体

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} 请求示例

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/connections/actions/probe-mcp" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "endpoint_uri": "https://mcp.example.com",
    "transport": "http-streaming"
  }'
```

:::::
:::::{tab-item} 参数说明

| 字段 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `endpoint_uri` | string | 否 | 要探测的 MCP 服务地址。未提供 connection_id 时必须提供。 |
| `connection_id` | string | 否 | 已保存的连接 ID。未提供 endpoint_uri 时必须提供。 |
| `auth_type` | string | 否 | 认证类型。 |
| `api_key_header` | string | 否 | API Key 使用的请求头名称。 |
| `credential` | object | 否 | 探测时使用的凭据，可包含 bearer_token、api_key、basic_username、basic_password 或 custom_headers。 |
| `transport` | string | 否 | MCP 传输方式：sse 或 http-streaming。未提供时使用 http-streaming。 |

:::::
::::::
:::::::

## 成功响应

成功时返回 `200` 和发现的工具。

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{"code":0,"data":{"tools":[]}}
```

:::::
:::::{tab-item} 字段说明

::::{tab-set}

:::{tab-item} 时间、版本与分页

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `data.tool_count` | integer | 发现的工具数量。 |
| `data.protocol_version` | string | MCP 协议版本；未提供时不返回。 |

:::

:::{tab-item} 列表数据

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `data.tools` | array | MCP 服务返回的工具。 |

:::

::::

:::::
::::::
:::::::

## 错误响应

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{"code":2,"message":"invalid request body"}
```

:::::
:::::{tab-item} 字段说明

::::{tab-set}
:::{tab-item} 通用字段

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `code` | integer | 错误代码。 |
| `message` | string | 面向调用者的错误信息。 |

:::
::::

:::::
::::::
:::::::
