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


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
