Overview
The DocRouter MCP Server is an implementation of Anthropic's Model Context Protocol (MCP) for docrouter.ai. It enables Claude and other MCP clients to securely access and interact with docrouter.ai workspaces, providing standardized interfaces for documents, prompts, extraction schemas, and extraction results.
MCP is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.
Features
Authentication
Uses docrouter.ai's existing user token-based authentication system to ensure secure access
Workspace Exposure
Exposes a single workspace (organization) based on the authenticated user's token
Document Management
Interfaces to list, view, and search documents in the workspace
Prompts Access
Interfaces to list and view prompts and their configurations
Extraction Schemas
Interfaces to list and view extraction schemas and their configurations
Extraction Results
Interfaces to list and view extraction results for documents
Architecture
The MCP server is implemented as a separate directory and process from the main docrouter.ai application. This separation provides several benefits:
- Isolation: The MCP server can run independently, reducing the risk of affecting the main application.
- Scalability: The MCP server can be scaled separately from the main application.
- Deployment Flexibility: The MCP server can be deployed on the same or different machines as the main application.
- Development Independence: Changes to the MCP server can be made without affecting the main application.
Directory Structure
packages/docrouter_mcp/
├── __init__.py # Package initialization
├── docrouter_mcp_server.py # Main server implementation
└── requirements.txt # Server dependencies
Installation
To install the MCP server, follow these steps:
1. Clone the repository
git clone https://github.com/analytiq-hub/doc-router.git
cd doc-router
2. Install required dependencies
pip install -r packages/docrouter_mcp/requirements.txt
Usage
Running the Server
You can run the MCP server using the MCP CLI:
python packages/docrouter_mcp/docrouter_mcp_server.py --url https://app.docrouter.ai/fastapi --org-id ORG_ID --org-api-token ORG_API_TOKEN
Testing the Server
To test the server functionality:
npx @modelcontextprotocol/inspector python docrouter_mcp_server.py --url https://app.docrouter.ai/fastapi --org-id ORG_ID --org-api-token ORG_API_TOKEN
Integration with Claude
To use this MCP server with Claude Desktop:
- Run the MCP server
- In Claude Desktop, go to Settings > Developer, open claude_desktop_config.json
- Add a new MCP server with the appropriate connection details
- Adjust the path to the python executable and to the MCP server script to match your local setup
- Url, org-id and org-api-token need to be specified as environment variables (Claude Desktop limitation)
- Claude will now be able to access your docrouter.ai workspace through the MCP server
{
"mcpServers": {
"docrouter": {
"command": "/Users//build/analytiq/doc-router/packages/docrouter_mcp/.venv/bin/python",
"args": [
"/Users//build/analytiq/doc-router/packages/docrouter_mcp/docrouter_mcp_server.py"
],
"env": {
"DOCROUTER_URL": "https://app.docrouter.ai/fastapi",
"DOCROUTER_ORG_ID": "",
"DOCROUTER_ORG_API_TOKEN": ""
}
}
}
}
Interfaces
Document Tools
get_docrouter_documents()
- List all documents in the workspaceget_docrouter_document(document_id)
- Get a specific document by IDget_docrouter_document_ocr(document_id)
- Get the raw OCR text for a documentget_docrouter_document_ocr_page(document_id, page_num)
- Get OCR text for a specific pageget_docrouter_document_ocr_metadata(document_id)
- Get OCR metadata for a document
Tag Tools
get_docrouter_tags()
- List all tags in the workspaceget_docrouter_tag(tag_id)
- Get a specific tag by IDsearch_docrouter_tags(query)
- Search tags by name or description
Prompt Tools
get_docrouter_prompts()
- List all prompts in the workspaceget_docrouter_prompt(prompt_id)
- Get a specific prompt by IDsearch_docrouter_prompts(query)
- Search prompts by name or content
Search & Extraction Tools
search_docrouter_documents(query, tag_ids)
- Search documents by name or content with optional tag filteringget_docrouter_extraction(document_id, prompt_id)
- Get extraction results for a document using a specific promptrun_docrouter_extraction(document_id, prompt_id, force)
- Run AI extraction on a document using a specific prompt
Help Tools
docrouter_help()
- Get comprehensive help information about using the DocRouter APIdocrouter_document_analysis_guide(document_id)
- Get guidance for analyzing a specific document
Example Workflows
Here are some common workflows using the MCP server:
Finding Documents
search_docrouter_documents("invoice")
Viewing Document Content
get_docrouter_document_ocr("doc123")
Running Extractions
run_docrouter_extraction("doc123", "prompt456")
Viewing Extraction Results
get_docrouter_extraction("doc123", "prompt456")
GitHub Repository
The DocRouter MCP Server is part of the docrouter.ai open source project. You can find the source code on GitHub.
View on GitHub