cli/manuals/mcp.md
Turso includes a built-in MCP (Model Context Protocol) server that allows AI assistants and other tools to interact with your databases programmatically.
To start Turso in MCP server mode, use the --mcp flag:
/path/to/tursodb --mcp
This will start an MCP server that listens on stdio for commands. The server starts without a database connection, allowing you to select or create databases using MCP commands.
The MCP server exposes the following tools:
queryExecute a SQL query and get results.
Parameters:
sql (string, required): The SQL query to executeExample:
{
"tool": "query",
"arguments": {
"sql": "SELECT * FROM users WHERE age > 21"
}
}
executeExecute a SQL statement that modifies data (INSERT, UPDATE, DELETE).
Parameters:
sql (string, required): The SQL statement to executeExample:
{
"tool": "execute",
"arguments": {
"sql": "INSERT INTO users (name, age) VALUES ('Alice', 30)"
}
}
list_tablesList all tables in the database.
Example:
{
"tool": "list_tables",
"arguments": {}
}
describe_tableGet the schema of a specific table.
Parameters:
table (string, required): The name of the table to describeExample:
{
"tool": "describe_table",
"arguments": {
"table": "users"
}
}
To use with Claude Desktop, add the following to your Claude Desktop configuration:
{
"mcpServers": {
"turso": {
"command": "/path/to/tursodb",
"args": ["--mcp"]
}
}
}
Note: You must use the full path to the tursodb executable as Claude Desktop may not recognize items in your PATH.
The Turso MCP server follows the standard MCP protocol and can be used with any MCP-compatible client.
Here's an example of using the MCP server:
Start the server:
/path/to/tursodb --mcp
Query data:
> What tables are in the database?
[Uses list_tables tool]
> Show me all users older than 25
[Uses query tool with "SELECT * FROM users WHERE age > 25"]
Modify data:
> Add a new user named Bob who is 28 years old
[Uses execute tool with INSERT statement]