Skip to content

Python Quickstart

This quickstart takes you to a first running agent: install the SDK, pick a model provider, run the agent, then give it a tool. Everything past that (streaming, memory, observability, deployment) has its own guide, linked from next steps.

Using a coding agent? Copy this prompt into Codex, Claude Code, Kiro, or any coding assistant and it will walk you through this page, ask which model provider you want, and offer to set up the Strands MCP server.

Make sure you have Python 3.10+ installed and a virtual environment activated. See the Python docs on virtual environments if you need to set one up. Then install the SDK:

Terminal window
pip install strands-agents

Strands works with any major model provider. The model is one object you hand to the agent, and the rest of your code is the same no matter which provider is behind it. The tabs below cover the most common providers; pick the one you already have access to, then create agent.py with the snippet from that tab:

Amazon Bedrock is the default provider, using Claude Sonnet 4.6 in the us-west-2 region, so no extra install or model object is needed.

from strands import Agent
# Bedrock is the default, so no model object is needed.
agent = Agent()
agent("What is an agent harness, in one sentence?")

Give the SDK AWS credentials with permission to invoke the model, using one of:

  • Bedrock API key: set the AWS_BEARER_TOKEN_BEDROCK environment variable to a Bedrock API key. Quickest for local development.
  • AWS credentials: aws configure, or the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and optionally AWS_SESSION_TOKEN environment variables
  • IAM roles: on AWS services like EC2, ECS, or Lambda

Enable access to the models you use in the Amazon Bedrock console, following the AWS documentation.

Run it:

Terminal window
python -u agent.py

Don’t see your provider? Strands also supports LiteLLM, Mistral, SageMaker, Llama API, llama.cpp, Writer, OpenAI-compatible endpoints, and any model behind a custom provider you write. See all supported model providers.

You now have a working agent loop, but the agent has nothing to act with. It can only answer from what the model already knows. Tools are what let an agent do things: read a file, call an API, run a command, or look something up.

A tool is a function the model can decide to call. Tools come from two places: Strands ships vended tools for common jobs like editing files, running shell commands, and making HTTP requests, and you can turn any Python function of your own into a tool with the @tool decorator. You’ll use one of each.

Add this to the top of agent.py. It imports the file_editor vended tool and defines a custom letter_counter tool. The docstring and type hints are what the model reads to decide when to call the tool and what to pass it:

from strands import Agent, tool
from strands.vended_tools import file_editor
@tool
def letter_counter(word: str, letter: str) -> int:
"""
Count occurrences of a specific letter in a word.
Args:
word (str): The input word to search in
letter (str): The specific letter to count
Returns:
int: The number of occurrences of the letter in the word
"""
if len(letter) != 1:
raise ValueError("The 'letter' parameter must be a single character")
return word.lower().count(letter.lower())

Then replace the agent creation with this. Both tools go in the tools list, and the prompt asks for something that needs each of them (keep your model line if you set one):

agent = Agent(tools=[letter_counter, file_editor])
agent('How many letter R\'s are in the word "strawberry"? Write the answer to answer.txt.')

Run it again. The model works out that counting letters is what letter_counter is for and that writing a file is what file_editor is for, calls both, and you end up with an answer.txt in your working directory. You wrote one of those tools; the other came with the SDK.

The agent decides when to call a tool based on the request, loops until it has an answer, and streams the response to your console.

flowchart LR
A[Input & Context] --> Loop
subgraph Loop[" "]
direction TB
B["Reasoning (LLM)"] --> C["Tool Selection"]
C --> D["Tool Execution"]
D --> B
end
Loop --> E[Response]

Every invocation returns an AgentResult carrying the run’s messages, metrics, and traces, so you can see which tools the agent called and why. The Agent Loop explains the cycle above, and Observability covers reading traces and metrics. To silence the streamed console output, pass callback_handler=None to the Agent.

Strands ships an MCP server that gives AI coding assistants in your IDE live access to the Strands documentation — search, section browsing, and on-demand fetching — so the code they generate follows current APIs. It helps you build, but it isn’t required to run an agent.

The server requires uv. Once uv is installed, add the server to your AI coding tool:

Add the following to ~/.kiro/settings/mcp.json:

{
"mcpServers": {
"strands-agents": {
"command": "uvx",
"args": ["strands-agents-mcp-server"],
"disabled": false,
"autoApprove": ["search_docs", "fetch_doc"]
}
}
}

See the Kiro MCP documentation for more details.

Verify the connection with the MCP Inspector:

Terminal window
npx @modelcontextprotocol/inspector uvx strands-agents-mcp-server

You have a running agent with a tool. From here:

  • Vended Tools - file editing, shell, HTTP, and more, ready to drop into tools
  • MCP Tools - connect to external tool servers
  • Examples - agents for many use cases, from multi-agent systems to autonomous agents
  • Model Providers - every supported provider and its options
  • Agent Loop - how Strands agents work under the hood
  • Context Management - keep long conversations inside the model’s context window
  • Memory - give the agent long-term memory across sessions with memory stores
  • State & Sessions - how agents keep context across a conversation or workflow
  • Streaming - stream events to a UI with async iterators or callback handlers
  • Multi-agent - orchestrate multiple agents as one system
  • Observability & Evaluation - understand agent decisions and improve them with data
  • Operating Agents in Production - take agents from development to production at scale