> ## 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`とともに返します。リストは名前順に並べられるため、呼び出し間で安定しています。

利用できる機能はここで確認してください。ハードコードは避けてください。ツールの追加はいつでも行う可能性がある追加的な変更です。既存ツールのスキーマの変更は行いません。

## 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としてパースします。

## エラー

2つのレイヤーがあり、見た目が異なります。

**プロトコルエラー**はJSON-RPCエラーとして返されます。

| コード | 意味 |
| - | - |
| `-32600` | リクエストが有効なJSON-RPCではありませんでした |
| `-32601` | 不明なメソッドです |

**ツールエラー**は`isError: true`を持つ成功したJSON-RPCレスポンスで、テキストブロックに`{ "error": "..." }`が含まれます。不明なツール名もこれに該当し、黙って何も起こらないわけではありません。下書きを作成したと思ったクライアントが静かに成功を受け取るのが、最も避けたい結果だからです。

**トランスポートエラー**は通常のHTTPです。`401`は認証情報が欠落している、形式が不正、取り消されている、またはMCP用ではなくAPIトークンであることを意味します。`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.