mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-03-29 05:33:07 +00:00
* feat: add n8n_create_data_table MCP tool and projectId for create workflow (#640) Add new MCP tool to create n8n data tables via the REST API: - n8n_create_data_table tool definition with name + columns schema - handleCreateDataTable handler with Zod validation and N8nApiError handling - N8nApiClient.createDataTable() calling POST /data-tables - DataTable, DataTableColumn, DataTableColumnResponse types per OpenAPI spec - Column types: string | number | boolean | date | json - Input validation: .min(1) on table name and column names - Tool documentation with examples, use cases, and pitfalls Also adds projectId parameter to n8n_create_workflow for enterprise project support, and fixes stale management tool count in health check. Based on work by @djakielski in PR #646. Co-Authored-By: Dominik Jakielski <dominik.jakielski@urlaubsguru.de> Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: replace n8n_create_data_table with n8n_manage_datatable (10 actions) Replaces the single-purpose n8n_create_data_table tool with a comprehensive n8n_manage_datatable tool covering all 10 n8n data table API endpoints: Table operations: createTable, listTables, getTable, updateTable, deleteTable Row operations: getRows, insertRows, updateRows, upsertRows, deleteRows - Filter system with and/or logic and 8 condition operators - Dry-run support for updateRows, upsertRows, deleteRows - Pagination, sorting, and full-text search for row listing - 9 new N8nApiClient methods for all data table endpoints - Shared error handler and consolidated Zod schemas - Comprehensive tool documentation with examples per action - 36 handler tests + 18 API client tests BREAKING: n8n_create_data_table removed. Use n8n_manage_datatable with action="createTable" instead. Based on work by @djakielski in PR #646. Co-Authored-By: Dominik Jakielski <dominik.jakielski@urlaubsguru.de> Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en
This commit is contained in:
committed by
GitHub
parent
47a1cb135d
commit
be3d07dbdc
@@ -22,6 +22,15 @@ import {
|
||||
SourceControlStatus,
|
||||
SourceControlPullResult,
|
||||
SourceControlPushResult,
|
||||
DataTable,
|
||||
DataTableColumn,
|
||||
DataTableListParams,
|
||||
DataTableRow,
|
||||
DataTableRowListParams,
|
||||
DataTableInsertRowsParams,
|
||||
DataTableUpdateRowsParams,
|
||||
DataTableUpsertRowParams,
|
||||
DataTableDeleteRowsParams,
|
||||
} from '../types/n8n-api';
|
||||
import { handleN8nApiError, logN8nError } from '../utils/n8n-errors';
|
||||
import { cleanWorkflowForCreate, cleanWorkflowForUpdate } from './n8n-validation';
|
||||
@@ -582,6 +591,95 @@ export class N8nApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
async createDataTable(params: { name: string; columns?: DataTableColumn[] }): Promise<DataTable> {
|
||||
try {
|
||||
const response = await this.client.post('/data-tables', params);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async listDataTables(params: DataTableListParams = {}): Promise<{ data: DataTable[]; nextCursor?: string | null }> {
|
||||
try {
|
||||
const response = await this.client.get('/data-tables', { params });
|
||||
return this.validateListResponse<DataTable>(response.data, 'data-tables');
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataTable(id: string): Promise<DataTable> {
|
||||
try {
|
||||
const response = await this.client.get(`/data-tables/${id}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async updateDataTable(id: string, params: { name: string }): Promise<DataTable> {
|
||||
try {
|
||||
const response = await this.client.patch(`/data-tables/${id}`, params);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteDataTable(id: string): Promise<void> {
|
||||
try {
|
||||
await this.client.delete(`/data-tables/${id}`);
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataTableRows(id: string, params: DataTableRowListParams = {}): Promise<{ data: DataTableRow[]; nextCursor?: string | null }> {
|
||||
try {
|
||||
const response = await this.client.get(`/data-tables/${id}/rows`, { params });
|
||||
return this.validateListResponse<DataTableRow>(response.data, 'data-table-rows');
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async insertDataTableRows(id: string, params: DataTableInsertRowsParams): Promise<any> {
|
||||
try {
|
||||
const response = await this.client.post(`/data-tables/${id}/rows`, params);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async updateDataTableRows(id: string, params: DataTableUpdateRowsParams): Promise<any> {
|
||||
try {
|
||||
const response = await this.client.patch(`/data-tables/${id}/rows/update`, params);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async upsertDataTableRow(id: string, params: DataTableUpsertRowParams): Promise<any> {
|
||||
try {
|
||||
const response = await this.client.post(`/data-tables/${id}/rows/upsert`, params);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteDataTableRows(id: string, params: DataTableDeleteRowsParams): Promise<any> {
|
||||
try {
|
||||
const response = await this.client.delete(`/data-tables/${id}/rows/delete`, { params });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw handleN8nApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and normalizes n8n API list responses.
|
||||
* Handles both modern format {data: [], nextCursor?: string} and legacy array format.
|
||||
|
||||
Reference in New Issue
Block a user