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

# Markdown Reader

> Convert Markdown files into knowledge base documents with MarkdownReader.

Pass `MarkdownReader` to `Knowledge.insert()` to load a Markdown file.

```python markdown_reader.py theme={null}
from pathlib import Path

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.reader.markdown_reader import MarkdownReader
from agno.models.openai import OpenAIResponses
from agno.vectordb.pgvector import PgVector

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

knowledge = Knowledge(
    vector_db=PgVector(
        table_name="markdown_documents",
        db_url=db_url,
    ),
)

agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    knowledge=knowledge,
    search_knowledge=True,
)

if __name__ == "__main__":
    markdown_path = Path("tmp/project.md")
    markdown_path.parent.mkdir(parents=True, exist_ok=True)
    markdown_path.write_text(
        "# Project Atlas\n\nProject Atlas tracks deployment readiness.\n",
        encoding="utf-8",
    )
    knowledge.insert(path=markdown_path, reader=MarkdownReader())
    agent.print_response("What does Project Atlas track?", markdown=True)
```

## Run the Agent

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U "agno[markdown]" openai pgvector psycopg sqlalchemy
```

**2. Export the API key**

```bash theme={null}
export OPENAI_API_KEY=your_openai_api_key_here
```

<Snippet file="run-pgvector-step.mdx" />

**3. Run the agent**

```bash theme={null}
python markdown_reader.py
```

## Reader Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `chunking_strategy` | `Optional[ChunkingStrategy]` | `MarkdownChunking()` when available | Strategy used to chunk the Markdown content |

`MarkdownReader` also accepts the base [Reader](https://agno-v2.mintlify.site/reference/knowledge/reader/base.md) constructor parameters.

The `agno[markdown]` extra installs `unstructured`, `markdown`, and `aiofiles`, so this setup uses `MarkdownChunking`. With the base `agno` package alone, the reader falls back to `FixedSizeChunking`.

`MarkdownReader.async_read()` uses `aiofiles` when it is installed and falls back to synchronous file I/O otherwise.

## Next Steps

| Task | Guide |
| - | - |
| Configure Markdown chunking | [Markdown Chunking](https://agno-v2.mintlify.site/knowledge/concepts/chunking/markdown-chunking.md) |
| Choose another chunking strategy | [Chunking Overview](https://agno-v2.mintlify.site/knowledge/concepts/chunking/overview.md) |
| Compare available readers | [Readers Overview](https://agno-v2.mintlify.site/knowledge/concepts/readers/overview.md) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.