Skip to main content
Glama

oeis-mcp

A fast index over a local snapshot of the OEIS, and an MCP server that lets Claude Code (or any MCP client) search it without going to oeis.org. It also identifies a sequence as a transform of a known one, guesses recurrences, and evaluates the relations entries state.

Lookups take well under a second. The index files are memory-mapped, so the server process stays small (tens of MB). The pages it touches sit in the OS file cache, and the OS takes them back when it needs the memory.

Tools

Tool

What it does

search_terms

Sequences containing the given terms consecutively; sub=True finds partial overlaps (runs of ≥ min_run terms)

search_terms_batch

Many exact term searches in one call

search_text

Word, phrase or regex in names, comments, formulas, xrefs, links, authors, programs, keywords, with snippets

get_entry

One entry: terms, offset and chosen text fields (long fields are clipped)

get_raw_entry

The entry's exact internal-format record (%S %N %C ... %E), including extensions

get_summaries

Name, keywords and first terms of many entries at once

get_bfile

Lines of the entry's b-file, when the clone has it (git lfs)

identify_transform

Is this sequence (terms, or an A-number) a chain of up to 3 of ~140 transforms of a known one? A local superseeker (~2 s at depth 2)

guess_recurrence

Guess a P-recursive recurrence (polynomial coefficients, order and degree ≤ 6) and predict terms

extend_from_formulas

Evaluate an entry's own stated relations (a(n) = ...A######(n)..., "Euler transform of A######", ...) on the other sequences' current terms, giving new terms

index_info

Snapshot date and what is indexed

Terms are passed and returned as comma-separated strings, because OEIS terms routinely exceed what JSON numbers hold exactly. ext=True searches DATA extended with real b-file terms (up to 256 per sequence) instead of DATA alone.

Related MCP server: mathlas

Data

Everything lives in data/, which is not tracked. The location can be changed with the OEIS_DATA env var.

data/oeisdata/     shallow clone of github.com/oeis/oeisdata (~680k files); b-files (~245k, ~35 GB) via git lfs
data/seqs.pkl      one row per sequence (python -m oeis_mcp.parse, ~400 MB)
data/oeis_cache/   the search index (~3.3 GB; python -m oeis_mcp.search --build; --build-ext for b-file terms)

To set it up from scratch (the clone's .lfsconfig fetches no LFS content by default, so the b-files are asked for explicitly; skip those lines to work from DATA alone):

git clone --depth 1 https://github.com/oeis/oeisdata.git data/oeisdata
git -C data/oeisdata lfs fetch origin main -I "files/*/b*.txt" -X ""
git -C data/oeisdata lfs checkout "files/*/b*.txt"

To refresh it (the OEIS pushes a new snapshot daily):

git -C data/oeisdata fetch --depth 1 origin main
git -C data/oeisdata lfs fetch origin origin/main -I "files/*/b*.txt" -X ""   # new b-files first, so the
git -C data/oeisdata reset --hard origin/main                                 # checkout fills them in
python -m oeis_mcp.parse                 # -> data/seqs.pkl
python -m oeis_mcp.search --build        # also automatic when seqs.pkl is newer than the cache
python -m oeis_mcp.search --build-ext    # DATA + b-file terms

The cache is rebuilt into staged _new_* files and swapped in at the end. Windows will not replace a file another process has open, so stop running oeis MCP servers (and search scripts) first; if one is still running, the swap is refused and the old index stays as it was.

Install and register

git clone https://github.com/guillochon/oeis-mcp.git && cd oeis-mcp
uv venv --python 3.12 .venv
uv pip install --python .venv/Scripts/python.exe -e .     # .venv/bin/python on Linux/macOS
claude mcp add --scope user oeis -- "$PWD/.venv/Scripts/python.exe" -m oeis_mcp.server

Then set up data/ as described above. The OEIS data itself is not part of this repo; it is the OEIS's, under its own license (CC BY-SA 4.0).

Command line and Python

The same index from a shell:

python -m oeis_mcp.search 1,2,5,14,42,132        # sequences containing these terms
python -m oeis_mcp.search 1,2,5,14,42 --sub      # partial overlaps
python -m oeis_mcp.search -t "plane partitions" -f all
python -m oeis_mcp.search A000108

And from Python: from oeis_mcp.search import TermIndex, text_search, field_line, entry, plus oeis_mcp.identify (identify), oeis_mcp.recur (guess, predict), oeis_mcp.formulas (init, extend) and oeis_mcp.transform_lib (all_transforms, apply; python -m oeis_mcp.transform_lib self-tests). Only numpy is needed for search, pandas for building, python-flint for recurrences, and mcp for the server.

How the index works

  • Every window of 4 consecutive terms that has some |term| ≥ 10 is hashed to a uint64. The hashes are sorted, so a query looks up all its windows with one vectorised searchsorted. Hits are then extended to maximal runs against the stored terms, which also weeds out hash collisions.

  • Each text field is one UTF-8 line per sequence, with line-start offsets, plus an ASCII-lowercased copy. A plain word or phrase is found with mmap.find (~1 GB/s); a regex runs on the mapped bytes. Nothing is decoded in bulk.

Available Tools

11 tools
extend_from_formulasA
Read-only

Can an entry be extended from its own stated relations? Parses the entry's "a(n) = <expr in n, a(), and A######()>" FORMULA lines and its "Euler / binomial / INVERT / ... transform of A######", "partial sums of A######" phrases (NAME, COMMENTS, FORMULA), checks each against the entry's known terms (all but at most the first 3 must agree, at least 6), and evaluates it past them on the other sequences' current terms (ext=True: DATA + b-file). Lines flagged as conjectural ("appears", "seems", "empirical", ...) are skipped. Each relation that gives new terms is returned with the new terms (from n = offset + n_terms on). The relation is the entry's own claim; check its source before using the terms.

Inputs: anum (required), ext, max_new.

get_bfileB
Read-only

Lines of the entry's b-file from the local oeisdata clone (n, a(n) pairs), when it was fetched with git lfs. start/count select lines of (n, a(n)) data, comments skipped.

Inputs: anum (required), count, start.

get_entryA
Read-only

One OEIS entry from the snapshot.

anum: "A000108" (also accepts "108", "a108"). fields: which text fields to include (name, comments, formula, xrefs, links, author, programs, keywords, or ["all"]); default name, keywords, formula, comments, xrefs, author. Terms and offset always come back. ext: return DATA extended with the real b-file terms (up to 256) instead of DATA. max_terms: cut the terms to this many. max_chars: cut each text field (links and programs can be long). For the exact internal-format record (%S/%N/%E... lines, incl. extensions), use get_raw_entry.

Inputs: anum (required), ext, fields, max_chars, +1 more.

get_raw_entryA
Read-only

The entry's record exactly as stored in oeisdata (internal format: %I %S %T %U %N %C %D %H %F %e %p %t %o %Y %K %O %A %E lines), including extension (%E) lines that get_entry does not carry.

Inputs: anum (required), max_chars. Returns: result

get_summariesC
Read-only

Short summaries of many entries at once: name, keywords, offset, number of terms and the first n_terms terms. Unknown A-numbers come back with an error.

Inputs: anums (required), n_terms. Returns: result

guess_recurrenceA
Read-only

Guess a P-recursive (holonomic) recurrence sum_{i=0..r} p_i(n) a(n-i) = 0 with deg p_i <= d, and predict further terms from it.

Give either terms (comma-separated, with the offset = n of the first term) or an anum (its terms; ext=True uses DATA + b-file terms). (r, d) are tried in order of the number of unknowns (r+1)(d+1); the first whose kernel is one-dimensional (mod a 61-bit prime, then exactly over Z) with at least spare more equations than unknowns is returned. Constant coefficients are d = 0. A guess, not a proof; spare_equations says how much the data over-determines it, and integral whether all predicted terms came out integers.

Inputs: ext, anum, spare, terms, +4 more.

identify_transformA
Read-only

Is this sequence a simple transform of a known OEIS sequence? A local "superseeker".

Give either terms (comma-separated, with their offset, i.e. the n of the first term) or an anum (its own terms; the entry itself is never reported). Every chain of up to depth (1-3) of ~140 primitive transforms is applied (x or / by n!, (2n)!, 2^n, n, Catalan, Bell, ...; binomial, Euler, weigh, EGF exp/log, INVERT, Stirling, Moebius and their inverses; partial sums, differences, bisections, signs, +-1, ...) and each result is looked up in the term index. Depth 1 takes about a second; depth 2 (~20k lookups) can take tens of seconds, and stops after time_budget seconds (complete=false). A hit needs a long, informative common run (>= 6 terms at depth <= 1, >= 8 at depth 2, >= 10 at depth 3) and agreement up to the end of one of the two. Each hit says which side has more terms: match_extends_query: the match continues past your terms (it may give new terms of your sequence); query_extends_match: your transformed terms continue past the match's DATA. Hits are empirical identities, to be proved before use.

Inputs: ext, anum, depth, limit, +3 more.

index_infoA
Read-only

Which snapshot is loaded and what is indexed.

Inputs: no named parameters.

search_termsA
Read-only

Find sequences containing the given terms consecutively, like the OEIS search box.

terms: comma-separated integers, e.g. "1, 2, 5, 14, 42, 132". At least 4 consecutive terms with some |term| >= 10 are needed (shorter or tinier queries are too generic to index). ext: search DATA plus b-file terms instead of DATA only. sub: instead of the whole query, report every maximal common run of >= min_run terms between the query and a sequence (useful when the query has a wrong term or a different start), longest first. Each hit gives the A-number, name, keywords, offset, and where the match starts: at is the index into the sequence's terms (0-based), n the corresponding n (offset + at).

Inputs: terms (required), ext, sub, limit, +1 more.

search_terms_batchA
Read-only

Run many exact term searches at once (each as in search_terms with sub=False).

queries: list of comma-separated term strings. Returns, per query, the total number of sequences containing it and up to limit of their A-numbers with the match position. Queries too generic to index come back with an error instead of hits.

Inputs: queries (required), ext, limit. Returns: result

search_textA
Read-only

Find sequences whose text fields match a word, phrase or regex (case-insensitive).

pattern: a plain word/phrase (fast literal scan) or a Python regex, e.g. "Catalan", "plane partitions", r"\bLyndon words?\b", "Sloane, \d{4}". fields: any of name, comments, formula, xrefs, links, author, programs, keywords; or ["all"]. Default: ["name"]. Hits are in A-number order. Each gives the name and keywords, and, when the match is outside the name, a snippet around the first match.

Inputs: pattern (required), limit, fields, snippet_chars.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 11 tools

    Disambiguation5/5

    Each tool has a clearly distinct role: retrieval (get_entry, get_raw_entry, get_summaries, get_bfile), search (search_terms, search_terms_batch, search_text), and analysis (identify_transform, guess_recurrence, extend_from_formulas). The retrieval variants are differentiated by output format and scope, and the search variants by query type and batching.

    Naming Consistency4/5

    Names are consistently snake_case and predominantly verb_noun (get_entry, search_terms, identify_transform, guess_recurrence). The only minor deviation is index_info, which is a noun phrase rather than an action, but the overall pattern remains predictable.

    Tool Count5/5

    Eleven tools is well-scoped for an OEIS server covering retrieval, search, and sequence analysis. Each tool appears to earn its place without redundant capabilities.

    Completeness4/5

    The surface covers core lookup, search, raw records, b-files, transform identification, recurrence guessing, and formula-based extension. Minor gaps exist, such as no dedicated keyword-browsing or snapshot-update tool, but these are workable via the existing search and index_info tools.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables exploration and computation of mathematical integer sequences from OEIS using the LODA assembly language. Supports sequence discovery, program execution, algorithmic mining, and real-time computation of mathematical sequences.
      8
      1
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Airtight math tools an AI uses over MCP — 3.7M-theorem search, PSLQ constant ID, OEIS, real Lean kernel checks, applicability checklists. No LLM inside, no API key.
      12
      13
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server for semantic search over 9.27 million mathematical statements from sources like arXiv and Stacks Project, offering 5 tools for filtered search, citation weighting, and dependency graph traversal.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables local MCP clients to search software names, look up exact identifiers, and retrieve project summaries, packages, and direct dependencies from ecosyste.ms Science, with an optional offline SQLite snapshot for lookup.
      4
      1
      MIT