# Swarms

> Prebuilt sequential, concurrent and hierarchical multi-agent architectures in one Python package

- Category: Agents & Automation / Multi-Agent Systems
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/kyegomez/swarms
- Website: https://swarms.ai
- Canonical page: https://ai-tldr.dev/tools/swarms/

## In short

Swarms is an Apache-2.0 Python framework for orchestrating several LLM agents together. It sits in the Multi-Agent Systems category of the Agents & Automation tools and is open-source, written in Python and licensed Apache-2.0. To get started: install the package.

## Overview

Swarms is an Apache-2.0 Python framework for orchestrating several LLM agents together. Its base unit is an Agent — an autonomous entity built from a model, tools and memory — and on top of that it ships a suite of prebuilt multi-agent architectures, including sequential, concurrent and hierarchical arrangements, so you assemble a known topology instead of inventing a control loop each time.

The framework is deliberately unopinionated about which model you run. An agent is configured with a `model_name` string, so the same swarm can be pointed at OpenAI, Anthropic or Groq models by changing configuration and environment keys. Agents can run for a fixed number of loops or with `max_loops="auto"`, in which case the agent keeps planning, acting and reflecting until it decides the task is finished — the mode the project recommends for open-ended work whose step count isn't known in advance.

Swarms treats the Model Context Protocol as a two-way street. Setting `mcp_url` or `mcp_urls` on an agent pulls in the tools an MCP server exposes with no manual wiring, and `MCPDeployer` turns any agent or swarm into an MCP server of its own, with an auth layer in front, so other agents and MCP hosts can call it as a tool. The project also states backward compatibility with other leading agent frameworks.

## What it does

- Prebuilt multi-agent architectures — sequential, concurrent and hierarchical — rather than a single hard-coded control flow
- Provider-agnostic agents configured by a `model_name` string, with keys supplied through the environment
- `max_loops="auto"` lets an agent decide for itself when a task is complete instead of stopping at a fixed iteration cap
- MCP client support: point an agent at one or many MCP server URLs and its tools become available automatically
- `MCPDeployer` serves any agent or swarm as an MCP server, with static API-key auth and one tool per target
- Installable from PyPI with pip, uv or poetry, or run from source

## Getting started

Swarms is a PyPI package. Install it, set the provider keys you plan to use in the environment, then build a single agent before composing several into a swarm.

1. Install the package

   pip works, and the README recommends uv. Poetry and a from-source install are also documented.

```bash
pip3 install -U swarms
# or, recommended:
uv pip install swarms
```

2. Configure the environment

   Swarms reads provider keys and a workspace directory from the environment. Set only the providers you intend to call.

```bash
OPENAI_API_KEY=""
WORKSPACE_DIR="agent_workspace"
ANTHROPIC_API_KEY=""
GROQ_API_KEY=""
```

3. Run your first agent

   An Agent is the building block of every swarm. Give it a model and a loop budget, then call run with a task.

```python
from swarms import Agent

agent = Agent(
    model_name="gpt-5.4",
    max_loops="auto",
    interactive=True,
    temperature=None,
)

agent.run("What are the key benefits of using a multi-agent system?")
```

4. Give the agent MCP tools

   Setting mcp_url points the agent at an MCP server; its tools are discovered and offered to the agent without further configuration.

```python
from swarms import Agent

agent = Agent(
    agent_name="MCP-Agent",
    model_name="claude-sonnet-5",
    mcp_url="https://mcp.deepwiki.com/mcp",
    max_loops=1,
    temperature=None,
    max_tokens=16_000,
)

print(agent.run("Use your tools to explain what the kyegomez/swarms repository does."))
```

5. Serve an agent as an MCP server

   MCPDeployer exposes an agent (or a list or dict of them) as MCP tools behind an API key, so other agents and MCP hosts can call it.

```python
from swarms import Agent, MCPDeployer

researcher = Agent(
    agent_name="Researcher",
    agent_description="Answers research questions with a short summary.",
    model_name="gpt-5.4",
    max_loops=1,
)

# Serves http://127.0.0.1:8000/mcp as the tool "researcher".
MCPDeployer(researcher, api_keys=["sk-local-dev"], port=8000).run()
```

## When to use it

- Compose a fixed pipeline of specialist agents — research, then draft, then review — using the prebuilt sequential architecture instead of hand-rolled queueing
- Fan a task out across several agents concurrently and collect the results under one hierarchical coordinator
- Give an existing agent a catalogue of external tools by pointing it at one or more MCP servers
- Publish an in-house agent as an MCP tool so other teams' agents and MCP hosts can call it behind an API key
