> ## Documentation Index
> Fetch the complete documentation index at: https://adcp-docs-ja.pier1.co.jp/llms.txt
> Use this file to discover all available pages before exploring further.

# プロトコル比較

> AdCP における MCP と A2A の比較: トランスポート形式、非同期処理、ステータスシステムのサイドバイサイド比較、および広告エージェント統合での使い分け。

MCP と A2A は、統一ステータスシステムを用いて同じ AdCP 機能を提供します。異なるのはトランスポート形式と非同期処理だけです。

## クイック比較

| Aspect              | MCP                         | A2A                           |
| ------------------- | --------------------------- | ----------------------------- |
| **Request Style**   | Tool calls                  | Task messages                 |
| **Response Style**  | Direct JSON                 | Artifacts                     |
| **Status System**   | Unified status field        | Unified status field          |
| **Async Handling**  | Polling with tasks/get      | SSE streaming                 |
| **Webhooks**        | Protocol wrapper extension  | Native PushNotificationConfig |
| **Task Management** | tasks/list, tasks/get tools | Native tasks/list, tasks/get  |
| **Context**         | Manual (pass context\_id)   | Automatic (protocol-managed)  |
| **Best For**        | Claude, AI assistants       | Agent workflows               |

## 統一ステータスシステム

両プロトコルは同じステータスフィールドを同じ値で使用します。

### ステータス処理（両プロトコル）

すべてのレスポンスに、次に取るべき行動を示すステータスフィールドが含まれます:

```json theme={null}
{
  "status": "input-required",    // Same values for both protocols
  "message": "Need your budget", // Same human explanation
  // ... protocol-specific formatting below
}
```

| Status           | What It Means                | Your Action                             |
| ---------------- | ---------------------------- | --------------------------------------- |
| `completed`      | Task finished                | Process data, show success              |
| `input-required` | Need user input              | Read message, prompt user, follow up    |
| `working`        | Processing (\< 120s)         | Poll frequently, show progress          |
| `submitted`      | Long-running (hours to days) | Provide webhook or poll less frequently |
| `failed`         | Error occurred               | Show error, handle gracefully           |
| `auth-required`  | Need auth                    | Prompt for credentials                  |

[Task Lifecycle](/docs/building/by-layer/L3/task-lifecycle) でステータス処理の完全ガイドを確認してください。

## トランスポート形式の違い

ステータスとデータは同じで、パッケージングが異なります:

### MCP レスポンス形式

```json theme={null}
{
  "status": "input-required",
  "message": "I need your budget and target audience",
  "context_id": "ctx-123",
  "products": [],
  "suggestions": ["budget", "audience"]
}
```

### A2A レスポンス形式

```json theme={null}
{
  "status": "input-required",
  "contextId": "ctx-123",
  "artifacts": [{
    "artifactId": "artifact-product-discovery-xyz",
    "name": "product_discovery",
    "parts": [
      {
        "kind": "text",
        "text": "I need your budget and target audience"
      },
      {
        "kind": "data",
        "data": {
          "products": [],
          "suggestions": ["budget", "audience"]
        }
      }
    ]
  }]
}
```

## 非同期処理の違い

両プロトコルは同じステータス遷移で非同期処理を扱います:
`submitted` → `working` → `completed`/`failed`

### MCP の非同期パターン

```javascript theme={null}
// Initial response with task_id
{
  "status": "submitted",
  "message": "Creating media buy, requires manual approval",
  "context_id": "ctx-123",
  "task_id": "task-456",
}

// Poll using tasks/get
const updates = await session.call('tasks/get', {
  task_id: "task-456",
  include_result: true
});

// Optional: Configure webhook
const response = await session.call('create_media_buy', params, {
  push_notification_config: {
    url: "https://buyer.com/webhooks",
    authentication: {
      schemes: ["HMAC-SHA256"],
      credentials: "shared_secret_32_chars"
    }
  }
});
```

### A2A の非同期パターン

```javascript theme={null}
// Initial response with native task tracking
{
  "status": "submitted",
  "taskId": "task-456",
  "contextId": "ctx-123",
  "estimatedCompletionTime": "2025-01-23T10:00:00Z"
}

// Real-time updates via SSE
const events = new EventSource(`/tasks/${response.taskId}/events`);
events.onmessage = (event) => {
  const update = JSON.parse(event.data);
  console.log(`Status: ${update.status}, Message: ${update.message}`);
};

// Native webhook support
await a2a.send({
  message: { /* skill invocation */ },
  push_notification_config: {
    webhook_url: "https://buyer.com/webhooks",
    authentication: {
      schemes: ["Bearer"],
      credentials: "secret_token_min_32_chars"
    }
  }
});
```

## コンテキスト管理

### MCP: 手動コンテキスト

```javascript theme={null}
let contextId = null;

async function callAdcp(request) {
  if (contextId) {
    request.context_id = contextId;
  }

  const response = await mcp.call('get_products', request);
  contextId = response.context_id; // Save for next call

  return response;
}
```

### A2A: 自動コンテキスト

```javascript theme={null}
// A2A manages context automatically
const response1 = await a2a.send({ message: "Find video products" });
const response2 = await a2a.send({
  contextId: response1.contextId, // Optional - A2A tracks this
  message: "Focus on premium inventory"
});
```

## 確認・追加情報の扱い

両プロトコルは同じ `status: "input-required"` パターンを使用します:

```javascript theme={null}
// Works for both MCP and A2A
function handleResponse(response) {
  if (response.status === 'input-required') {
    const info = promptUser(response.message);
    return sendFollowUp(response.context_id, info);
  }

  if (response.status === 'completed') {
    return processResults(response);
  }
}
```

## エラーハンドリング

両者とも `status: "failed"` と同じエラー構造を使用します:

```json theme={null}
{
  "status": "failed",
  "message": "Insufficient inventory for your targeting criteria",
  "context_id": "ctx-123",
  "error_code": "insufficient_inventory",
  "suggestions": ["Expand targeting", "Increase CPM"]
}
```

## プロトコルを選ぶには

### MCP を選ぶ場合:

* Claude Desktop または Claude Code を使用
* MCP 対応の AI アシスタントを利用
* シンプルなツールベース統合が必要
* 直接 JSON のレスポンスが欲しい

### A2A を選ぶ場合:

* Google AI agents または Agent Engine を利用
* マルチモーダル（テキスト + ファイル）なワークフロー
* リアルタイムなストリーミング更新
* アーティファクトベースのデータ処理

### 両プロトコルが提供するもの:

* 同じ AdCP タスクと機能
* クライアントロジックを明確にする統一ステータスシステム
* 会話のためのコンテキスト管理
* 非同期処理のサポート
* Human-in-the-loop ワークフロー
* エラーハンドリングと復旧

## 次のステップ

* **MCP Guide**: ツールコールとコンテキスト管理は [MCP Guide](/docs/building/by-layer/L0/mcp-guide) を参照
* **A2A Guide**: アーティファクトとストリーミングは [A2A Guide](/docs/building/by-layer/L0/a2a-guide) を参照
* **Both protocols**: 統一ステータスで同じ機能を提供
