Public
Remixed
MCP server exposing a Turso database to AI agents
aidatabasemcpturso
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

B8

An MCP (Model Context Protocol) server that exposes your Turso database to AI agents (Claude, Cursor, Gemini, etc.) as callable tools. Hosted on Val Town and served over Streamable HTTP at /mcp.

Tools

ToolDescription
queryRun a read-only SQL query (SELECT / PRAGMA)
executeRun a write statement (INSERT / UPDATE / DELETE)
list_tablesList tables/views in the database
describe_tableShow a table's schema (PRAGMA table_info)

Setup

  1. Set these environment variables on the val:
    • TURSO_DATABASE_URL — e.g. libsql://your-db-org.turso.io
    • TURSO_AUTH_TOKEN — a database token from the Turso dashboard
  2. Your MCP endpoint is:
    https://b8-mcp.val.run/mcp
    

Connect an MCP client

For example, with Claude Code:

claude mcp add --transport http turso https://b8-mcp.val.run/mcp

Or in a generic mcp.json:

{ "mcpServers": { "turso": { "type": "http", "url": "https://b8-mcp.val.run/mcp" } } }

Files

  • main.ts — HTTP handler: Hono + @hono/mcp transport, exposes /mcp
  • mcp.ts — the MCP server and its tool definitions
  • turso.ts — Turso client helper (@libsql/client/web, reads env vars)

Security note

The execute tool can modify your database, and this val is currently public (httpPrivacy: public). Anyone with the URL can call it. If you want to restrict who can reach it, mark the val restricted and grant access only to your own orgs, or add your own auth check in main.ts.