Repository avatar
Search & Data Extraction
v0.11.1
active

koreader

io.github.laughedelic/koreader

Read, search and annotate the book open in KOReader.

Documentation

MCP Server Plugin for KOReader

A KOReader plugin that implements a Model Context Protocol (MCP) server, enabling AI assistants to interact with your e-books in real-time.

Website and guides: a short demo, setup with pictures, and what you can ask.

What is MCP?

The Model Context Protocol (MCP) is an open standard that enables AI assistants to securely connect to external data sources and tools. This plugin implements an MCP server that exposes your KOReader book content and functionality to compatible AI assistants.

Features

  • Book Content Access: AI assistants can read your current book's content at different scopes (current page, chapter, specific page ranges)
  • Metadata Retrieval: Access book metadata including title, author, reading progress, and statistics
  • Interactive Tools: Search within books, navigate to pages, get table of contents, add highlights and notes
  • Any modern MCP client: Speaks both stateless MCP (2026-07-28) and the earlier handshake-based versions (2025-03-26 to 2025-11-25) on the same endpoint
  • Asks you when it matters: With clients that support elicitation (e.g. Claude), the server asks you before overwriting a note you already wrote
  • Local Network Protection: Requests from web pages on other sites are rejected (Origin validation against DNS rebinding)
  • Cloud Relay: Access your e-reader from anywhere via a cloud relay

How is this different from KOAssistant?

KOAssistant is a well-established AI plugin that runs on the reader itself, and it's very good at quick help while you read. KOReader MCP takes the opposite approach: instead of bringing an AI chat onto the e-reader, it brings your book into the AI app you already use.

  • Type comfortably, or just talk. The book stays on the e-reader, and you chat from your phone or laptop, with a real keyboard or voice input. E-readers are built for reading, not writing, and long discussions don't have to mean typing on an e-ink screen
  • Use the AI app and plan you already have. Claude, ChatGPT, Gemini or any other MCP client. You add the reader as a connector and pair it once, with nothing else to set up on the reader
  • Keep your reading chats with all your other chats. History and memories live in your AI app, so it can connect today's chapter to last month's discussion, or to a different book entirely (if you want it to)
  • Let the AI work with the book. It reads the page, chapter or search results it needs, jumps to a page, and saves highlights and notes back to the reader

This is especially handy when studying or reading on complex topics (research, philosophy, technical books), where you want to discuss ideas and think out loud.

The two plugins work well side by side. I use both: KOAssistant for quick lookups and translations on the device, KOReader MCP for longer conversations about what I'm reading.

Installation

[!IMPORTANT] This is an early implementation. Use it at your own risk. I make NO GUARANTEES about stability, security, or data integrity. You're welcome to review the code and suggest improvements.

Via an app store plugin (recommended)

Use the App Store plugin (or any other similar one) to install the MCP server plugin directly from KOReader. Simply search for "MCP" and install the plugin via the UI. This method ensures you get updates automatically.

Manually

  1. Download or clone this repository
  2. Copy the mcp.koplugin directory to your KOReader plugins folder
  3. Restart KOReader

To update, repeat the steps above with the latest version.

Over Wi-Fi (for testing a branch)

Turn on KOReader's SSH server (⚙️ Settings → Network → SSH server, port 2222) and add your public key to koreader/settings/SSH/authorized_keys. Then, from a checkout of the branch you want:

scripts/push-to-device.sh <reader-ip>

It finds KOReader's folder on Kobo, Kindle, Android and PocketBook, or takes the folder as a second argument. Restart KOReader afterwards (Menu → Exit → Restart KOReader).

Usage

Starting the Server

  1. Tap the menu (top of screen) and open 🛠️ Tools
  2. You will see a checkbox for MCP server
    • Tap it to start or stop the server
    • Long-press to switch between local/remote modes or to see the details

Settings

  1. Tap the menu and navigate to ⚙️ Settings → Network → MCP server
  2. Configure server settings:
    • Start server automatically: Enable to start the server when KOReader launches (requires WiFi)

    • Idle timeout: Set inactivity period before auto-stopping the server.
      When the idle timeout is enabled, you'll see a warning notification 5 seconds before the server stops. Tap the notification to reset the idle timer and keep the server alive.

    • Offline memory (remote mode, off by default): Let connected AI apps keep answering from a saved copy while the reader is asleep or away. See Offline memory

  3. Switch between local and cloud relay modes:
    • Local mode: Server listens on local network only
    • Cloud relay: Enable to use the cloud relay for remote access

[!TIP] Hold any menu item to open the help tooltip

Connecting an AI Assistant

Check the MCP server status in the Tools menu for the MCP server address. Use this address to configure your AI assistant or MCP client (e.g., Claude, ChatGPT or Gemini).

Claude

  1. Go to Settings → Connectors → Add custom connector, or just us this link: https://claude.ai/settings/connectors?modal=add-custom-connector.
  2. Enter the name (e.g., "KOReader") and the MCP server URL.
  3. When Claude opens the relay's sign-in page, open MCP server → Connect an AI app on the reader and enter the 6-digit code it shows. (No reader set up yet? Choose Try it with a sample book to try a demo reader first. To switch to your own reader later, disconnect and reconnect the connector.)
  4. Open a new chat and in the ➕ menu you should see the new connector available. You can either add resources to the context, or ask it to use tools to fetch data from your book.

ChatGPT

  1. Open Plugins (in the sidebar, or in Settings), then Add → Add custom MCP server.
  2. Enter the name (e.g., "KOReader") and the MCP server URL as the connection, accept the warning and choose Create as a plugin.
  3. On the relay's sign-in page, enter the 6-digit code from MCP server → Connect an AI app on the reader (or choose Try it with a sample book).
  4. In a chat, pick KOReader from the ➕ menu or mention it with @, and ask about the book you're reading.

Gemini

  1. Go to Settings → Developer mode → Create new (app).
  2. Paste the MCP server URL (with the cloud relay, it is https://mcp-relay.laughedelic.workers.dev/mcp) and follow the pairing step: open MCP server → Connect an AI app on the reader and enter the 6-digit code on the relay's sign-in page.
  3. Start a chat and ask about the book you're reading.

[!NOTE] KOReader has to be running with a book open and the MCP server on while you chat.

Chatting About Your Book

Once connected, you can ask your AI assistant questions like:

  • "What is the book I'm reading in KOReader about?"
  • "Summarize the current chapter"
  • "What does the quote on this page mean?"
  • "Search for other mentions of [character/topic] on this page and explain their significance"
  • "Add a note with a translation of this selected text"
  • "Highlight this important passage"

Assistant will use the MCP resources and tools to understand which book you're reading, what's on your screen, search within the book, and provide relevant responses. You can also ask the assistant to add highlights and notes to your book based on your conversation.

[!TIP] It might be helpful to create a separate project with more focused instructions for using KOReader MCP or even for a particular book that you want to discuss with your AI assistant. This will keep the context relevant and maintain separate memory for different books or topics.

MCP server capabilities

[!WARNING] This is an early implementation and this list may change and be not up-to-date.

Resources

The plugin exposes these resources:

Current Book Resources

Resource URIDescription
book://current/contextCurrent reading context (page, chapter, selection)
book://current/metadataBook metadata (title, author, progress, etc.)
book://current/tocTable of contents
book://current/bookmarksBookmarks and highlights in the current book
book://current/pages/{range}Text from specific pages (e.g., 5 or 10-15)
book://current/chapters/{idx}Text from a specific chapter by index

Library Resources

Resource URIDescription
library://booksBooks you have opened, with progress
library://collectionsBook collections/shelves
library://historyReading history
library://books/{path}Metadata for a specific book by path

Tools

The plugin provides these callable tools:

ToolDescriptionParameters
get_reading_contextGet current reading context (book, chapter, page, selection/highlight focus)extra_pages_before (optional), extra_pages_after (optional)
get_book_metadataGet full book metadata (for clients without resource support)None
read_pagesRead text from specific pages or chapterspages (e.g., "5" or "10-15"), chapter (index)
search_bookSearch for text in the bookquery, case_sensitive (optional)
goto_pageNavigate to a specific pagepage
annotateAdd highlight or note to text (EPUB, FB2, PDF, DjVu...)note, note_format, text, start, end, if_note_exists (all optional)

Tool Annotations

All tools include MCP annotations to help AI assistants understand their behavior:

  • readOnlyHint: Tools like get_reading_context, get_book_metadata, read_pages, search_book are read-only
  • destructiveHint: The annotate tool is marked destructive, because with if_note_exists = "replace" it can overwrite an existing note
  • idempotentHint: Multiple calls with the same parameters produce the same result
  • openWorldHint: Whether the tool interacts with external entities

Prompts

Prompts are pre-defined conversation starters for common reading companion interactions. MCP clients that support prompts (like Claude) can present these as quick actions.

PromptTitleDescription
explainExplain ThisExplain selected text or current page content
summarizeSummarizeSummarize page, chapter, or reading progress
discussLet's DiscussStart a conversation about themes and ideas
researchResearch ThisGet background info about book, author, or historical context
noteTake a NoteCreate and save annotations with assistant help
quizQuiz MeTest comprehension with generated questions
translateTranslateTranslate text to another language
recommendRecommend BooksGet personalized book recommendations

Protocol Versions

Client speaksHow it connects
2026-07-28 (stateless)Every request carries its version and capabilities in _meta; server/discover describes the server
2025-03-26 to 2025-11-25initialize handshake; the server answers with the client's version

Clients that speak both try 2026-07-28 first and fall back automatically.

Elicitation

On 2026-07-28 clients that declare form elicitation, annotate asks the user before changing a note that already exists (replace it, add below it, or keep it). The question travels inside the tool result (an input_required result, the protocol's multi round-trip request pattern) and the client retries the call with the answer, so it works through the cloud relay without any extra channel. With other clients, the tool doesn't touch the note and asks the AI to check with you and call again with if_note_exists.

Not Supported

  • Sampling and server logging: deprecated in MCP 2026-07-28 and not implemented.
  • Live change notifications (page turns, book changes): planned through the 2026-07-28 subscriptions/listen stream. Until then the server doesn't advertise resource subscriptions, so clients don't wait for updates that never arrive.

Local & Remote Modes

Local Mode

In local mode, the MCP server runs on your e-reader and listens for connections on your local network (WiFi). This would be the default mode, but unfortunately some AI clients (most notably Claude Mobile) cannot connect to local network addresses and require a fully remote-accessible server.

The server accepts requests on / and /mcp. Requests carrying an Origin header are accepted only from localhost or the e-reader's own address, so a web page you open can't reach your library through your browser. Local mode has no authentication, so use it only on networks you trust.

So for now this mode is kept for testing and limited use with compatible clients. I've tested it with GitHub Copilot with this configuration (replace LOCAL_IP):

"koreader": {
  "type": "http",
  "url": "http://LOCAL_IP:8788"
}

[!INFO] If you test it with other clients in local mode, please share your experience. Or if you have ideas on how to make local mode more useful, let me know!

Remote Mode (Cloud Relay)

The cloud relay feature allows you to access your MCP server from anywhere — Claude Desktop, Claude Mobile, or other AI tools — without complex network setup like VPNs or port forwarding.

graph LR
  A["E-Reader<br/>(KOReader)"] --> B["Cloud Relay<br/>(Cloudflare)"]
  B --> C["Claude/Client"]
  C --> B
  B --> A
  1. On first connection, your e-reader generates a device ID (based on your device type) and a random device secret, and registers with the relay
  2. Your e-reader shows the relay URL and a one-time 6-digit pairing code
  3. You add the URL as a connector in your AI app and enter the code on the relay's sign-in page
  4. The AI app exchanges the authorization for a short-lived access token; the code is used up

Authentication Flow

When you first start the MCP server in remote mode, you'll see the relay URL and a pairing code. To connect another app later, use Connect an AI app in the MCP settings menu (Settings → Network → MCP server). Each code works once, for 10 minutes. Once an app signs in, the reader closes the code and tells you which app connected.

Connected apps in the same menu lists the AI apps that can reach your reader. Tap one to disconnect it.

The relay uses OAuth 2.1 Authorization Code flow with PKCE, so MCP clients that support OAuth will handle authentication automatically.

[!NOTE] With an older or self-hosted relay that doesn't support pairing codes, the plugin shows a device ID and a permanent 6-digit passcode instead, which you enter on the sign-in page.

[!IMPORTANT] The relay is just a bridge forwarding requests between your e-reader and AI clients. Unless you turn on offline memory, it does not store book content, highlights or notes; it keeps only what it needs to route and authorize requests (see the privacy policy).

The relay implementation is open source: koreader-mcp-cloud-relay. You can deploy your own instance for full control. By default, plugin uses the relay I deployed for myself. I'll be sharing it as long as it's within the free tier limits.

Security

  • One-time pairing codes: A code works once and expires after 10 minutes; only your e-reader can request one (with its device secret), and the relay limits wrong guesses. Once the reader requests its first pairing code, the old permanent passcode stops working for new sign-ins
  • OAuth 2.1 Authorization Code + PKCE: MCP clients authenticate via the /authorize sign-in page, then exchange a code for a token
  • Revocable: Disconnect any AI app from Connected apps on the reader
  • Short-lived tokens: Access tokens expire in 1 hour
  • Audience validation: Tokens are bound to your specific device
  • All traffic is encrypted (HTTPS), and the plugin verifies the relay's certificate and host name before sending its credentials. If your e-reader's clock is far off, the check fails; fix the date and time. For a development relay with a self-signed certificate, set mcp_relay_tls_verify = false in KOReader's settings.reader.lua
  • The relay doesn't store any book content, only forwards authenticated requests. The one exception is the encrypted copy you can opt into with offline memory
  • Device secret (needs an up-to-date relay): Your e-reader also generates a random secret that authenticates its connection to the relay, so knowing your device ID is not enough to receive your requests. The relay never forwards your AI client's access token to the e-reader. An older self-hosted relay ignores the secret, lets anyone who knows the device ID poll, and forwards the client's Authorization header, so the plugin shows a warning when the relay doesn't confirm the secret
  • You can reset your device ID anytime from the settings menu

When the reader is offline

E-readers sleep, turn WiFi off and stop the MCP server to save battery, so the reader is often away when you ask your AI app something. The relay then answers for it: the app keeps its tools and is told that the reader is offline and when it was last connected, instead of getting an error. Nothing from your books is involved in that answer.

Offline memory

Offline memory is optional and off by default. Turn it on in Settings → Network → MCP server → Offline memory, and your reader keeps a copy of what you are reading on the relay, so connected AI apps can still discuss it while the reader is asleep or away.

  • Save my place, highlights and notes: the book's title and author, where you are, the table of contents, and your highlights and notes
  • Also save the pages around my place: additionally the text of the page you are on, 2 pages before it and 10 after
  • Off: nothing is saved, and a copy saved earlier is deleted

While you read with WiFi on, the reader updates the copy about once a minute, also while the MCP server is off. It also saves a few seconds after you open a book, when you close it, when the MCP server stops, when you turn WiFi off in KOReader and when the reader goes to sleep. The reader asks before it starts sending, and again before it adds the page text. It never turns WiFi on by itself. If you read with WiFi off, the copy is updated the next time WiFi is on.

When the reader is offline, the AI app gets answers from the copy for reading context, book metadata, the saved pages and search within them. Every such answer says that it comes from a saved copy, when it was saved and which pages it covers. Turning pages and adding highlights or notes need the reader itself. As soon as the reader is back online, answers come from the reader again.

The relay stores the copy encrypted, so that opening it takes one of your connected AI apps, and deletes it 30 days after its last update (you can choose 1 or 7 days). An app you connect later can read the copy from the next save on. The privacy policy has the details.

[!NOTE] Offline memory needs a relay that supports it. The menu entry only shows up when the relay offers it.

Privacy

See PRIVACY.md for what the public relay stores and how to delete it.

References

No installation packages available.