Skip to content

feat(mcp): add minimal Python MCP client for reactome-mcp integration - #127

Closed
GovindhKishore wants to merge 1 commit into
reactome:mainfrom
GovindhKishore:feat/mcp-client
Closed

GovindhKishore wants to merge 1 commit into
reactome:mainfrom
GovindhKishore:feat/mcp-client

Conversation

@GovindhKishore

Copy link
Copy Markdown

Summary

Adds a minimal Python MCP integration layer under src/mcp/ that allows the Reactome Chatbot to communicate with the reactome-mcp server over JSON-RPC stdio.

Closes #126


Motivation

The reactome-mcp server exposes 53 live tools covering search, pathway queries, enrichment analysis, entity lookup, and more. These tools query Reactome APIs directly, meaning they always return current data regardless of when embeddings were last built. The chatbot currently has no way to talk to this server. This PR adds the foundation that makes all future MCP-based features possible.

This PR does not wire MCP into the LangGraph agent or add query routing - that is follow-up work. The sole purpose here is a working, tested communication layer between Python and the MCP server.


Changes

mcp_process_manager.py

  • Spawns the MCP server as a subprocess via asyncio.create_subprocess_exec
  • Validates server path at init time with a clear error if missing
  • Detects startup failures by reading stderr
  • Graceful shutdown with terminate(), falls back to kill() after 5 seconds
  • Async context manager support so the server is always stopped cleanly

mcp_client.py

  • Constructs and sends JSON-RPC requests over stdin
  • Reads responses from stdout with a configurable timeout
  • Handles malformed JSON and JSON-RPC error responses explicitly
  • call_tool() convenience method for cleaner tool invocation

Testing

Tested locally by starting the server programmatically and calling tools/list and reactome_search.

tools/list confirmed all 53 tools are accessible.

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

AI Usage Transparency

AI tools were used during development and drafting. All code was manually reviewed and tested locally.

@GovindhKishore

Copy link
Copy Markdown
Author

Hi @adamjohnwright , this PR adds a minimal Python MCP client as a foundation for integrating the reactome-mcp server into the chatbot. It's a prototype at this stage. The next steps would be wiring it into the LangGraph agent and adding query routing. Would appreciate your thoughts on the approach before building further on top of it.

@adamjohnwright

Copy link
Copy Markdown
Contributor

Closing in favour of #137 — not because the work is wrong, but because it is entirely contained in it.

All three files here (src/mcp/__init__.py, mcp_client.py, mcp_process_manager.py) appear in #137 unchanged, with the LangChain tool wrappers built on top. Reviewing and merging both would mean merging the same code twice, so the review is happening on #137 and this stays credited to you there.

Two notes on the client itself, since they carry forward to #137 and are worth saying to the author rather than discovering later:

The package name src/mcp/ will collide. There is no mcp dependency in this repo today, so nothing breaks now — but the official MCP Python SDK is published on PyPI as mcp, and it is the obvious library to adopt. The day anyone adds it, from mcp.mcp_client import ... becomes ambiguous in a way that is genuinely unpleasant to debug. Worth renaming before it lands.

Spawning the server as a subprocess is the right call for now. For what it is worth, reactome-mcp gained a Streamable HTTP transport today, so a future version of this can talk to a hosted instance instead of spawning one. Your process-manager shape is what makes that swap easy, because the transport is isolated behind it.

Thank you for this, and sorry it sat so long.

adamjohnwright added a commit that referenced this pull request Sep 14, 2026
Add an MCP client for reactome-mcp, harvested from #127 and #137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add minimal Python MCP client for reactome-mcp integration

2 participants