> For the complete documentation index, see [llms.txt](https://docs.mozilla.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mozilla.ai/tinyagent/index.md).

# Introduction

A minimal agent framework with first-class tracing, callbacks, MCP, and serving support.

## Why tinyagent

* **Tiny**: One small Python implementation of the agent loop. You can read it in one sitting.
* **Tracing built in**: Every run produces an `AgentTrace` with OpenTelemetry-compatible spans, token counts, and cost.
* **Callbacks**: Subclass `Callback` for guardrails, metrics, observability, or intentional cancellation.
* **MCP-native**: First-class support for [Model Context Protocol](https://modelcontextprotocol.io/) tools (stdio, SSE, streamable HTTP).
* **Serve as a service**: Run your agent over MCP or A2A.
* **Provider-agnostic**: Built on [`any-llm`](https://github.com/mozilla-ai/any-llm). Swap providers by changing `model_id`.

## Install

```bash
pip install mozilla-ai-tinyagent
```

The PyPI distribution name is `mozilla-ai-tinyagent`; the import name is `tinyagent`.

Optional extras:

```bash
pip install 'mozilla-ai-tinyagent[a2a]'       # A2A serving
pip install 'mozilla-ai-tinyagent[composio]'  # Composio tools
pip install 'mozilla-ai-tinyagent[all]'       # everything
```

## Quickstart

```python
from tinyagent import TinyAgent, AgentConfig
from tinyagent.tools import search_web, visit_webpage

agent = TinyAgent.create(
    AgentConfig(
        model_id="mistral:mistral-small-latest",
        instructions="Use the tools to find an answer.",
        tools=[search_web, visit_webpage],
    )
)

trace = agent.run("Which agent framework is the simplest?")
print(trace.final_output)
```

## What's next

* [Models](/tinyagent/guides/models.md) — configuring providers and `model_id` syntax.
* [Tools](/tinyagent/guides/tools.md) — using callable tools, MCP servers, and the built-in helpers.
* [Callbacks](/tinyagent/guides/callbacks.md) — observe and control execution.
* [Tracing](/tinyagent/guides/tracing.md) — inspect spans, tokens, and cost.
* [Serving](/tinyagent/guides/serving.md) — serve your agent over MCP or A2A.
* [Evaluation](/tinyagent/guides/evaluation.md) — judge an agent's behavior with `LlmJudge` and `AgentJudge`.
* [Cookbook](/tinyagent/cookbook/your-first-agent.md) — runnable examples.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mozilla.ai/tinyagent/index.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
