Skip to main content
Glama
timeplus-io

mcp-timeplus

by timeplus-io

run_sql

Execute SQL queries to analyze real-time streaming data from Kafka or Pulsar sources in a Timeplus database.

Instructions

Run a query in a Timeplus database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The run_sql tool handler - decorated with @mcp.tool(), executes a SQL query against Timeplus database with timeout handling and error management.
    @mcp.tool()
    def run_sql(query: str):
        """Run a query in a Timeplus database"""
        logger.info(f"Executing query: {query}")
        try:
            future = QUERY_EXECUTOR.submit(execute_query, query)
            try:
                result = future.result(timeout=SELECT_QUERY_TIMEOUT_SECS)
                # Check if we received an error structure from execute_query
                if isinstance(result, dict) and "error" in result:
                    logger.warning(f"Query failed: {result['error']}")
                    # MCP requires structured responses; string error messages can cause
                    # serialization issues leading to BrokenResourceError
                    return {"status": "error", "message": f"Query failed: {result['error']}"}
                return result
            except concurrent.futures.TimeoutError:
                logger.warning(f"Query timed out after {SELECT_QUERY_TIMEOUT_SECS} seconds: {query}")
                future.cancel()
                # Return a properly structured response for timeout errors
                return {"status": "error", "message": f"Query timed out after {SELECT_QUERY_TIMEOUT_SECS} seconds"}
        except Exception as e:
            logger.error(f"Unexpected error in run_select_query: {str(e)}")
            # Catch all other exceptions and return them in a structured format
            # to prevent MCP serialization failures
            return {"status": "error", "message": f"Unexpected error: {str(e)}"}
  • execute_query helper function - creates a Timeplus client, runs the query, and returns structured results or error dictionaries.
    def execute_query(query: str):
        client = create_timeplus_client()
        try:
            readonly = 1 if config.readonly else 0
            res = client.query(query, settings={"readonly": readonly})
            column_names = res.column_names
            rows = []
            for row in res.result_rows:
                row_dict = {}
                for i, col_name in enumerate(column_names):
                    row_dict[col_name] = row[i]
                rows.append(row_dict)
            logger.info(f"Query returned {len(rows)} rows")
            return rows
        except Exception as err:
            logger.error(f"Error executing query: {err}")
            # Return a structured dictionary rather than a string to ensure proper serialization
            # by the MCP protocol. String responses for errors can cause BrokenResourceError.
            return {"error": str(err)}
  • The run_sql tool accepts a single 'query' parameter of type str, no explicit schema/Pydantic model.
    def run_sql(query: str):
  • Registration via @mcp.tool() decorator on the run_sql function.
    @mcp.tool()
  • run_sql is exported from the package's __init__.py via import from mcp_server.
    from .mcp_server import (
        create_timeplus_client,
        list_databases,
        list_tables,
        run_sql,
Behavior1/5

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

With no annotations provided, the description must disclose behavioral traits. However, it only states 'Run a query' without indicating potential side effects, required permissions, query limits, or whether results are returned. This is insufficient for a tool that executes arbitrary SQL.

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

Conciseness2/5

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

The description is very short (one sentence), which might seem concise, but it is under-specified. It lacks critical information needed for proper tool usage, making it insufficient rather than appropriately concise.

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

Completeness1/5

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

Given the complexity of executing SQL queries, the absence of output schema, and no annotations, the description is woefully incomplete. It does not explain return values, error handling, or whether the query can be any valid SQL statement.

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

Parameters1/5

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

The input schema has a single required parameter 'query' with no description, and the schema description coverage is 0%. The description adds minimal meaning beyond 'run a query', failing to explain what type of SQL is supported, syntax constraints, or how to specify parameters.

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 'Run a query in a Timeplus database' clearly specifies the action (run) and the resource (query in a Timeplus database). It effectively distinguishes this tool from sibling tools like connect_to_apache_iceberg or list_tables, as it is the only one focused on executing SQL queries.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. For example, it does not clarify whether it supports read-only queries or modifications, nor does it mention any prerequisites or restrictions.

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/timeplus-io/mcp-timeplus'

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