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

# A2A and MCP Integration

> Learn how to integrate with Narada using Agent-to-Agent (A2A) and Model Context Protocol (MCP) standards

Narada supports two industry-standard protocols for agent integration: **Agent-to-Agent (A2A)** and **Model Context Protocol (MCP)**. These protocols enable seamless communication between Narada and other AI agents or systems.

## Overview

Both A2A and MCP provide standardized ways to interact with Narada's capabilities:

* **A2A Protocol**: Enables direct agent-to-agent communication following the A2A specification
* **MCP Protocol**: Uses the Model Context Protocol with Streamable HTTP for structured interactions

<CardGroup cols={2}>
  <Card title="A2A Integration" icon="link" href="#a2a-protocol">
    Direct agent-to-agent communication using the A2A specification
  </Card>

  <Card title="MCP Integration" icon="code" href="#mcp-protocol">
    Structured interactions using Model Context Protocol with Streamable HTTP
  </Card>
</CardGroup>

## A2A Protocol

The Agent-to-Agent (A2A) protocol enables direct communication between AI agents using a standardized specification.

### Agent Discovery

Narada's A2A agent information is available at the well-known endpoint. You can discover the agent card as :

```bash cURL theme={null}
curl -X GET 'https://api.narada.ai/fast/v2/a2a/.well-known/agent.json'
```

```json Agent Information theme={null}
{
  "name": "Narada AI Agent",
  "description": "AI agent for automating tasks through web browsing and integrations",
  "version": "0.0.1",
  "url": "https://api.narada.ai/fast/v2/a2a",
  "authentication": {
    "type": "bearer",
    "description": "API key required"
  },
  // Additional fields...
}
```

### A2A Endpoint

The main A2A endpoint follows the exact A2A protocol specification:

**Endpoint**: `https://api.narada.ai/fast/v2/a2a`

<Info>
  The A2A endpoint implements the complete A2A protocol specification. Refer to
  the [official A2A documentation](https://a2a-protocol.org/latest/) for detailed protocol requirements and message
  formats.
</Info>

### Authentication

A2A requests require authentication using your Narada API key:

<ParamField header="Authorization" type="string" required>
  Bearer token for API authentication. Format: `Bearer YOUR_API_KEY`
</ParamField>

### Example A2A Request

This example demonstrates how to use the A2A Python SDK to discover Narada's agent card and send a streaming message request asking the Operator agent to navigate to google.

First, install the A2A Python SDK:

```bash theme={null}
pip install a2a-sdk
```

<Tip>
  The A2A SDK is the official Python library for the Agent2Agent Protocol. You can find more details in the [A2A Python SDK repository](https://github.com/a2aproject/a2a-python).
</Tip>

```python wrap expandable theme={null}
import httpx
from a2a.client import A2ACardResolver, A2AClient
from a2a.types import (
    MessageSendParams,
    MessageSendConfiguration,
    Message,
    TextPart,
    JSONRPCErrorResponse,
    SendStreamingMessageRequest,
)
from uuid import uuid4

headers = {
    "Authorization": f"Bearer <NARADA_API_KEY>"
}

agent = "https://api.narada.ai/fast/v2/a2a"
async with httpx.AsyncClient(timeout=30, headers=headers) as client:
    card_resolver = A2ACardResolver(
        client, base_url=agent, agent_card_path="/.well-known/agent.json"
    )
    card = await card_resolver.get_agent_card()

    client = A2AClient(client, agent_card=card)

    # Create message
    message = Message(
        role="user",
        parts=[TextPart(text="/Operator navigate to google.com")],
        message_id=str(uuid4()),
        context_id=uuid4().hex,
    )

    # Send streaming request
    response_stream = client.send_message_streaming(
        SendStreamingMessageRequest(
            id=str(uuid4()),
            params=MessageSendParams(
                id=str(uuid4()),
                message=message,
                configuration=MessageSendConfiguration(accepted_output_modes=["text"]),
            ),
        )
    )

    # Print streaming responses
    async for result in response_stream:
        if isinstance(result.root, JSONRPCErrorResponse):
            print(f"Error: {result.root.error}")
        else:
            event = result.root.result
            print(f"stream event => {event.model_dump_json(exclude_none=True)}")
```

## MCP Protocol

The Model Context Protocol (MCP) provides structured communication using Streamable HTTP for efficient data exchange.

### MCP Endpoint

**Endpoint**: `https://api.narada.ai/fast/v2/mcp`

<Info>
  The MCP endpoint implements the complete Model Context Protocol specification. Refer to the [official MCP documentation](https://modelcontextprotocol.io/docs/) for the detailed protocol requirements and message formats
</Info>

### Authentication

MCP requests use the same authentication method as A2A:

<ParamField header="Authorization" type="string" required>
  Bearer token for API authentication. Format: `Bearer YOUR_API_KEY`
</ParamField>

### Example MCP Request

This example demonstrates how to use the FastMCP Python SDK to send a streaming message request asking the Operator agent to navigate to google.

First, install the FastMCP Python SDK:

```bash theme={null}
pip install fastmcp
```

<Tip>
  FastMCP is a Python library for the Model Context Protocol. You can find more details in the [FastMCP documentation](https://gofastmcp.com/clients/client).
</Tip>

```python wrap expandable theme={null}
from fastmcp import Client
from fastmcp.client.transports import StreamableHttpTransport

headers = {
    "Authorization": f"Bearer <NARADA_API_KEY>"
}

url = "https://api.narada.ai/fast/v2/mcp"
client = Client(
    transport=StreamableHttpTransport(
        url,
        headers=headers,
    ),
)

async with client:
    await client.ping()

    # Create a new task
    result = await client.call_tool(
        name="narada",
        arguments={
            "prompt": "/Operator navigate to google.com"
        }
    )
    print(result.content)
```

## Error Handling

Both protocols return standardized error responses:

```json Error Response theme={null}
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32601,
    "message": "Method not found",
    "data": // Some data...
  }
}
```

### Common Error Codes

<AccordionGroup>
  <Accordion title="Authentication Errors">
    * **401 Unauthorized**: Invalid or missing API key
  </Accordion>

  <Accordion title="Request Errors">
    * **400 Bad Request**: Invalid request format or parameters
    * **422 Unprocessable Entity**: Request validation failed
  </Accordion>

  <Accordion title="Server Errors">
    * **500 Internal Server Error**: Unexpected server error
    * **503 Service Unavailable**: Service temporarily unavailable
  </Accordion>
</AccordionGroup>
