run_scenario_11704
Execute predefined automation scenarios on the Make MCP Server, handling diverse inputs like arrays, collections, booleans, dates, JSON, numbers, and text for workflow integration.
Instructions
Scenario Inputs All Types
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| array_of_arrays | No | description | |
| array_of_collections | No | description | |
| boolean | No | ||
| collection | No | description | |
| date | No | description | |
| json | No | description | |
| number | Yes | required + default | |
| primitive_array | No | description | |
| select | No | ||
| text | No |
Implementation Reference
- src/index.ts:60-85 (handler)Core handler logic for executing 'run_scenario_*' tools: parses scenario ID from tool name, calls make.scenarios.run, formats output or error response.if (/^run_scenario_\d+$/.test(request.params.name)) { try { const output = ( await make.scenarios.run(parseInt(request.params.name.substring(13)), request.params.arguments) ).outputs; return { content: [ { type: 'text', text: output ? JSON.stringify(output, null, 2) : 'Scenario executed successfully.', }, ], }; } catch (err: unknown) { return { isError: true, content: [ { type: 'text', text: String(err), }, ], }; } }
- src/index.ts:37-57 (registration)Dynamically registers 'run_scenario_{id}' tools for each on-demand scenario, generating name, description, and inputSchema dynamically.server.setRequestHandler(ListToolsRequestSchema, async () => { const scenarios = await make.scenarios.list(teamId); return { tools: await Promise.all( scenarios .filter(scenario => scenario.scheduling.type === 'on-demand') .map(async scenario => { const inputs = (await make.scenarios.interface(scenario.id)).input; return { name: `run_scenario_${scenario.id}`, description: scenario.name + (scenario.description ? ` (${scenario.description})` : ''), inputSchema: remap({ name: 'wrapper', type: 'collection', spec: inputs, }), }; }), ), }; });
- src/make.ts:33-42 (handler)Implements the actual API call to run the scenario: POST /scenarios/{id}/run with input data.async run(scenarioId: number, body: unknown): Promise<ScenarioRunServerResponse> { return await this.#fetch<ScenarioRunServerResponse>(`/scenarios/${scenarioId}/run`, { method: 'POST', body: JSON.stringify({ data: body, responsive: true }), headers: { 'content-type': 'application/json', }, }); } }
- src/utils.ts:60-108 (schema)Helper function to remap Make scenario input interfaces to JSON schema for tool inputSchema. Used in tool registration.export function remap(field: Input): unknown { switch (field.type) { case 'collection': const required: string[] = []; const properties: unknown = (Array.isArray(field.spec) ? field.spec : []).reduce((object, subField) => { if (!subField.name) return object; if (subField.required) required.push(subField.name); return Object.defineProperty(object, subField.name, { enumerable: true, value: remap(subField), }); }, {}); return { type: 'object', description: noEmpty(field.help), properties, required, }; case 'array': return { type: 'array', description: noEmpty(field.help), items: field.spec && remap( Array.isArray(field.spec) ? { type: 'collection', spec: field.spec, } : field.spec, ), }; case 'select': return { type: 'string', description: noEmpty(field.help), enum: (field.options || []).map(option => option.value), }; default: return { type: PRIMITIVE_TYPE_MAP[field.type as keyof typeof PRIMITIVE_TYPE_MAP], default: field.default != '' && field.default != null ? field.default : undefined, description: noEmpty(field.help), }; } }
- src/make.ts:44-82 (helper)Make class providing authenticated API client, including scenarios.run method delegation.export class Make { readonly #apiKey: string; public readonly zone: string; public readonly version: number; public readonly scenarios: Scenarios; constructor(apiKey: string, zone: string, version = 2) { this.#apiKey = apiKey; this.zone = zone; this.version = version; this.scenarios = new Scenarios(this.fetch.bind(this)); } async fetch<T = any>(url: string, options?: RequestInit): Promise<T> { options = Object.assign({}, options, { headers: Object.assign({}, options?.headers, { 'user-agent': 'MakeMCPServer/0.1.0', authorization: `Token ${this.#apiKey}`, }), }); if (url.charAt(0) === '/') { if (url.charAt(1) === '/') { url = `https:${url}`; } else { url = `https://${this.zone}/api/v${this.version}${url}`; } } const res = await fetch(url, options); if (res.status >= 400) { throw await createMakeError(res); } const contentType = res.headers.get('content-type'); const result = contentType?.includes('application/json') ? await res.json() : await res.text(); return result; }