# Docs Chatbot

Answers questions about a library's functions by looking up structured documentation.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).



<DocsBaseSwitcher base="mastra" agent="docs-chatbot" />

<AgentPreview
  agent="docs-chatbot"
  framework="mastra"
  inputFields="[
  {
    name: &#x22;query&#x22;,
    label: &#x22;Question&#x22;,
    placeholder: &#x22;Tell me about the getPlanetaryData function.&#x22;,
    type: &#x22;text&#x22;,
  },
]"
/>

## Summary [#summary]

The **Docs Chatbot Agent** answers questions about a code library's API. It looks
up structured function documentation — signatures, parameters, and examples — and
answers using only what the docs say. Reach for it to drop a grounded "ask the
docs" assistant into a docs site, an IDE, or a support channel.

## Installation [#installation]

<CodeTabs>
  <TabsList>
    <TabsTrigger value="cli">
      Command
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add @agentcn/mastra/docs-chatbot
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      npm install @mastra/core
      ```

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource src="registry/mastra/docs-chatbot/config.ts" title="config.ts" />

      <ComponentSource src="registry/mastra/docs-chatbot/instructions.md" title="instructions.md" />

      <ComponentSource src="registry/mastra/docs-chatbot/data/functions.json" title="data/functions.json" />

      <ComponentSource src="registry/mastra/docs-chatbot/tools/lookup_docs.ts" title="tools/lookup_docs.ts" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</CodeTabs>

## Composition [#composition]

```text
├── config.ts             # Agent definition (model + config)
├── instructions.md       # Docs-grounded answering instructions
├── data/
│   └── functions.json    # Sample documentation source
└── tools/
    └── lookup_docs.ts    # Looks up functions by name or keyword
```

## Customization [#customization]

* **Point at your docs.** Replace `data/functions.json` with your generated API
  docs (e.g. from TypeDoc), or change `lookup_docs` to fetch from a remote source.
* **Improve matching.** Swap the substring filter for embeddings-based search to
  handle paraphrased questions.
* **Expose it as MCP.** Wrap `lookup_docs` in an MCP server so other clients can
  query the same docs.
* **Swap the model.** Edit `config.ts`.
