{
  "schema_version": 1,
  "diagram_type": "architecture",
  "meta": {
    "title": "Model Context Protocol Multi-Server Architecture",
    "quality_profile": "showcase",
    "repository": {
      "url": "https://github.com/langchain-ai/langchain-mcp-adapters",
      "revision": "cc0f2843fd5becf2cdb641c910533c3747c3b1ef"
    },
    "views": [
      {
        "id": "hub-discovery",
        "label": "Multi-Server Multiplexing",
        "focus": ["agent-loop", "mcp-client", "stdio-transport", "sse-transport"],
        "note": "Follow concurrent tool aggregation across local subprocesses and remote HTTP endpoints."
      },
      {
        "id": "interceptor-pipeline",
        "label": "Token Refresh & Interception",
        "focus": ["mcp-client", "interceptor", "sse-transport"],
        "note": "Inspect OAuth bearer token injection and transparent 401 retry cycles."
      },
      {
        "id": "schema-synthesis",
        "label": "Dynamic Pydantic Synthesis",
        "focus": ["stdio-transport", "fs-server", "tool-adapter"],
        "note": "Trace JSON Schema property extraction to compiled BaseTool input schemas."
      }
    ]
  },
  "components": [
    {
      "id": "agent-loop",
      "type": "backend",
      "label": "Agent Reasoner",
      "sublabel": "LangGraph Runtime",
      "pos": [50, 270],
      "size": [140, 60],
      "tag": "LLM Host"
    },
    {
      "id": "mcp-client",
      "type": "backend",
      "label": "MultiServerMCPClient",
      "sublabel": "Transport Router",
      "pos": [260, 270],
      "size": [150, 60],
      "tag": "client.py",
      "sources": [
        {
          "path": "langchain_mcp_adapters/client.py",
          "line": 48,
          "end_line": 160,
          "label": "MultiServerMCPClient"
        }
      ]
    },
    {
      "id": "interceptor",
      "type": "security",
      "label": "ToolCallInterceptor",
      "sublabel": "Token Refresh Middleware",
      "pos": [260, 110],
      "size": [150, 60],
      "tag": "interceptors.py",
      "sources": [
        {
          "path": "langchain_mcp_adapters/interceptors.py",
          "line": 15,
          "end_line": 85,
          "label": "ToolCallInterceptor"
        }
      ]
    },
    {
      "id": "stdio-transport",
      "type": "backend",
      "label": "StdioConnection",
      "sublabel": "Process stdin/stdout",
      "pos": [480, 190],
      "size": [150, 60],
      "tag": "sessions.py",
      "sources": [
        {
          "path": "langchain_mcp_adapters/sessions.py",
          "line": 40,
          "end_line": 90,
          "label": "StdioConnection"
        }
      ]
    },
    {
      "id": "sse-transport",
      "type": "cloud",
      "label": "SSEConnection",
      "sublabel": "HTTP EventStream",
      "pos": [480, 350],
      "size": [150, 60],
      "tag": "sessions.py",
      "sources": [
        {
          "path": "langchain_mcp_adapters/sessions.py",
          "line": 95,
          "end_line": 150,
          "label": "SSEConnection"
        }
      ]
    },
    {
      "id": "fs-server",
      "type": "database",
      "label": "Filesystem MCP",
      "sublabel": "Local Tools",
      "pos": [710, 190],
      "size": [150, 60],
      "tag": "stdio pipe"
    },
    {
      "id": "api-server",
      "type": "cloud",
      "label": "Remote API MCP",
      "sublabel": "Cloud Microservice",
      "pos": [710, 350],
      "size": [150, 60],
      "tag": "HTTP/SSE"
    },
    {
      "id": "tool-adapter",
      "type": "backend",
      "label": "Tool Adapter",
      "sublabel": "Pydantic Schema Synth",
      "pos": [940, 270],
      "size": [140, 60],
      "tag": "tools.py",
      "sources": [
        {
          "path": "langchain_mcp_adapters/tools.py",
          "line": 35,
          "end_line": 110,
          "label": "Tool Adapter"
        }
      ]
    }
  ],
  "boundaries": [
    {
      "kind": "region",
      "label": "MCP Client Layer",
      "wraps": ["agent-loop", "mcp-client", "interceptor"]
    },
    {
      "kind": "security-group",
      "label": "Connected MCP Server Network",
      "wraps": ["stdio-transport", "sse-transport", "fs-server", "api-server", "tool-adapter"]
    }
  ],
  "connections": [
    {
      "id": "agent-to-client",
      "from": "agent-loop",
      "to": "mcp-client",
      "label": "get_tools()",
      "variant": "emphasis"
    },
    {
      "id": "client-to-interceptor",
      "from": "mcp-client",
      "to": "interceptor",
      "label": "authorize",
      "fromSide": "top",
      "toSide": "bottom"
    },
    {
      "id": "client-to-stdio",
      "from": "mcp-client",
      "to": "stdio-transport",
      "label": "pipe IPC"
    },
    {
      "id": "client-to-sse",
      "from": "mcp-client",
      "to": "sse-transport",
      "label": "stream SSE"
    },
    {
      "id": "stdio-to-fs",
      "from": "stdio-transport",
      "to": "fs-server",
      "label": "spawn subproc"
    },
    {
      "id": "sse-to-api",
      "from": "sse-transport",
      "to": "api-server",
      "label": "JSON-RPC post"
    },
    {
      "id": "fs-to-adapter",
      "from": "fs-server",
      "to": "tool-adapter",
      "label": "schema manifest"
    },
    {
      "id": "api-to-adapter",
      "from": "api-server",
      "to": "tool-adapter",
      "label": "schema manifest"
    }
  ],
  "cards": [
    {
      "dot": "cyan",
      "title": "Multiplexed Transport Support",
      "items": [
        "Concurrent handling of stdio child processes, HTTP SSE streams, and WebSockets",
        "Unified get_tools() discovery interface aggregating tools across distinct servers"
      ]
    },
    {
      "dot": "emerald",
      "title": "Dynamic Schema Translation",
      "items": [
        "Synthesizes Pydantic input models directly from JSON Schema properties",
        "Binds validation logic to LangChain BaseTool instances at runtime"
      ]
    },
    {
      "dot": "violet",
      "title": "Interceptor Middleware",
      "items": [
        "Transparently injects authorization headers into outbound requests",
        "Handles OAuth token refreshing on 401 Unauthorized responses"
      ]
    }
  ]
}
