Skip to main content

Overview

The get tool retrieves the full content of a document by its file path or docid. Use paths or docids from search results to fetch complete documents.

Input Schema

file
string
required
File path, docid, or path with line number suffixFormats:
  • pages/meeting.md — Relative file path
  • #abc123 — Docid from search results (# prefix optional)
  • pages/meeting.md:100 — Path with line offset
fromLine
number
Start reading from this line number (1-indexed). Overrides :line suffix in file.
maxLines
number
Maximum number of lines to return. Truncates long documents.
lineNumbers
boolean
default:"false"
Add line numbers to output (format: N: content)

Response Format

Success

content
array
Array with a single resource object

Error

content
array
Array with a single text element
isError
boolean
Always true for errors

Examples

Retrieve by Path

Request:
{
  "file": "docs/errors.md"
}
Response:
{
  "content": [
    {
      "type": "resource",
      "resource": {
        "uri": "qmd://myproject/docs/errors.md",
        "name": "myproject/docs/errors.md",
        "title": "Error Handling Guide",
        "mimeType": "text/markdown",
        "text": "# Error Handling Guide\n\nThis document describes error handling patterns...\n"
      }
    }
  ]
}

Retrieve by Docid

Request:
{
  "file": "#abc123"
}
Response:
{
  "content": [
    {
      "type": "resource",
      "resource": {
        "uri": "qmd://myproject/src/errors.ts",
        "name": "myproject/src/errors.ts",
        "title": "errors.ts",
        "mimeType": "text/markdown",
        "text": "<!-- Context: Source code for error utilities -->\n\nexport function handleError(err: Error) {\n  logger.error(err.message);\n}\n"
      }
    }
  ]
}
Note the <!-- Context: ... --> prefix from qmd context add.

Start at Specific Line

Request:
{
  "file": "docs/api.md:100"
}
Or equivalently:
{
  "file": "docs/api.md",
  "fromLine": 100
}

With Line Numbers

Request:
{
  "file": "src/utils.ts",
  "lineNumbers": true
}
Response:
{
  "content": [
    {
      "type": "resource",
      "resource": {
        "uri": "qmd://myproject/src/utils.ts",
        "name": "myproject/src/utils.ts",
        "title": "utils.ts",
        "mimeType": "text/markdown",
        "text": "1: export function formatDate(date: Date): string {\n2:   return date.toISOString();\n3: }\n"
      }
    }
  ]
}

Truncate Long Documents

Request:
{
  "file": "docs/architecture.md",
  "maxLines": 50
}
Returns only the first 50 lines.

File Not Found

Request:
{
  "file": "docs/missing.md"
}
Response:
{
  "content": [
    {
      "type": "text",
      "text": "Document not found: docs/missing.md\n\nDid you mean one of these?\n  - docs/api.md\n  - docs/errors.md"
    }
  ],
  "isError": true
}

Path Resolution

The tool tries multiple strategies to find documents:
  1. Exact matchcollection + path
  2. Suffix match — If exact match fails, finds paths ending with the query
  3. Docid lookup — If file starts with #, treats it as a docid
This means you can use shortened paths:
{ "file": "errors.md" }  // Matches docs/errors.md

Context Metadata

If you’ve added context with qmd context add, it appears as a comment at the top:
<!-- Context: Source code for error utilities -->

export function handleError(err: Error) {
  ...
}
This helps LLMs understand the file’s purpose without additional prompting.

CLI Equivalent

qmd get docs/errors.md
qmd get "#abc123"
qmd get docs/errors.md:100
Add --line-numbers for numbered output.

multi_get Tool

Retrieve multiple documents by glob pattern

query Tool

Search to find document paths and docids

Context

Add context metadata with qmd context

Build docs developers (and LLMs) love