Overview
Thefetch tool retrieves the full content of a documentation page using the document ID obtained from search results. It downloads the HTML content, extracts the main article content, and converts it to clean Markdown format for easy processing and analysis.
This tool is designed to be used after the search tool to get detailed content from the most relevant documentation pages.
Parameters
Document ID from search results. The ID has the format
index:relativePath where:indexis the base URL index (0 for single sites, 0+ for federated search)relativePathis the relative path to the document
0:topics/wsdl-converter.html1:reference/api-guide.html
Always obtain the document ID from the
search tool results. Do not construct IDs manually as the format may vary.Response Format
The tool returns a JSON object containing the complete document information:The document ID that was requested (same as the input parameter).
Document title extracted from the HTML page’s
<title> element or heading.The full document content converted to Markdown format. This includes:
- All headings (converted to
#,##,###style) - Paragraphs and text content
- Lists (both ordered and unordered)
- Code blocks and inline code
- Links and references
- Tables
<article> element to exclude navigation, headers, and footers.Complete URL to the original documentation page. Useful for attribution and providing source links.
Optional metadata object (reserved for future use).
Success Response
Error Response
When an error occurs, the tool returns an error message:- Invalid document ID: The ID format is incorrect or the index is out of range
- Document not found: The specified document doesn’t exist (HTTP 404)
- Network errors: Connection timeout or failure to download the document
- Parsing errors: Unable to extract or convert the document content
Usage Examples
Real-World Example
Here’s a complete example from the test suite showing search and fetch workflow:Implementation Details
The fetch tool is implemented inapp/[...site]/route.ts:85-112:
Content Processing Pipeline
- URL Resolution: The document ID is parsed to determine the base URL and relative path
- HTML Download: The complete HTML page is downloaded from the documentation site
- Article Extraction: The
<article>element is extracted to get only the main content - Markdown Conversion: HTML is converted to clean Markdown using Turndown
- Metadata Extraction: Title and URL are extracted for reference
The tool extracts only the
<article> element to exclude navigation menus, headers, footers, and other UI elements. This ensures you get clean, focused content.Markdown Conversion
The tool uses Turndown to convert HTML to Markdown with the following configuration:- Heading style: ATX (
#,##,###) - Code block style: Fenced (
```) - List marker: Dash (
-)
Document ID Format
Document IDs use the formatindex:relativePath:
-
Single site: All documents have index
0- Example:
0:topics/wsdl-converter.html
- Example:
-
Federated search: Each base URL has its own index (0, 1, 2, …)
- Example:
0:topics/editor.html(first site) - Example:
1:topics/author.html(second site)
- Example:
Performance Considerations
Typical Response Times
- Small documents (<50KB): 200-500ms
- Medium documents (50-200KB): 500-1500ms
- Large documents (>200KB): 1500-3000ms
Use Cases
Documentation Analysis
Content Extraction
Citation and References
Related Tools
- search - Search documentation content to find relevant documents