Mastra and the A2A Protocol — How Agents Talk to Each Other in TypeScript

Mastra와 A2A 프로토콜 — TypeScript로 에이전트끼리 대화하는 법

Mastra and the A2A Protocol — How Agents Talk to Each Other in TypeScript

Why is there so much talk these days about using TypeScript instead of Python to build AI agents? Until now, heavy and complex Python frameworks have been the standard for agent development, but the landscape is shifting, particularly in the web ecosystem. With the rise of Mastra, a framework that has surged past 22,000 GitHub stars, meeting the A2A (Agent-to-Agent) protocol v1.0.0—a communication standard for agents spearheaded by Google and donated to the Linux Foundation—a lighter, more organic TypeScript-based agent collaboration ecosystem is finally unfolding.

Mastra: A Robust Workflow Engine for TypeScript Developers

Mastra has established itself as the most intuitive and powerful agent framework in the TypeScript environment. Its greatest appeal lies in its ability to design complex control flows using clear, graph-based code, such as sequential execution (.then), conditional branching (.branch), and parallel processing (.parallel).

This process is much like laying down modular tracks for a toy train set. Just as you assemble and connect tracks to ensure the train runs safely, developers simply need to declaratively map out the paths the agents will take. As a result, even complex AI inference routines and memory systems that branch into multiple directions flow smoothly without getting tangled.

You can manage agents in a way that feels as familiar as a frontend developer working with a state management library. It has become a fantastic alternative for countless web developers who were previously hesitant due to the heavy and unfamiliar Python-based development environments.

A2A Protocol: How Agents Communicate Horizontally

While Anthropic's Model Context Protocol (MCP) has served as a 'vertical' bridge connecting agents to tools, the A2A protocol v1.0.0 is a 'horizontal' peer-to-peer (P2P) standard that helps agents meet and converse directly.

To put it simply, MCP is a channel that connects a toolbox—like a hammer or screwdriver—so an agent can work smartly. In contrast, the A2A protocol is more like a standard specification that opens a conference room where agents can exchange business cards and coordinate joint projects.

Thanks to this standard, agents built in different development environments or by different companies can communicate organically, much like navigating to a website. It paves the way for agents to recognize each other without complex integration work, exchange messages in a standardized format, and maintain long-term collaboration.

The Changes Brought by Mastra and A2A

Mastra has seamlessly integrated the A2A v1.0.0 standard into its framework as a default specification through @a2a-js/sdk. Thanks to this, deploying agents built with Mastra to remote endpoints has become incredibly simple.

The key is to issue an 'Agent Card,' which acts as an agent's self-introduction and business card. By exposing basic information at the agreed-upon web server path, /.well-known/agent-card.json, other agents on the network can automatically detect and call them.

For example, an Agent Card is written in a very intuitive JSON format, as shown below.

json
{
  "schema_version": "1.0.0",
  "name": "code-reviewer-agent",
  "description": "TypeScript 코드를 분석하고 리뷰를 작성하는 에이전트",
  "endpoint": "https://api.example.com/v1/agent",
  "capabilities": ["code-analysis", "syntax-check"]
}

Once registered, an agent can be instantly recruited by other systems as a sub-agent to begin collaboration. Developers no longer need to build massive infrastructure from scratch. They can simply launch lightweight agents onto the network and connect them organically like puzzle pieces.

Dreaming of an Agent Network That Collaborates Together

Rather than a single 'do-it-all' agent that handles everything, collaborative agents that focus on what they do best and talk to one another are far more powerful and flexible. The meeting of Mastra—with its lightweight web ecosystem—and the A2A protocol—the communication standard between agents—will be a very attractive option for TypeScript developers. Now that the worries of complex infrastructure are behind us, why not try building your own network of agents that communicate with each other easily?

No comments yet.