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

# 其他任意客户端

> 原始协议，用于构建您自己的智能体。

客户端所需的一切，无需客户端。

| | |
| - | - |
| 端点 | `https://api.minidesk.ai/mcp` |
| 方法 | `POST` |
| 传输方式 | Streamable HTTP |
| 协议版本 | `2025-06-18` |
| 认证 | `Authorization: Bearer mdsk_mcp_...` |
| 内容类型 | `application/json` |

请求采用 JSON-RPC 2.0。每次调用都是一次单独的 POST；无需打开或保持会话。

## initialize

```bash theme={null}
curl -X POST https://api.minidesk.ai/mcp \
  -H "Authorization: Bearer $MINIDESK_MCP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "jsonrpc": "2.0", "id": 1, "method": "initialize" }'
```

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "protocolVersion": "2025-06-18",
    "capabilities": { "tools": {} },
    "serverInfo": { "name": "minidesk", "version": "1.0.0" }
  }
}
```

## tools/list

```bash theme={null}
curl -X POST https://api.minidesk.ai/mcp \
  -H "Authorization: Bearer $MINIDESK_MCP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/list" }'
```

返回每个工具及其 `name`、`description` 和 `inputSchema`。列表按名称排序，因此多次调用之间保持稳定。

请在此处发现可用接口，而不是硬编码。新增工具是我们可能随时进行的增量变更；更改现有工具的 schema 则不是。

## tools/call

```bash theme={null}
curl -X POST https://api.minidesk.ai/mcp \
  -H "Authorization: Bearer $MINIDESK_MCP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "list_oldest_unanswered",
      "arguments": { "limit": 5 }
    }
  }'
```

结果是 MCP 内容块。工具输出是文本块内的 JSON，这是可互操作的格式：每个客户端都能读取，而结构化块尚未被广泛支持。

```json theme={null}
{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "content": [
      { "type": "text", "text": "{\n  \"as_of\": \"2026-08-28T14:22:10Z\",\n  \"data\": []\n}" }
    ],
    "isError": false
  }
}
```

因此，读取结果意味着将 `result.content[0].text` 解析为 JSON。

## 错误

两层，且看起来不同。

**协议错误**以 JSON-RPC 错误返回：

| 代码 | 含义 |
| - | - |
| `-32600` | 请求不是有效的 JSON-RPC |
| `-32601` | 未知方法 |

**工具错误**是成功的 JSON-RPC 响应，带有 `isError: true`，文本块中包含 `{ "error": "..." }`。未知工具名称属于此类，而不是静默无操作，因为客户端以为已提交草稿却得到静默成功是最糟糕的结果。

**传输错误**是普通的 HTTP 错误。`401` 表示凭证缺失、格式错误、已撤销，或者是 API Token 而非 MCP Token。`429` 表示已超过[速率限制](https://docs.minidesk.ai/guides/rate-limits.md)，`Retry-After` 指明何时重试。

## 最小客户端

```js theme={null}
async function callTool(name, args = {}) {
  const response = await fetch("https://api.minidesk.ai/mcp", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.MINIDESK_MCP_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      jsonrpc: "2.0",
      id: Date.now(),
      method: "tools/call",
      params: { name, arguments: args },
    }),
  });

  if (!response.ok) throw new Error(`HTTP ${response.status}`);

  const { result, error } = await response.json();

  if (error) throw new Error(error.message);

  return JSON.parse(result.content[0].text);
}

const summary = await callTool("get_support_summary");
```

## 使用官方 SDK

任何支持 Streamable HTTP 的 MCP SDK 均可使用。将其指向端点并传递请求头。

```js theme={null}
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

const transport = new StreamableHTTPClientTransport(
  new URL("https://api.minidesk.ai/mcp"),
  {
    requestInit: {
      headers: { Authorization: `Bearer ${process.env.MINIDESK_MCP_TOKEN}` },
    },
  },
);

const client = new Client({ name: "my-agent", version: "1.0.0" });
await client.connect(transport);

const { tools } = await client.listTools();
```


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