> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/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

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[markdown]" openai pgvector psycopg sqlalchemy
    ```
  </Step>

  <Step title="Export the API key">
    ```bash theme={null}
    export OPENAI_API_KEY=your_openai_api_key_here
    ```
  </Step>

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

  <Step title="Run the agent">
    ```bash theme={null}
    python markdown_reader.py
    ```
  </Step>
</Steps>

## 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](/reference/knowledge/reader/base) 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](/knowledge/concepts/chunking/markdown-chunking) |
| Choose another chunking strategy | [Chunking Overview](/knowledge/concepts/chunking/overview)          |
| Compare available readers        | [Readers Overview](/knowledge/concepts/readers/overview)            |
