Skip to main content
Glama
sam2332

SQLite MCP Server

by sam2332

execute_query

Execute SQL queries (INSERT, UPDATE, DELETE) to interact with SQLite databases, enabling data manipulation and management operations.

Instructions

Execute any SQL query (INSERT, UPDATE, DELETE, etc.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSQL query to execute

Implementation Reference

  • The main handler function that executes the provided SQL query using better-sqlite3's .run() method and returns the number of changes and last insert row ID.
    private async executeQuery(args: { query: string }): Promise<CallToolResult> {
      if (!this.db) {
        throw new Error("No database connected. Use connect_database first.");
      }
    
      try {
        const result = this.db.prepare(args.query).run();
        
        return {
          content: [
            {
              type: "text",
              text: `Query executed successfully. Changes: ${result.changes}, Last insert row ID: ${result.lastInsertRowid}`,
            } satisfies TextContent,
          ],
        };
      } catch (error) {
        throw new Error(`Query execution failed: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Input schema definition for the execute_query tool, specifying an object with a required 'query' string property.
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "SQL query to execute",
        },
      },
      required: ["query"],
    },
  • src/index.ts:119-132 (registration)
    Tool registration in the listTools response, defining name, description, and input schema.
    {
      name: "execute_query",
      description: "Execute any SQL query (INSERT, UPDATE, DELETE, etc.)",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "SQL query to execute",
          },
        },
        required: ["query"],
      },
    },
  • src/index.ts:174-175 (registration)
    Dispatch case in the CallToolRequest handler that routes calls to execute_query to the executeQuery method.
    case "execute_query":
      return await this.executeQuery(args as { query: string });
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool executes queries but doesn't mention critical behaviors: whether it requires authentication, what permissions are needed, if it's destructive (given it handles DELETE), what happens on errors, or what the return format is. For a mutation tool with zero annotation coverage, this leaves significant gaps.

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 extremely concise (one sentence) and front-loaded with the core purpose. Every word earns its place by specifying the action and scope, with no redundant information. It efficiently communicates the essential function 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 this is a mutation tool (handling INSERT, UPDATE, DELETE) with no annotations and no output schema, the description is incomplete. It doesn't address safety concerns, authentication needs, error handling, or return values. For a tool that can modify data, this level of documentation is inadequate and could lead to misuse.

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%, with the single parameter 'query' fully documented in the schema. The description adds no additional parameter semantics beyond implying the query can include various SQL operations. Baseline 3 is appropriate since the schema does the heavy lifting, though the description doesn't compensate with extra details like syntax examples.

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') and resource ('SQL query') with specific examples of query types (INSERT, UPDATE, DELETE). It distinguishes from siblings like 'query_data' by emphasizing 'any SQL query' rather than just data retrieval. However, it doesn't explicitly differentiate from all siblings like 'describe_table' or 'list_tables'.

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?

The description provides no guidance on when to use this tool versus alternatives like 'query_data' (which likely handles SELECT queries) or other siblings. It mentions 'any SQL query' but doesn't specify when to choose this over more specialized tools, nor does it mention prerequisites like needing a database connection first.

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/sam2332/mcp-quick-sqlite3'

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