Skip to main content
Glama
OpenLinkSoftware

mcp-sqlalchemy

podbc_execute_query_md

Run SQL queries and retrieve results formatted as Markdown tables using SQLAlchemy connectivity, enabling easy integration with any DBMS.

Instructions

Execute a SQL query and return results in Markdown table format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_rowsNo
paramsNo
queryYes
urlNo

Implementation Reference

  • The @mcp.tool decorator registers the tool, and the function podbc_execute_query_md implements the logic: connects to DB via pyodbc, executes the query, truncates long values, formats results as Markdown table, limits to max_rows.
    @mcp.tool(
        name="podbc_execute_query_md",
        description="Execute a SQL query and return results in Markdown table format."
    )
    def podbc_execute_query_md(query: str, max_rows: int = 100, params: Optional[Dict[str, Any]] = None, 
                         user:Optional[str]=None, password:Optional[str]=None, dsn:Optional[str]=None) -> str:
        """
        Execute a SQL query and return results in Markdown table format.
    
        Args:
            query (str): The SQL query to execute.
            max_rows (int): Maximum number of rows to return. Default is 100.
            params (Optional[Dict[str, Any]]): Optional dictionary of parameters to pass to the query.
            user (Optional[str]=None): Optional username.
            password (Optional[str]=None): Optional password.
            dsn (Optional[str]=None): Optional dsn name.
    
        Returns:
            str: Results in Markdown table format.
        """
        try:
            with get_connection(True, user, password, dsn) as conn:
                cursor = conn.cursor()
                rs = cursor.execute(query) if params is None else cursor.execute(query, params)
                columns = [column[0] for column in rs.description]            
                results = []
                for row in rs:
                    rs_dict = dict(zip(columns, row))
                    truncated_row = {key: (str(value)[:MAX_LONG_DATA] if value is not None else None) for key, value in rs_dict.items()}
                    results.append(truncated_row)                
                    if len(results) >= max_rows:
                        break
                    
                # Create the Markdown table header
                md_table = "| " + " | ".join(columns) + " |\n"
                md_table += "| " + " | ".join(["---"] * len(columns)) + " |\n"
    
                # Add rows to the Markdown table
                for row in results:
                    md_table += "| " + " | ".join(str(row[col]) for col in columns) + " |\n"
    
                # Return the Markdown formatted results
                return md_table
    
        except pyodbc.Error as e:
            logging.error(f"Error executing query: {e}")
            raise
  • The tool is registered with FastMCP using the @mcp.tool decorator specifying the name.
    name="podbc_execute_query_md",
  • Input schema defined by function parameters with type hints: query (str, required), max_rows (int=100), params (Optional[Dict]), user/password/dsn optional.
    def podbc_execute_query_md(query: str, max_rows: int = 100, params: Optional[Dict[str, Any]] = None, 
                         user:Optional[str]=None, password:Optional[str]=None, dsn:Optional[str]=None) -> str:
Behavior2/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 mentions execution and output format, but lacks critical behavioral details: it doesn't specify if this is read-only or mutating, potential risks (e.g., data modification), authentication needs, rate limits, or error handling. For a tool with 4 parameters and no annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence that front-loads the core functionality ('Execute a SQL query') and adds value with the output detail ('in Markdown table format'). There is no wasted wording, making it appropriately sized for its purpose.

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

Completeness2/5

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

Given 4 parameters with 0% schema coverage, no annotations, no output schema, and sibling tools with similar names, the description is incomplete. It doesn't explain parameters, behavioral traits, or differentiate from alternatives, making it inadequate for a tool of this complexity. The output format is mentioned, but other critical context is missing.

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

Parameters2/5

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

Schema description coverage is 0%, meaning none of the 4 parameters have descriptions in the schema. The tool description adds no information about parameters like 'query', 'max_rows', 'params', or 'url', failing to compensate for the coverage gap. This leaves parameters largely unexplained beyond their titles and types.

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 action ('Execute a SQL query') and the output format ('return results in Markdown table format'), which distinguishes it from siblings like 'podbc_execute_query' that likely return different formats. However, it doesn't explicitly mention what resource it acts on (e.g., a database), making it slightly less specific than a perfect score.

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

Usage Guidelines3/5

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

The description implies usage for SQL queries needing Markdown output, but provides no explicit guidance on when to use this vs. alternatives like 'podbc_execute_query' or other query tools. There's no mention of prerequisites, limitations, or specific scenarios favoring this tool, leaving usage context inferred rather than stated.

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

Related 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/OpenLinkSoftware/mcp-sqlalchemy-server'

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