Initial commit of n8n MCP Server
A Model Context Protocol (MCP) server that integrates with n8n, providing tools for workflow and execution management via the n8n API.
This commit is contained in:
68
src/tools/execution/get.ts
Normal file
68
src/tools/execution/get.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Get Execution Tool
|
||||
*
|
||||
* This tool retrieves detailed information about a specific workflow execution.
|
||||
*/
|
||||
|
||||
import { BaseExecutionToolHandler } from './base-handler.js';
|
||||
import { ToolCallResult, ToolDefinition, Execution } from '../../types/index.js';
|
||||
import { McpError } from '@modelcontextprotocol/sdk/types.js';
|
||||
import { ErrorCode } from '../../errors/error-codes.js';
|
||||
import { formatExecutionDetails } from '../../utils/execution-formatter.js';
|
||||
|
||||
/**
|
||||
* Handler for the get_execution tool
|
||||
*/
|
||||
export class GetExecutionHandler extends BaseExecutionToolHandler {
|
||||
/**
|
||||
* Execute the tool
|
||||
*
|
||||
* @param args Tool arguments (executionId)
|
||||
* @returns Execution details
|
||||
*/
|
||||
async execute(args: Record<string, any>): Promise<ToolCallResult> {
|
||||
return this.handleExecution(async () => {
|
||||
// Validate required parameters
|
||||
if (!args.executionId) {
|
||||
throw new McpError(
|
||||
ErrorCode.InvalidRequest,
|
||||
'Missing required parameter: executionId'
|
||||
);
|
||||
}
|
||||
|
||||
// Get execution details
|
||||
const execution = await this.apiService.getExecution(args.executionId);
|
||||
|
||||
// Format the execution for display
|
||||
const formattedExecution = formatExecutionDetails(execution);
|
||||
|
||||
return this.formatSuccess(
|
||||
formattedExecution,
|
||||
`Execution Details for ID: ${args.executionId}`
|
||||
);
|
||||
}, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tool definition for the get_execution tool
|
||||
*
|
||||
* @returns Tool definition
|
||||
*/
|
||||
export function getGetExecutionToolDefinition(): ToolDefinition {
|
||||
return {
|
||||
name: 'get_execution',
|
||||
description: 'Retrieve detailed information about a specific workflow execution',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
executionId: {
|
||||
type: 'string',
|
||||
description: 'ID of the execution to retrieve',
|
||||
},
|
||||
},
|
||||
required: ['executionId'],
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user