mcp_powerdrill_create_dataset
Create datasets for AI-powered data analysis in Powerdrill by specifying names and descriptions to organize information for smart insights.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The dataset name, which can be up to 128 characters in length | |
| description | No | The dataset description, which can be up to 128 characters in length |
Implementation Reference
- src/index.ts:543-601 (handler)The complete handler function for the mcp_powerdrill_create_dataset tool, including input schema validation with Zod, client initialization, API call to createDataset, response handling, and error management.server.tool( 'mcp_powerdrill_create_dataset', { name: z.string().describe('The dataset name, which can be up to 128 characters in length'), description: z.string().optional().describe('The dataset description, which can be up to 128 characters in length') }, async (args, extra) => { try { const { name, description } = args; // Initialize Powerdrill client const client = new (await import('./utils/powerdrillClient.js')).PowerdrillClient(); // Create dataset parameters const datasetParams = { name, description }; // Create dataset const response = await client.createDataset(datasetParams); // Check if response is valid if (response.code !== 0 || !response.data) { throw new Error(`Invalid API response: ${JSON.stringify(response)}`); } // Format the response as MCP content return { content: [ { type: "text", text: JSON.stringify({ id: response.data.id, message: "Dataset created successfully" }, null, 2) } ] }; } catch (error: any) { console.error(`Error creating dataset: ${error.message}`); // Return error response return { content: [ { type: "text", text: JSON.stringify({ error: `Error creating dataset: ${error.message}`, errorType: error.name, errorStack: process.env.NODE_ENV === 'development' ? error.stack : undefined }, null, 2) } ], isError: true }; } } );
- Supporting utility in PowerdrillClient class that sends the POST request to the Powerdrill API /datasets endpoint to create the dataset.async createDataset(params: CreateDatasetParams) { try { // Include user_id in the request body if not provided const requestBody = { ...params, user_id: params.user_id || this.config.userId }; const response = await this.client.post('/datasets', requestBody); return response.data; } catch (error: any) { console.error('Error creating dataset:', error.message); throw error; } }
- src/utils/powerdrillClient.ts:14-18 (schema)TypeScript interface defining the input parameters for the createDataset method (name required, description and user_id optional).export interface CreateDatasetParams { name: string; description?: string; user_id?: string; }
- src/index.ts:543-543 (registration)Tool registration call using McpServer.tool method, specifying the tool name 'mcp_powerdrill_create_dataset'.server.tool(
- src/index.ts:545-548 (schema)Zod schema for the tool's input parameters used in MCP server registration.{ name: z.string().describe('The dataset name, which can be up to 128 characters in length'), description: z.string().optional().describe('The dataset description, which can be up to 128 characters in length') },