trigger_make_scenario
Execute Make.com automation scenarios to perform tasks like creating tasks, sending notifications, or processing data through webhook integrations with third-party services.
Instructions
触发Make.com scenario执行指定任务
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | 要执行的动作类型 | |
| data | No | 传递给scenario的数据 |
Implementation Reference
- src/server.ts:118-174 (handler)The main execution handler for the 'trigger_make_scenario' tool. Validates input, constructs payload, sends HTTP POST to Make.com webhook, and returns formatted response with execution details or error.private async triggerMakeScenario(args: any) { if (!this.makeWebhookUrl) { throw new Error('Make.com webhook URL未配置。请在.env文件中设置MAKE_WEBHOOK_URL'); } // 验证输入参数 this.validatePayload(args); const payload = { action: args.action, data: args.data || {}, timestamp: new Date().toISOString(), source: 'claude-mcp', request_id: `mcp-${Date.now()}-${Math.random().toString(36).substr(2, 9)}` }; try { const response = await axios.post(this.makeWebhookUrl, payload, { headers: { 'Content-Type': 'application/json', 'User-Agent': 'Claude-MCP-Server/1.0.0' }, timeout: 30000, validateStatus: (status) => status < 500 // 接受所有非5xx状态码 }); const executionId = response.data?.executionId || response.data?.id || 'N/A'; const statusMessage = response.status >= 200 && response.status < 300 ? '✅ 成功' : '⚠️ 部分成功'; return { content: [ { type: 'text', text: `${statusMessage} Make scenario已触发\n` + `动作类型: ${args.action}\n` + `响应状态: ${response.status}\n` + `执行ID: ${executionId}\n` + `请求ID: ${payload.request_id}\n` + `时间戳: ${payload.timestamp}` } ] }; } catch (error) { if (axios.isAxiosError(error)) { const status = error.response?.status || 'N/A'; const statusText = error.response?.statusText || 'Unknown'; const errorData = error.response?.data || 'No additional error info'; throw new Error( `HTTP请求失败: ${status} - ${statusText}\n` + `错误详情: ${JSON.stringify(errorData)}\n` + `请检查Make.com scenario状态和webhook配置` ); } throw error; } }
- src/server.ts:45-60 (schema)Input schema definition for the tool, specifying required 'action' enum and optional 'data' object.inputSchema: { type: 'object', properties: { action: { type: 'string', description: '要执行的动作类型', enum: ['create_task', 'send_notification', 'process_data', 'custom'] }, data: { type: 'object', description: '传递给scenario的数据', additionalProperties: true } }, required: ['action'] }
- src/server.ts:90-108 (registration)Tool call request handler registration with switch statement dispatching 'trigger_make_scenario' calls to the handler function.this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { switch (name) { case 'trigger_make_scenario': return await this.triggerMakeScenario(args); case 'get_scenario_status': return await this.getScenarioStatus(args); case 'test_webhook_connection': return await this.testWebhookConnection(); default: throw new McpError(ErrorCode.MethodNotFound, `未知工具: ${name}`); } } catch (error) { const errorMessage = error instanceof Error ? error.message : '未知错误'; throw new McpError(ErrorCode.InternalError, `工具执行失败: ${errorMessage}`); } });
- src/server.ts:42-61 (registration)Tool specification registration in the ListTools response, including name, description, and schema.{ name: 'trigger_make_scenario', description: '触发Make.com scenario执行指定任务', inputSchema: { type: 'object', properties: { action: { type: 'string', description: '要执行的动作类型', enum: ['create_task', 'send_notification', 'process_data', 'custom'] }, data: { type: 'object', description: '传递给scenario的数据', additionalProperties: true } }, required: ['action'] } },
- src/server.ts:111-116 (helper)Helper function to validate the 'action' parameter against allowed enum values, called by the handler.private validatePayload(args: any) { const allowedActions = ['create_task', 'send_notification', 'process_data', 'custom']; if (!allowedActions.includes(args.action)) { throw new Error(`无效的动作类型: ${args.action}. 允许的类型: ${allowedActions.join(', ')}`); } }