Skip to main content
Glama
namabile

Malloy MCP Server

by namabile

execute_malloy_query

Execute Malloy queries against models by providing a query string or specifying a source and named query, returning results including data styles and model definitions.

Instructions

Execute a Malloy query.

This tool connects to the Malloy Publisher API (default: http://localhost:4000/api/v0)
and executes a Malloy query against a model.

Args:
    project_name: The name of the project, defaults to "home"
    package_name: The name of the package containing the model
    model_path: The path to the model within the package
    query: The Malloy query string to execute (mutually exclusive with query_name)
    source_name: Name of the source in the model (required when using query_name)
    query_name: Name of a query to execute on a source
        (mutually exclusive with query)
    version_id: Version ID of the package

Returns:
    Any: Query execution result with structure:
        {
            "data_styles": Object containing style information
            "model_def": Object containing model definition
            "query_result": Array of result objects
        }

Raises:
    MalloyError: If query execution fails or parameters are invalid
        Error codes:
        - QUERY_EXECUTION_ERROR: Error during query execution
        - CONNECTION_ERROR: Error connecting to Malloy Publisher API

Example:
    ```python
    # Example 1: Direct query
    result = await execute_malloy_query(
        project_name="home",
        package_name="sales",
        model_path="sales.malloy",
        query="query: orders -> { aggregate: count() }"
    )

    # Example 2: Named query
    result = await execute_malloy_query(
        project_name="home",
        package_name="sales",
        model_path="sales.malloy",
        source_name="orders",
        query_name="top_customers"
    )
    ```

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_nameNohome
package_nameNo
model_pathNo
queryNo
source_nameNo
query_nameNo
version_idNo
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses the API endpoint, parameters, return structure, and error codes, but does not specify whether the tool is read-only or has side effects. The examples suggest it is read-only (aggregate query), but this is not explicit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with Args, Returns, Raises, and Examples sections. It is front-loaded with the core purpose. However, it is somewhat verbose, repeating default values already present in the schema. The examples are helpful but add length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 7 parameters and no output schema, the description covers the API connection, return structure, error codes, and provides examples. It misses details on authentication, idempotency, and whether queries can modify data. Overall, it addresses most of the query execution context adequately.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description compensates fully. It provides detailed parameter explanations, including defaults (e.g., project_name defaults to 'home'), mutual exclusivity between query and query_name, and requirements like source_name being required when using query_name. This adds significant value beyond the schema's titles and defaults.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Execute a Malloy query' and explains it connects to the Malloy Publisher API. It distinguishes from siblings like get_model and list_models, which are about retrieving or listing resources, not executing queries.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains when to use query vs query_name (mutually exclusive) and provides examples. However, it does not explicitly state when not to use this tool or compare it to alternatives like get_model for exploration.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/namabile/malloy-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server