Skip to main content
Glama
penguinszp001

mcp-server-demo

query_db

Execute read-only SELECT queries against a local SQLite database to retrieve data.

Instructions

Run a read-only SELECT query against local SQLite demo.db.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sqlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `query_db` tool handler function. It accepts a SQL string, validates it starts with SELECT (read-only), executes it against a local SQLite database, and returns results as JSON. Decorated with @mcp.tool() which registers it as an MCP tool.
    @mcp.tool()
    def query_db(sql: str) -> str:
        """Run a read-only SELECT query against local SQLite demo.db."""
        normalized = sql.strip().lower().rstrip(";")
        if not normalized.startswith("select"):
            raise ValueError("Only SELECT queries are allowed for this demo.")
    
        with _db_connection() as conn:
            rows = conn.execute(sql).fetchall()
        return json.dumps([dict(r) for r in rows], indent=2)
  • server.py:99-99 (registration)
    The @mcp.tool() decorator on line 99 registers the `query_db` function as an MCP tool with the FastMCP server instance.
    @mcp.tool()
  • The `_db_connection()` helper function used by query_db to get a SQLite connection with row_factory set to sqlite3.Row.
    def _db_connection() -> sqlite3.Connection:
        conn = sqlite3.connect(DB_PATH)
        conn.row_factory = sqlite3.Row
        return conn
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses read-only behavior and the SQL query nature. It does not detail error handling or query restrictions, but the core behavioral trait is clear.

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?

A single concise sentence that directly states the tool's function with no unnecessary words or fluff.

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?

While the description covers the basic purpose and the output schema exists, it lacks details on SQL restrictions, parameter specifics, and usage context. Adequate for a simple tool but gaps remain.

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%. The description does not explain the 'sql' parameter beyond the schema's type string. It fails to specify valid SQL syntax, allowed statements, or constraints like single-statement limitation.

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 clearly states it runs a read-only SELECT query against a specific local SQLite database, distinguishing it from sibling tools focused on file operations, weather, or image analysis.

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

Usage Guidelines4/5

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

The description explicitly mentions 'read-only SELECT query', implying it should not be used for writes. However, it does not provide explicit when-to-use or when-not-to-use guidance relative to alternatives, though siblings are unrelated.

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/penguinszp001/mcp-server-demo'

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