mcp-turso

MCP.Pizza Chef: nbbaier

mcp-turso is an MCP server that enables structured interaction with Turso-hosted LibSQL databases. It supports retrieving database tables, schemas, and executing SELECT queries, facilitating real-time database access and management within MCP-enabled environments. This server integrates seamlessly with tools like Claude Desktop, allowing secure and efficient database querying through standardized MCP protocols.

Use This MCP server To

List tables in a Turso-hosted LibSQL database Retrieve database schema details for analysis Fetch schema of specific tables for data inspection Execute SELECT queries on Turso-hosted databases Integrate Turso database querying into AI workflows Enable real-time database access in MCP clients Automate data retrieval from LibSQL databases Support secure database querying with authentication tokens

README

mcp-turso

A Model Context Protocol (MCP) server that provides access to the Turso-hosted LibSQL databases. Currently, the server provides the following functionality:

  • Retrieving a list of tables in a database
  • Retrieving a database's schema
  • Retrieving the schema of a table
  • Performing SELECT queries

Configuration

With Claude Desktop

Add this to your claude_desktop_config.json:

{
   "mcpServers": [
      "turso": {
         "command": "npx",
         "args": ["-y", "mcp-turso"],
         "env": {
            "TURSO_DATABASE_URL": "your_url",
            "TURSO_AUTH_TOKEN": "your_token"
         }
      }
   ]
}

You will need an existing database to continue. If you don't have one, create one. To get the database URL via the Turso CLI, run:

turso db show --url <database-name>

Then get the database authentication token:

turso db tokens create <database-name>

Add those values to your configuration as shown above.

With Cursor

To configure the Turso MCP server with Cursor, add the following to your Cursor settings:

  1. Open Cursor and go to Settings (⚙️) > Settings (JSON)
  2. Add the following configuration to your settings JSON:
"mcpServers": {
  "turso": {
    "command": "npx",
    "args": ["-y", "mcp-turso"],
    "env": {
      "TURSO_DATABASE_URL": "your_url",
      "TURSO_AUTH_TOKEN": "your_token"
    }
  }
}

Replace your_url and your_token with your Turso database URL and authentication token as described in the previous section.

Logging

The server includes a custom logger for debugging outside of Claude Desktop. By default, this logger writes to <parent-dir>/logs/mcp-turso.log, where <parent-dir> is the parent directory of directory containing the mcp-turso script. In other words, if the path to mcp-turso is ~/foo/bin/mcp-turso, the logs will be at ~/foo/logs/mcp-turso.log. If running with NPX as above, the default logs will be:

~/.npm/_npx/<npx-dir-name>/node_modules/mcp-turso/logs/mcp-turso.log

If you would like to specify a custom path, you can include a --logs flag with an absolute posix path in the server's configuration:

{
   "mcpServers": [
      "turso": {
         "command": "npx",
         "args": ["-y", "mcp-turso", "--logs", "/Users/<username>/path/to/dir/mcp-logs.log"],
         "env": {
            "TURSO_DATABASE_URL": "your_url",
            "TURSO_AUTH_TOKEN": "your_token"
         }
      }
   ]
}

The path to the log file (default or custom) is always logged to stderr when the server is created. For Claude desktop, this will show up in your server logs in ~/Library/Logs/Claude.

Note: Right now, I haven't implemented specifying a custom logging file for Windows, but this is coming.

Server Capabilities

The server provides the following tools:

  • list_tables
    • Get a list of all the tables in the database
    • No input
    • Returns: an array of table names
  • get_db_schema
    • Get the schemas of all tables in the database
    • No input
    • Returns: an array of SQL creation statements
  • describe_table
    • View schema information for a specific table
    • Input:
      • table_name (string): Name of table to describe
    • Returns: Array of column definitions with names and types
  • query_database
    • Execute a SELECT query to read data from the database
    • Input:
      • sql (string): The SELECT SQL query to execute
    • Returns: Query results as an object of type { columns: string[]; rows: Record<string, unknown>[]; rowCount: number; }

Todo

  • Add the ability to specify a custom log file on windows
  • Add more query tools

License

MIT License - see the LICENSE file for details.

mcp-turso FAQ

How do I configure mcp-turso with Claude Desktop?
Add the mcp-turso server configuration to your claude_desktop_config.json with your Turso database URL and authentication token.
What database operations does mcp-turso support?
It supports listing tables, retrieving database and table schemas, and performing SELECT queries.
Do I need an existing Turso database to use mcp-turso?
Yes, you must have an existing Turso-hosted LibSQL database and its access credentials.
How do I obtain the Turso database URL and authentication token?
Use the Turso CLI commands 'turso db show --url <database-name>' and 'turso db tokens create <database-name>'.
Is mcp-turso limited to SELECT queries only?
Currently, mcp-turso supports only SELECT queries for safe read-only access.
Can mcp-turso be used with other MCP hosts besides Claude Desktop?
Yes, it can be integrated with any MCP host that supports server configuration and environment variables.
How does mcp-turso ensure secure database access?
It uses authentication tokens provided by Turso to securely connect to the database.
What LLM providers can work with mcp-turso?
mcp-turso can be used with LLMs like OpenAI, Claude, and Gemini through MCP clients.