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:
| Protocol | Purpose | Analogy |
|---|---|---|
| MCP | Agent β Tools/Data | USB-C for AI |
| A2A | Agent β Agent | HTTP for agents |
| NLWeb | Agent β Web | Natural 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
| Feature | MCP | A2A | NLWeb |
|---|---|---|---|
| Purpose | Agent β Tools | Agent β Agent | Agent β Web |
| Use case | Extend capabilities | Collaboration | Data retrieval |
| Transport | stdio, HTTP/SSE | HTTP | HTTP |
| Maturity | High | Medium | Low |
| Adoption | Widespread | Growing | New |
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