Skip to main content
Glama
OpenLinkSoftware

mcp-sqlalchemy

podbc_spasql_query

Execute SPASQL queries on databases via SQLAlchemy connectivity, enabling retrieval of structured results with customizable row limits and timeout settings.

Instructions

Execute a SPASQL query and return results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_rowsNo
queryYes
timeoutNo
urlNo

Implementation Reference

  • The main handler function for the 'podbc_spasql_query' tool, including the @mcp.tool decorator which also serves as registration. It connects to the database using pyodbc, executes a SPASQL query via a specific Virtuoso command, and returns the result.
    @mcp.tool(
        name="podbc_spasql_query",
        description="Execute a SPASQL query and return results."
    )
    def podbc_spasql_query(query: str, max_rows:Optional[int] = 20, timeout:Optional[int] = 300000,
                        user:Optional[str]=None, password:Optional[str]=None, dsn:Optional[str]=None) -> str:
        """
        Execute a SPASQL query and return results in JSONL format.
    
        Args:
            query (str): The SPASQL query to execute.
            max_rows (int): Maximum number of rows to return. Default is 100.
            timeout (int): Query timeout. Default is 30000ms.
            user (Optional[str]=None): Optional username.
            password (Optional[str]=None): Optional password.
            dsn (Optional[str]=None): Optional dsn name.
    
        Returns:
            str: Results in requested format as string.
        """
        try:
            with get_connection(True, user, password, dsn) as conn:
                cursor = conn.cursor()
                cmd = f"select Demo.demo.execute_spasql_query(charset_recode(?, '_WIDE_', 'UTF-8'), ?, ?) as result"
                rs = cursor.execute(cmd, (query, max_rows, timeout,)).fetchone()
                return rs[0]
        except pyodbc.Error as e:
            logging.error(f"Error executing query: {e}")
            raise
  • The tool function is exported in the package's __all__ list for easy import.
    "podbc_spasql_query",
  • The tool function is imported from server.py into the package namespace.
    podbc_spasql_query,
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 states the tool executes a query and returns results, but lacks critical behavioral details such as whether it's read-only or destructive, authentication requirements, rate limits, error handling, or what format results are returned in. This is inadequate for a tool with potential data access implications.

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 with no wasted words. It's appropriately sized for a basic tool description and front-loads the core functionality without unnecessary elaboration.

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 multiple sibling tools, the description is incomplete. It doesn't provide enough context about behavior, parameters, or usage differentiation to adequately guide an agent in selecting and invoking this tool correctly.

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%, so the description must compensate but adds no parameter information. It doesn't explain what 'query' should contain, what 'max_rows' limits, what 'timeout' controls, or what 'url' specifies. With 4 parameters (1 required) and no schema descriptions, this leaves significant gaps in understanding.

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 verb 'Execute' and the resource 'SPASQL query', specifying the action and target. It distinguishes from siblings like 'podbc_sparql_query' by specifying SPASQL rather than SPARQL, but doesn't fully differentiate from other query execution tools like 'podbc_execute_query' or 'podbc_query_database' beyond the query language type.

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?

No guidance is provided on when to use this tool versus alternatives. With multiple sibling tools for querying and execution (e.g., podbc_execute_query, podbc_sparql_query, podbc_query_database), the description lacks context about specific use cases, prerequisites, or comparisons to help an agent choose appropriately.

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