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
| Name | Required | Description | Default |
|---|---|---|---|
| group | No | Optional group name for the database | |
| name | Yes | Name of the database to create | |
| regions | No | Optional list of regions to deploy the database to |
Implementation Reference
- src/tools/handler.ts:127-137 (handler)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); } },
- src/tools/handler.ts:17-21 (schema)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)'), });
- src/tools/handler.ts:122-126 (registration)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, },
- src/clients/organization.ts:68-116 (helper)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, ); } }