Reference architecture

Agent Interoperability: Unifying Agent Protocol & Model Context Protocol (MCP)

Architecting enterprise agent control planes: bridging Agent Protocol REST/SSE execution lifecycles with Model Context Protocol multi-server tool, resource, and prompt federation.

20 minVerified 2026-09-293 primary sources
A governed production AI reference architecture with observable, secured service boundaries.

Architecture: The Enterprise Agent Interoperability Gap

Enterprise autonomous AI systems are frequently architected as monolithic silos: proprietary agent execution loops are tightly coupled with bespoke database connectors, file system APIs, and internal tools. This architectural coupling creates severe operational fragilities:

  1. Client Lock-In: User interfaces, evaluation harnesses, and workflow orchestrators cannot control agents uniformly across different frameworks (LangGraph, CrewAI, AutoGen, custom runtimes).
  2. Integration Explosion: Connecting $M$ distinct agent engines to $N$ enterprise data stores requires $M \times N$ ad-hoc integrations, each with separate authentication, serialization, and error-handling schemes.
  3. Control-Plane Fragility: Lack of standardized state persistence, step execution boundaries, and human-in-the-loop (HITL) checkpoints prevents safe enterprise deployment.

The modern production architecture resolves this fragmentation by establishing a clean separation between two complementary open standards:

text(21 lines)
1┌─────────────────────────────────────────────────────────────────────────┐
2│ Enterprise Client / Front-End / CI/CD │
3└────────────────────────────────────┬────────────────────────────────────┘
4 │ Agent Protocol (REST / SSE)
5 ▼
6┌─────────────────────────────────────────────────────────────────────────┐
7│ Agent Protocol Control Plane │
8│ (Tasks, Iterative Steps, Artifacts, Checkpointing, HITL) │
9└────────────────────────────────────┬────────────────────────────────────┘
10 │ Internal Execution Engine (LangGraph / DeepAgents)
11 ▼
12┌─────────────────────────────────────────────────────────────────────────┐
13│ LangChain MCP Adapter Router │
14│ (Connection Pooling, Capability Discovery, Schema Sync) │
15└──────────┬─────────────────────────┼─────────────────────────┬──────────┘
16 │ JSON-RPC (stdio) │ JSON-RPC (HTTP/SSE) │ JSON-RPC (mTLS)
17 ▼ ▼ ▼
18┌──────────────────────┐ ┌──────────────────────┐ ┌──────────────────────┐
19│ MCP Filesystem Svc │ │ MCP PostgreSQL Svc │ │ MCP GitHub CI Svc │
20└──────────────────────┘ └──────────────────────┘ └──────────────────────┘
  • Agent Protocol: Defines the Northbound Control Plane—how external systems trigger, monitor, step through, pause, inspect, and terminate agent tasks over standard REST and Server-Sent Events (SSE).
  • Model Context Protocol (MCP): Defines the Southbound Integration Plane—how the agent dynamically discovers, inspects, and executes tools, prompts, and resources exposed by decoupled, multi-server infrastructure via JSON-RPC 2.0.
Client dispatches POST agent tasks initializing persistent session
Agent engine schedules iterative POST agent task steps
Autonomous agent loop executes cognitive step and invokes tool boundary
Step outputs thoughts and intermediate artifacts streamed via SSE
Human-in-the-loop breakpoint pauses execution awaiting client input
Terminal step completion artifact generation and task status commit
Conceptual teaching model synthesized from:Agent Communication Protocol Specification and Data Model Generator RepositoryModel Context Protocol Architecture and Tools Specification

The diagram above details the Agent Protocol lifecycle: tasks represent long-lived goals, executed through discrete, atomic steps that emit streaming thoughts, structured events, and persistent artifacts.

Host client initializes JSON-RPC transport over Stdio and Streamable HTTP
MCP router discovers tool resource and prompt capabilities across servers
LangChain MCP adapters convert MCP tools into unified schema bindings
Connection pool manages persistent process sessions and health heartbeats
Dynamic tool invocation routed to designated target MCP server instance
Resource subscription notifications and logging events multiplexed to host
Conceptual teaching model synthesized from:LangChain Model Context Protocol (MCP) Multi-Client and Server Adapters RepositoryModel Context Protocol Architecture and Tools Specification

The complementary Southbound topology (shown above) federates heterogeneous MCP servers behind an intelligent router, mapping JSON-RPC capabilities into validated agent tool definitions.


1. Dual Protocol Specification & Architectural Comparison

Understanding where Agent Protocol ends and Model Context Protocol begins is essential for architecting enterprise control planes without redundant abstractions.

| Architectural Dimension | Agent Protocol (AI Engineer Foundation) | Model Context Protocol (Anthropic Open Standard) | |---|---|---| | Architectural Role | Northbound Agent Execution & Task Lifecycle Control Plane | Southbound Tool, Context & Data Resource Federation Plane | | Primary Actors | Client App / Workflow Orchestrator $\longleftrightarrow$ Autonomous Agent | Agent Reasoning Core $\longleftrightarrow$ External Systems / Data Sources | | Transport Layer | HTTP/1.1 REST (GET, POST) + Server-Sent Events (SSE) streaming | JSON-RPC 2.0 over stdio (local subprocess) or Streamable HTTP/SSE | | Core Primitives | Task, Step, Artifact, StepResult | Tool (tools/call), Resource (resources/read), Prompt (prompts/get) | | State Semantics | Statefully tracks multi-step task execution history and checkpointing | Sessions manage transport connection; tools and resources are typically idempotent | | Human-in-the-Loop | Native step pause: is_last: false with client input requirement | Handled upstream in agent or via MCP prompt/sampling approvals | | Artifact Management | Native /tasks/{task_id}/artifacts multipart upload and download | Out-of-band via file resources or base64 encoded tool outputs | | Authentication | Bearer JWT / API Key at HTTP API Gateway ingress | mTLS, OAuth2 Bearer token, or OS process permission boundary |


2. Agent Protocol Specification & REST/SSE Runtime Lifecycle

Agent Protocol standardizes the execution boundary of autonomous agents into three hierarchical entities: Tasks, Steps, and Artifacts.

Core REST Endpoints

text(9 lines)
1POST /ap/v1/agent/tasks --> Initialize a new agent execution session
2GET /ap/v1/agent/tasks --> List active and historical agent tasks
3GET /ap/v1/agent/tasks/{task_id} --> Retrieve current task state and status
4POST /ap/v1/agent/tasks/{task_id}/steps --> Execute next discrete cognitive step
5GET /ap/v1/agent/tasks/{task_id}/steps --> List all historical steps for a task
6GET /ap/v1/agent/tasks/{task_id}/steps/{step_id} --> Inspect inputs, outputs, and status
7GET /ap/v1/agent/tasks/{task_id}/artifacts --> List generated output files/deliverables
8POST /ap/v1/agent/tasks/{task_id}/artifacts --> Upload context files for agent ingestion

The Step Execution Loop

Rather than running a completely black-box infinite loop, Agent Protocol mandates an iterative step execution model. A client drives agent progress by invoking POST /tasks/{task_id}/steps:

json(26 lines)
1// Request: POST /ap/v1/agent/tasks/task-9812/steps
2{
3 "input": "Analyze quarterly revenue logs and flag discrepancies exceeding $50,000."
4}
5
6// Response: HTTP 200 OK
7{
8 "task_id": "task-9812",
9 "step_id": "step-0001",
10 "name": "Analyze Revenue Data",
11 "status": "completed",
12 "output": "Parsed 14,200 transactions. Identified 3 candidate discrepancies requiring SQL audit.",
13 "is_last": false,
14 "artifacts": [
15 {
16 "artifact_id": "art-101",
17 "file_name": "anomalies_summary.csv",
18 "agent_created": true
19 }
20 ],
21 "additional_properties": {
22 "tokens_consumed": 1840,
23 "mcp_tools_invoked": ["postgres_query_builder", "csv_exporter"]
24 }
25}
6 lines hidden

When is_last: false, the agent indicates that further cognitive processing is required. The client (or automated orchestrator) immediately schedules the subsequent step until is_last: true signals goal achievement.

Real-Time Streaming via Server-Sent Events (SSE)

In production environments, synchronous HTTP step requests time out during deep agentic reasoning. Agent Protocol specifies SSE streaming on /tasks/{task_id}/steps/{step_id}/events or streaming task progress:

text(12 lines)
1event: thought
2data: {"step_id": "step-0001", "content": "Checking database connection to ledger-replica-01..."}
3
4event: tool_call_start
5data: {"tool": "postgres_query", "params": {"query": "SELECT * FROM transactions WHERE amount > 50000;"}}
6
7event: tool_call_end
8data: {"tool": "postgres_query", "duration_ms": 42, "rows_returned": 3}
9
10event: step_completed
11data: {"step_id": "step-0001", "is_last": false, "output": "Query completed successfully."}

3. Model Context Protocol (MCP) Multi-Server Federation

While Agent Protocol manages the top-level task lifecycle, the agent needs a resilient, secure mechanism to interact with external tools and databases. The Model Context Protocol (MCP) provides a client-server architecture where the agent acts as an MCP Client connecting to multiple MCP Servers.

MCP Core Capabilities & JSON-RPC Framing

MCP communications use strict JSON-RPC 2.0 framing. An MCP Server advertises its capabilities during the initial initialize handshake:

json(36 lines)
1// Request: Client -> Server (Initialize)
2{
3 "jsonrpc": "2.0",
4 "id": 1,
5 "method": "initialize",
6 "params": {
7 "protocolVersion": "2024-11-05",
8 "capabilities": {
9 "roots": { "listChanged": true },
10 "sampling": {}
11 },
12 "clientInfo": {
13 "name": "EnterpriseAgentControlPlane",
14 "version": "1.2.0"
15 }
16 }
17}
18
19// Response: Server -> Client
20{
21 "jsonrpc": "2.0",
22 "id": 1,
23 "result": {
24 "protocolVersion": "2024-11-05",
25 "capabilities": {
26 "tools": { "listChanged": true },
27 "resources": { "subscribe": true },
28 "prompts": { "listChanged": false }
29 },
30 "serverInfo": {
31 "name": "mcp-production-postgres",
32 "version": "2.4.0"
33 }
34 }
35}
16 lines hidden

LangChain MCP Adapters (langchain-mcp-adapters)

To bridge MCP servers into production agent frameworks (such as LangGraph or LangChain), systems use langchain-mcp-adapters. This library translates remote MCP tool definitions into standard LangChain BaseTool instances dynamically at runtime:

python(40 lines)
1# Production Multi-Server MCP Integration using LangChain Adapters
2import asyncio
3from langchain_mcp_adapters.client import MultiServerMCPClient
4from langchain_mcp_adapters.tools import load_mcp_tools
5from langgraph.pregel import Pregel
6
7async def initialize_agent_mcp_control_plane() -> MultiServerMCPClient:
8 # Configure federated multi-server topology
9 client = MultiServerMCPClient(
10 server_configs={
11 # 1. Local sandboxed filesystem server over stdio
12 "filesystem": {
13 "command": "npx",
14 "args": ["-y", "@modelcontextprotocol/server-filesystem", "/var/agent/workspace"],
15 "transport": "stdio"
16 },
17 # 2. Remote PostgreSQL enterprise data service over Streamable HTTP/SSE
18 "database": {
19 "url": "https://mcp-db.internal.corp/sse",
20 "transport": "sse",
21 "headers": {"Authorization": "Bearer internal-service-secret-token"}
22 },
23 # 3. Code intelligence and Git VCS server
24 "vcs": {
25 "url": "https://mcp-github.internal.corp/sse",
26 "transport": "sse",
27 "headers": {"Authorization": "Bearer github-mcp-access-token"}
28 }
29 }
30 )
31
32 # Establish connection pool and negotiate capabilities
33 await client.initialize_all()
34 return client
35
36async def get_federated_tools(client: MultiServerMCPClient):
37 # Dynamically converts remote tools into LangChain BaseTools
38 tools = await load_mcp_tools(client)
39 return tools
20 lines hidden

4. Unified Control Plane: The Agent Bridge Architecture

The centerpiece of enterprise deployment is the Agent Bridge Pattern. An Agent Protocol server hosts an internal stateful graph engine (e.g., LangGraph with Postgres checkpointer), connected downstream to an MCP Client Router.

text(28 lines)
1┌────────────────────────────────────────────────────────────────────────┐
2│ AGENT PROTOCOL SERVER │
3│ │
4│ FastAPI / Starlette Router (/ap/v1/agent/tasks) │
5│ │ │
6│ ▼ │
7│ Task Manager (Session Store: Redis / Postgres) │
8│ │ │
9│ ▼ │
10│ LangGraph Pregel State Machine (Worker Graph) │
11│ │ │
12│ ├─ Checkpointer: PostgresSaver (Thread ID = Task ID) │
13│ │ │
14│ ├─ HITL Gate: Interrupt on destructive action │
15│ │ │
16│ └─ Tool Invoker │
17│ │ │
18│ ▼ │
19│ ┌──────────────────────────────────────────────────────────────┐ │
20│ │ MCP CLIENT ROUTER & CONNECTION POOL │ │
21│ │ │ │
22│ │ [MCP Client: DB] [MCP Client: FS] [MCP Client: Git] │ │
23│ └────────────┬──────────────────┬─────────────────┬────────────┘ │
24└─────────────────┼──────────────────┼─────────────────┼─────────────────┘
25 │ │ │
26 ▼ ▼ ▼
27 (Postgres Cluster) (Host Sandbox) (Internal GitHub)
8 lines hidden

Mapping Task ID to Thread Checkpointing

A primary requirement of enterprise agent resilience is that agent tasks must survive process restarts and node failures. In this architecture:

  1. Every incoming Agent Protocol task_id is mapped directly to a LangGraph thread_id.
  2. Every POST /tasks/{task_id}/steps loads the latest checkpoint from Postgres using the thread_id.
  3. If the agent executes a destructive tool (e.g., drop_table, git_push_main), the graph triggers a Pregel interrupt().
  4. The Agent Protocol step returns immediately with is_last: false and a metadata payload requiring human authorization:
json(16 lines)
1{
2 "task_id": "task-9812",
3 "step_id": "step-0004",
4 "status": "awaiting_approval",
5 "is_last": false,
6 "output": "Requires human authorization to execute schema migration on production-replica-01.",
7 "additional_properties": {
8 "hitl_gate": {
9 "action": "execute_schema_migration",
10 "target_mcp_server": "database",
11 "risk_level": "critical",
12 "approval_token": "appr-8742-uuid"
13 }
14 }
15}

The human operator inspects the proposed action in their management console and posts an approval step:

json(5 lines)
1// POST /ap/v1/agent/tasks/task-9812/steps
2{
3 "input": "APPROVED: Proceed with migration token appr-8742-uuid."
4}

The agent graph resumes execution from the exact checkpoint, invokes the MCP database tool, and completes the task cleanly.


5. Multi-Server Connection Pooling & Resiliency Engineering

Production agents frequently invoke dozens of tools across multiple MCP servers. Managing these connections requires high-availability connection pooling:

text(12 lines)
1Connection Pool Invariants:
21. Process Lifespan Management (stdio):
3 - Subprocess zombies must be reaped on agent task termination or crash.
4 - Standard error (stderr) streams must be redirected to structured logging.
52. HTTP/SSE Stream Heartbeating:
6 - Ping interval: Every 15 seconds.
7 - Reconnect backoff: Exponential jitter (, , , max ).
8 - Session resumption: Use MCP session headers to preserve tool execution state.
93. Concurrency Limits:
10 - Max concurrent JSON-RPC requests per MCP server instance: 16.
11 - Global circuit breaker trips after 3 consecutive transport timeouts.

Connection Pool Implementation Pattern

python(29 lines)
1import asyncio
2from typing import Dict, Any
3
4class ResilientMCPConnectionPool:
5 def __init__(self, server_endpoints: Dict[str, str]):
6 self.endpoints = server_endpoints
7 self.pools: Dict[str, asyncio.Queue] = {}
8 self.active_sessions: Dict[str, Any] = {}
9
10 async def acquire_client(self, server_id: str):
11 if server_id not in self.pools:
12 self.pools[server_id] = asyncio.Queue(maxsize=16)
13 for _ in range(4): # Warm connection pool
14 conn = await self._create_mcp_session(server_id)
15 await self.pools[server_id].put(conn)
16 return await self.pools[server_id].get()
17
18 async def release_client(self, server_id: str, client):
19 if client.is_healthy():
20 await self.pools[server_id].put(client)
21 else:
22 await client.close()
23 new_client = await self._create_mcp_session(server_id)
24 await self.pools[server_id].put(new_client)
25
26 async def _create_mcp_session(self, server_id: str):
27 # Initializes SSE / Stdio transport with automatic ping watchdog
28 pass
9 lines hidden

Decisions

| Decision | Required evidence | Review trigger | |---|---|---| | Use Agent Protocol (REST + SSE) as northbound agent control plane. | Requirement to integrate heterogeneous agent frameworks with standardized task lifecycles | Requirement to support third-party orchestrators | | Adopt Model Context Protocol (MCP) as southbound tool federation plane. | Multi-service integration requiring decoupled, dynamic tool discovery and sandboxing | Adding more than 5 distinct external data integrations | | Deploy hybrid MCP transport: stdio locally, Streamable HTTP/SSE for remote services. | Network and security audit requiring mTLS for cross-node calls and process isolation locally | Tool execution moving from local worker to distributed pod | | Persist agent checkpoints in PostgreSQL JSONPlus rather than ephemeral memory. | Audit compliance requiring deterministic replay and HITL state recovery | Deploying agents into regulated enterprise environments |


Alternatives and trade-offs

Custom WebSocket protocols provide low-latency duplex messaging but lack standardized schemas, locking client applications into specific agent frameworks. Hardcoding database tools directly into agent code minimizes network hops but creates tight coupling, security attack surfaces, and redeployment friction. Unifying Agent Protocol and MCP achieves modular, language-agnostic agent orchestration with standardized multi-server tool federation at the cost of managing dual protocol boundaries.


Failure modes

  • Subprocess Zombie Leaks in stdio Transports: If an Agent Protocol worker process is terminated abruptly, child stdio MCP server processes remain orphaned. Mitigate with POSIX process group supervision and automated EOF shutdown watchdogs.
  • Cascading JSON-RPC Request Timeouts: Long-running analytical database queries block the JSON-RPC transport loop, timing out subsequent tool calls. Mitigate with strict per-tool timeouts and asynchronous job ticket polling.
  • Schema Drift Between Agent and MCP Tool Registry: An MCP server modifies parameter definitions while the agent uses cached schemas. Mitigate by subscribing to notifications/tools/list_changed events for dynamic re-binding.
  • Broken SSE Stream Reconnection in Agent Protocol: Transient network drops disconnect client SSE streams, triggering duplicate step executions. Mitigate by enforcing server-side idempotency keys on all step executions.

Operational checklist

  • [ ] Protocol Compliance Audit: Verify Agent Protocol endpoints adhere strictly to the /ap/v1/agent/* OpenAPI schema specification.
  • [ ] Transport Sandbox Isolation: Ensure stdio MCP servers run with restricted non-root user permissions under Linux cgroups or Docker container constraints.
  • [ ] Mutual TLS (mTLS) Enforcement: Verify all remote MCP HTTP/SSE endpoints require valid client certificates and bearer token authorization.
  • [ ] Connection Pool Watchdogs: Validate that MCP connection pools enforce 15-second heartbeat pings and reap unresponsive sessions within 30 seconds.
  • [ ] Idempotency Gate Verification: Confirm that agent tool calls with side effects (financial transactions, email emissions, code merges) enforce unique idempotency tokens.
  • [ ] Prometheus Alerting: Configure alerts for agent_step_timeout_count (alert if $> 5$ in 5 min) and mcp_server_unhealthy_gauge (alert immediately if $> 0$).

Connected practice


Sources

  • agent-protocol-repo
  • langchain-mcp-adapters-repo
  • mcp-specification