Readwise MCP HTTP Server

Readwise MCP HTTP Server

Enables searching and accessing Readwise highlights and documents through HTTP endpoints using the Model Context Protocol. Provides vector and full-text search capabilities with streaming responses for retrieving reading highlights and notes.

Category
访问服务器

README

Readwise MCP HTTP Server

A Node.js HTTP server that provides proper MCP (Model Context Protocol) over HTTP access to Readwise highlights and documents, using the official @readwise/readwise-mcp module.

Features

  • 🔍 Search Highlights: Vector and full-text search through your Readwise highlights (using official Readwise MCP module)
  • 📡 Streaming Responses: Real-time streaming of search results
  • 🏥 Health Checks: Server health monitoring
  • 🔄 Automatic Retries: Built-in retry logic for API failures
  • 🛡️ CORS Support: Cross-origin request support
  • 🔍 Comprehensive Debugging: Detailed logging for development and troubleshooting
  • 🌐 Network Access: Accessible from all network interfaces
  • Official Module: Uses the same tool implementation as the official Readwise MCP module

Installation

  1. Install dependencies:
npm install
  1. Create environment file:
cp .env.example .env
  1. Add your Readwise access token to .env:
ACCESS_TOKEN=your_readwise_access_token_here
PORT=3000

Usage

Development

npm run dev

Production

npm run build
npm start

Watch Mode

npm run watch

Debug Mode

Enable detailed debugging by setting the DEBUG environment variable:

# Enable debug mode
DEBUG=true npm run dev

# Or set in .env file
DEBUG=true

Debug mode provides detailed logging for:

  • Connection attempts
  • Request/response details
  • Tool execution steps
  • API calls to Readwise
  • Error details

API Endpoints

MCP Protocol Endpoint

POST /mcp
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search_readwise_highlights",
    "arguments": {
      "vector_search_term": "machine learning"
    }
  }
}

MCP Streaming Endpoint

POST /mcp/stream
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "search_readwise_highlights",
    "arguments": {
      "vector_search_term": "machine learning"
    }
  }
}

Server Info

GET /mcp/info

Health Check

GET /health

Available Tools

The server provides the same tools as the official Readwise MCP module:

search_readwise_highlights

Search through your Readwise highlights using vector search and full-text queries.

Parameters:

  • vector_search_term (required): Semantic search term for vector search
  • full_text_queries (required): Array of field-specific searches

Note: Both parameters are required. Empty arguments will result in a validation error.

Search Field Types:

  • document_author - Author of the source document
  • document_title - Title of the source document
  • highlight_note - Notes you've added to highlights
  • highlight_plaintext - The actual highlighted text
  • highlight_tags - Tags you've applied to highlights

Example Usage

Initialize MCP Connection

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize"
  }'

List Available Tools

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/list"
  }'

Search Highlights (MCP Protocol)

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "search_readwise_highlights",
      "arguments": {
        "vector_search_term": "machine learning"
      }
    }
  }'

Stream Search Results (MCP Protocol)

curl -X POST http://localhost:3000/mcp/stream \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 4,
    "method": "tools/call",
    "params": {
      "name": "search_readwise_highlights",
      "arguments": {
        "vector_search_term": "machine learning",
        "full_text_queries": [
          {
            "field_name": "highlight_plaintext",
            "search_term": "artificial intelligence"
          }
        ]
      }
    }
  }'

Invalid Arguments Example

# This will return an error because both parameters are required
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 5,
    "method": "tools/call",
    "params": {
      "name": "search_readwise_highlights",
      "arguments": {}
    }
  }'

Response:

{
  "jsonrpc": "2.0",
  "id": 5,
  "error": {
    "code": -32602,
    "message": "Invalid arguments: Required, Required"
  }
}

Environment Variables

  • ACCESS_TOKEN (required): Your Readwise access token
  • PORT (optional): Server port (default: 3000)
  • BASE_URL (optional): Readwise API base URL (default: https://readwise.io)
  • DEBUG (optional): Enable debug logging (set to true for detailed logs)
  • NODE_ENV (optional): Set to development to enable debug mode automatically

Network Connectivity

The servers are configured to bind to all network interfaces (0.0.0.0), making them accessible from:

  • Localhost: http://localhost:3000
  • Local Network: http://YOUR_IP_ADDRESS:3000
  • Docker: http://host.docker.internal:3000

To find your server's IP address:

# macOS/Linux
ifconfig | grep "inet " | grep -v 127.0.0.1

# Windows
ipconfig | findstr "IPv4"

Error Handling

The server includes comprehensive error handling:

  • Input validation using Zod schemas
  • Automatic retry logic for failed API calls
  • Proper HTTP status codes
  • Detailed error messages
  • Comprehensive logging for debugging

Debugging

The server provides extensive debugging capabilities:

Debug Logs

When debug mode is enabled, you'll see detailed logs for:

  • Connection tracking: Every incoming request with IP and user agent
  • Request processing: Step-by-step MCP request handling
  • Tool execution: Detailed tool call processing
  • API interactions: Readwise API calls and responses
  • Streaming: Real-time streaming progress
  • Error details: Full error stack traces and context

Debug Output Example

[2024-01-15T10:30:00.000Z] ℹ️  INFO: Initializing Readwise MCP HTTP Server
[2024-01-15T10:30:00.000Z] 🔍 DEBUG: Port: 3000, Debug: true, NodeEnv: development
[2024-01-15T10:30:00.000Z] 🔗 CONNECTION: POST /mcp from 127.0.0.1
[2024-01-15T10:30:00.000Z] 🔍 DEBUG: Request body: {"jsonrpc":"2.0","id":1,"method":"tools/call"...}
[2024-01-15T10:30:00.000Z] 🔍 DEBUG: Processing MCP method: tools/call
[2024-01-15T10:30:00.000Z] 🔍 DEBUG: Tool call requested: search_readwise_highlights
[2024-01-15T10:30:00.000Z] 🔍 DEBUG: Calling Readwise API: {"vector_search_term":"machine learning"}
[2024-01-15T10:30:00.000Z] 🔍 DEBUG: Readwise API response received: 5 results

Development

Project Structure

src/
  index.ts          # Main server file
dist/               # Compiled JavaScript (generated)
node_modules/       # Dependencies

Scripts

  • npm run build - Compile TypeScript to JavaScript
  • npm run dev - Run in development mode with hot reload
  • npm run watch - Watch for changes and restart
  • npm start - Run compiled JavaScript

License

MIT

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选