> ## Documentation Index
> Fetch the complete documentation index at: https://docs.didit.me/llms.txt
> Use this file to discover all available pages before exploring further.

# 安装 Didit MCP：Claude、Cursor、VS Code、Windsurf

> 在 Claude、Cursor、VS Code、Windsurf、Zed 或任意 MCP 客户端中配置 Didit 托管 MCP 服务器，或自托管开源服务器。无需 API 密钥。

Pick your client below. The **托管服务器**（`https://mcp.didit.me/mcp`）无需 API 密钥。首次连接时，您的客户端会打开浏览器，您点击 **[使用 Didit 登录](https://docs.didit.me/zh/integration/mcp/authentication.md)** 并批准权限。

> [!TIP]
>
> **正在使用 Claude？** [连接 Claude](https://docs.didit.me/zh/integration/mcp/claude.md) 页面提供一键连接器链接，可打开 **Add custom connector** 对话框，其中已预填名称和 URL，您只需确认并登录即可。

> [!NOTE]
>
> 尚不支持远程/HTTP MCP 的客户端（Windsurf、Zed）通过 `mcp-remote` 桥接器连接。该桥接器会将 stdio 转发到托管 URL，并为您处理 OAuth 握手。

***

## 推荐的托管服务器

> [tab] Claude Code
>
> 使用 CLI 添加服务器，然后触发登录：
>
> ```bash theme={null}
> claude mcp add --transport http didit https://mcp.didit.me/mcp
> ```
>
> 启动 Claude Code 并运行 `/mcp`，它会打开浏览器以进行 **使用 Didit 登录**。批准后，`didit` 工具即可使用。

> [tab] Claude 网页版和桌面版
>
> 网页版：点击 [**Add Didit to Claude →**](https://claude.ai/customize/connectors?modal=add-custom-connector\&connectorName=Didit\&connectorUrl=https://mcp.didit.me/mcp)，然后确认已预填内容的对话框。
>
> 桌面版：**Settings → Connectors → Add custom connector**，将名称设为 `Didit`，并将 URL 设置为：
>
> ```text theme={null}
> https://mcp.didit.me/mcp
> ```
>
> 点击 **连接**，然后在浏览器中完成 **使用 Didit 登录**。Didit 工具随后会出现在聊天的工具菜单中。

> [tab] Cursor
>
> 将以下内容添加到 `~/.cursor/mcp.json`（全局）或 `.cursor/mcp.json`（项目级）：
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "didit": {
>       "url": "https://mcp.didit.me/mcp"
>     }
>   }
> }
> ```
>
> 或使用 **Settings → Tools & Integrations → New MCP Server**。Cursor 会通过动态客户端注册（Dynamic Client Registration）向 Didit 注册自身，并在首次使用时打开浏览器进行登录。

> [tab] VS Code
>
> 在 GitHub Copilot 代理模式下，添加 `.vscode/mcp.json`：
>
> ```json theme={null}
> {
>   "servers": {
>     "didit": {
>       "type": "http",
>       "url": "https://mcp.didit.me/mcp"
>     }
>   }
> }
> ```
>
> 或从命令面板运行 **MCP: Add Server**，然后选择 **HTTP**。出现提示时登录。请让 VS Code 指向完整的 `/mcp` URL：服务器会为该路径发布其 OAuth 资源元数据。

> [tab] Windsurf
>
> Windsurf 通过 `mcp-remote` 桥接器连接。将以下内容添加到 `~/.codeium/windsurf/mcp_config.json`：
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "didit": {
>       "command": "npx",
>       "args": ["-y", "mcp-remote@latest", "https://mcp.didit.me/mcp"]
>     }
>   }
> }
> ```
>
> 打开 **Settings → Cascade → MCP Servers → Manage** 以确认服务器已加载，然后通过浏览器登录。

> [tab] Zed
>
> 在 Zed 的 `settings.json` 中添加上下文服务器：
>
> ```json theme={null}
> {
>   "context_servers": {
>     "didit": {
>       "source": "custom",
>       "command": "npx",
>       "args": ["-y", "mcp-remote@latest", "https://mcp.didit.me/mcp"]
>     }
>   }
> }
> ```
>
> Zed 会启动桥接器，并打开浏览器以进行 **使用 Didit 登录**。

> [tab] 其他客户端
>
> 任何通过 **Streamable HTTP** 实现 MCP 并支持 **OAuth 2.1** 的客户端，都可以直接连接 `https://mcp.didit.me/mcp`。它会从 `https://mcp.didit.me/.well-known/oauth-protected-resource/mcp` 发现授权服务器，通过动态客户端注册（Dynamic Client Registration）注册自身，并运行 PKCE 流程。服务器仅接受对 `/mcp` 的 `POST` 请求；`GET` 和 `DELETE` 会返回 `405`，因为它是无状态的，不保留服务器发起的流。
>
> 仅支持 stdio 的客户端可以使用与 Windsurf 和 Zed 相同的 `mcp-remote` 桥接器：
>
> ```bash theme={null}
> npx -y mcp-remote@latest https://mcp.didit.me/mcp
> ```
>
> 如需在不使用客户端的情况下试用服务器，[MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) 会连接到同一 URL，并引导您完成登录。

> [!NOTE]
>
> **配置中没有 API 密钥。** 托管服务器通过浏览器为您验证身份，并以 **您** 的身份行事：可访问您所属的每个组织，并具有您角色对应的权限。参见 [身份验证](https://docs.didit.me/zh/integration/mcp/authentication.md)。

托管服务器会对 `GET https://mcp.didit.me/healthz` 返回其版本号。

***

## 验证连接

登录后，向您的客户端提问：

```text theme={null}
Use the Didit MCP server to call didit_context_get and list my organizations and applications.
```

智能体应调用 `didit_context_get`，并显示您的组织及其应用。如果它提示没有 Didit 工具，则说明服务器未连接，或登录未完成：请参阅 [故障排除](https://docs.didit.me/zh/integration/mcp/advanced.md#故障排查)。

## 自托管

托管服务器由开源仓库 [github.com/didit-protocol/mcp](https://github.com/didit-protocol/mcp)（MIT）构建。每个版本也会发布到 npm，地址为 [`@didit-protocol/mcp-server`](https://www.npmjs.com/package/@didit-protocol/mcp-server)，因此您可以直接从 npm 运行 stdio 服务器，也可以从克隆的代码构建任一入口点。同一代码库提供两个入口点：

| 入口点 | 模式 | 传输 | 认证 |
| - | - | - | - |
| `dist/http.js` | 托管 | 基于 `MCP_PORT`（默认 3000）的 Streamable HTTP，`POST /mcp`，`GET /healthz` | OAuth 2.1 Bearer，通过令牌内省验证 |
| `dist/index.js` | stdio（无头模式） | MCP stdio | `DIDIT_ACCESS_TOKEN` 中的用户访问令牌 |

两种模式都以 Didit **用户**身份运行。不存在应用 API 密钥模式。

**1. 克隆并构建**

```bash theme={null}
git clone https://github.com/didit-protocol/mcp.git && cd mcp
npm install && npm run build
```

或构建容器：`docker build -t didit-mcp .`。该镜像以非 root 用户运行 `dist/http.js`，暴露 3000 端口，并在 `/healthz` 上提供健康检查。

**2. 运行 HTTP 服务器（OAuth）**

将 `.env.example` 复制为 `.env`，填写托管模式所需的值，然后运行：

```bash theme={null}
node dist/http.js
# or
docker run -p 3000:3000 --env-file .env didit-mcp
```

该服务器仅作为 OAuth 资源服务器运行。需要将 `MCP_RESOURCE_URI` 设置为传输端点的完整公开 URL（例如 `https://mcp.example.com/mcp`，而非仅含源站的裸地址），并配置用于向 Didit 授权服务器进行令牌内省的凭据（`MCP_OAUTH_CLIENT_ID`、`MCP_OAUTH_CLIENT_SECRET`）。完整的变量列表见 [高级 → 自托管](https://docs.didit.me/zh/integration/mcp/advanced.md#自托管)。

**3. 或通过 stdio 运行（无头模式）**

对于无法执行 OAuth 流程的本地代理，请运行已发布的包（无需克隆仓库），并通过环境变量传入用户访问令牌：

```bash theme={null}
DIDIT_ACCESS_TOKEN=<user-access-token> npx -y @didit-protocol/mcp-server
```

从克隆的代码运行时，执行 `DIDIT_ACCESS_TOKEN=<user-access-token> node dist/index.js` 可实现相同效果。若未提供令牌，代理可使用 `didit_account_login` 登录；如果账户已启用双因素认证，则再使用 `didit_account_verify_2fa`。

可选的 `MCP_DEFAULT_ORG` 和 `MCP_DEFAULT_APP` 用于在单租户部署中固定作用范围。在 Claude Code 中注册方式如下：

```bash theme={null}
claude mcp add didit-local -e DIDIT_ACCESS_TOKEN=<user-access-token> -- npx -y @didit-protocol/mcp-server
```

或在 Cursor 的 `mcp.json` 中配置：

```json theme={null}
{
  "mcpServers": {
    "didit-local": {
      "command": "npx",
      "args": ["-y", "@didit-protocol/mcp-server"],
      "env": { "DIDIT_ACCESS_TOKEN": "<user-access-token>" }
    }
  }
}
```

开源的 stdio 服务器不包含托管服务器的 Travel Rule、市场、欺诈网络和交易 SDK 令牌工具，也不包含除构建工作流以外的其他合规工具。
它额外提供 `didit_org_top_up`、`didit_org_reveal_application_api_key`，以及五个账户设置工具（`didit_account_register`、`didit_account_verify_email`、`didit_account_resend_otp`、`didit_account_login`、`didit_account_verify_2fa`）。这些工具以凭据作为参数，因此从不随远程连接器提供。在 stdio 模式下，接收文件的工具还接受 `*_path` 参数，因为服务器与您共享文件系统。

***

## 后续步骤

> [card] [认证](https://docs.didit.me/zh/integration/mcp/authentication.md)
>
> 登录、权限范围和角色。

> [card] [工具参考](https://docs.didit.me/zh/integration/mcp/tools.md)
>
> 代理可调用的所有工具。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.