Skip to main content
Glama
isaacgounton

SQLite MCP Server

write_query

Execute SQL modification queries (INSERT, UPDATE, DELETE, REPLACE) and retrieve the number of affected rows.

Instructions

Execute a data modification query (INSERT, UPDATE, DELETE, REPLACE). Returns affected row count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe SQL modification query to execute

Implementation Reference

  • src/index.ts:210-220 (registration)
    Registration of the 'write_query' tool definition with name, description, and inputSchema.
    {
      name: 'write_query',
      description: 'Execute a data modification query (INSERT, UPDATE, DELETE, REPLACE). Returns affected row count.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          query: { type: 'string', description: 'The SQL modification query to execute' },
        },
        required: ['query'],
      },
    },
  • Handler for 'write_query' tool call: extracts query, validates it, runs it via db.run(), and returns affected row count.
    case 'write_query': {
      const { query } = toolArgs as { query: string };
      validateWriteQuery(query);
      const result = db.run(query);
      return {
        content: [{ type: 'text', text: JSON.stringify({ affected_rows: result.changes }, null, 2) }],
      };
    }
  • Validation helper function that checks the query starts with INSERT, UPDATE, DELETE, or REPLACE, and disallows multiple statements.
    function validateWriteQuery(query: string): void {
      const normalized = query.trim().toLowerCase();
      const allowed = ['insert', 'update', 'delete', 'replace'];
      if (!allowed.some(prefix => normalized.startsWith(prefix))) {
        throw new McpError(ErrorCode.InvalidParams, 'Only INSERT, UPDATE, DELETE, and REPLACE queries are allowed for write_query');
      }
      if (queryHasMultipleStatements(query)) {
        throw new McpError(ErrorCode.InvalidParams, 'Multiple statements are not allowed');
      }
    }
Behavior2/5

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

With no annotations, the description only mentions supported query types and return value. It omits important behavioral details such as error handling, transaction behavior, or permission requirements, which are critical for a write operation.

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 two sentences, entirely front-loaded with the core purpose and return value. Every word earns its place with no redundancy.

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?

Given the low complexity (one parameter, no output schema), the description is mostly complete. However, it lacks details on error states and data safety, which would be valuable for a mutation tool.

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?

There is one parameter 'query' with 100% schema coverage. The description does not add meaning beyond the schema's 'The SQL modification query to execute'. Baseline score is appropriate.

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 the action (execute), the types of queries (INSERT, UPDATE, DELETE, REPLACE), and the return value (affected row count). It effectively distinguishes from sibling tools like read_query.

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 use for data modification queries but does not explicitly state when to use this tool versus alternatives like read_query or schema tools. No exclusions or scenarios are given.

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/isaacgounton/sqlite-mcp-server'

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