mcp-metricflow
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-metricflowlist all metrics in the project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-metricflow
A Model Context Protocol (MCP) server that provides MetricFlow CLI tools through both SSE (with optional API key authentication) and STDIO interfaces.
This repository is a learning project focused on MetricFlow integration with MCP. For production use cases, please refer to the officialdbt-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.
Setup
# Install uv at https://docs.astral.sh/uv/getting-started/installation/
# Copy environment template
cp .env.template .env
# ...and then jump to # Configuration section to fulfill itConfiguration
Edit the .env file with your specific configuration:
# Required: Path to your dbt project
DBT_PROJECT_DIR=/path/to/your/dbt/project e.g. /Users/dat/repos/il/jaffle-shop
# Optional: Other configurations
DBT_PROFILES_DIR=/path/to/.dbt
MF_PATH=mf
MF_TMP_DIR=/path/to/tmp
# SSE server configuration (optional)
MCP_HOST=localhost
MCP_PORT=8000
# API key authentication for SSE mode (optional)
MCP_API_KEY=your-secret-api-key
MCP_REQUIRE_AUTH=falseRunning the MCP Server
STDIO Mode ✅
For integration with Claude Desktop (or any other MCP Client tool), use STDIO mode with the following uvx command:
uvx --env-file /path/to/.env --with "mcp-metricflow[snowflake]" mcp-metricflowSample .env file:
DBT_PROJECT_DIR=/Users/xxx/sources/jaffle-shop
DBT_PROFILES_DIR=/Users/xxx/.dbt
MF_TMP_DIR=/Users/xxx/.dbt/tmpAdd this configuration to the respective client's config file:
{
"mcpServers": {
"mcp-metricflow": {
"command": "uvx",
"args": [
"--env-file", "<path-to-.env-file>",
"--with", "mcp-metricflow[snowflake]",
"mcp-metricflow"
]
},
}
}NOTE: Currently only support Snowflake with this extra dependency specified:
"--with", "mcp-metricflow[snowflake]"
NOTE: We might have to use absolute path for example:
/Users/xxx/.local/bin/uvxinstead ofuvxalone. Usewhich uvxto get the full path
SSE Mode 🚧
For web-based integration or direct HTTP access:
# export DBT_PROFILES_DIR=~/.dbt
uv run python src/main_sse.pyThe server will start on http://localhost:8000 (or the host/port specified in your environment variables).
API Key Authentication
The SSE server supports optional API key authentication. To enable authentication:
Set the required environment variables:
export MCP_API_KEY="your-secret-api-key" export MCP_REQUIRE_AUTH="true"Access authenticated endpoints by including the API key in the Authorization header:
# Health check (no authentication required) curl http://localhost:8000/health # SSE endpoint (requires authentication when enabled) curl -H "Authorization: Bearer your-secret-api-key" http://localhost:8000/sse
Authentication Configuration:
MCP_API_KEY: The secret API key for authentication (required whenMCP_REQUIRE_AUTH=true)MCP_REQUIRE_AUTH: Enable/disable authentication (true,1,yes,onto enable; default:false)
Security Notes:
The
/healthendpoint is always accessible without authentication for monitoring purposesThe
/sseendpoint requires authentication whenMCP_REQUIRE_AUTH=trueAPI keys are case-sensitive and support special characters
Store API keys securely and avoid committing them to version control
Available Tools
The MCP server exposes the following MetricFlow CLI tools:
Tool | Description | Required Parameters | Optional Parameters |
| Execute MetricFlow queries |
|
|
| List available metrics | None |
|
| List available dimensions | None |
|
| List available entities | None |
|
| List values for a dimension |
|
|
| Validate model configurations | None |
|
| 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/
│ ├── auth.py # API key authentication
│ ├── 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 pointContributing ✨
If you've ever wanted to contribute to this tool, and a great cause, now is your chance!
See the contributing docs CONTRIBUTING for more information.
If you've found this tool to be very helpful, please consider giving the repository a star, sharing it on social media, or even writing a blog post about it 💌
Finally, super thanks to our Contributors:
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/datnguye/mcp-metricflow'
If you have feedback or need assistance with the MCP directory API, please join our Discord server