> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-codex-docs-audit-20260719-0149.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Wiki

> Read and write a markdown wiki backed by Git, the local filesystem, or Notion.

Read and write to a directory of markdown files. The provider exposes two tools: `query_wiki` for reading, `update_wiki` for writing. With a Git backend, writes auto-commit and push. With a Notion backend, writes sync to a Notion database.

```python theme={null}
from os import getenv
from agno.agent import Agent
from agno.context.wiki import WikiContextProvider
from agno.context.wiki.backend import GitBackend

wiki = WikiContextProvider(
    backend=GitBackend(
        repo_url="https://github.com/org/wiki.git",
        branch="main",
        github_token=getenv("GITHUB_TOKEN"),
        local_path="./demo-wiki-git",
    )
)

await wiki.asetup()

agent = Agent(
    model=...,
    tools=wiki.get_tools(),
)

await agent.arun("Add a page about our deployment process")
await wiki.aclose()
```

<Warning>
  Git and Notion backends can write to external systems. Scope credentials to only the target repository or database. For query-only access, set `write=False` on `WikiContextProvider`; this omits the `update_wiki` tool.
</Warning>

## Backends

<Tabs>
  <Tab title="Git">
    Auto-commits and pushes changes.

    ```python theme={null}
    from os import getenv
    from agno.context.wiki.backend import GitBackend

    backend = GitBackend(
        repo_url="https://github.com/org/wiki.git",
        branch="main",
        github_token=getenv("GITHUB_TOKEN"),
        local_path="./demo-wiki-git",
    )
    wiki = WikiContextProvider(backend=backend)
    ```
  </Tab>

  <Tab title="Filesystem">
    Local directory, no Git.

    ```python theme={null}
    from agno.context.wiki.backend import FileSystemBackend

    backend = FileSystemBackend(path="./wiki")
    wiki = WikiContextProvider(backend=backend)
    ```
  </Tab>

  <Tab title="Notion">
    Mirrors a Notion database. Each row becomes a local markdown page; writes push back to Notion, which stays the source of truth.

    ```shell theme={null}
    uv pip install -U notion-client
    ```

    ```python theme={null}
    from os import getenv
    from agno.context.wiki.backend import NotionDatabaseBackend

    backend = NotionDatabaseBackend(
        database_id=getenv("NOTION_DATABASE_ID"),
        token=getenv("NOTION_API_KEY"),
        local_path="./demo-wiki-notion",
    )
    wiki = WikiContextProvider(backend=backend)
    ```

    `token` falls back to the `NOTION_API_KEY` environment variable. `NotionPageBackend` (nested page trees) is planned and raises `NotImplementedError` today. See the [Notion wiki example](https://github.com/agno-agi/agno/blob/v2.7.4/cookbook/12_context/15a_wiki_notion.py).
  </Tab>
</Tabs>

## Configuration

| Parameter | Type             | Default  | Description                                                  |
| --------- | ---------------- | -------- | ------------------------------------------------------------ |
| `backend` | `WikiBackend`    | required | GitBackend, FileSystemBackend, or NotionDatabaseBackend.     |
| `id`      | `str`            | `"wiki"` | Tools become `query_<id>` and `update_<id>`.                 |
| `web`     | `ContextBackend` | `None`   | Optional web backend for ingestion (fetch URL → write page). |
| `model`   | `Model`          | `None`   | Model for sub-agents.                                        |
| `read`    | `bool`           | `True`   | Expose `query_wiki`.                                         |
| `write`   | `bool`           | `True`   | Expose `update_wiki`.                                        |

## Tools Exposed

| Tool          | Description                                                |
| ------------- | ---------------------------------------------------------- |
| `query_wiki`  | Search pages, read content, list structure.                |
| `update_wiki` | Create pages, edit content. Auto-commits with Git backend. |

## Web Ingestion

Add a web backend to let the agent fetch URLs and write them as wiki pages:

```python theme={null}
from agno.context.web import ExaBackend

wiki = WikiContextProvider(
    backend=GitBackend(..., local_path="./demo-wiki-git"),
    web=ExaBackend(),
)

# Agent can now: "Add this article to the wiki: https://..."
```

`ExaBackend` requires the `exa-py` package (`uv pip install -U exa-py`) and the `EXA_API_KEY` environment variable. See [Web](/context-providers/providers/web) for other backends.

## Lifecycle Management

With GitBackend, `asetup()` clones the repo. Queries and updates run it automatically on first use; call it at startup to surface clone errors early:

```python theme={null}
await wiki.asetup()   # Clone repo
try:
    agent = Agent(model=..., tools=wiki.get_tools())
    await agent.arun("What do we have documented about deployments?")
finally:
    await wiki.aclose()
```

## Example queries

| Query                                              | What happens                   |
| -------------------------------------------------- | ------------------------------ |
| "What do we have documented about authentication?" | Searches wiki content          |
| "Create a page about the new API endpoints"        | Creates markdown file, commits |
| "Update the deployment guide with the new steps"   | Edits file, commits            |

## Resources

<CardGroup cols={2}>
  <Card title="Workspace Reference" icon="wrench" href="/tools/toolkits/local/workspace">
    Underlying file operations
  </Card>

  <Card title="Cookbook Example" icon="book" href="https://github.com/agno-agi/agno/blob/v2.7.4/cookbook/12_context/15_wiki_git.py">
    Git-backed wiki example
  </Card>
</CardGroup>
