Nanonets MCP Server

Nanonets MCP Server

Converts images, PDFs, Word documents, and Excel spreadsheets to structured markdown using Nanonets OCR, with support for tables, LaTeX equations, and complex layouts.

Category
访问服务器

README

Nanonets MCP Server

An MCP (Model Context Protocol) server that exposes Nanonets OCR functionality for converting images to structured markdown.

Features

  • Advanced OCR: Convert documents to structured markdown using Nanonets-OCR-s (3.75B parameter model)
  • Multi-format Support: Handles images, PDFs, Word documents, and Excel spreadsheets
    • Images: PNG, JPEG, BMP, TIFF, WEBP
    • Documents: PDF, DOCX, XLSX
  • PDF Processing: Complete multi-page PDF document processing with page-by-page OCR
  • Office Document Processing: Direct text extraction from Word and Excel files
  • Intelligent Recognition: Detects and converts:
    • Text and paragraphs
    • Tables with structure preservation
    • LaTeX equations
    • Images with descriptions
    • Signatures and watermarks
    • Checkboxes
    • Complex layouts
    • Multi-page documents with proper page separation
    • Word document headings and formatting
    • Excel worksheets and data tables

Installation

Option 1: Docker (Recommended with GPU)

# Clone the repository
git clone <repository-url>
cd nanonets_mcp

# Build and run with Docker Compose (requires NVIDIA Docker runtime)
docker-compose up --build

Prerequisites for GPU support:

Option 2: Local Installation

# Clone the repository
git clone <repository-url>
cd nanonets_mcp

# Install dependencies with uv
uv pip install -e .

Usage

Running the Server

With Docker:

# Start with Docker Compose
docker-compose up

# Or run directly with Docker
docker run --gpus all -p 8000:8000 nanonets-mcp:latest

Local Installation:

# Start the MCP server
nanonets-mcp

# Or run directly
python -m nanonets_mcp.server

Available Tools

ocr_image_to_markdown

Convert an image to structured markdown format.

Parameters:

  • image_data (string): Image data as base64 string, data URL, or file path
  • image_format (optional string): Format hint (png, jpg, etc.)

Returns: Structured markdown representation of the document

ocr_pdf_to_markdown

Convert an entire PDF document to structured markdown format.

Parameters:

  • pdf_data (string): PDF data as base64 string, data URL, or file path

Returns: Structured markdown representation of the entire PDF document with page separators

process_word_to_markdown

Convert a Word document (.docx) to structured markdown format.

Parameters:

  • docx_data (string): Word document data as base64 string, data URL, or file path

Returns: Structured markdown representation of the Word document with headings and tables

process_excel_to_markdown

Convert an Excel file (.xlsx) to structured markdown format.

Parameters:

  • excel_data (string): Excel file data as base64 string, data URL, or file path

Returns: Structured markdown representation of all worksheets in the Excel workbook

get_supported_formats

Get information about supported formats and capabilities.

Returns: Dictionary with supported formats, input methods, capabilities, and processing options

Available Resources

nanonets://model-info

Provides detailed information about the Nanonets OCR model, including capabilities and specifications.

Examples

Basic OCR Usage

Image Processing

# Using file path
result = await ocr_image_to_markdown("/path/to/document.png")

# Using base64 data
with open("document.jpg", "rb") as f:
    image_b64 = base64.b64encode(f.read()).decode()
result = await ocr_image_to_markdown(image_b64)

# Using data URL
data_url = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
result = await ocr_image_to_markdown(data_url)

PDF Processing

# Process entire PDF document
result = await ocr_pdf_to_markdown("/path/to/document.pdf")

# Using base64 PDF data
with open("document.pdf", "rb") as f:
    pdf_b64 = base64.b64encode(f.read()).decode()
result = await ocr_pdf_to_markdown(pdf_b64)

# Result includes all pages with separators
# Example output:
# # PDF Document
# *Total pages: 3*
# 
# ---
# # Page 1
# [Content of page 1]
# 
# ---
# # Page 2
# [Content of page 2]
# ...

Word Document Processing

# Process Word document
result = await process_word_to_markdown("/path/to/document.docx")

# Using base64 Word document data
with open("document.docx", "rb") as f:
    docx_b64 = base64.b64encode(f.read()).decode()
result = await process_word_to_markdown(docx_b64)

# Result includes text, headings, and tables
# Example output:
# # Word Document
# 
# # Main Title
# 
# This is a paragraph of text.
# 
# ## Section Header
# 
# More content here.
# 
# | Name | Age | City |
# | --- | --- | --- |
# | John | 30 | NYC |

Excel Spreadsheet Processing

# Process Excel file
result = await process_excel_to_markdown("/path/to/spreadsheet.xlsx")

# Using base64 Excel data
with open("spreadsheet.xlsx", "rb") as f:
    excel_b64 = base64.b64encode(f.read()).decode()
result = await process_excel_to_markdown(excel_b64)

# Result includes all worksheets as tables
# Example output:
# # Excel Workbook
# 
# ## Sheet: Employee Data
# 
# | Name | Department | Salary |
# | --- | --- | --- |
# | Alice | Engineering | 75000 |
# | Bob | Marketing | 65000 |
# 
# ## Sheet: Financial Data
# 
# | Quarter | Revenue | Expenses |
# | --- | --- | --- |
# | Q1 | 150000 | 120000 |

Integration with Claude Desktop

Add to your Claude Desktop configuration:

{
  "mcpServers": {
    "nanonets-ocr": {
      "command": "nanonets-mcp"
    }
  }
}

Model Information

  • Model: nanonets/Nanonets-OCR-s
  • Parameters: 3.75B (based on Qwen2.5-VL-3B-Instruct)
  • Input: Images up to 2048x2048 pixels (recommended) and PDF documents
  • Output: Structured markdown with semantic tagging
  • PDF Processing: 200 DPI conversion, all pages processed sequentially

Requirements

Core Dependencies

  • Python ≥3.10
  • PyTorch ≥2.0.0
  • Transformers =4.53.0
  • PIL/Pillow ≥10.0.0
  • MCP ≥1.0.0

Optional Dependencies

  • pdf2image ≥1.16.0 (for PDF support)
  • PyMuPDF ≥1.23.0 (for PDF support)
  • python-docx ≥0.8.11 (for Word document support)
  • openpyxl ≥3.1.0 (for Excel support)
  • pandas ≥2.0.0 (for Excel support)

Development

Testing

Docker Testing:

# Test Docker build
docker-compose build

# Run health check
docker-compose up -d
docker-compose ps

# View logs
docker-compose logs -f nanonets-mcp

# Stop services
docker-compose down

Local Testing:

# Test with MCP Inspector
mcp dev nanonets_mcp/server.py

# Install for development
uv pip install -e .

Docker Management

# Rebuild image after changes
docker-compose build --no-cache

# View resource usage
docker stats nanonets-mcp-server

# Access container shell
docker-compose exec nanonets-mcp bash

# Clean up volumes and images
docker-compose down -v
docker image prune -f

License

[Add your license information here]

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选