Cube.js MCP Server

Cube.js MCP Server

Enables AI assistants to query and analyze data from Cube.js analytics platforms, allowing natural language access to cubes, measures, dimensions, and complex analytics queries.

Category
访问服务器

README

Cube.js MCP Server

A Model Context Protocol (MCP) server implementation for Cube.js, enabling seamless integration between AI assistants and Cube.js analytics platforms.

Overview

This project provides a FastMCP-based server that exposes Cube.js analytics capabilities through the Model Context Protocol. It allows AI models and applications to:

  • List available data cubes and their metadata
  • Query data using natural language-friendly interfaces
  • Access measures, dimensions, and segments from your Cube.js instance
  • Execute complex analytics queries programmatically

Features

  • Cube Listing: Retrieve all available cubes with their measures, dimensions, and segments
  • Query Support: Execute queries against Cube.js with flexible filtering and aggregation
  • Metadata Access: Get detailed information about cube structure and relationships
  • Async Support: Built on FastMCP for high-performance async operations
  • Error Handling: Robust error handling with meaningful error messages
  • Token Authentication: Secure API access with token-based authentication

Prerequisites

  • Python 3.8 or higher
  • Cube.js instance running and accessible
  • pip package manager

Installation

  1. Clone the repository:
git clone https://github.com/zsembek/Cube.js-MCP-server.git
cd Cube.js-MCP-server
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
cp .env.example .env

Edit .env with your Cube.js configuration:

CUBEJS_API_BASE_URL=http://localhost:4000/cubejs-api/v1
CUBEJS_API_TOKEN=your_api_token_here

Configuration

Environment Variables

  • CUBEJS_API_BASE_URL: The base URL of your Cube.js API (default: http://localhost:4000/cubejs-api/v1)
  • CUBEJS_API_TOKEN: Authentication token for Cube.js API (required if your instance requires authentication)

Claude Configuration

To use this MCP server with Claude or other compatible clients, add it to your configuration file (~/.config/Claude/claude_desktop_config.json):

{
    "mcpServers": {
        "cubejs": {
            "command": "uvx",
            "args": [
                "--with",
                "cubejs-mcp-server @ git+https://github.com/zsembek/Cube.js-MCP-server.git",
                "python",
                "-m",
                "cubejs_mcp.server"
            ],
            "env": {
                "CUBEJS_API_BASE_URL": "http://localhost:4000/cubejs-api/v1",
                "CUBEJS_API_TOKEN": "your_api_token"
            }
        }
    }
}

Usage

Running the Server

python server.py

The server will start and be ready to accept MCP protocol requests.

Available Tools

1. list_cubes()

Retrieves the list of available cubes with their metadata.

Returns: A dictionary containing:

  • Cube names and descriptions
  • Available measures for each cube
  • Available dimensions for each cube
  • Available segments for each cube

Example:

cubes = await list_cubes()

2. query_cube(cube_name, measures, dimensions, filters)

Execute a query against a specific cube.

Parameters:

  • cube_name (string): Name of the cube to query
  • measures (list): List of measures to include in the query
  • dimensions (list): List of dimensions to group by
  • filters (optional, list): List of filter conditions

Returns: Query results with aggregated data

Example:

result = await query_cube(
    cube_name="Orders",
    measures=["Orders.count", "Orders.total"],
    dimensions=["Orders.status"],
    filters=["Orders.created_date > 2024-01-01"]
)

Project Structure

.
├── cubejs_mcp/
│   ├── __init__.py        # Package initialization
│   └── server.py          # MCP server implementation
├── server.py              # Legacy entry point (kept for compatibility)
├── config.json            # Configuration file for MCP clients
├── pyproject.toml         # Python package configuration
├── requirements.txt       # Python dependencies
├── .env.example          # Environment variables template
└── README.md             # This file

Dependencies

  • fastmcp: FastMCP framework for building MCP servers
  • httpx: Async HTTP client for making requests to Cube.js
  • python-dotenv: Environment variable management

See requirements.txt for specific versions.

Error Handling

The server includes comprehensive error handling for:

  • Network connectivity issues
  • Authentication failures
  • Invalid cube or metric names
  • API rate limiting
  • Malformed queries

Error responses include descriptive messages to help diagnose issues.

Security Considerations

  • Always keep your CUBEJS_API_TOKEN secret and never commit it to version control
  • Use .env files with proper permissions (600 or restricted access)
  • Consider using environment variables managed by your deployment platform
  • Ensure your Cube.js instance is properly secured behind authentication/firewall

Development

Setting up Development Environment

# Install dependencies
pip install -r requirements.txt

# Set up environment variables
cp .env.example .env

# Edit .env with your local Cube.js instance details
nano .env

Running Tests

Tests can be added to verify functionality. Use pytest or unittest frameworks.

Troubleshooting

Connection Issues

  • Verify CUBEJS_API_BASE_URL is correct and Cube.js is running
  • Check network connectivity to the Cube.js instance
  • Ensure firewall allows connections

Authentication Errors

  • Confirm CUBEJS_API_TOKEN is correct
  • Check if your Cube.js instance requires authentication
  • Verify token hasn't expired

Query Errors

  • Ensure cube names, measures, and dimensions are spelled correctly
  • Check if filters are properly formatted
  • Verify you have permission to access the requested cubes

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

This project is open source and available under the MIT License.

Support

For issues, questions, or suggestions, please open an issue on the GitHub repository.

Resources

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选