Skip to main content
Glama

MQScript MCP Server

by allegiant
basic-commands.ts19.4 kB
import { z } from 'zod'; // Touch Commands - 触摸命令 export const TouchCommands = { // Tap - 短暂点击屏幕 tap: { name: 'mqscript_tap', description: 'Tap on screen at specified coordinates. Short tap once on the specified coordinates.', inputSchema: { type: 'object' as const, properties: { x: { type: 'number', description: 'X coordinate to tap (horizontal position)' }, y: { type: 'number', description: 'Y coordinate to tap (vertical position)' } }, required: ['x', 'y'] }, handler: async (args: { x: number; y: number }) => { const { x, y } = args; const script = `Tap ${x}, ${y}`; return { content: [ { type: 'text', text: `Generated MQScript touch command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will tap on screen coordinates (${x}, ${y}).` } ] }; } }, // Touch - 按住一段时间 touch: { name: 'mqscript_touch', description: 'Hold touch on screen for specified duration', inputSchema: { type: 'object' as const, properties: { x: { type: 'number', description: 'X coordinate to touch' }, y: { type: 'number', description: 'Y coordinate to touch' }, duration: { type: 'number', description: 'Duration to hold in milliseconds', default: 1000 } }, required: ['x', 'y'] }, handler: async (args: { x: number; y: number; duration?: number }) => { const { x, y, duration = 1000 } = args; const script = `Touch ${x}, ${y}, ${duration}`; return { content: [ { type: 'text', text: `Generated MQScript touch command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will hold touch at coordinates (${x}, ${y}) for ${duration}ms.` } ] }; } }, // Swipe - 划动 swipe: { name: 'mqscript_swipe', description: 'Swipe from one point to another with specified duration', inputSchema: { type: 'object' as const, properties: { x1: { type: 'number', description: 'Starting X coordinate' }, y1: { type: 'number', description: 'Starting Y coordinate' }, x2: { type: 'number', description: 'Ending X coordinate' }, y2: { type: 'number', description: 'Ending Y coordinate' }, duration: { type: 'number', description: 'Swipe duration in milliseconds', default: 500 } }, required: ['x1', 'y1', 'x2', 'y2'] }, handler: async (args: { x1: number; y1: number; x2: number; y2: number; duration?: number }) => { const { x1, y1, x2, y2, duration = 500 } = args; const script = `Swipe ${x1}, ${y1}, ${x2}, ${y2}, ${duration}`; return { content: [ { type: 'text', text: `Generated MQScript swipe command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will swipe from (${x1}, ${y1}) to (${x2}, ${y2}) over ${duration}ms.` } ] }; } }, // KeyPress - 按键 keyPress: { name: 'mqscript_keypress', description: 'Press a key once', inputSchema: { type: 'object' as const, properties: { keyCode: { type: 'number', description: 'Key code to press (e.g., 4 for back, 3 for home, 82 for menu)' } }, required: ['keyCode'] }, handler: async (args: { keyCode: number }) => { const { keyCode } = args; const script = `KeyPress ${keyCode}`; return { content: [ { type: 'text', text: `Generated MQScript key press command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will press key with code ${keyCode}.` } ] }; } }, // KeyDown - 按下 keyDown: { name: 'mqscript_keydown', description: 'Press and hold a key', inputSchema: { type: 'object' as const, properties: { keyCode: { type: 'number', description: 'Key code to press down' } }, required: ['keyCode'] }, handler: async (args: { keyCode: number }) => { const { keyCode } = args; const script = `KeyDown ${keyCode}`; return { content: [ { type: 'text', text: `Generated MQScript key down command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will press and hold key with code ${keyCode}.` } ] }; } }, // KeyUp - 弹起 keyUp: { name: 'mqscript_keyup', description: 'Release a key', inputSchema: { type: 'object' as const, properties: { keyCode: { type: 'number', description: 'Key code to release' } }, required: ['keyCode'] }, handler: async (args: { keyCode: number }) => { const { keyCode } = args; const script = `KeyUp ${keyCode}`; return { content: [ { type: 'text', text: `Generated MQScript key up command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will release key with code ${keyCode}.` } ] }; } } }; // Control Commands - 控制命令 export const ControlCommands = { // Delay - 延时 delay: { name: 'mqscript_delay', description: 'Pause script execution for specified duration', inputSchema: { type: 'object' as const, properties: { milliseconds: { type: 'number', description: 'Delay duration in milliseconds' } }, required: ['milliseconds'] }, handler: async (args: { milliseconds: number }) => { const { milliseconds } = args; const script = `Delay ${milliseconds}`; return { content: [ { type: 'text', text: `Generated MQScript delay command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will pause execution for ${milliseconds}ms (${milliseconds/1000} seconds).` } ] }; } }, // For - 循环 forLoop: { name: 'mqscript_for', description: 'Create a For loop structure', inputSchema: { type: 'object' as const, properties: { variable: { type: 'string', description: 'Loop variable name', default: 'i' }, start: { type: 'number', description: 'Start value', default: 1 }, end: { type: 'number', description: 'End value' }, step: { type: 'number', description: 'Step size', default: 1 }, body: { type: 'string', description: 'Loop body code (optional)', default: ' // Loop body' } }, required: ['end'] }, handler: async (args: { variable?: string; start?: number; end: number; step?: number; body?: string }) => { const { variable = 'i', start = 1, end, step = 1, body = ' // Loop body' } = args; const script = `For ${variable} = ${start} To ${end} Step ${step}\n${body}\nNext`; return { content: [ { type: 'text', text: `Generated MQScript for loop:\n\`\`\`\n${script}\n\`\`\`\n\nThis creates a loop from ${start} to ${end} with step ${step}.` } ] }; } }, // If - 条件判断 ifStatement: { name: 'mqscript_if', description: 'Create an If statement structure', inputSchema: { type: 'object' as const, properties: { condition: { type: 'string', description: 'Condition to evaluate' }, thenBody: { type: 'string', description: 'Code to execute if condition is true', default: ' // Then body' }, elseBody: { type: 'string', description: 'Code to execute if condition is false (optional)', default: '' } }, required: ['condition'] }, handler: async (args: { condition: string; thenBody?: string; elseBody?: string }) => { const { condition, thenBody = ' // Then body', elseBody = '' } = args; let script = `If ${condition} Then\n${thenBody}`; if (elseBody) { script += `\nElse\n${elseBody}`; } script += '\nEnd If'; return { content: [ { type: 'text', text: `Generated MQScript if statement:\n\`\`\`\n${script}\n\`\`\`\n\nThis creates a conditional statement.` } ] }; } }, // While - 循环 whileLoop: { name: 'mqscript_while', description: 'Create a While loop structure', inputSchema: { type: 'object' as const, properties: { condition: { type: 'string', description: 'Loop condition' }, body: { type: 'string', description: 'Loop body code', default: ' // Loop body' } }, required: ['condition'] }, handler: async (args: { condition: string; body?: string }) => { const { condition, body = ' // Loop body' } = args; const script = `While ${condition}\n${body}\nWend`; return { content: [ { type: 'text', text: `Generated MQScript while loop:\n\`\`\`\n${script}\n\`\`\`\n\nThis creates a while loop with condition: ${condition}.` } ] }; } }, // Dim - 定义变量 dimVariable: { name: 'mqscript_dim', description: 'Define variables or arrays', inputSchema: { type: 'object' as const, properties: { variables: { type: 'string', description: 'Variable names separated by commas (e.g., "a, b(), c")' } }, required: ['variables'] }, handler: async (args: { variables: string }) => { const { variables } = args; const script = `Dim ${variables}`; return { content: [ { type: 'text', text: `Generated MQScript variable declaration:\n\`\`\`\n${script}\n\`\`\`\n\nThis declares variables: ${variables}.` } ] }; } } }; // Color Commands - 颜色命令 export const ColorCommands = { // GetPixelColor - 获取指定点颜色 getPixelColor: { name: 'mqscript_getpixelcolor', description: 'Get color of pixel at specified coordinates', inputSchema: { type: 'object' as const, properties: { x: { type: 'number', description: 'X coordinate' }, y: { type: 'number', description: 'Y coordinate' }, returnVariable: { type: 'string', description: 'Variable name to store the color value', default: 'color' } }, required: ['x', 'y'] }, handler: async (args: { x: number; y: number; returnVariable?: string }) => { const { x, y, returnVariable = 'color' } = args; const script = `${returnVariable} = GetPixelColor(${x}, ${y})`; return { content: [ { type: 'text', text: `Generated MQScript get pixel color command:\n\`\`\`\n${script}\n\`\`\`\n\nThis gets the color of pixel at (${x}, ${y}) and stores it in variable '${returnVariable}'.` } ] }; } }, // FindColor - 寻找颜色 findColor: { name: 'mqscript_findcolor', description: 'Find color in specified region with support for multiple colors, color deviation, and similarity', inputSchema: { type: 'object' as const, properties: { left: { type: 'number', description: 'Left boundary of search region (0 for full screen)', default: 0 }, top: { type: 'number', description: 'Top boundary of search region (0 for full screen)', default: 0 }, right: { type: 'number', description: 'Right boundary of search region (0 for full screen)', default: 0 }, bottom: { type: 'number', description: 'Bottom boundary of search region (0 for full screen)', default: 0 }, colorValue: { type: 'string', description: 'Color value in BBGGRR format, multiple colors separated by |, deviation with - (e.g., "FFFFFF-101010|123456")' }, direction: { type: 'number', description: 'Search direction: 0=top-left to bottom-right, 1=center outward, 2=bottom-right to top-left, 3=bottom-left to top-right, 4=top-right to bottom-left', default: 0 }, similarity: { type: 'number', description: 'Color similarity (0-1, higher is more similar)', default: 0.9 }, xVariable: { type: 'string', description: 'Variable name to store found X coordinate', default: 'intX' }, yVariable: { type: 'string', description: 'Variable name to store found Y coordinate', default: 'intY' }, resultVariable: { type: 'string', description: 'Variable name to store result index', default: 'result' } }, required: ['colorValue'] }, handler: async (args: { left?: number; top?: number; right?: number; bottom?: number; colorValue: string; direction?: number; similarity?: number; xVariable?: string; yVariable?: string; resultVariable?: string; }) => { const { left = 0, top = 0, right = 0, bottom = 0, colorValue, direction = 0, similarity = 0.9, xVariable = 'intX', yVariable = 'intY', resultVariable = 'result' } = args; const script = `Dim ${xVariable}, ${yVariable}, ${resultVariable}\n${resultVariable} = FindColor(${left}, ${top}, ${right}, ${bottom}, "${colorValue}", ${direction}, ${similarity}, ${xVariable}, ${yVariable})\nIf ${resultVariable} > -1 Then\n TracePrint "Found color at:", ${xVariable}, ${yVariable}\nElse\n TracePrint "Color not found"\nEnd If`; return { content: [ { type: 'text', text: `Generated MQScript find color command:\n\`\`\`\n${script}\n\`\`\`\n\nThis searches for color "${colorValue}" in region (${left},${top})-(${right},${bottom}) with ${similarity} similarity.` } ] }; } }, // CmpColor - 对比指定点颜色 cmpColor: { name: 'mqscript_cmpcolor', description: 'Compare color at specified point with expected color', inputSchema: { type: 'object' as const, properties: { x: { type: 'number', description: 'X coordinate to check' }, y: { type: 'number', description: 'Y coordinate to check' }, expectedColor: { type: 'string', description: 'Expected color in BBGGRR format' }, similarity: { type: 'number', description: 'Color similarity tolerance (0-1)', default: 0.9 }, resultVariable: { type: 'string', description: 'Variable name to store comparison result', default: 'result' } }, required: ['x', 'y', 'expectedColor'] }, handler: async (args: { x: number; y: number; expectedColor: string; similarity?: number; resultVariable?: string }) => { const { x, y, expectedColor, similarity = 0.9, resultVariable = 'result' } = args; const script = `Dim ${resultVariable}\n${resultVariable} = CmpColor(${x}, ${y}, "${expectedColor}", ${similarity})\nIf ${resultVariable} Then\n TracePrint "Color matches at (${x}, ${y})"\nElse\n TracePrint "Color does not match at (${x}, ${y})"\nEnd If`; return { content: [ { type: 'text', text: `Generated MQScript compare color command:\n\`\`\`\n${script}\n\`\`\`\n\nThis compares color at (${x}, ${y}) with expected color "${expectedColor}" using ${similarity} similarity.` } ] }; } } }; // Other Commands - 其他命令 export const OtherCommands = { // ShowMessage - 显示信息 showMessage: { name: 'mqscript_showmessage', description: 'Display a message dialog', inputSchema: { type: 'object' as const, properties: { message: { type: 'string', description: 'Message to display' } }, required: ['message'] }, handler: async (args: { message: string }) => { const { message } = args; const script = `ShowMessage "${message}"`; return { content: [ { type: 'text', text: `Generated MQScript show message command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will display message: "${message}".` } ] }; } }, // TracePrint - 调试输出 tracePrint: { name: 'mqscript_traceprint', description: 'Output debug information', inputSchema: { type: 'object' as const, properties: { message: { type: 'string', description: 'Debug message to output' } }, required: ['message'] }, handler: async (args: { message: string }) => { const { message } = args; const script = `TracePrint "${message}"`; return { content: [ { type: 'text', text: `Generated MQScript trace print command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will output debug message: "${message}".` } ] }; } }, // RunApp - 运行应用 runApp: { name: 'mqscript_runapp', description: 'Launch an application', inputSchema: { type: 'object' as const, properties: { packageName: { type: 'string', description: 'Package name of the app to launch' } }, required: ['packageName'] }, handler: async (args: { packageName: string }) => { const { packageName } = args; const script = `RunApp "${packageName}"`; return { content: [ { type: 'text', text: `Generated MQScript run app command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will launch app with package name: "${packageName}".` } ] }; } }, // InputText - 输入文本 inputText: { name: 'mqscript_inputtext', description: 'Input text into the current focused field', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'Text to input' } }, required: ['text'] }, handler: async (args: { text: string }) => { const { text } = args; const script = `InputText "${text}"`; return { content: [ { type: 'text', text: `Generated MQScript input text command:\n\`\`\`\n${script}\n\`\`\`\n\nThis will input text: "${text}".` } ] }; } } };

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/allegiant/MQScript_MCP'

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