A SQLite extension that integrates the Model Context Protocol (MCP) Rust SDK, enabling SQLite databases to connect to MCP servers and call their tools.
Download for your platform: macOS, Linux, Windows, Android, and iOS.
-- Load the extension
.load ./dist/mcp.dylib
-- Check version
SELECT mcp_version();
-- 0.1.0
-- Connect to an MCP server
SELECT mcp_connect('http://localhost:8000/mcp');
-- {"status": "connected", "transport": "streamable_http"}
-- List available tools
SELECT mcp_list_tools();
-- Returns JSON with tool schemas
-- Call a tool
SELECT mcp_call_tool('airbnb_search', '{"location": "Rome", "maxPrice": 100}');
-- Returns search results| Function | Description |
|---|---|
mcp_version() |
Returns extension version |
mcp_connect(url, [sse], [headers], [use_json_ext]) |
Connect to MCP server with optional custom headers and JSON extension mode |
mcp_list_tools() |
List available tools with schemas |
mcp_call_tool(name, args) |
Call a tool on the MCP server |
mcp_tools_table |
Virtual table that returns each tool as a row with structured columns |
mcp_call_tool_table |
Virtual table that extracts text results from tool calls |
See API.md for complete API documentation with examples.
- Rust: 1.85+ toolchain
- C Compiler: gcc or clang
- Make: GNU Make
# Clone the repository
git clone https://github.com/sqliteai/sqlite-mcp.git
cd sqlite-mcp
# Initialize submodules
git submodule update --init --recursive
# Build the extension
makeThe compiled extension will be in dist/mcp.{dylib,so,dll}.
The extension supports two MCP transport protocols:
Modern streaming HTTP transport for MCP servers.
SELECT mcp_connect('http://localhost:8000/mcp');Server-Sent Events for compatibility with older servers.
SELECT mcp_connect('http://localhost:8931/sse', 1);#include <sqlite3.h>
#include <stdio.h>
int main() {
sqlite3 *db;
sqlite3_open(":memory:", &db);
sqlite3_enable_load_extension(db, 1);
sqlite3_load_extension(db, "./dist/mcp", NULL, NULL);
sqlite3_stmt *stmt;
// Connect to MCP
sqlite3_prepare_v2(db,
"SELECT mcp_connect('http://localhost:8000/mcp')",
-1, &stmt, NULL);
sqlite3_step(stmt);
printf("Connected: %s\n", sqlite3_column_text(stmt, 0));
sqlite3_finalize(stmt);
// Call tool
sqlite3_prepare_v2(db,
"SELECT mcp_call_tool('airbnb_search', '{\"location\": \"NYC\"}')",
-1, &stmt, NULL);
if (sqlite3_step(stmt) == SQLITE_ROW) {
printf("Result: %s\n", sqlite3_column_text(stmt, 0));
}
sqlite3_finalize(stmt);
sqlite3_close(db);
return 0;
}See USAGE.md for complete usage examples.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - See LICENSE for details
- sqlite-agent - A powerful AI agent for SQLite
- sqlite-ai - LLM integration for SQLite
- sqlite-vector - Vector search extension
- sqlite-sync - Cloud synchronization
- sqlite-js - JavaScript engine integration