ML

MLflow MCP Server: Experiment Tracking, Querying, Model Registry

Track, query, and compare ML experiments with an MCP server offering artifact access and a model registry.

Quick Install
npx -y @kkruglik/mlflow-mcp

Overview

The MLflow MCP Server implements the Model Context Protocol (MCP) on top of MLflow storage and tracking backends. It provides a lightweight HTTP API to discover experiments and runs, read artifacts, and interact with a simple model registry. For teams that already use MLflow for experiment tracking, this server makes it easier to query, compare and consume experiment metadata and artifacts from other services or production pipelines.

By exposing a consistent REST surface that focuses on experiment querying and model metadata, the MCP server is useful for automation, CI/CD integration, model promotion workflows, and dashboards. It can sit next to an MLflow tracking server and provide additional convenience endpoints (search, compare, artifact download, model lookup) without changing existing tracking stores.

Features

  • REST API for listing experiments, runs and run metadata
  • Query and filter runs by tags, metrics, params and time range
  • Artifact access and streaming download for any run artifact
  • Simple model registry with model name, versions and metadata
  • Run comparison utilities (metric diffs, parameter diffs)
  • OpenAPI / Swagger UI for interactive exploration
  • Pagination and basic filtering for large result sets
  • Deployable as a standalone service or containerized app

Installation / Configuration

Run from source (recommended for development):

git clone https://github.com/kkruglik/mlflow-mcp.git
cd mlflow-mcp

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .

Configure environment variables and start the server (example):

export MLFLOW_TRACKING_URI="sqlite:///mlflow.db"   # or an HTTP MLflow server
export MCP_HOST="0.0.0.0"
export MCP_PORT="8080"
export MCP_LOG_LEVEL="info"

# Assuming the app entrypoint is `mcp.app:app` (adjust to actual package)
uvicorn mcp.app:app --host $MCP_HOST --port $MCP_PORT --log-level $MCP_LOG_LEVEL

Run with Docker (example):

docker run -p 8080:8080 \
  -e MLFLOW_TRACKING_URI="http://mlflow:5000" \
  kkruglik/mlflow-mcp:latest

Example docker-compose fragment linking to MLflow:

version: "3.7"
services:
  mlflow:
    image: mlfloworg/mlflow:latest
    ports: ["5000:5000"]
    # configure backend store and artifact store
  mcp:
    image: kkruglik/mlflow-mcp:latest
    ports: ["8080:8080"]
    environment:
      - MLFLOW_TRACKING_URI=http://mlflow:5000

Configuration notes:

  • MLFLOW_TRACKING_URI should point to your MLflow tracking server or backend store URI.
  • The server may accept additional env vars for auth or storage paths — check the repo for exact names when deploying.

Available Resources

Common HTTP endpoints (paths are illustrative; refer to the running server’s OpenAPI for exact signatures):

PathMethodDescription
/experimentsGETList experiments with pagination
/experiments/{id}/runsGETList runs for an experiment, supports filtering
/runs/{run_id}GETFetch run metadata, metrics, params, tags
/runs/{run_id}/artifacts/{path}GETStream/download an artifact file or folder
/modelsGET/POSTList models / register new model
/models/{name}GETGet model metadata and versions
/models/{name}/versionsPOSTCreate a new model version from a run/artifact
/compareGETCompare two or more runs (metrics/params diffs)
/openapi.json, /docsGETOpenAPI schema and Swagger UI

The server typically exposes an interactive Swagger UI at /docs for exploration and an OpenAPI JSON at /openapi.json.

Use Cases

  1. Automating model promotion
  • CI pipeline queries the MCP server for the latest model version that passed validation:
    • GET /models/{model_name} -> find approved/latest version
    • GET /runs/{run_id}/artifacts/path/to/model -> download artifact
  • Promote the found version to staging or production via registry metadata.
  1. Comparing experiments programmatically
  • Script to compare two runs’ key metrics before deploying:
    • GET /compare?runs=runA,runB -> receive metric diffs and parameter differences
  • Use results to gate deployment: only deploy if metric delta > threshold.
  1. Artifact-driven deployments
  • Production service fetches a serialized model directly from the MCP server:
    • curl -o model.pkl “http://mcp:8080/runs/<run_id>/artifacts/model/model.pkl”
  • Keeps deployment decoupled from MLflow internals; the MCP server can add caching, auth or ACLs as needed.
  1. Centralized experiment dashboards
  • A lightweight dashboard polls /experiments and /models endpoints to surface recent runs, top-performing runs, and model versions without needing direct MLflow DB access.

Example curl to list experiments:

curl "http://localhost:8080/experiments?page=1&per_page=20"

Example Python snippet to download an artifact:

import requests

url = "http://localhost:8080/runs/1234/artifacts/model/model.pkl"
resp = requests.get(url, stream=True)
resp.raise_for_status()
with open("model.pkl", "wb") as f:
    for chunk in resp.iter_content(1024*64):
        f.write(chunk)

Next steps and resources

  • Start the server and open /docs to inspect the full API schema and example payloads.
  • Integrate into CI/CD or orchestration pipelines to automate model selection and artifact retrieval.
  • For advanced deployments, place the server behind an API gateway and add authentication (JWT, mTLS) and logging as needed.