Skip to content

Add minimal Python MCP client for reactome-mcp integration #126

@GovindhKishore

Description

@GovindhKishore

Summary

This issue documents the addition of a minimal Python MCP integration layer that allows the Reactome Chatbot to communicate with the reactome-mcp server over the JSON-RPC stdio protocol.

A pull request implementing this will be opened shortly.


Background

The reactome-mcp repository exposes 53 tools for interacting with the Reactome knowledgebase - search, pathway queries, enrichment analysis, entity lookup, diagram export, and more. However, the chatbot currently has no Python client capable of communicating with the MCP server.

This integration addresses that gap and lays the groundwork for future query routing between ChromaDB (static embeddings) and live MCP tool calls.


Implementation

A small MCP module is added under src/mcp/:

src/mcp/
├── __init__.py
├── mcp_process_manager.py
└── mcp_client.py

MCPProcessManager - manages the lifecycle of the MCP server subprocess:

  • Spawns node dist/index.js via asyncio.create_subprocess_exec
  • Detects startup failures by checking process return code and reading stderr
  • Graceful shutdown with terminate(), falls back to kill() after 5 seconds
  • Implements async context manager for safe lifecycle handling

MCPClient - minimal JSON-RPC client over stdin/stdout:

  • Constructs and sends JSON-RPC requests
  • Reads and parses responses from stdout
  • Timeout on readline() so the chatbot never hangs indefinitely
  • Handles JSON-RPC error responses explicitly
  • call_tool() convenience method for cleaner tool invocation

Development Setup

The MCP server was cloned as a sibling directory alongside the chatbot project and built with:

npm install
npm run build

Project structure used during development:

PycharmProjects/
├── reactome_chatbot/
│   └── src/
│       └── mcp/
│           ├── mcp_process_manager.py
│           └── mcp_client.py
└── reactome-mcp/
    └── dist/
        └── index.js

Testing

Tested locally by starting the server programmatically, calling tools/list and reactome_search via both call() and call_tool().

tools/list confirmed all 53 tools are accessible, including reactome_search, reactome_analyze_identifiers, reactome_get_pathway, reactome_export_diagram, and others.

reactome_search output via call_tool():

Search Results for "TP53"
Found: 3420 results

- TP53 (R-HSA-69488) - ReferenceGeneProduct, Homo sapiens
- TP53 (R-HSA-8869337) - ReferenceGeneProduct, Homo sapiens
- Unfolded TP53 (R-HSA-6813797) - ReferenceGeneProduct, Homo sapiens
...
Showing 25 of 3420 results

This confirms the server starts and stops correctly from Python, JSON-RPC communication works over stdin/stdout, and tool arguments are passed and parsed correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions