Skip to main content
Glama
lensesio

Lenses MCP Server

by lensesio

execute_sql

Execute SQL queries on Kafka topics across multiple clusters using Lenses.io WebSocket API to manage, explore, transform, and join streaming data.

Instructions

Executes SQL statements/queries using Lenses WebSocket API.

Args: environment: The environment name. sql: The SQL statement/query to execute.

Returns: A list of MessageRecord objects representing the result of the SQL query.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentYes
sqlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'execute_sql' tool, decorated with @mcp.tool(). It executes the provided SQL query in the specified Lenses environment using the WebSocket API.
    @mcp.tool()
    async def execute_sql(environment: str, sql: str) -> List[Dict[str, Any]]:
        """
        Executes SQL statements/queries using Lenses WebSocket API.
    
        Args:
            environment: The environment name.
            sql: The SQL statement/query to execute.
        
        Returns:
            A list of MessageRecord objects representing the result of the SQL query.
        """
        endpoint = f"/api/v1/environments/{environment}/proxy/api/ws/v2/sql/execute"
        return await websocket_client._make_request(endpoint=endpoint, sql=sql)
  • Registers the SQL tools (including execute_sql) by calling register_sql(mcp) in the main MCP server setup.
    register_sql(mcp)
  • Imports the register_sql function used to register the execute_sql tool.
    from tools.sql import register_sql
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the API ('Lenses WebSocket API') but lacks critical behavioral details: whether this is read-only or can mutate data, authentication requirements, rate limits, or error handling. The description is minimal and doesn't compensate for the absence of annotations.

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

Conciseness5/5

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

The description is well-structured and concise, with three clear sections: purpose, parameters, and returns. Each sentence adds value without redundancy, and it's front-loaded with the core functionality.

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

Completeness3/5

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

Given the tool's complexity (executing SQL via an API) and no annotations, the description is incomplete—it lacks behavioral context and usage guidelines. However, the presence of an output schema (returns 'MessageRecord objects') mitigates some gaps by documenting return values, keeping it from being severely inadequate.

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

Parameters3/5

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

Schema description coverage is 0%, but the description's 'Args' section adds meaning by explaining 'environment' as 'The environment name' and 'sql' as 'The SQL statement/query to execute.' This clarifies semantics beyond the bare schema, though it doesn't detail format or constraints (e.g., SQL dialect, environment options).

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Executes SQL statements/queries using Lenses WebSocket API.' It specifies the verb ('executes') and resource ('SQL statements/queries'), though it doesn't explicitly differentiate from siblings like 'create_sql_processor' or 'get_sql_processor' which might involve SQL but serve different functions.

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. With siblings like 'create_sql_processor' or 'get_dataset', there's no indication of whether this is for ad-hoc queries, batch processing, or other contexts, leaving usage unclear.

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/lensesio/lenses-mcp'

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