Files
turso/cli/manuals/mcp.md
Glauber Costa fbc3d0dbc3 Add built-in manual pages for Turso
In the hopes of doing a good job at teaching people what Turso can do,
I am adding built-in manual pages. When the CLI starts, it picks a
feature at random, and tells the user that the feature exists:

```
Turso v0.2.0-pre.8
Enter ".help" for usage hints.
Did you know that Turso supports Change Data Capture? Type .manual cdc to learn more.
This software is ALPHA, only use for development, testing, and experimentation.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
```

There is a lot we can do to make this feature world class:
- we can automatically compile examples during compile time like
  rust-doc, to make sure examples used in the manuals always work
- we can implement scrolling and navigation
- we can document a lot more features

But for now, this is a start!
2025-09-24 11:29:24 -03:00

2.8 KiB

display_name
display_name
a built-in MCP server

MCP Server - Model Context Protocol

Overview

Turso includes a built-in MCP (Model Context Protocol) server that allows AI assistants and other tools to interact with your databases programmatically.

Starting the MCP Server

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.

Available Tools

The MCP server exposes the following tools:

query

Execute a SQL query and get results.

Parameters:

  • sql (string, required): The SQL query to execute

Example:

{
  "tool": "query",
  "arguments": {
    "sql": "SELECT * FROM users WHERE age > 21"
  }
}

execute

Execute a SQL statement that modifies data (INSERT, UPDATE, DELETE).

Parameters:

  • sql (string, required): The SQL statement to execute

Example:

{
  "tool": "execute",
  "arguments": {
    "sql": "INSERT INTO users (name, age) VALUES ('Alice', 30)"
  }
}

list_tables

List all tables in the database.

Example:

{
  "tool": "list_tables",
  "arguments": {}
}

describe_table

Get the schema of a specific table.

Parameters:

  • table (string, required): The name of the table to describe

Example:

{
  "tool": "describe_table",
  "arguments": {
    "table": "users"
  }
}

Integration with AI Assistants

Claude Desktop

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.

Other MCP Clients

The Turso MCP server follows the standard MCP protocol and can be used with any MCP-compatible client.

Example Session

Here's an example of using the MCP server:

  1. Start the server:

    /path/to/tursodb --mcp
    
  2. 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"]
    
  3. Modify data:

    > Add a new user named Bob who is 28 years old
    [Uses execute tool with INSERT statement]
    

Troubleshooting

Server doesn't start

  • Ensure the tursodb executable path is correct
  • Check that you're using the full path to the executable

Commands fail

  • Verify SQL syntax is correct
  • Check that tables and columns exist
  • Ensure you have write permissions if modifying data

See Also