{"_id":"mcp-server-sqlite","_rev":"2-c2685fe7beec6f37f0c9d5f4baf27389","name":"mcp-server-sqlite","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"mcp-server-sqlite","version":"0.0.1","keywords":["mcp","sqlite","database","model-context-protocol"],"author":{"name":"MaDnh"},"license":"MIT","_id":"mcp-server-sqlite@0.0.1","maintainers":[{"name":"madnh","email":"dodanhmanh@gmail.com"}],"homepage":"https://github.com/madnh/mcp-server-sqlite#readme","bugs":{"url":"https://github.com/madnh/mcp-server-sqlite/issues"},"bin":{"mcp-server-sqlite":"dist/cli.js"},"dist":{"shasum":"97812e41c5980c2e7ca7049e303aff7fa8c9a722","tarball":"https://registry.npmjs.org/mcp-server-sqlite/-/mcp-server-sqlite-0.0.1.tgz","fileCount":13,"integrity":"sha512-lFYX7oU0GAADilZvYHZXMTfcoVgeG5M1sn1nwNyNX98g34HuOB6bwQkoa7x5wXbTjyKEnDWN9xRZ26QtMIRvEA==","signatures":[{"sig":"MEUCIDNgXvQvPfJ/27h4HCSVk7My2U2Q05+Nvg+mKzHKbUx2AiEA/wL1Ct4cQSBRQozkSN+AyKjH0Qtr742KUV5RjkWuViQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":76799},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"gitHead":"25e09351e661228e7d4b932bdf5921e0842b53d2","scripts":{"dev":"tsx src/index.ts","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","start":"node dist/index.js","stdio":"tsx src/index.ts","postpack":"echo \"Package created successfully!\"","prepublishOnly":"npm run build"},"_npmUser":{"name":"madnh","email":"dodanhmanh@gmail.com"},"repository":{"url":"git+https://github.com/madnh/mcp-server-sqlite.git","type":"git"},"_npmVersion":"10.9.2","description":"Model Context Protocol (MCP) server for SQLite database operations","directories":{},"_nodeVersion":"22.15.1","dependencies":{"zod":"^3.25.76","better-sqlite3":"^12.4.1","@modelcontextprotocol/sdk":"^1.18.2"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.6","typescript":"^5.9.2","@types/node":"^24.5.2","@types/better-sqlite3":"^7.6.13"},"_npmOperationalInternal":{"tmp":"tmp/mcp-server-sqlite_0.0.1_1759023425956_0.9928660108822409","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"mcp-server-sqlite","version":"0.0.2","main":"dist/index.js","type":"module","scripts":{"build":"tsc","start":"node dist/index.js","dev":"tsx src/index.ts","stdio":"tsx src/index.ts","test":"echo \"Error: no test specified\" && exit 1","prepublishOnly":"npm run build","postpack":"echo \"Package created successfully!\""},"bin":{"mcp-server-sqlite":"dist/cli.js"},"author":{"name":"MaDnh"},"homepage":"https://github.com/madnh/mcp-server-sqlite#readme","repository":{"type":"git","url":"git+https://github.com/madnh/mcp-server-sqlite.git"},"bugs":{"url":"https://github.com/madnh/mcp-server-sqlite/issues"},"license":"MIT","engines":{"node":">=18.0.0"},"description":"Model Context Protocol (MCP) server for SQLite database operations","keywords":["mcp","sqlite","database","model-context-protocol"],"dependencies":{"@modelcontextprotocol/sdk":"^1.18.2","better-sqlite3":"^12.4.1","zod":"^3.25.76"},"devDependencies":{"@types/better-sqlite3":"^7.6.13","@types/node":"^24.5.2","tsx":"^4.20.6","typescript":"^5.9.2"},"_id":"mcp-server-sqlite@0.0.2","gitHead":"cf54d19d3d53b852001f222250e677a0abc99294","types":"./dist/index.d.ts","_nodeVersion":"22.15.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-ZuHdaOxNNJUWUhhE7lt1hBFM0UcUoViuRFXAqe74C08ONsiM/xlqzX8NdPmmPhpjtGo2jfU+fGtxM3iH1RVUAA==","shasum":"05570237c60a240dcc5feb799c2e9c8e791850c1","tarball":"https://registry.npmjs.org/mcp-server-sqlite/-/mcp-server-sqlite-0.0.2.tgz","fileCount":13,"unpackedSize":77371,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDnrGfnHv8pYLNFvxzazDV2ozMufpSeQ7/88JApyy7zEQIgb5dqyqbetl1xBLrlDfKc0Nz6VSDViyJEhHSpd6CHB7Y="}]},"_npmUser":{"name":"madnh","email":"dodanhmanh@gmail.com"},"directories":{},"maintainers":[{"name":"madnh","email":"dodanhmanh@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mcp-server-sqlite_0.0.2_1759024678793_0.2469048740590556"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-28T01:37:05.955Z","modified":"2025-09-28T01:57:59.252Z","0.0.1":"2025-09-28T01:37:06.150Z","0.0.2":"2025-09-28T01:57:59.067Z"},"bugs":{"url":"https://github.com/madnh/mcp-server-sqlite/issues"},"author":{"name":"MaDnh"},"license":"MIT","homepage":"https://github.com/madnh/mcp-server-sqlite#readme","keywords":["mcp","sqlite","database","model-context-protocol"],"repository":{"type":"git","url":"git+https://github.com/madnh/mcp-server-sqlite.git"},"description":"Model Context Protocol (MCP) server for SQLite database operations","maintainers":[{"name":"madnh","email":"dodanhmanh@gmail.com"}],"readme":"# SQLite MCP Server\n\nA comprehensive Model Context Protocol (MCP) server for SQLite database operations. This server enables AI assistants to interact with SQLite databases through a standardized interface, providing safe and efficient database operations.\n\n## Features\n\n### 🔍 **Resources**\n\n- **Database Schema**: View complete database schema with all tables and structures\n- **Tables List**: Get a list of all tables in the database\n- **Table Info**: Detailed information about specific tables including columns, indexes, and foreign keys\n\n### 🛠️ **Tools**\n\n- **query**: Execute read-only SQL queries (SELECT statements)\n- **execute**: Execute write operations (INSERT, UPDATE, DELETE, CREATE, DROP)\n- **create-table**: Create new tables with column definitions and constraints\n- **drop-table**: Remove tables from the database\n- **describe-table**: Get detailed table structure information\n- **list-tables**: List all tables in the database\n- **insert-record**: Insert new records with data validation\n- **update-record**: Update existing records with WHERE conditions\n- **delete-record**: Delete records with WHERE conditions\n- **transaction**: Execute multiple SQL statements atomically\n\n### 💬 **Prompts**\n\n- **analyze-schema**: Generate comprehensive database schema analysis\n- **generate-query**: Help create SQL queries based on natural language requirements\n- **optimize-query**: Get optimization suggestions for existing SQL queries\n\n## Installation\n\n### Option 1: Install from npm (Recommended)\n\nInstall globally:\n\n```bash\nnpm install -g mcp-server-sqlite\n```\n\nOr use with npx (no installation required):\n\n```bash\nnpx mcp-server-sqlite --help\n```\n\n### Option 2: Local Development with npm link\n\nFor local development and testing:\n\n1. Clone this repository:\n\n```bash\ngit clone https://github.com/madnh/mcp-server-sqlite.git\ncd mcp-server-sqlite\n```\n\n2. Install dependencies and build:\n\n```bash\nnpm install\nnpm run build\n```\n\n3. Link globally for development:\n\n```bash\nnpm link\n```\n\n4. Now you can use the command globally:\n\n```bash\nmcp-server-sqlite --db ./database.db\nmcp-server-sqlite --help\n```\n\n5. To unlink when done developing:\n\n```bash\nnpm unlink -g mcp-server-sqlite\n```\n\n### Option 3: From Source (Development Mode)\n\n1. Follow steps 1-2 from Option 2\n2. Run directly with:\n\n```bash\nnpm run dev                    # Development mode\nnpm run build && npm start     # Production mode\n```\n\n## Usage\n\n### Basic Usage\n\n#### Via npm/npx (Recommended)\n\n```bash\n# Basic usage (creates database.db if not exists)\nnpx mcp-server-sqlite\n\n# Specify database path\nnpx mcp-server-sqlite --db ./my-database.db\n\n# Using long form\nnpx mcp-server-sqlite --database /path/to/production.db\n\n# Get help\nnpx mcp-server-sqlite --help\n\n# Check version\nnpx mcp-server-sqlite --version\n```\n\n#### Via environment variable\n\n```bash\nexport SQLITE_DB_PATH=./my-database.db\nnpx mcp-server-sqlite\n```\n\n#### Development mode (from source)\n\n```bash\nnpm run dev\n```\n\n#### Production mode (from source)\n\n```bash\nnpm run build\nnpm start\n```\n\n### Environment Configuration\n\nCreate a `.env` file based on `.env.example`:\n\n```bash\ncp .env.example .env\n```\n\nConfigure your database path:\n\n```\nSQLITE_DB_PATH=./your-database.db\n```\n\n### Example Database Setup\n\nCreate a sample database with test data:\n\n```bash\nnode examples/setup-database.js\n```\n\nThis creates `example.db` with sample tables and data for testing.\n\n### With Claude Desktop\n\n#### Option 1: Using npx (Recommended)\n\nAdd to your Claude Desktop configuration (`claude_desktop_config.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"sqlite\": {\n      \"command\": \"npx\",\n      \"args\": [\"mcp-server-sqlite\", \"--db\", \"/path/to/your/database.db\"]\n    }\n  }\n}\n```\n\n#### Option 2: Using global installation\n\nIf you installed globally with `npm install -g mcp-server-sqlite`:\n\n```json\n{\n  \"mcpServers\": {\n    \"sqlite\": {\n      \"command\": \"mcp-server-sqlite\",\n      \"args\": [\"--database\", \"/path/to/your/database.db\"]\n    }\n  }\n}\n```\n\n#### Option 3: Using environment variables\n\n```json\n{\n  \"mcpServers\": {\n    \"sqlite\": {\n      \"command\": \"npx\",\n      \"args\": [\"mcp-server-sqlite\"],\n      \"env\": {\n        \"SQLITE_DB_PATH\": \"/path/to/your/database.db\"\n      }\n    }\n  }\n}\n```\n\n#### Option 4: From source (development)\n\n```json\n{\n  \"mcpServers\": {\n    \"sqlite\": {\n      \"command\": \"node\",\n      \"args\": [\"/path/to/mcp-server-sqlite/dist/cli.js\"],\n      \"env\": {\n        \"SQLITE_DB_PATH\": \"/path/to/your/database.db\"\n      }\n    }\n  }\n}\n```\n\n## API Reference\n\n### Resources\n\n#### `schema://database`\n\nReturns the complete database schema including all tables and their SQL definitions.\n\n#### `tables://list`\n\nReturns a JSON list of all table names in the database.\n\n#### `table-info://{tableName}`\n\nReturns detailed information about a specific table including:\n\n- Column definitions\n- Indexes\n- Foreign key constraints\n\n### Tools\n\n#### `query`\n\nExecute read-only SQL queries.\n\n```typescript\n{\n  sql: string; // SELECT query to execute\n}\n```\n\n#### `execute`\n\nExecute write operations.\n\n```typescript\n{\n  sql: string; // INSERT, UPDATE, DELETE, CREATE, or DROP statement\n}\n```\n\n#### `create-table`\n\nCreate a new table with structured column definitions.\n\n```typescript\n{\n  name: string,\n  columns: Array<{\n    name: string,\n    type: string, // TEXT, INTEGER, REAL, BLOB\n    primaryKey?: boolean,\n    notNull?: boolean,\n    unique?: boolean,\n    defaultValue?: string\n  }>,\n  ifNotExists?: boolean\n}\n```\n\n#### `insert-record`\n\nInsert a new record into a table.\n\n```typescript\n{\n  table: string,\n  data: Record<string, any> // Column-value pairs\n}\n```\n\n#### `update-record`\n\nUpdate existing records.\n\n```typescript\n{\n  table: string,\n  data: Record<string, any>, // Column-value pairs to update\n  where: string // WHERE clause\n}\n```\n\n#### `delete-record`\n\nDelete records from a table.\n\n```typescript\n{\n  table: string,\n  where: string // WHERE clause\n}\n```\n\n#### `transaction`\n\nExecute multiple statements atomically.\n\n```typescript\n{\n  statements: string[] // Array of SQL statements\n}\n```\n\n### Prompts\n\n#### `analyze-schema`\n\nGenerate comprehensive database analysis.\n\n```typescript\n{\n  includeData?: boolean // Include sample data in analysis\n}\n```\n\n#### `generate-query`\n\nGenerate SQL queries from natural language requirements.\n\n```typescript\n{\n  requirement: string, // What you want to query\n  tables?: string[] // Specific tables to focus on\n}\n```\n\n#### `optimize-query`\n\nGet query optimization suggestions.\n\n```typescript\n{\n  query: string, // SQL query to optimize\n  executionContext?: string // Additional context\n}\n```\n\n## Database Features\n\n### Safety & Security\n\n- **SQL Injection Protection**: Uses parameterized queries\n- **Query Validation**: Validates SQL statements before execution\n- **Read/Write Separation**: Separate tools for read-only vs write operations\n- **Transaction Support**: Atomic execution of multiple statements\n\n### Performance Optimizations\n\n- **Connection Pooling**: Efficient database connection management\n- **WAL Mode**: Write-Ahead Logging for better performance\n- **Prepared Statements**: Cached and optimized query execution\n- **Memory Optimization**: Configured for optimal memory usage\n\n### Supported SQLite Features\n\n- All standard SQL data types (TEXT, INTEGER, REAL, BLOB)\n- Primary keys, foreign keys, unique constraints\n- Indexes and query optimization\n- Views and complex queries\n- Transactions and ACID compliance\n- PRAGMA statements for configuration\n\n## Examples\n\n### Query Data\n\n```sql\nSELECT u.username, COUNT(o.id) as order_count, SUM(o.total_amount) as total_spent\nFROM users u\nLEFT JOIN orders o ON u.id = o.user_id\nGROUP BY u.id, u.username\nORDER BY total_spent DESC;\n```\n\n### Create Table\n\n```typescript\n{\n  \"name\": \"customers\",\n  \"columns\": [\n    {\"name\": \"id\", \"type\": \"INTEGER\", \"primaryKey\": true},\n    {\"name\": \"name\", \"type\": \"TEXT\", \"notNull\": true},\n    {\"name\": \"email\", \"type\": \"TEXT\", \"unique\": true},\n    {\"name\": \"created_at\", \"type\": \"DATETIME\", \"defaultValue\": \"CURRENT_TIMESTAMP\"}\n  ]\n}\n```\n\n### Insert Record\n\n```typescript\n{\n  \"table\": \"customers\",\n  \"data\": {\n    \"name\": \"John Doe\",\n    \"email\": \"john@example.com\"\n  }\n}\n```\n\n### Transaction\n\n```typescript\n{\n  \"statements\": [\n    \"BEGIN TRANSACTION\",\n    \"INSERT INTO orders (user_id, total_amount) VALUES (1, 99.99)\",\n    \"INSERT INTO order_items (order_id, product_id, quantity, price) VALUES (last_insert_rowid(), 1, 2, 49.99)\",\n    \"UPDATE products SET stock_quantity = stock_quantity - 2 WHERE id = 1\",\n    \"COMMIT\"\n  ]\n}\n```\n\n## Development\n\n### Local Development with npm link\n\nThe recommended way to develop and test locally:\n\n```bash\n# Setup for development\nnpm install\nnpm run build\nnpm link\n\n# Now test your changes globally\nmcp-server-sqlite --db ./example.db\n\n# After making changes, rebuild and test\nnpm run build\nmcp-server-sqlite --version\n\n# Clean up when done\nnpm unlink -g mcp-server-sqlite\n```\n\n### Scripts\n\n- `npm run build`: Build TypeScript to JavaScript\n- `npm run dev`: Run in development mode with auto-reload\n- `npm start`: Run the compiled server\n- `npm run stdio`: Run server with stdio transport\n- `npm link`: Link package globally for development testing\n- `npm pack --dry-run`: Preview what will be published\n\n### Project Structure\n\n```\nmcp-server-sqlite/\n├── src/\n│   └── index.ts          # Main server implementation\n├── examples/\n│   ├── sample-data.sql   # Sample database schema and data\n│   └── setup-database.js # Database setup script\n├── dist/                 # Compiled JavaScript (after build)\n├── package.json\n├── tsconfig.json\n├── README.md\n└── .env.example\n```\n\n## Error Handling\n\nThe server provides comprehensive error handling:\n\n- **SQL Syntax Errors**: Clear error messages for malformed queries\n- **Constraint Violations**: Detailed information about constraint failures\n- **Connection Issues**: Graceful handling of database connection problems\n- **Permission Errors**: Safe handling of unauthorized operations\n\n## Limitations\n\n- **File System Access**: Server can only access databases in allowed paths\n- **Resource Limits**: Large result sets may be truncated for performance\n- **Concurrent Access**: Uses SQLite's built-in locking mechanisms\n- **Schema Changes**: Some DDL operations may require server restart\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Make your changes\n4. Add tests if applicable\n5. Submit a pull request\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Support\n\nFor issues and questions:\n\n- Check the examples/ directory for usage patterns\n- Review the SQLite documentation for SQL syntax\n- Open an issue on the project repository\n","readmeFilename":"README.md"}