# Mastra RAG

> Mastra RAG pipeline development - document processing, chunking, embedding, vector databases, retrieval, GraphRAG, and agent integration tools. Covers MDocument chunking strategies (recursive, markdown), AI SDK embed()/embedMany() and embedding model choice, vector stores (PgVector, Pinecone, Qdrant) and migrating between them, rerank()/rerankWithScorer(), and createVectorQueryTool().

- Skill: `artsmc-claude-dev-agents/mastra-rag` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add artsmc-claude-dev-agents/mastra-rag`
- Raw SKILL.md: https://api.skillmd.com/api/skills/artsmc-claude-dev-agents/mastra-rag/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- Author: artsmc (https://skillmd.com/u/artsmc-claude-dev-agents)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/artsmc-claude-dev-agents/mastra-rag

---


# Mastra RAG Pipeline Development

Comprehensive guide for building retrieval-augmented generation pipelines with Mastra. Covers document processing (MDocument), chunking strategies, embedding with AI SDK, 17+ vector database providers, retrieval patterns, reranking, GraphRAG, and agent integration tools.

## Usage

```bash
/mastra-rag
```

Provides context for:
- `MDocument` class (fromText, fromMarkdown, fromHTML)
- Chunking with `.chunk({ strategy, maxSize, overlap })`
- Embedding via AI SDK `embed()` from `'ai'`
- Vector store setup (PgVector, Pinecone, Qdrant, Chroma, etc.)
- `createVectorQueryTool()`, `createDocumentChunkerTool()`, `createGraphRAGTool()`
- Reranking with `rerank()` and `rerankWithScorer()`
- Metadata filters

