Agentic Protocols (MCP, A2A)

Model Context Protocol, Agent-to-Agent, and NLWeb β€” communication standards for AI agents

Overview

AI Agents need to communicate β€” with tools, with each other, and with the web. Three key protocols:

ProtocolPurposeAnalogy
MCPAgent ↔ Tools/DataUSB-C for AI
A2AAgent ↔ AgentHTTP for agents
NLWebAgent ↔ WebNatural language web queries

Model Context Protocol (MCP)

What Is MCP?

MCP is an open standard that lets AI agents connect to external tools and data sources. Instead of custom integrations for each tool, MCP provides a unified interface.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    MCP     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ AI Agent β”‚ ◄────────► β”‚  MCP Server  β”‚
β”‚ (Client) β”‚            β”‚  (Database)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚         MCP      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     └─────────────────►│  MCP Server  β”‚
                        β”‚  (GitHub)    β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Core Concepts

  • MCP Host: Application containing the agent (IDE, chatbot)
  • MCP Client: Connects to MCP servers
  • MCP Server: Exposes tools, resources, and prompts via the standard protocol

Example: Creating an MCP Server

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer({
  name: "weather-server",
  version: "1.0.0"
});

server.tool(
  "get-weather",
  "Get current weather information",
  {
    city: z.string().describe("City name")
  },
  async ({ city }) => {
    const weather = await fetchWeather(city);
    return {
      content: [
        { type: "text", text: JSON.stringify(weather) }
      ]
    };
  }
);

server.resource(
  "config",
  "config://app",
  async () => ({
    contents: [
      {
        uri: "config://app",
        text: JSON.stringify({ version: "1.0", region: "asia" })
      }
    ]
  })
);

const transport = new StdioServerTransport();
await server.connect(transport);

MCP Client (Agent Side)

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

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

const transport = new StdioClientTransport({
  command: "node",
  args: ["weather-server.js"]
});

await client.connect(transport);

const tools = await client.listTools();
console.log("Available tools:", tools);

const result = await client.callTool({
  name: "get-weather",
  arguments: { city: "Tokyo" }
});

Agent-to-Agent Protocol (A2A)

What Is A2A?

A2A enables agents from different systems to communicate. Each agent has an β€œAgent Card” describing its capabilities.

Core Components

interface AgentCard {
  name: string;
  description: string;
  capabilities: string[];
  endpoints: {
    send: string;
    status: string;
  };
  authentication: {
    type: "api_key" | "oauth2";
  };
}

interface A2ATask {
  id: string;
  from: string;
  to: string;
  description: string;
  status: "submitted" | "working" | "completed" | "failed";
  result?: any;
}

Example: Multi-Agent Travel System

async function travelOrchestrator(request: string) {
  const flightAgent = await discoverAgent("flight-booking");
  const hotelAgent = await discoverAgent("hotel-booking");

  const [flightTask, hotelTask] = await Promise.all([
    sendTask(flightAgent, {
      description: "Find flights to Tokyo on March 15"
    }),
    sendTask(hotelAgent, {
      description: "Find hotels in Shinjuku for 5 nights"
    })
  ]);

  const [flights, hotels] = await Promise.all([
    waitForCompletion(flightTask.id),
    waitForCompletion(hotelTask.id)
  ]);

  return { flights: flights.result, hotels: hotels.result };
}

NLWeb

NLWeb allows querying any website using natural language instead of parsing HTML.

const response = await fetch("https://example.com/nlweb", {
  method: "POST",
  body: JSON.stringify({
    query: "What are the best hotels near Shibuya under $200?",
    format: "json"
  })
});

const results = await response.json();

Protocol Comparison

FeatureMCPA2ANLWeb
PurposeAgent ↔ ToolsAgent ↔ AgentAgent ↔ Web
Use caseExtend capabilitiesCollaborationData retrieval
Transportstdio, HTTP/SSEHTTPHTTP
MaturityHighMediumLow
AdoptionWidespreadGrowingNew

When to Use Which?

Agent needs databases, APIs         β†’ MCP
Agent needs to delegate to another  β†’ A2A
Agent needs to query websites       β†’ NLWeb
Building internal tools             β†’ MCP
Building agent marketplace          β†’ A2A

Summary

  • MCP: Standard for connecting agents to tools β€” you’ve already used Supabase MCP in Antigravity!
  • A2A: Agent-to-Agent communication for distributed systems
  • NLWeb: Natural language queries for web content
  • MCP is currently the most widely adopted protocol β€” focus here first