MCP server for Malloy queries
Project description
Malloy MCP Server
An MCP server implementation for executing Malloy queries and managing Malloy resources.
Features
- Execute Malloy queries via MCP
- Access Malloy project, package, and model metadata
- Robust error handling with detailed context
- Comprehensive test coverage
- Type-safe implementation
Installation
# Install using uv (recommended)
uv pip install malloy-mcp-server
# Or using pip
pip install malloy-mcp-server
Usage
Starting the Server
from malloy_mcp_server import mcp
# Run the server
if __name__ == "__main__":
mcp.serve()
Configuration
The server can be configured using environment variables:
| Variable | Description | Default |
|---|---|---|
MALLOY_PUBLISHER_ROOT_URL |
URL of the Malloy Publisher API | http://localhost:4000 |
Example:
# Set the publisher URL
export MALLOY_PUBLISHER_ROOT_URL="http://malloy-publisher:4000"
# Run with custom configuration
python -m malloy_mcp_server
Executing Queries
The server provides an MCP tool for executing Malloy queries:
from malloy_mcp_server import ExecuteMalloyQueryTool
# Example query execution
result = await ExecuteMalloyQueryTool(
query="select * from users",
model_path="my_package/users"
)
Accessing Resources
The server provides the following resource endpoints:
malloy://project/home/metadata- Project metadatamalloy://project/home/package/{package_name}- Package metadatamalloy://project/home/model/{model_path}- Model metadata
Development
Setup
- Clone the repository:
git clone https://github.com/namabile/malloy-mcp-server.git
cd malloy-mcp-server
- Install dependencies:
uv pip install -e ".[dev]"
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=malloy_mcp_server
Code Quality
The project uses:
blackfor code formattingmypyfor type checkingrufffor linting
Run quality checks:
black .
mypy .
ruff check .
Error Handling
The server provides detailed error handling with context:
from malloy_mcp_server.errors import QueryExecutionError
try:
result = await ExecuteMalloyQueryTool(...)
except QueryExecutionError as e:
print(f"Error: {e.message}")
print("Context:", e.context)
Architecture
The server is built on:
- FastMCP for the MCP server implementation
- Malloy Publisher Client for Malloy interactions
- Pydantic for data validation
Key components:
server.py- Core server implementationtools/query_executor.py- Query execution toolerrors.py- Error handling utilities
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
License
MIT License - see LICENSE file for details
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 malloy_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: malloy_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b808000acba2ca5eead7a356b388f0c6c8aa630a0ca23dafd3f3d2f64e2d42ed
|
|
| MD5 |
09d6183bc1b02405dac44e66fcd2865f
|
|
| BLAKE2b-256 |
a0bfa0aa03751534ea2a58ee19cddadda8e6a901fe009dcf3e5ea0c143990251
|
File details
Details for the file malloy_mcp_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: malloy_mcp_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a792d910fc5d4eb63c98ca9228b073f12686c65c27f47bbeef2c34f177a8d75c
|
|
| MD5 |
8837e19016e0540c1c619c0c7d259365
|
|
| BLAKE2b-256 |
b7c0fba20121a67d7737c11dbb75406146453bcd6c24c4b1ef692fb70b80ad02
|