A Model Context Protocol (MCP) server that provides MetricFlow CLI tools
Project description
mcp-metricflow
A Model Context Protocol (MCP) server that provides MetricFlow CLI tools through both SSE (currently no auth) and STDIO interfaces.
[!WARNING] This repository is a learning project focused on MetricFlow integration with MCP. For production use cases, please refer to the official dbt-mcp implementation by dbt Labs.
Table of Contents
Overview
This project provides a Model Context Protocol (MCP) server that wraps MetricFlow CLI commands, making them accessible through both Server-Sent Events (SSE) and Standard Input/Output (STDIO) interfaces. It enables seamless integration with Claude Desktop and other MCP-compatible clients.
Installation
# Clone the repository
git clone https://github.com/datnguye/mcp-metricflow.git
cd mcp-metricflow
# Install dependencies
uv sync
# Copy environment template
cp .env.template .env
Configuration
Edit the .env file with your specific configuration:
# Required: Path to your dbt project
DBT_PROJECT_DIR=/path/to/your/dbt/project
# Optional: Other configurations
DBT_PROFILES_DIR=~/.dbt
MF_PATH=mf
MF_TMP_DIR=/tmp
# SSE server configuration (optional)
MCP_HOST=localhost
MCP_PORT=8000
Running the MCP Server
STDIO Mode (Claude Desktop)
For integration with Claude Desktop, use STDIO mode:
uv run python src/main_stdio.py
Claude Desktop Configuration
Add this to your Claude Desktop MCP configuration:
{
"mcpServers": {
"metricflow": {
"command": "uv",
"args": ["run", "python", "/path/to/mcp-metricflow/src/main_stdio.py"],
"cwd": "/path/to/mcp-metricflow",
"env": {
"DBT_PROJECT_DIR": "/path/to/your/dbt/project",
"DBT_PROFILES_DIR": "~/.dbt",
"MF_PATH": "mf"
}
}
}
}
SSE Mode
For web-based integration or direct HTTP access:
# export DBT_PROFILES_DIR=~/.dbt
uv run python src/main_sse.py
The server will start on http://localhost:8000 (or the host/port specified in your environment variables).
Available Tools
The MCP server exposes the following MetricFlow CLI tools:
| Tool | Description | Required Parameters | Optional Parameters |
|---|---|---|---|
query |
Execute MetricFlow queries | session_id, metrics |
group_by, start_time, end_time, where, order, limit, saved_query, explain, show_dataflow_plan, show_sql_descriptions |
list_metrics |
List available metrics | None | search, show_all_dimensions |
list_dimensions |
List available dimensions | None | metrics |
list_entities |
List available entities | None | metrics |
list_dimension_values |
List values for a dimension | dimension, metrics |
start_time, end_time |
validate_configs |
Validate model configurations | None | dw_timeout, skip_dw, show_all, verbose_issues, semantic_validation_workers |
health_checks |
Perform system health checks | None | None |
Each tool includes comprehensive documentation accessible through the MCP interface.
Project Structure
src/
├── config/
│ └── config.py # Configuration management
├── server/
│ ├── sse_server.py # SSE server implementation
│ └── stdio_server.py # STDIO server implementation
├── tools/
│ ├── prompts/mf_cli/ # Tool documentation (*.md files)
│ ├── metricflow/ # MetricFlow CLI wrappers
│ │ ├── base.py # Shared command execution
│ │ ├── query.py # Query functionality
│ │ ├── list_metrics.py # List metrics
│ │ ├── list_dimensions.py # List dimensions
│ │ ├── list_entities.py # List entities
│ │ ├── list_dimension_values.py # List dimension values
│ │ ├── validate_configs.py # Configuration validation
│ │ └── health_checks.py # Health checks
│ └── cli_tools.py # MCP tool registration
├── utils/
│ ├── logger.py # Logging configuration
│ └── prompts.py # Prompt loading utilities
├── main_sse.py # SSE server entry point
└── main_stdio.py # STDIO server entry point
Development
Code Quality
The project uses ruff for code formatting and linting:
# Format code
uv run ruff format
# Check code quality
uv run ruff check .
TODO
- Test STDIO mode
- Add API KEY auth to SSE mode
- Publish package
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_metricflow-1.0.0b2.tar.gz.
File metadata
- Download URL: mcp_metricflow-1.0.0b2.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d170b36c986f05ab0c43bef63846919d3e79b87e5fd69698800b11ba9a77d9fb
|
|
| MD5 |
244b37da7c1d1f83f890dd7836fc9e5b
|
|
| BLAKE2b-256 |
7285763a09b609de49ba8ff5bc481671e2d7d85ed2511180d510f745c8a165c0
|
Provenance
The following attestation bundles were made for mcp_metricflow-1.0.0b2.tar.gz:
Publisher:
pypi-publish.yml on datnguye/mcp-metricflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_metricflow-1.0.0b2.tar.gz -
Subject digest:
d170b36c986f05ab0c43bef63846919d3e79b87e5fd69698800b11ba9a77d9fb - Sigstore transparency entry: 237241737
- Sigstore integration time:
-
Permalink:
datnguye/mcp-metricflow@3e1818591bb04e587301bfba74e7d3581dba942a -
Branch / Tag:
refs/tags/1.0.0b2 - Owner: https://github.com/datnguye
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@3e1818591bb04e587301bfba74e7d3581dba942a -
Trigger Event:
push
-
Statement type:
File details
Details for the file mcp_metricflow-1.0.0b2-py3-none-any.whl.
File metadata
- Download URL: mcp_metricflow-1.0.0b2-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4c67e96b5acc77a7245b5846441baede59d4d2c3384860292ef6aa85d6dcfa5
|
|
| MD5 |
56c9df9adc4c5252637d5e83a3bf61cf
|
|
| BLAKE2b-256 |
8b4fc6977cf7f26600d099652c4ff1eb07fd5c86230f5dfb7e8e767da7071496
|
Provenance
The following attestation bundles were made for mcp_metricflow-1.0.0b2-py3-none-any.whl:
Publisher:
pypi-publish.yml on datnguye/mcp-metricflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_metricflow-1.0.0b2-py3-none-any.whl -
Subject digest:
d4c67e96b5acc77a7245b5846441baede59d4d2c3384860292ef6aa85d6dcfa5 - Sigstore transparency entry: 237241741
- Sigstore integration time:
-
Permalink:
datnguye/mcp-metricflow@3e1818591bb04e587301bfba74e7d3581dba942a -
Branch / Tag:
refs/tags/1.0.0b2 - Owner: https://github.com/datnguye
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@3e1818591bb04e587301bfba74e7d3581dba942a -
Trigger Event:
push
-
Statement type: