# sdk-python

> MCP Client

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 

## Overview

- **Category:** AI
- **Language:** Python
- **Stars:** 6699
- **Forks:** 190
- **Owner:** strands-agents
- **GitHub:** https://github.com/strands-agents/sdk-python
- **Homepage:** https://strandsagents.com
- **Created:** 2025-05-14T19:59:51+00:00
- **Updated:** 2025-07-07T17:03:28+00:00
- **Source:** https://model-context-protocol.com/clients/sdk-python

## Setup

## Setup

**Prerequisites:**

*   Python 3.10 or higher is required.

**Installation:**

1.  **Create a virtual environment (recommended):**

    ```bash
    python -m venv .venv
    ```

2.  **Activate the virtual environment:**

    *   On Linux/macOS:

        ```bash
        source .venv/bin/activate
        ```

    *   On Windows:

        ```bash
        .venv\Scripts\activate
        ```

3.  **Install Strands Agents and the optional tools package:**

    ```bash
    pip install strands-agents strands-agents-tools
    ```

**Configuration:**

*   **Model Provider Credentials:** Strands Agents supports various model providers. For the default Amazon Bedrock model provider, you'll need AWS credentials configured and model access enabled for Claude 3 Sonnet in the `us-west-2` region. Refer to the [Quickstart Guide](https://strandsagents.com/latest/user-guide/quickstart/) for detailed instructions on configuring other model providers (Anthropic, LiteLLM, Llama, Ollama, OpenAI, etc.).

**Environment Variables:**

*   Specific environment variables may be required depending on the model provider you choose. Consult the documentation for your chosen provider for details. For example, when using Bedrock, you'll need standard AWS environment variables configured (e.g., `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`).

## Tools

## Available Tools

Strands Agents provides a flexible framework for building AI agents, with support for various tools and features. Here's a breakdown:

*   **Python-Based Tools:**

    *   **What it does:** Allows you to define custom tools using Python functions and decorators. The docstrings of these functions are used by the LLM to understand the tool's purpose.
    *   **Usage Example:**

        ```python
        from strands import Agent, tool

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

            This docstring is used by the LLM to understand the tool's purpose.
            """
            return len(text.split())

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

*   **MCP (Model Context Protocol) Support:**

    *   **What it does:** Enables seamless integration with MCP servers, providing access to a wide range of pre-built tools. MCP allows agents to discover and utilize tools dynamically.
    *   **Usage Example:**

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

        aws_docs_client = MCPClient(
            lambda: stdio_client(StdioServerParameters(command="uvx", args=["awslabs.aws-documentation-mcp-server@latest"]))
        )

        with aws_docs_client:
           agent = Agent(tools=aws_docs_client.list_tools_sync())
           response = agent("Tell me about Amazon Bedrock and how to use it with Python")
        ```

*   **Pre-built Tools (strands-agents-tools):**

    *   **What it does:** Offers a collection of pre-built tools for common tasks, facilitating quick experimentation and agent development.  The `strands-agents-tools` package is optional.
    *   **Example:** The `calculator` tool performs calculations.
    *   **Usage Example:**

        ```python
        from strands import Agent
        from strands_tools import calculator
        agent = Agent(tools=[calculator])
        agent("What is the square root of 1764")
        ```

*   **Multiple Model Providers:**

    *   **What it does:** Supports a variety of LLM providers, including Amazon Bedrock, Anthropic, LiteLLM, LlamaAPI, Ollama, and OpenAI. This allows you to choose the best model for your specific needs.
    *   **Usage Example:**

        ```python
        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")
        ```
