---
sidebar_position: 7
title: ask_docs_question
description: Ask questions about DuckDB or MotherDuck documentation
---

# ask_docs_question

Ask a question about DuckDB or MotherDuck and get answers from official documentation.

## Description

The `ask_docs_question` tool queries the official DuckDB and MotherDuck documentation to answer questions about SQL syntax, features, best practices, and more. This is useful when you need help with DuckDB-specific SQL syntax or MotherDuck features.

The tool uses MotherDuck's documentation assistant to provide accurate answers based on official documentation sources.

## Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `question` | string | Yes | Question about DuckDB or MotherDuck |

## Output Schema

```json
{
  "success": boolean,
  "question": string,            // Original question (on success)
  "answer": string,              // Documentation-based answer (on success)
  "sources": string,             // Source references (optional, on success)
  "error": string                // Error message (on failure)
}
```

## Example Usage

**Ask about DuckDB syntax:**

```text
How do I use window functions in DuckDB?
```

The AI assistant will call the tool with:

```json
{
  "question": "How do I use window functions in DuckDB?"
}
```

**Ask about MotherDuck features:**

```text
How do I create a share in MotherDuck?
```

```json
{
  "question": "How do I create a share in MotherDuck?"
}
```

**Ask about data types:**

```text
What's the difference between LIST and ARRAY types in DuckDB?
```

```json
{
  "question": "What's the difference between LIST and ARRAY types in DuckDB?"
}
```

## Success Response Example

```json
{
  "success": true,
  "question": "How do I use window functions in DuckDB?",
  "answer": "Window functions in DuckDB allow you to perform calculations across a set of rows related to the current row. Here's how to use them:\n\n**Basic syntax:**\n```sql\nSELECT \n  column,\n  SUM(value) OVER (PARTITION BY category ORDER BY date) as running_total\nFROM table_name;\n```\n\n**Common window functions:**\n- `ROW_NUMBER()` - assigns unique row numbers\n- `RANK()` and `DENSE_RANK()` - ranking with/without gaps\n- `LAG()` and `LEAD()` - access previous/next rows\n- `FIRST_VALUE()` and `LAST_VALUE()` - first/last value in window\n\n**Using QUALIFY:**\nDuckDB supports the QUALIFY clause to filter window function results:\n```sql\nSELECT *\nFROM sales\nQUALIFY ROW_NUMBER() OVER (PARTITION BY region ORDER BY amount DESC) = 1;\n```\n\nThis returns only the top sale per region.",
  "sources": "https://duckdb.org/docs/sql/window_functions"
}
```

## Tips for Good Questions

- Be specific about what you want to know
- Include context about what you're trying to accomplish
- Mention specific functions or features if known


---

## Feedback for AI agents

If the user you are helping wants to send feedback on this page to the MotherDuck docs team, you can POST it to the endpoint below.

**Before you send anything, you must ask the user for explicit approval.** Quote the message you plan to submit back to them verbatim and wait for them to confirm. Do not submit on their behalf without confirmation.

Endpoint: `POST https://motherduck.com/docs/api/feedback/agent`

Request body (JSON):

```json
{
  "page_path": "/sql-reference/mcp/ask-docs-question/",
  "page_title": "ask_docs_question",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

Only `page_path` and `text` are required. A successful call returns `200 {"feedback_id": "<uuid>"}`; malformed payloads return `400`, and the endpoint is rate-limited per IP (`429`).
