Skip to main content
Glama
index_20250401174258.ts8.53 kB
// MCP Server for Make.com with full tool implementations import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { CallToolRequestSchema, ListToolsRequestSchema, ToolSchema, } from "@modelcontextprotocol/sdk/types.js"; import { z } from "zod"; import { zodToJsonSchema } from "zod-to-json-schema"; const MAKE_API_KEY = process.env.MAKE_DOT_COM_API_KEY!; const MAKE_BASE_URL = process.env.MAKE_DOT_COM_BASE_URL || "eu2.make.com"; const MAKE_TEAM_ID = process.env.MAKE_DOT_COM_TEAM_ID; if (!MAKE_API_KEY || !MAKE_TEAM_ID) { throw new Error("Missing Make.com credentials or team ID"); } function makeHeaders() { return { Authorization: `Token ${MAKE_API_KEY}`, "Content-Type": "application/json", Accept: "application/json", }; } // ========== Zod Schemas ========== const ScenarioIdSchema = z.object({ scenario_id: z.number(), draft: z.boolean().optional().default(false), }); const CreateScenarioSchema = z.object({ name: z.string(), folderId: z.number().optional(), description: z.string().optional(), }); const UpdateScenarioSchema = z.object({ scenario_id: z.number(), name: z.string().optional(), description: z.string().optional(), }); const DescribeModuleSchema = z.object({ scenario_id: z.number(), module_id: z.number(), draft: z.boolean().optional().default(false), }); const UpdateModuleParametersArgsSchema = z.object({ scenario_id: z.number().describe("ID of the scenario containing the module"), module_id: z.number().describe("ID of the module to update"), parameters: z.record(z.any()).describe("Key-value pairs to patch into the module parameters"), draft: z.boolean().optional().default(false), }); const CheckModuleSchema = z.object({ scenario_id: z.number(), module_id: z.number(), draft: z.boolean().optional().default(false), }); // ========== Server ========== const server = new Server( { name: "mcp-server-make-dot-com", version: "1.0.0" }, { capabilities: { tools: {} } } ); // ========== Tool List ========== const tools = [ { name: "read_make_dot_com_scenario_blueprint", description: "Retrieve blueprint for a scenario", inputSchema: zodToJsonSchema(ScenarioIdSchema), }, { name: "create_make_dot_com_scenario", description: "Create a new Make.com scenario", inputSchema: zodToJsonSchema(CreateScenarioSchema), }, { name: "update_make_dot_com_scenario", description: "Update an existing Make.com scenario", inputSchema: zodToJsonSchema(UpdateScenarioSchema), }, { name: "describe_make_dot_com_module", description: "Describe module parameters from blueprint", inputSchema: zodToJsonSchema(DescribeModuleSchema), }, { name: "update_module_parameters", description: "Update module parameters in blueprint", inputSchema: zodToJsonSchema(UpdateModuleParamsSchema), }, { name: "check_make_dot_com_module_data", description: "Check if module required fields are filled", inputSchema: zodToJsonSchema(CheckModuleSchema), }, { name: "list_make_dot_com_scenarios", description: "List available Make.com scenarios", inputSchema: { type: "object", properties: {}, required: [] }, }, { name: "list_make_dot_com_connections", description: "List Make.com connections and their validity", inputSchema: { type: "object", properties: {}, required: [] }, }, ]; server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools })); server.setRequestHandler(CallToolRequestSchema, async ({ params: { name, arguments: args } }) => { switch (name) { case "read_make_dot_com_scenario_blueprint": { const { scenario_id, draft } = ScenarioIdSchema.parse(args); const url = `https://${MAKE_BASE_URL}/api/v2/scenarios/${scenario_id}/blueprint?includeDraft=${draft}&teamId=${MAKE_TEAM_ID}`; const res = await fetch(url, { headers: makeHeaders() }); return { content: [{ type: "text", text: await res.text() }] }; } case "create_make_dot_com_scenario": { const { name, folderId, description } = CreateScenarioSchema.parse(args); const res = await fetch(`https://${MAKE_BASE_URL}/api/v2/scenarios`, { method: "POST", headers: makeHeaders(), body: JSON.stringify({ name, folderId, description, teamId: MAKE_TEAM_ID }) }); return { content: [{ type: "text", text: await res.text() }] }; } case "update_make_dot_com_scenario": { const { scenario_id, name, description } = UpdateScenarioSchema.parse(args); const url = `https://${MAKE_BASE_URL}/api/v2/scenarios/${scenario_id}?teamId=${MAKE_TEAM_ID}`; const res = await fetch(url, { method: "PATCH", headers: makeHeaders(), body: JSON.stringify({ name, description }) }); return { content: [{ type: "text", text: await res.text() }] }; } case "describe_make_dot_com_module": { const { scenario_id, module_id, draft } = DescribeModuleSchema.parse(args); const url = `https://${MAKE_BASE_URL}/api/v2/scenarios/${scenario_id}/blueprint?includeDraft=${draft}&teamId=${MAKE_TEAM_ID}`; const res = await fetch(url, { headers: makeHeaders() }); const blueprint = await res.json(); const mod = blueprint.response?.blueprint?.flow?.find((m: any) => m.id === module_id); if (!mod) throw new Error("Module not found"); return { content: [{ type: "text", text: JSON.stringify(mod, null, 2) }] }; } case "update_module_parameters": { const parsed = UpdateModuleParametersArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments: ${parsed.error.message}`); } const { scenario_id, module_id, parameters, draft } = parsed.data; const url = `https://${MAKE_BASE_URL}/api/v2/scenarios/${scenario_id}/blueprint?includeDraft=${draft}&teamId=${MAKE_TEAM_ID}`; const res = await fetch(url, { headers: makeHeaders() }); const blueprint = await res.json(); const flow = blueprint.response?.blueprint?.flow; const mod = flow.find((m: any) => m.id === module_id); if (!mod) throw new Error("Module not found"); mod.parameters = { ...mod.parameters, ...parameters }; await fetch(url, { method: "PATCH", headers: makeHeaders(), body: JSON.stringify({ blueprint: blueprint.response.blueprint }) }); return { content: [{ type: "text", text: `Module ${module_id} updated.` }] }; } case "check_make_dot_com_module_data": { const { scenario_id, module_id, draft } = CheckModuleSchema.parse(args); const url = `https://${MAKE_BASE_URL}/api/v2/scenarios/${scenario_id}/blueprint?includeDraft=${draft}&teamId=${MAKE_TEAM_ID}`; const res = await fetch(url, { headers: makeHeaders() }); const blueprint = await res.json(); const mod = blueprint.response?.blueprint?.flow?.find((m: any) => m.id === module_id); if (!mod) throw new Error("Module not found"); const required = mod.metadata?.interface?.filter((f: any) => f.required)?.map((f: any) => f.name) || []; const filled = required.filter((name: string) => mod.parameters?.[name] !== undefined); return { content: [{ type: "text", text: `${filled.length}/${required.length} required fields filled.` }] }; } case "list_make_dot_com_scenarios": { const url = `https://${MAKE_BASE_URL}/api/v2/scenarios?teamId=${MAKE_TEAM_ID}`; const res = await fetch(url, { headers: makeHeaders() }); const data = await res.json(); const result = data?.scenarios?.map((s: any) => `• ${s.name} (ID: ${s.id})`)?.join("\n") || "No scenarios found."; return { content: [{ type: "text", text: result }] }; } case "list_make_dot_com_connections": { const url = `https://${MAKE_BASE_URL}/api/v2/connections?teamId=${MAKE_TEAM_ID}`; const res = await fetch(url, { headers: makeHeaders() }); const data = await res.json(); const result = data.map((c: any) => `• ${c.label || c.name} (${c.id}) ${c.valid ? "✅" : "❌"}`).join("\n"); return { content: [{ type: "text", text: result }] }; } default: throw new Error(`Unknown tool: ${name}`); } }); // Start the server (async () => { const transport = new StdioServerTransport(); await server.connect(transport); console.error("✅ Make.com MCP Server running..."); })();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sparxHub/mcp-makesync'

If you have feedback or need assistance with the MCP directory API, please join our Discord server