n8n-mcp-server
Version:
Model Context Protocol (MCP) server for n8n workflow automation
134 lines • 3.2 kB
JavaScript
/**
* n8n API Client Interface
*
* This module defines interfaces and types for the n8n API client.
*/
import { N8nApiClient } from './client.js';
/**
* n8n API service - provides functions for interacting with n8n API
*/
export class N8nApiService {
/**
* Create a new n8n API service
*
* @param config Environment configuration
*/
constructor(config) {
this.client = new N8nApiClient(config);
}
/**
* Check connectivity to the n8n API
*/
async checkConnectivity() {
return this.client.checkConnectivity();
}
/**
* Get all workflows from n8n
*
* @returns Array of workflow objects
*/
async getWorkflows() {
return this.client.getWorkflows();
}
/**
* Get a specific workflow by ID
*
* @param id Workflow ID
* @returns Workflow object
*/
async getWorkflow(id) {
return this.client.getWorkflow(id);
}
/**
* Execute a workflow by ID
*
* @param id Workflow ID
* @param data Optional data to pass to the workflow
* @returns Execution result
*/
async executeWorkflow(id, data) {
return this.client.executeWorkflow(id, data);
}
/**
* Create a new workflow
*
* @param workflow Workflow object to create
* @returns Created workflow
*/
async createWorkflow(workflow) {
return this.client.createWorkflow(workflow);
}
/**
* Update an existing workflow
*
* @param id Workflow ID
* @param workflow Updated workflow object
* @returns Updated workflow
*/
async updateWorkflow(id, workflow) {
return this.client.updateWorkflow(id, workflow);
}
/**
* Delete a workflow
*
* @param id Workflow ID
* @returns Deleted workflow or success message
*/
async deleteWorkflow(id) {
return this.client.deleteWorkflow(id);
}
/**
* Activate a workflow
*
* @param id Workflow ID
* @returns Activated workflow
*/
async activateWorkflow(id) {
return this.client.activateWorkflow(id);
}
/**
* Deactivate a workflow
*
* @param id Workflow ID
* @returns Deactivated workflow
*/
async deactivateWorkflow(id) {
return this.client.deactivateWorkflow(id);
}
/**
* Get all workflow executions
*
* @returns Array of execution objects
*/
async getExecutions() {
return this.client.getExecutions();
}
/**
* Get a specific execution by ID
*
* @param id Execution ID
* @returns Execution object
*/
async getExecution(id) {
return this.client.getExecution(id);
}
/**
* Delete an execution
*
* @param id Execution ID
* @returns Deleted execution or success message
*/
async deleteExecution(id) {
return this.client.deleteExecution(id);
}
}
/**
* Create a new n8n API service
*
* @param config Environment configuration
* @returns n8n API service
*/
export function createApiService(config) {
return new N8nApiService(config);
}
//# sourceMappingURL=n8n-client.js.map