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.

Start with a local wiki. Create a virtual environment, run uv pip install -U agno openai, and set OPENAI_API_KEY. Save the following as wiki_context.py, then run python wiki_context.py. It creates a demonstration page only when that file is absent.

wiki_context.py
import asyncio
from pathlib import Path

from agno.agent import Agent
from agno.context.wiki import WikiContextProvider
from agno.context.wiki.backend import FileSystemBackend
from agno.models.openai import OpenAIResponses

async def main():
    root = Path(__file__).resolve().parent / "demo-wiki"
    root.mkdir(exist_ok=True)
    page = root / "deployment.md"
    if not page.exists():
        page.write_text("# Deployment\nRun tests before deploying.\n")
    wiki = WikiContextProvider(
        backend=FileSystemBackend(path=root),
        model=OpenAIResponses(id="gpt-5.4-mini"),
        write=False,
    )
    try:
        await wiki.asetup()
        agent = Agent(
            model=OpenAIResponses(id="gpt-5.4"),
            tools=wiki.get_tools(),
            instructions=wiki.instructions(),
        )
        await agent.aprint_response("What is documented about deployment?")
    finally:
        await wiki.aclose()

if __name__ == "__main__":
    asyncio.run(main())

This example exposes only query_wiki. The backend fragments below replace the provider construction inside main(); configure their prerequisites before running.

Backends

With write=True, updates commit and push changes. Use Git 2.31 or later and a dedicated repository you own with an existing main branch. Set WIKI_REPO_URL to its HTTPS URL and GITHUB_TOKEN to a PAT with the required repository permissions. Use a dedicated local clone directory.

import os
from agno.context.wiki.backend import GitBackend

backend = GitBackend(
    repo_url=os.environ["WIKI_REPO_URL"],
    branch="main",
    github_token=os.environ["GITHUB_TOKEN"],
    local_path="./demo-wiki-git",
)
wiki = WikiContextProvider(backend=backend)

Configuration

ParameterTypeDefaultDescription
backendWikiBackendrequiredGitBackend, FileSystemBackend, or NotionDatabaseBackend.
idstr"wiki"Tools become query_<id> and update_<id>.
webContextBackendNoneOptional web backend for ingestion (fetch URL → write page).
modelModelNoneModel for sub-agents.
readboolTrueExpose query_wiki.
writeboolTrueExpose update_wiki.

Tools Exposed

ToolDescription
query_wikiSearch pages, read content, list structure.
update_wikiCreate pages, edit content. Auto-commits with Git backend.

Web Ingestion

Configuration fragment for the async runner: add a web backend to let the agent fetch URLs and write them as wiki pages. This enables local file writes:

from agno.context.web import ExaBackend

wiki = WikiContextProvider(
    backend=FileSystemBackend(path="./demo-wiki-web"),
    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 for other backends.

Lifecycle Management

Always call await wiki.asetup() before exposing query tools. Direct aquery() and updates run setup, but the current query-tool path does not. Git setup clones or validates the local repository; Notion setup resolves metadata only.

Queries do not automatically refresh remote content. Use await wiki.sync() for a fresh Git/Notion snapshot, including before the first Notion read. Updates sync before writing and call the backend’s commit hook afterward. Git commits and pushes; the filesystem hook is a no-op; Notion writes back its supported markdown subset. Put await wiki.aclose() in finally, particularly when using an MCP web backend.

Example queries

QueryWhat 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