mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-01 07:24:19 +01:00
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!
145 lines
2.8 KiB
Markdown
145 lines
2.8 KiB
Markdown
---
|
|
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:
|
|
|
|
```bash
|
|
/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:**
|
|
```json
|
|
{
|
|
"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:**
|
|
```json
|
|
{
|
|
"tool": "execute",
|
|
"arguments": {
|
|
"sql": "INSERT INTO users (name, age) VALUES ('Alice', 30)"
|
|
}
|
|
}
|
|
```
|
|
|
|
### `list_tables`
|
|
List all tables in the database.
|
|
|
|
**Example:**
|
|
```json
|
|
{
|
|
"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:**
|
|
```json
|
|
{
|
|
"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:
|
|
|
|
```json
|
|
{
|
|
"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:**
|
|
```bash
|
|
/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
|
|
|
|
- MCP Protocol Documentation: https://modelcontextprotocol.io
|
|
- Turso Documentation: https://turso.tech/docs |