Indexes your Linear issues and Notion pages into pgvector (on Neon) and exposes a single agent that answers questions over them. The agent searches the indexed corpus first, falls back to live Linear/Notion lookups via MCP (mcp.linear.app and @notionhq/notion-mcp-server), and uses provider-native web search through Mastra's Gateway as a last resort.
A scheduled workflow (index-knowledge) re-indexes every 6 hours automatically. Input is normalized with UnicodeNormalizer, and PIIDetector redacts emails, phone numbers, SSNs, credit card numbers, and API keys from responses before they reach the user.
- Node.js
>= 22.13.0 - A Neon Postgres database (or any Postgres 11+ with the
vectorextension) - A Gateway API key — get one at gateway.mastra.ai
- A Linear API key and/or Notion integration token
pnpm install
cp .env.example .env
# fill in MASTRA_GATEWAY_API_KEY, DATABASE_URL, LINEAR_API_KEY, NOTION_API_KEY
pnpm devOn Neon, make sure CREATE EXTENSION IF NOT EXISTS vector; has been run on your database.
Run the index-knowledge workflow from Mastra Studio (pnpm dev → workflows tab) or programmatically. It will:
- Pull up to N recent Linear issues via the Linear GraphQL API.
- Search Notion pages the integration has access to via the Notion REST API.
- Embed each document with
mastra/openai/text-embedding-3-smallthrough the Gateway. - Upsert into the
company_knowledgepgvector index.
The workflow is scheduled to run every 6 hours automatically. You can also trigger it manually from Studio or programmatically.
The agent's instructions force this order:
search-knowledge— semantic search over the indexed corpus.- Live Linear / Notion tools (via MCP) — when fresh data is needed.
- Provider-native
web_search— for public information.
Sources (URLs) are always cited in the response.
| Variable | Purpose |
|---|---|
MASTRA_GATEWAY_API_KEY |
Routes the chat model, embeddings, and provider tools through the Gateway. |
DATABASE_URL |
Neon (or other) Postgres connection string with ?sslmode=require. |
LINEAR_API_KEY |
Linear personal API key (for Linear MCP server). |
NOTION_API_KEY |
Notion internal integration token (for Notion MCP server). |
This template enables the code-backed Agent Editor with new MastraEditor({ source: 'code', codePath: 'mastra/editor' }). Edits made in Studio are written as deterministic JSON overrides under mastra/editor/agents/, so Mastra Platform can open GitHub pull requests for agent changes instead of only saving them to the database.