Skip to main content
Glama

query_database

Run SQL against a Neverwinter Nights SQLite database to inspect or modify campaign data, returning rows for SELECT/PRAGMA or change summaries for INSERT/UPDATE/DELETE.

Instructions

Run a SQL statement against a NWN SQLite database. Returns rows for SELECT/PRAGMA, or change summary for INSERT/UPDATE/DELETE. Database name can omit the .sqlite3 extension. The main table is 'db' with columns: varname (varchar), playerid (varchar), vartype (tinyint), payload (blob), compressed (bool). vartype codes (ASCII char): 70='F' float, 73='I' int, 74='J' json (SetCampaignJson), 76='L' location (areaId@x:y;z!facing), 79='O' object (StoreCampaignObject, GFF JSON), 83='S' string, 86='V' vector. F/I/L/V are uncompressed ASCII. J/O/S are CPDB/zstd compressed. Compressed rows use CPDB/zstd format — use read_database_object to deserialize blobs.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "database": "<database>",
      "sql": "<sql>"
    },
    "name": "query_database"
  }
}

Input Schema

NameRequiredDescriptionDefault
sqlYesSQL statement to execute. Use PRAGMA table_info(tablename) to inspect schema.
limitNoMax rows to return for SELECT queries (default 500)
paramsNoJSON array of bind parameters (e.g. '["value1", 42]')
databaseYesDatabase filename (e.g. 'mymodule' or 'mymodule.sqlite3')

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.1

TDQS

A4.1/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does reasonably well: it discloses the two execution modes and their different return shapes, that the database name may omit the .sqlite3 extension, and that certain payloads are CPDB/zstd compressed rather than plain text. It omits write safety (irreversibility, transactions, permissions), which is a real gap for a tool that accepts INSERT/UPDATE/DELETE.

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

Conciseness4/5

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

Front-loaded with the core action and return behavior, then the data-model reference material in a compact, scannable enumeration. The vartype code list is long but dense with actionable detail and is placed after the essentials, so nothing blocks the agent's primary decision.

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

Completeness4/5

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

There is no output schema, and the description compensates by explaining what SELECT/PRAGMA versus mutation statements return, plus how to interpret payload columns. Combined with the table schema and vartype decoding, an agent has enough to query correctly; missing write-safety semantics is the main residual gap for a tool this powerful.

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 100%, so all four parameters are already documented, including the bind-parameter JSON format and the default limit of 500. The description adds only the extension-omission note for 'database', which the schema already implies, and otherwise contributes data-model context rather than parameter meaning. Baseline 3 applies.

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?

States a specific verb and resource ('Run a SQL statement against a NWN SQLite database') and immediately distinguishes read vs. write outcomes ('Returns rows for SELECT/PRAGMA, or change summary for INSERT/UPDATE/DELETE'). The agent can tell this is the raw-SQL escape hatch, distinct from sibling object-level tools like read_database_object and write_database_object.

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?

Gives clear routing advice for compressed blob payloads ('use read_database_object to deserialize blobs') and the schema advises PRAGMA table_info for schema inspection. It does not explicitly say when to prefer write_database_object or read_database_object over raw SQL, so a little inference is required, but the context for use is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools