link_automation_rule
Link an automation rule to a test cycle using the automation rule key and test cycle ID. Enables the rule to be triggered for that cycle.
Instructions
Associate an automation rule with a test cycle so it can be triggered for that cycle. automationRuleKey is the rule's string key from your QMetry automation config. Returns 200 on success.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cycleId | Yes | Test cycle ID | |
| automationRuleKey | Yes | Automation rule key to link |
Implementation Reference
- src/index.ts:694-700 (handler)The async handler function that executes the 'link_automation_rule' tool logic. It calls the QTMetry API at /testcycles/{cycleId}/automation-rule/link/{automationRuleKey} via PUT to associate an automation rule with a test cycle, then wraps the response using the ok() helper.
async ({ cycleId, automationRuleKey }) => { const data = await qtmFetch( `/testcycles/${cycleId}/automation-rule/link/${automationRuleKey}`, { method: "PUT", body: JSON.stringify({}) } ); return ok(data ?? { message: "Automation rule linked" }); } - src/index.ts:690-693 (schema)Input schema for the 'link_automation_rule' tool: requires cycleId (string or number) and automationRuleKey (string), validated via Zod.
{ cycleId: ID.describe("Test cycle ID"), automationRuleKey: z.string().describe("Automation rule key to link"), }, - src/index.ts:687-701 (registration)Registration of the 'link_automation_rule' tool via the local 'tool()' wrapper function, which delegates to server.registerTool on the McpServer instance at line 179.
tool( "link_automation_rule", "Associate an automation rule with a test cycle so it can be triggered for that cycle. automationRuleKey is the rule's string key from your QMetry automation config. Returns 200 on success.", { cycleId: ID.describe("Test cycle ID"), automationRuleKey: z.string().describe("Automation rule key to link"), }, async ({ cycleId, automationRuleKey }) => { const data = await qtmFetch( `/testcycles/${cycleId}/automation-rule/link/${automationRuleKey}`, { method: "PUT", body: JSON.stringify({}) } ); return ok(data ?? { message: "Automation rule linked" }); } ); - src/index.ts:69-73 (helper)The ok() helper function used by the handler to wrap the API response into the expected MCP tool content format.
function ok(data: unknown) { return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } - src/index.ts:172-184 (helper)The 'tool()' wrapper helper that registers tools on the McpServer instance, reducing boilerplate for each tool definition.
const tool = <Shape extends z.ZodRawShape>( name: string, description: string, inputSchema: Shape, // eslint-disable-next-line @typescript-eslint/no-explicit-any callback: (args: z.infer<z.ZodObject<Shape>>) => Promise<any> ) => server.registerTool( name, { description, inputSchema }, // eslint-disable-next-line @typescript-eslint/no-explicit-any callback as any );