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 });

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