Skip to main content
Glama
sam2332

SQLite MCP Server

by sam2332

execute_query

Run SQL queries (INSERT, UPDATE, DELETE) on SQLite databases using the MCP Server to manage and manipulate data efficiently.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSQL query to execute

Implementation Reference

  • Implements the core logic for executing any SQL query (INSERT, UPDATE, DELETE, etc.) on the connected SQLite database using better-sqlite3's prepare().run(), returning 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)}`); } }
  • Defines the tool metadata including name, description, and input schema for 'execute_query', which requires a single 'query' string parameter.
    { 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)
    In the CallToolRequest handler's switch statement, routes calls to the 'execute_query' tool to the executeQuery method.
    case "execute_query": return await this.executeQuery(args as { query: string });

Other Tools

Related 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