Agent

Analysis of Agent Framework, Library and SDKs

LangChain MCP Adapters, Amazon Bedrock Inline Agent SDK, and Multi-Agent Orchestrator

Analysis of Agent Framework, Library and SDKs

Analysis of Agent Framework, Library and SDKs

Current there are various frameworks and libraries for building agents, whether it's vendor specific or open source. This document provides an analysis of the LangChain MCP Adapters, Amazon Bedrock Inline Agent SDK, and a proposed new SDK for building agents.

Overview of the assets compared in table

Analysis of LangChain MCP

The langchain_mcp_adapters package serves as a bridge between LangChain and MCP servers. It allows LangChain applications to leverage tools and prompts from MCP servers by providing adapters that convert between the two formats. It abstracts away the complexities of server communication and protocol conversion, allowing LangChain applications to seamlessly utilize tools and prompts from MCP servers.

The architecture follows a clear separation of concerns:

  • Client component handles connection management
  • Tools component handles tool conversion and execution
  • Prompts component handles message conversion

Core Data Structures

  1. Connection Configurations:
    • `StdioConnection`: TypedDict for stdio-based server connections
    • `SSEConnection`: TypedDict for Server-Sent Events (SSE) connections
  2. MultiServerMCPClient:
    • Main client class that manages connections to multiple MCP servers
    • Key attributes:
      • `connections`: Dictionary mapping server names to connection configurations
      • `exit_stack`: AsyncExitStack for managing async resources
      • `sessions`: Dictionary mapping server names to ClientSession objects
      • `server_name_to_tools`: Dictionary mapping server names to lists of tools

Feature Components

  1. Client Component (`client.py`)

The client component handles server connections and session management:

Key features:

  • Support for multiple simultaneous server connections
  • Two transport types: stdio (subprocess) and SSE (HTTP)
  • Async context manager interface for proper resource management
  • Environment variable handling for subprocess execution
  • Tools Component (`tools.py`)

Handles conversion between MCP tools and LangChain tools:

Key features:

  • Converts MCP tools to LangChain StructuredTools
  • Handles various content types in tool results
  • Supports async tool execution
  • Error handling via ToolException
  • Prompts Component (`prompts.py`)

Handles conversion between MCP prompts and LangChain messages:

Key features:

  • Converts MCP prompt messages to LangChain message types
  • Currently supports text content only
  • Maps MCP roles to appropriate LangChain message classes

Workflow Interaction

Overall Architecture Diagram is shown below:

Sequence Diagram for Tool Loading and Usage is shown below:

Key Integration Points

  1. Session Management:
    • The client manages MCP ClientSession objects for each server
    • Uses AsyncExitStack for proper resource cleanup
  2. Tool Conversion:
    • MCP tools are wrapped in LangChain StructuredTools
    • Tool schemas are preserved for proper argument validation
    • Tool execution is handled asynchronously
  3. Message Conversion:
    • MCP prompt messages are converted to appropriate LangChain message types
    • Role mapping: "user" → HumanMessage, "assistant" → AIMessage
  4. Content Handling:
    • Supports both text and non-text content (images, embedded resources)
    • Handles error results from tool execution

Analysis of Amazon Bedrock Inline Agent SDK

After analyzing the code implementation inside src/InlineAgent/, this document provides a comprehensive overview of its architecture, core data structures, feature components, and workflow interaction between AWS Bedrock agent and the MCP library.

Core Architecture

The Amazon Bedrock Inline Agent SDK is a Python framework designed to simplify interactions with Amazon Bedrock's Inline Agent API. It provides a high-level abstraction for configuring and invoking agents with tool capabilities, knowledge bases, and multi-agent collaboration.

Core Data Structures

  1. InlineAgent
    • The main class representing an Amazon Bedrock Inline Agent
    • Handles configuration, invocation, and response processing
    • Manages agent collaboration when working with multiple agents
  2. ActionGroup
    • Represents a logical group of tools that the agent can use
    • Can contain Python functions or MCP clients
    • Has different execution modes: RETURN_CONTROL, LAMBDA, INBUILT_TOOL
  3. ActionGroups
    • Collection of ActionGroup objects
    • Provides functionality to convert to the Bedrock API format
    • Builds a tool map for function dispatch
  4. MCPServer
    • Abstract base class for MCP server connections
    • Implementations for different transports: stdio (MCPStdio) and HTTP+SSE (MCPHttp)
    • Manages tool registration and invocation through MCP

Feature Components

  1. Tool Definition and Execution

The SDK supports multiple ways to define tools:

  1. MCP Integration

The SDK provides seamless integration with the Model Context Protocol:

  1. Return of Control Flow

The ProcessROC class handles the Return of Control flow, which is essential for tool invocation:

  1. Docstring Parsing

The SDK uses Python docstrings to generate schemas for tools:

Workflow Interaction

The complete workflow for agent invocation is:

  1. Create tool functions or connect to MCP servers
  2. Group tools into ActionGroups
  3. Initialize the InlineAgent with the action groups
  4. Invoke the agent with user input
  5. The agent processes the input through the Bedrock API
  6. When tools need to be executed, control returns to the SDK (Return of Control)
  7. The SDK executes the tool and sends the result back to the agent
  8. The agent generates a final response

Key Integration Points

  1. Foundation Models: The SDK supports various Claude models via the foundation_model parameter
  2. Knowledge Bases: Integration with Amazon Bedrock Knowledge bases for RAG
  3. Guardrails: Support for Amazon Bedrock Guardrails
  4. Multi-agent Collaboration: Support for Supervisor and Supervisor with Routing modes
  5. Observability: Built-in tracing with Langfuse and Phoenix

Code Example

Analysis of Multi-Agent Orchestrator TypeScript

The framework relies on several foundational data structures:

System Architecture

The overall architecture is illustrated below:

Key Components

  1. MultiAgentOrchestrator

The central component that manages the workflow:

  1. Agent Base Class

The foundation for all agent implementations:

  1. BedrockLLMAgent Implementation

A key implementation that interacts with AWS Bedrock:

  1. Classifier Implementation

Responsible for selecting the appropriate agent:

  • Tool Handling Example

Workflow Interaction Between Components

The workflow sequence is illustrated below:

AWS Bedrock Integration

The framework provides robust integration with AWS Bedrock services, particularly:

  1. Bedrock Runtime Client: For model invocation using ConverseCommand or ConverseStreamCommand
  2. Tool Integration: Support for tool definition, invocation, and handling
  3. Streaming Support: Efficient handling of streaming responses
  4. Guardrails: Configuration for content safety using Bedrock guardrails

Key Features and Capabilities

  1. Dynamic Agent Selection: Routes requests to the most appropriate specialized agent
  2. Context Management: Maintains conversation history for continuity
  3. Flexible Storage Options: In-memory, DynamoDB, or SQL-based storage
  4. Tool Integration: Allows agents to perform actions beyond text generation
  5. Streaming Support: Efficient handling of large responses
  6. Multiple LLM Support: AWS Bedrock, Anthropic, OpenAI, etc.
  7. Conversational Continuity: Maintains context across multi-turn conversations

Related Articles

Analysis of Agent Framework, Library and SDKs

LangChain MCP Adapters, Amazon Bedrock Inline Agent SDK, and Multi-Agent Orchestrator

Agent