Skip to main content
Glama
sql.py1.47 kB
from typing import Any, Dict, List from clients.websocket_client import websocket_client from fastmcp import FastMCP """ Registers all SQL-related operations (such as SQL execution) with the MCP server. """ def register_sql(mcp: FastMCP): @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) # ======= # PROMPTS # ======= @mcp.prompt() def generate_sql_query_for_task(task: str) -> str: """Write a Lenses SQL query to achieve a task""" return f""" Task: {task} Please write a SQL query that accomplishes this task efficiently. Use these specific guidelines in addition to SQL best practices for performance: 1. Use JOINs (INNER, LEFT) based on the data relationships where appropriate 2. Use WHERE clauses to reduce the number of records where possible 3. Use indentation to format the query for readability """

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

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