create_table
Create a new table in a SQLite database by providing a full CREATE TABLE SQL statement.
Instructions
Create a new table in the database with a full CREATE TABLE SQL statement.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | CREATE TABLE SQL statement |
Implementation Reference
- src/index.ts:221-231 (registration)Tool registration for 'create_table' in ListToolsRequestSchema handler. Defines the tool name, description, and input schema expecting a 'query' string parameter.
{ name: 'create_table', description: 'Create a new table in the database with a full CREATE TABLE SQL statement.', inputSchema: { type: 'object' as const, properties: { query: { type: 'string', description: 'CREATE TABLE SQL statement' }, }, required: ['query'], }, }, - src/index.ts:224-231 (schema)Input schema for create_table: accepts a single required 'query' string parameter containing the CREATE TABLE SQL statement.
inputSchema: { type: 'object' as const, properties: { query: { type: 'string', description: 'CREATE TABLE SQL statement' }, }, required: ['query'], }, }, - src/index.ts:296-301 (handler)Handler for the 'create_table' tool: extracts the query parameter, validates it is a CREATE TABLE statement, executes it via db.run(), and returns a success message.
case 'create_table': { const { query } = toolArgs as { query: string }; validateCreateTableQuery(query); db.run(query); return { content: [{ type: 'text', text: 'Table created successfully' }] }; } - src/index.ts:57-62 (helper)Validation helper that ensures the query string starts with 'create table' (case-insensitive), throwing an InvalidParams error otherwise.
function validateCreateTableQuery(query: string): void { const normalized = query.trim().toLowerCase(); if (!normalized.startsWith('create table')) { throw new McpError(ErrorCode.InvalidParams, 'Query must be a CREATE TABLE statement'); } }