Skip to main content

Overview

The Nanonets MCP server lets AI assistants (Claude, Cursor, VS Code Copilot, and other MCP-compatible clients) extract and explore documents directly through natural language. Instead of writing API calls, you describe what you need and the assistant handles the extraction.

15 Extraction Tools

Full-featured tools for sync, async, and streaming extraction across all output formats.

Document Exploration

Navigate large documents with TOC, page-level reading, search, and section extraction.

OAuth 2.1 Authentication

Secure Auth0-based login — no API key configuration needed for end users.

Workflow Recipes

Built-in skill recipes that teach AI assistants optimal extraction patterns.

Quick Start

Connect with Claude Desktop

Add this to your Claude Desktop configuration file (claude_desktop_config.json):
{
  "mcpServers": {
    "nanonets": {
      "url": "https://mcp.nanonets.com/mcp"
    }
  }
}
Claude Desktop will open a browser for OAuth login on first use. No API key needed.

Connect with Claude Code

claude mcp add nanonets --transport http https://mcp.nanonets.com/mcp

Local Development

For local testing without OAuth, set your API key and run the server directly:
export DOCSTRANGE_API_KEY="your-api-key"
cd mcp/
fastmcp run server/main.py:mcp --transport http --port 8080
Then connect your MCP client to http://localhost:8080/mcp.

Authentication

The MCP server supports two authentication modes:
ModeWhenHow
OAuth 2.1 (Auth0)Production / hosted serverUsers log in via browser redirect. The server resolves their Nanonets API key from their email.
API key fallbackLocal developmentSet DOCSTRANGE_API_KEY env var. No OAuth flow needed.
OAuth is enabled automatically when AUTH0_MCP_CLIENT_ID is set. When disabled, the server falls back to the DOCSTRANGE_API_KEY environment variable.

Tools

The server exposes 15 tools organized into three categories.

Core Extraction

These tools call the Nanonets extraction API to process documents.
ToolDescriptionBest For
extract_syncSynchronous extraction with full optionsSmall documents (≤5 pages)
extract_asyncQueue for async processing, returns record_idLarge documents (>5 pages)
extract_streamReal-time SSE streaming of extraction resultsUI integrations, progress display
get_resultGet status and result of a previous extractionPolling async jobs
list_resultsList all extraction jobs (paginated)Browsing extraction history

Convenience Extraction

Pre-configured tools for common document types.
ToolDescriptionOutput
extract_to_markdownSimple document-to-markdown conversionMarkdown
extract_invoiceStructured invoice data extractionJSON (invoice fields)
extract_contract_clausesKey clause extraction from contractsJSON (clause fields)
extract_bank_statementTabular bank statement extractionCSV
extract_hierarchyHierarchical document structureJSON (nested sections)
extract_with_bounding_boxesContent with spatial coordinatesMarkdown + bounding box metadata

Document Exploration

Navigate large documents without loading everything into context.
ToolDescriptionKey Inputs
get_tocStructural overview (table of contents)file_url or record_id
get_result_pagesRead specific pagesrecord_id + pages (e.g., "1-3,5")
search_documentFind text or regex in documentrecord_id + query
get_sectionsGet content of named sectionssection_titles + file_url or record_id

Document Exploration Workflow

For large documents (50+ pages), use the exploration tools to avoid flooding the AI context window:

Step 1: Get the Table of Contents

get_toc(file_url="/path/to/annual-report.pdf")
Returns section titles, hierarchy levels, page numbers, and a record_id for follow-up calls.

Step 2: Read Specific Pages

get_result_pages(record_id="abc-123", pages="1-3,15,20-22")
Returns only the requested pages. Reports total_pages and any missing_pages.

Step 3: Search for Content

search_document(record_id="abc-123", query="revenue growth")
Returns matching lines with page numbers, line numbers, and surrounding context (up to 50 matches).

Step 4: Get Named Sections

get_sections(record_id="abc-123", section_titles="Executive Summary, Financial Results")
Returns the full content of matching sections. Supports partial, case-insensitive title matching.
All exploration tools work with the record_id from any prior extraction. Once a document is extracted, you can explore it as many times as needed without re-processing.

Input Methods

All extraction tools accept documents via:
ParameterDescriptionRecommendation
file_urlLocal file path or HTTPS URLPreferred — saves context tokens
file_base64Base64-encoded file contentAvoid when possible — uses lots of tokens
Local file paths (e.g., /Users/name/doc.pdf, ~/Downloads/report.pdf) are automatically detected and uploaded. Always prefer file paths over base64 encoding.
Supported file types: PDF, Word (.docx), Excel (.xlsx, .xls), PowerPoint (.pptx), Images (PNG, JPG, TIFF, WebP)

Output Formats

FormatParameterUse Case
Markdownoutput_format="markdown"General text extraction, summaries
JSONoutput_format="json"Structured data, specific fields, schemas
CSVoutput_format="csv"Table extraction, financial data
HTMLoutput_format="html"Preserving rich formatting

JSON Options

  • Field list: json_options='["field1", "field2"]' — extract specific fields
  • Custom schema: json_options='{"type": "object", ...}' — define exact output structure
  • Hierarchy: json_options="hierarchy_output" — nested document structure
  • Table of contents: json_options="table-of-contents" — structural overview only

Example Conversations

Extract an invoice

User: Extract the invoice at ~/Downloads/invoice.pdf Assistant calls extract_invoice(file_url="~/Downloads/invoice.pdf") and returns structured fields: invoice number, vendor, line items, totals.

Explore a large report

User: I have a 200-page annual report. What’s in it? Assistant calls get_toc(file_url="~/Documents/report.pdf") to get the structure, then uses get_result_pages and search_document to read specific sections.

Search within a contract

User: Does this contract mention indemnification? Assistant calls search_document(record_id="...", query="indemnification") to find all mentions with page numbers and context.

Environment Variables

For self-hosted deployments, configure the server with these environment variables:
VariableDescriptionDefault
MCP_HOSTHost to bind to0.0.0.0
MCP_PORTPort to bind to8080
AUTH0_MCP_CLIENT_IDAuth0 application Client ID(none — OAuth disabled)
AUTH0_MCP_CLIENT_SECRETAuth0 application Client Secret
AUTH0_MCP_AUDIENCEAuth0 API audiencehttps://mcp.nanonets.com
MCP_BASE_URLPublic URL of the MCP serverhttps://mcp.nanonets.com
DATABASE_URLPostgreSQL connection string
DOCSTRANGE_API_KEYAPI key for local dev (no OAuth)