sdk-python

Here are a few options, prioritizing clarity and SEO: * **AI Agent SDK (Python): Model-driven agent creation with minimal code. #AI #Python #SDK** (79 characters) * **Python SDK for model-driven AI

1,972
190
<div align="center">
  <div>
    <a href="https://strandsagents.com">
      <img src="https://strandsagents.com/latest/assets/logo-auto.svg" alt="Strands Agents" width="55px" height="105px">
    </a>
  </div>

  <h1>
    Strands Agents
  </h1>

  <h2>
    A model-driven approach to building AI agents in just a few lines of code.
  </h2>

  <div align="center">
    <a href="https://github.com/strands-agents/sdk-python/graphs/commit-activity"><img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/strands-agents/sdk-python"/></a>
    <a href="https://github.com/strands-agents/sdk-python/issues"><img alt="GitHub open issues" src="https://img.shields.io/github/issues/strands-agents/sdk-python"/></a>
    <a href="https://github.com/strands-agents/sdk-python/pulls"><img alt="GitHub open pull requests" src="https://img.shields.io/github/issues-pr/strands-agents/sdk-python"/></a>
    <a href="https://github.com/strands-agents/sdk-python/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/strands-agents/sdk-python"/></a>
    <a href="https://pypi.org/project/strands-agents/"><img alt="PyPI version" src="https://img.shields.io/pypi/v/strands-agents"/></a>
    <a href="https://python.org"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/strands-agents"/></a>
  </div>

  <p>
    <a href="https://strandsagents.com/">Documentation</a>
    ◆ <a href="https://github.com/strands-agents/samples">Samples</a>
    ◆ <a href="https://github.com/strands-agents/sdk-python">Python SDK</a>
    ◆ <a href="https://github.com/strands-agents/tools">Tools</a>
    ◆ <a href="https://github.com/strands-agents/agent-builder">Agent Builder</a>
    ◆ <a href="https://github.com/strands-agents/mcp-server">MCP Server</a>
  </p>
</div>

Strands Agents is a simple yet powerful SDK that takes a model-driven approach to building and running AI agents. From simple conversational assistants to complex autonomous workflows, from local development to production deployment, Strands Agents scales with your needs.

## Feature Overview

- **Lightweight & Flexible**: Simple agent loop that just works and is fully customizable.
- **Model Agnostic**: Support for Amazon Bedrock, Anthropic, LiteLLM, Llama, Ollama, OpenAI, and custom providers.
- **Advanced Capabilities**: Multi-agent systems, autonomous agents, and streaming support.
- **Built-in MCP**: Native support for Model Context Protocol (MCP) servers, enabling access to thousands of pre-built tools.

## Quick Start

```bash
# Install Strands Agents and the optional tools package
pip install strands-agents strands-agents-tools
from strands import Agent
from strands_tools import calculator

# Create an agent with the calculator tool
agent = Agent(tools=[calculator])

# Ask the agent a question
agent("What is the square root of 1764")

Note: For the default Amazon Bedrock model provider, you'll need AWS credentials configured and model access enabled for Claude 3.7 Sonnet in the us-west-2 region. See the Quickstart Guide for details on configuring other model providers.

Installation

Ensure you have Python 3.10+ installed, then:

# Create and activate a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate  # On Windows use: .venv\Scripts\activate

# Install Strands Agents and the optional tools package
pip install strands-agents strands-agents-tools

Features at a Glance

Python-Based Tools

Easily build tools using Python decorators. The docstrings are used by the LLM to understand the tool's purpose:

from strands import Agent, tool

@tool
def word_count(text: str) -> int:
    """Count words in text.
    """
    return len(text.split())

agent = Agent(tools=[word_count])
response = agent("How many words are in this sentence?")
print(response)

Model Context Protocol (MCP) Support

Strands Agents provides seamless integration with Model Context Protocol (MCP) servers. MCP allows agents to access a vast ecosystem of pre-built tools and functionalities.

Key Concepts:

  • MCP Server: A server that exposes tools and functionalities via the MCP protocol.
  • MCP Client: A client within Strands Agents that connects to an MCP server and makes its tools available to the agent.

Example: Connecting to an MCP Server

This example demonstrates how to connect to an MCP server (in this case, an AWS documentation server) and use its tools within a Strands Agent.

from strands import Agent
from strands.tools.mcp import MCPClient
from mcp import stdio_client, StdioServerParameters

# Configure the MCP client to connect to the AWS documentation server.
aws_docs_client = MCPClient(
    lambda: stdio_client(StdioServerParameters(command="uvx", args=["awslabs.aws-documentation-mcp-server@latest"]))
)

# Use the MCP client within a context manager to ensure proper connection handling.
with aws_docs_client:
   # Retrieve the list of tools exposed by the MCP server.
   tools = aws_docs_client.list_tools_sync()

   # Create an agent with the tools from the MCP server.
   agent = Agent(tools=tools)

   # Ask the agent a question that leverages the AWS documentation tools.
   response = agent("Tell me about Amazon Bedrock and how to use it with Python")
   print(response)

Explanation:

  1. MCPClient: This class handles the connection and communication with the MCP server.
  2. stdio_client and StdioServerParameters: These are used to configure how the MCP client connects to the server. In this case, it's using stdio (standard input/output) to communicate with a server process. The command and args specify the command to run the MCP server.
  3. list_tools_sync(): This method retrieves the list of available tools from the MCP server.
  4. Agent(tools=tools): The agent is initialized with the tools obtained from the MCP server.

Benefits of using MCP:

  • Tool Reusability: Access a wide range of pre-built tools without having to implement them yourself.
  • Modularity: Easily integrate new functionalities into your agents by connecting to different MCP servers.
  • Standardization: The MCP protocol provides a standardized way for agents to interact with tools.

Multiple Model Providers

Strands Agents supports various model providers, allowing you to choose the best model for your specific needs.

from strands import Agent
from strands.models import BedrockModel
from strands.models.ollama import OllamaModel
from strands.models.llamaapi import LlamaAPIModel

# Bedrock
bedrock_model = BedrockModel(
  model_id="us.amazon.nova-pro-v1:0",
  temperature=0.3,
  streaming=True, # Enable/disable streaming
)
agent = Agent(model=bedrock_model)
agent("Tell me about Agentic AI")

# Ollama
ollama_model = OllamaModel(
  host="http://localhost:11434",
  model_id="llama3"
)
agent = Agent(model=ollama_model)
agent("Tell me about Agentic AI")

# Llama API
llama_model = LlamaAPIModel(
    model_id="Llama-4-Maverick-17B-128E-Instruct-FP8",
)
agent = Agent(model=llama_model)
response = agent("Tell me about Agentic AI")

Built-in Providers:

Repository

ST
strands-agents

strands-agents/sdk-python

Created

May 14, 2025

Updated

July 7, 2025

Language

Python

Category

AI