Skip to main content

Connections overview

Connections let Mastra work with remote agents, coding agents, provider software development kit (SDK) runtimes, and external tools and resources. Choose a connection type based on which system owns the agent runtime and what you need to exchange.

  • Agent-to-Agent (A2A): Expose or consume remote agents across service, framework, vendor, and language boundaries.
  • Agent Client Protocol (ACP): Run compatible coding-agent processes as Mastra tools or subagents.
  • SDK agents: Register Claude, Cursor, or OpenAI SDK-backed agents while the provider SDK retains control of the runtime, tools, permissions, and agent loop.
  • Model Context Protocol (MCP): Connect agents to external tools and resources, or expose Mastra agents, tools, workflows, prompts, and resources to MCP-compatible systems.

When to use connections
Direct link to When to use connections

Use connections when you need to:

  • Delegate work to an agent running in another service or runtime.
  • Run a coding agent against a project workspace.
  • Add a provider-native agent without replacing its SDK runtime or agent loop.
  • Connect agents to external tools and resources or publish Mastra capabilities to other systems.

Get started
Direct link to Get started

Start with the boundary you need to cross. Use A2A for remote agent endpoints, ACP for coding-agent processes, SDK agents for provider-owned runtimes, or MCP for tools and resources.

import { A2AAgent } from '@mastra/core/a2a'

const agent = new A2AAgent({
url: 'https://agent.example.com/.well-known/agent-card.json',
})

const result = await agent.generate('Summarize the latest report')
console.log(result.text)
On this page