Skip to main content
Glama
reactome-db-mcp

reactome-db-mcp

by tc2fh

reactome-db-mcp

An MCP server that gives coding agents direct SQL access to a locally hosted Reactome database — schema discovery, a guarded read-only query(), and ergonomic helpers over the full GKB relational schema, all from the chat.

Python 3.12+ MCP License: MIT

Built with the official Python MCP SDK (FastMCP) over stdio. It talks straight to MySQL with pure-Python PyMySQL (run via asyncio.to_thread), so there is no build toolchain to install.

reactome-db-mcp vs reactome-mcp

They are complementary — register both:

reactome-mcp (REST)

reactome-db-mcp (this)

Backend

Reactome REST + Analysis web services

local reactome_local MySQL DB

Needs

internet; zero setup

the local DB up (MySQL + dump loaded)

Strength

curated, pre-joined objects; enrichment p-values/FDR; always current

fast, arbitrary joins + reverse navigation over the raw 242-table schema

Use it for

"what does Reactome say about X", enrichment

bespoke relational queries the REST API never exposed

Tool names are deliberately distinct (get_object vs get_entry, search_by_name vs search, …) so both can be registered without ambiguity.


Prerequisites — the local database

This server needs a running MySQL with the Reactome gk_current dump loaded as reactome_local, reachable by a read-only user. On this machine that is already set up:

  • MySQL 9.6 (Homebrew), database reactome_local (~990 MB, 242 MyISAM tables, Reactome release 96).

  • Read-only user ro_user@localhost, empty password, SELECT-only.

If mysqld isn't running (it is not registered with brew services, so it won't survive a reboot):

brew services start mysql      # reliable auto-start, or:  /opt/homebrew/opt/mysql/bin/mysqld_safe &

To rebuild the DB from scratch, see ../reactome_local_build (keeps gk_current.sql.gz).


Related MCP server: mysql-mcp-server

Quickstart

Requires uv (which manages Python ≥ 3.12 for you).

cd reactome-db-mcp
uv sync                     # install runtime deps (mcp, PyMySQL)
uv run reactome-db-mcp      # boots the server on stdio (Ctrl+C to exit)

Then register it with your agent (below) and ask something like:

"Using the reactome-db tools, look up R-HSA-69278, then list its child events in order."


Register with your agent

Standard stdio MCP server launched with uv run reactome-db-mcp. Run from inside the cloned directory.

Claude Code

claude mcp add reactome-db -- uv --directory "$PWD" run reactome-db-mcp

Codex

codex mcp add reactome-db -- uv --directory "$PWD" run reactome-db-mcp

Cursor / any other MCP client — point it at the same stdio command; a ready-to-edit example lives in .mcp.json:

{
  "mcpServers": {
    "reactome-db": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "--directory", "/absolute/path/to/reactome-db-mcp", "reactome-db-mcp"],
      "env": { "REACTOME_DB_NAME": "reactome_local" }
    }
  }
}

Tools

All tools are async and return JSON-shaped dicts, degrading to {"error": ...} rather than raising on bad input or a down database.

Schema discovery

Tool

Signature

Purpose

schema_overview

()

Primer on the class-table-inheritance model + key joins + data release. Read first. Also the schema://reactome resource.

list_tables

(filter=None, limit=500)

Tables with exact row counts + engine; filter is a name substring (e.g. _2_).

describe_table

(table)

Columns of a table: type, nullability, key, default.

Guarded raw SQL

Tool

Signature

Purpose

query

(sql, max_rows=200)

Run one read-only statement (SELECT/WITH/SHOW/DESCRIBE/EXPLAIN). Auto-LIMIT, per-query timeout, result/cell truncation.

Ergonomic helpers (sugar over the common joins)

Tool

Signature

Purpose

get_object

(id)

Assemble a full object (stable id or DB_ID) across its inheritance chain.

search_by_name

(query, classes=None, limit=25, anchored=False)

_displayName search; anchored=True is fast, wildcard is a ~1-2s scan.

get_pathway_events

(id)

Ordered child events of a pathway (via Pathway_2_hasEvent).

get_participants

(id)

Inputs / outputs / catalysts of a reaction-like event.

get_referrers

(id, attribute=None, limit=50)

Reverse lookup — which objects point at this one (curated/best-effort).

Design notes

  • Read-only by construction. The connection is a SELECT-only user (writes fail at the server), PyMySQL rejects stacked statements by default, and query() additionally checks that the statement is a single read. The string check is for clear errors, not as the security boundary — the grant is.

  • Stable ids vs DB_IDs. Helpers accept either R-HSA-69278 or the numeric DB_ID. The 'R-HSA-...' text lives in StableIdentifier, joined via DatabaseObject.stableIdentifier.

  • Size-guarded. Every result is row-capped (max_rows, hard ceiling 5000) and long text cells are truncated; truncated flags either.

  • Point-in-time data. This is a dump (release reported by schema_overview). For the always-current Reactome, use the sibling reactome-mcp.

Configuration (env vars)

Var

Default

Meaning

REACTOME_DB_HOST / REACTOME_DB_PORT

127.0.0.1 / 3306

MySQL endpoint

REACTOME_DB_USER / REACTOME_DB_PASSWORD

ro_user / `` (empty)

credentials

REACTOME_DB_NAME

reactome_local

database

REACTOME_DB_POOL_SIZE

4

max pooled connections

REACTOME_DB_MAX_ROWS

200

default row cap

REACTOME_DB_STMT_TIMEOUT_MS

15000

per-query timeout

REACTOME_DB_MAX_CELL_CHARS

2000

per-cell text cap


Example prompts

  1. Lookup + drill-down — "Look up R-HSA-69278 with the reactome-db tools and list its child events in order."

  2. Raw SQL — "Run SELECT _class, COUNT(*) FROM DatabaseObject GROUP BY _class ORDER BY 2 DESC LIMIT 10 and summarize."

  3. Reverse navigation — "Which pathways and reactions reference the object named 'CYCB:CDK1'? Use get_referrers."

  4. Schema spelunking — "Call schema_overview, then describe the Pathway and Pathway_2_hasEvent tables."


Development

uv sync --extra dev     # pytest, pytest-asyncio
uv run pytest           # safety-layer suite runs fully offline (no DB)

# opt-in live-DB integration tests (needs reactome_local up):
REACTOME_DB_MCP_INTEGRATION=1 uv run pytest

Smoke-test the live server:

uv run reactome-db-mcp                          # console script
uv run python -m reactome_db_mcp                # module entry point
uv run python server.py                         # source-checkout shim
uv run mcp dev src/reactome_db_mcp/server.py    # MCP Inspector dev UI
reactome-db-mcp/
├── src/reactome_db_mcp/
│   ├── server.py   # FastMCP app, lifespan pool, all tools + resource
│   ├── db.py       # PyMySQL pool + read-only safety layer (pure, tested)
│   └── schema.py   # curated schema primer + class-inheritance map
├── server.py       # source-checkout compatibility shim
├── tests/          # offline safety-layer suite + opt-in DB integration tests
├── pyproject.toml  # uv-managed project
├── .mcp.json       # example stdio MCP config
└── PLAN.md         # design & build record (verified 2026-06-22)

Acknowledgements

Powered by Reactome, a free, open-source, open-access, curated and peer-reviewed pathway database. Please cite Reactome when publishing work that uses this data — see https://reactome.org/cite.

This project is not affiliated with or endorsed by the Reactome team.

License

MIT © Tien Comlekoglu

Available Tools

9 tools
describe_tableA

Show the columns of a table: name, type, nullability, key, default, extra.

Args:
    table: Exact table name (see `list_tables`). e.g. "Pathway",
        "Pathway_2_hasEvent", "DatabaseObject".

Returns:
    Dict `{table, columns: [{name, type, nullable, key, default, extra}]}`.

Inputs: table (required).

get_objectA

Fetch a full Reactome object, assembled across its inheritance chain.

Resolves a stable id ('R-HSA-69278') or numeric `DB_ID`, then merges the
`DatabaseObject` core fields with the subclass-table attributes that share
the same `DB_ID` (e.g. a Pathway pulls in `Event` + `Pathway` columns).

Args:
    id: An 'R-HSA-...' stable id or a numeric DB_ID.

Returns:
    Dict `{DB_ID, _class, _displayName, stable_id, attributes: {...}}` where
    `attributes` is the union of the subclass rows (leaf class wins on any
    name clash). `{"error": ...}` if the id is unknown.

Inputs: id (required).

get_participantsA

Get the inputs, outputs, and catalysts of a reaction-like event.

Args:
    id: A ReactionlikeEvent (Reaction/BlackBoxEvent/...) stable id or DB_ID.

Returns:
    Dict `{reaction_DB_ID, inputs, outputs, catalysts}` where `inputs`/
    `outputs` are physical-entity dicts and each `catalysts` entry also
    carries `catalyst_activity_DB_ID` and the GO `activity` DB_ID. Empty
    lists if the object isn't a reaction or has none.

Inputs: id (required).

get_pathway_eventsA

List the ordered child events (sub-pathways & reactions) of a pathway.

Args:
    id: A Pathway stable id ('R-HSA-69278') or numeric DB_ID.

Returns:
    Dict `{pathway_DB_ID, count, events: [{rank, DB_ID, _class,
    _displayName, stable_id}], truncated}`, ordered by `hasEvent_rank`.

Inputs: id (required).

get_referrersA

Reverse lookup: which objects point AT this one (the inverse navigation REST makes awkward).

Scans a curated set of common containment relations — which pathways contain
this event, which complexes/sets contain this entity, which reactions consume
or produce it. **Best-effort, not exhaustive** (the schema has 132 link
tables; this checks the high-value ones).

Args:
    id: A stable id or numeric DB_ID of the object being referred to.
    attribute: Optionally restrict to one relationship label
        (contained_in_pathway, component_of_complex, member_of_set,
        input_to_reaction, output_of_reaction).
    limit: Max referrers per relation (1-500, default 50).

Returns:
    Dict `{object_DB_ID, referrers: [{relationship, via_table, DB_ID, _class,
    _displayName, stable_id}], scanned, note}`.

Inputs: id (required), attribute, limit.

list_tablesA

List tables in the database with their (exact) row counts and engine.

Args:
    filter: If given, only tables whose name contains this substring
        (case-insensitive). e.g. "_2_" for link tables, "Reference" for
        reference-data tables.
    limit: Max tables to return (default 500; the DB has 242).

Returns:
    Dict `{count, tables: [{table, rows, engine}], truncated}`, ordered by
    row count descending. Row counts are exact (all tables are MyISAM).

Inputs: filter, limit.

queryA

Run a single READ-ONLY SQL statement against the Reactome DB.

Accepts one `SELECT` / `WITH` / `SHOW` / `DESCRIBE` / `EXPLAIN` statement.
Writes are impossible (the connection is a SELECT-only user) and multiple
statements are rejected. If a `SELECT`/`WITH` has no `LIMIT`, one is injected
automatically. Call `schema_overview` first to learn the join patterns.

Args:
    sql: The statement to run. Use parameter-free SQL; quote literals
        normally. e.g. `SELECT d.DB_ID, d._displayName FROM DatabaseObject d
        JOIN StableIdentifier si ON d.stableIdentifier = si.DB_ID
        WHERE si.identifier = 'R-HSA-69278'`.
    max_rows: Max rows to return (1-5000, default 200). Long text cells are
        also truncated; `truncated` flags either kind.

Returns:
    Dict `{columns, rows, row_count, truncated, sql}` where `rows` is a list
    of lists aligned to `columns`, and `sql` is the statement actually run
    (with any auto-injected LIMIT). On a bad statement or DB error, returns
    `{"error": ...}`.

Inputs: sql (required), max_rows.

schema_overviewA

Explain the Reactome GKB schema so you can write correct SQL.

Returns a primer on the class-table-inheritance model (the `DatabaseObject`
supertable, subclass tables sharing `DB_ID`, the `Class_2_attribute` link
tables, and the stable-id join), the most useful tables, key join recipes,
and the data release loaded. **Read this once before writing `query()` SQL.**
The same primer is also available as the `schema://reactome` MCP resource.

Inputs: no named parameters.

search_by_nameA

Search objects by _displayName.

Args:
    query: Text to look for in the display name.
    classes: Optional `_class` filter, e.g. ["Pathway", "Reaction"].
    limit: Max results (1-200, default 25).
    anchored: If True, match `name LIKE 'query%'` (fast — uses the prefix
        index). If False (default), match `'%query%'` — more thorough but a
        full scan of the 1.86M-row supertable (~1-2s). There are no FULLTEXT
        indexes, so prefer `anchored=True` and/or a `classes` filter for hot
        paths.

Returns:
    Dict `{count, anchored, results: [{DB_ID, _class, _displayName, stable_id}]}`.

Inputs: query (required), classes, limit, anchored.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 9 tools

    Disambiguation5/5

    Each tool has a distinct purpose: schema exploration (list_tables, describe_table, schema_overview), object retrieval (get_object, search_by_name), relationship queries (get_participants, get_pathway_events, get_referrers), and raw SQL (query). No overlapping functionality.

    Naming Consistency4/5

    Most tools follow a consistent verb_noun pattern (e.g., describe_table, get_object, list_tables). However, 'query' and 'schema_overview' are outliers—'query' is a bare verb and 'schema_overview' is noun_noun—but the overall pattern is mostly adhered to.

    Tool Count5/5

    With 9 tools, the server is well-scoped for a biological database MCP server. It provides essential operations without bloat, covering schema exploration, object retrieval, relationship navigation, and custom queries.

    Completeness5/5

    The tool set covers the primary interactions with Reactome: exploring schema, fetching objects, searching by name, retrieving participants and pathway events, reverse lookups, and arbitrary SQL queries. No obvious gaps for typical workflows.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Provides safe, configurable SQL database access via MCP tools, enabling schema introspection, predefined queries, and structured updates with multi-backend support.
      2
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides read-only MySQL query execution, database/table browsing, and table structure inspection with SQL safety validation.
      5
      9 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides secure, read-only access to a single MySQL database for schema inspection and querying.
      130 npm
      5
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      Provides read-only access to a local MySQL database, enabling SQL queries, database and table listings, and table schema descriptions.
      4
      -