Skip to main content
Glama

create_database

Create a new database in your Turso organization by specifying the name, optional group, and regions for deployment using the MCP server.

Instructions

Create a new database in your Turso organization

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupNoOptional group name for the database
nameYesName of the database to create
regionsNoOptional list of regions to deploy the database to

Implementation Reference

  • MCP tool handler function that calls the organization client to create the database and returns formatted success/error response.
    async ({ name, group, regions }) => { try { const database = await organization_client.create_database( name, { group, regions }, ); return create_tool_response({ database }); } catch (error) { return create_tool_error_response(error); } },
  • Zod schema for validating input parameters to the create_database tool.
    const CreateDatabaseSchema = z.object({ name: z.string().describe('Name of the database to create - Must be unique within organization'), group: z.string().optional().describe('Optional group name for the database (defaults to "default")'), regions: z.array(z.string()).optional().describe('Optional list of regions to deploy the database to (affects latency and compliance)'), });
  • Configuration object passed to server.tool() for registering the create_database tool, including name, description, and schema reference.
    { name: 'create_database', description: `✓ SAFE: Create a new database in your Turso organization. Database name must be unique.`, schema: CreateDatabaseSchema, },
  • Helper function in organization client that makes the actual POST request to Turso API to create the database.
    export async function create_database( name: string, options: { group?: string; regions?: string[]; } = {}, ): Promise<Database> { const organization_id = get_organization_id(); const url = `${API_BASE_URL}/organizations/${organization_id}/databases`; // Default to "default" group if not specified const group = options.group || 'default'; try { const response = await fetch(url, { method: 'POST', headers: { ...get_auth_header(), 'Content-Type': 'application/json', }, body: JSON.stringify({ name, group, regions: options.regions, }), }); if (!response.ok) { const errorData = await response.json().catch(() => ({})); const errorMessage = errorData.error || response.statusText; throw new TursoApiError( `Failed to create database ${name}: ${errorMessage}`, response.status, ); } return await response.json(); } catch (error) { if (error instanceof TursoApiError) { throw error; } throw new TursoApiError( `Failed to create database ${name}: ${ (error as Error).message }`, 500, ); } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/spences10/mcp-turso-cloud'

If you have feedback or need assistance with the MCP directory API, please join our Discord server