Skip to main content
Glama
library-of-babel-mcp

library-of-babel-mcp

by slaufer

Library of Babel MCP Server

An MCP (Model Context Protocol) server granting access to the Library of Babel, the largest knowledge base in the known universe.

Setup

No install step — npx fetches the server on demand.

In Claude Code:

claude mcp add library-of-babel -- npx -y library-of-babel-mcp

In Claude Desktop or any other MCP client, add this to your MCP config (e.g. claude_desktop_config.json):

{
  "mcpServers": {
    "library-of-babel": {
      "command": "npx",
      "args": ["-y", "library-of-babel-mcp"]
    }
  }
}

Then restart the client. You should see the four tools listed below.

Related MCP server: MCP Open Library & File Search Server

How it works

  • Alphabet: 29 symbols — a-z, comma, space, period.

  • Page length: 3200 characters (40 lines x 80 chars).

  • Address: hexagon (base-36 string, ~3004 digits), wall (1-4), shelf (1-5), volume (1-32), page (1-410) — 262,400 pages per hexagon.

  • Library size: 29^3200 pages, a 4680-digit number.

The library is a bijection between addresses and page contents, following the structure libraryofbabel.info uses. There is no PRNG and no special-cased slot: every address maps to exactly one page, every possible page maps back to exactly one address, and the mapping inverts in both directions.

  1. Flatten the address into a single integer index.

  2. Scramble it: content = (index * MULTIPLIER) mod N, where N = 29^3200.

  3. Write content out as 3200 base-29 digits — that's the page text.

MULTIPLIER is coprime to N, so step 2 is a permutation of the entire space and its inverse is another multiplication by MULTIPLIER⁻¹ mod N (computed by Hensel lifting, since N is a prime power). So searching means: build the exact page you want — your text plus padding — read it as a base-29 number, multiply by the inverse, and unpack the index into coordinates. The page really is at that address. Nothing is stored; nothing is scanned.

Because padding and offset are part of the page, changing either gives you a genuinely different page at a different address.

Fidelity to libraryofbabel.info

The structure and observable behaviour match the real site. The particular permutation does not: libraryofbabel.info's own constants are deliberately unpublished — the author's reference repo documents the method (an invertible LCG plus xorshift scrambling) but withholds its m, a, and c. Addresses produced here are therefore not portable to that site, and vice versa.

Tools

  • get_page(hexagon, wall, shelf, volume, page) — read the text at an address.

  • search_text(text, padding, offset) — find the address of a page containing your text. padding is "spaces" (default) or "random"; offset is a character position or "random". Max 3200 chars; input is lowercased and restricted to the library's alphabet.

  • lookup_page(text) — the exact inverse of get_page: give it a full 3200-character page, get back its address.

  • random_page() — jump to a uniformly random address.

Configuration

  • LOB_API_KEY — leave empty for provisional guest access, until you have located the volume containing your API key.

Running from a local checkout

npm install
npm run build
node dist/index.js

It speaks MCP over stdio, so it expects a client on the other end — it will just sit there logging "Library of Babel MCP server running on stdio" to stderr, which is normal.

To point a client at the checkout instead of the published package, use the built entrypoint:

{
  "mcpServers": {
    "library-of-babel": {
      "command": "node",
      "args": ["/absolute/path/to/library-of-babel-mcp/dist/index.js"]
    }
  }
}

Available Tools

4 tools
get_pageGet pageA

Retrieve the exact text on a page at a given address in the Library of Babel. Every address always returns the same content (the library never changes). Coordinates: hexagon (base-36 string id), wall (1-4), shelf (1-5), volume (1-32), page (1-410). Almost every address is gibberish — meaningful pages are found via search_text, not by browsing.

Inputs: hexagon (required), page, wall, shelf, +1 more.

lookup_pageLook up an exact pageA

Given a complete 3200-character page, return the address it lives at. This is the exact inverse of get_page: the text must be exactly 3200 characters drawn from the library's alphabet (a-z, comma, space, period). For partial text, use search_text instead.

Inputs: text (required).

random_pageRandom pageA

Jump to a uniformly random address in the Library of Babel and return its content. Almost always gibberish — that's the point.

Inputs: no named parameters.

search_textSearch for textA

Find the address of a page containing the given text (up to 3200 characters). The Library of Babel already contains every possible page, so 'search' doesn't scan anything: it constructs the exact page you asked for and inverts the address mapping to learn where that page sits. The returned address is a genuine location — get_page on it returns your text. Padding and offset are part of the page, so changing either yields a different address. Text is lowercased and restricted to the library's 29-symbol alphabet (a-z, comma, space, period); unsupported characters are dropped or converted to spaces.

Inputs: text (required), offset, padding.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: get_page retrieves content by address, random_page fetches a random page, search_text finds an address for arbitrary text, and lookup_page is the exact inverse of get_page. There is no overlap or ambiguity between them.

    Naming Consistency5/5

    All tool names follow the same snake_case pattern with two words, and the naming clearly reflects their function (get_page, random_page, search_text, lookup_page). The format is consistent and predictable.

    Tool Count5/5

    With 4 tools, the server is well-scoped for the Library of Babel concept. Each tool earns its place, covering the essential operations without unnecessary bloat or missing functionality.

    Completeness5/5

    The tool set provides complete coverage for the domain: retrieving pages, exploring randomly, searching for text, and mapping pages back to addresses. There are no obvious gaps or dead ends for the intended use case.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers