Skip to content

Add MCP server for managing MongoDB clusters#346

Draft
GromNaN wants to merge 2 commits intomongodb-labs:masterfrom
GromNaN:add-mcp-server
Draft

Add MCP server for managing MongoDB clusters#346
GromNaN wants to merge 2 commits intomongodb-labs:masterfrom
GromNaN:add-mcp-server

Conversation

@GromNaN
Copy link
Copy Markdown

@GromNaN GromNaN commented Apr 7, 2026

Summary

  • Add mongo_orchestration/mcp_server.py: an MCP (Model Context Protocol) server that exposes three tools to AI assistants (e.g. Claude Code): start_cluster, stop_cluster, and list_clusters.
  • The MCP server uses stdio transport and auto-starts mongo-orchestration if it is not already running.
  • Multi-version support via mo-config.json: map version labels to MongoDB binary directories (compatible with the m version manager).
  • Add mongo-orchestration-mcp entry point in pyproject.toml.
  • Document the MCP server in README.rst.
image

Why an MCP server rather than a prompt skill?

The primary use case is driver and library development against MongoDB: a developer asks an AI assistant to run a test suite against a specific topology and version, and the assistant needs to manage clusters autonomously as part of a larger task.

A prompt skill (e.g. /mongo-launch) requires the user to explicitly invoke each step. An MCP server exposes structured tools that the AI can call on its own initiative mid-task:

  1. Understand from context which topology and version are needed (e.g. replica set, MongoDB 7.0 with auth).
  2. Call start_cluster to provision the cluster and obtain the connection URI.
  3. Run the tests using that URI.
  4. Call stop_cluster to clean up.

This end-to-end flow — provision → test → teardown — happens without manual intervention, which is exactly what MCP tools are designed for. A skill would require the user to orchestrate each step themselves.

Test plan

  • Install the package in a virtualenv and verify mongo-orchestration-mcp is on the PATH.
  • Register the MCP server in ~/.claude.json and verify Claude Code lists the three tools.
  • Call start_cluster with cluster_type="single", "repl", and "shard" and verify each cluster starts and returns a connection URI.
  • Call list_clusters and verify all running clusters appear.
  • Call stop_cluster for each running cluster and verify they stop cleanly.
  • Create a mo-config.json with version paths and verify start_cluster(version="7.0") starts the correct binary.
  • Verify _ensure_running() starts mongo-orchestration automatically when not already running.

GromNaN added 2 commits April 7, 2026 21:52
- Add mongo_orchestration/mcp_server.py exposing three MCP tools:
  start_cluster, stop_cluster, list_clusters
- The MCP server auto-starts mongo-orchestration if not running,
  and picks up mo-config.json for multi-version support
- Add mongo-orchestration-mcp entry point to pyproject.toml
- Document the MCP server in README.rst
Tests cover start_cluster (all topologies, version, auth, error cases),
stop_cluster, list_clusters, and _ensure_running using mocked HTTP calls.
No MongoDB binary or running mongo-orchestration instance required.
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.

1 participant