Skip to main content
Glama
allegiant

MQScript MCP Server

by allegiant

mqscript_findcolor

Locate specified colors within a defined screen region using color deviation and similarity settings for mobile automation tasks.

Instructions

Find color in specified region with support for multiple colors, color deviation, and similarity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bottomNoBottom boundary of search region (0 for full screen)
colorValueYesColor value in BBGGRR format, multiple colors separated by |, deviation with - (e.g., "FFFFFF-101010|123456")
directionNoSearch 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
leftNoLeft boundary of search region (0 for full screen)
resultVariableNoVariable name to store result indexresult
rightNoRight boundary of search region (0 for full screen)
similarityNoColor similarity (0-1, higher is more similar)
topNoTop boundary of search region (0 for full screen)
xVariableNoVariable name to store found X coordinateintX
yVariableNoVariable name to store found Y coordinateintY

Implementation Reference

  • The main handler function for the 'mqscript_findcolor' tool. It constructs and returns an MQScript code snippet that declares variables, calls FindColor with the provided parameters, and includes a conditional trace print based on the search result.
    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.`
          }
        ]
      };
    }
  • Zod input schema defining the parameters for the findColor tool, including search region, color specs, direction, similarity, and output variable names.
    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']
    },
  • src/index.ts:32-61 (registration)
    The ALL_TOOLS object spreads ColorCommands (containing mqscript_findcolor) along with other command sets. This registry is used by the MCP server handlers to list and execute tools dynamically.
    const ALL_TOOLS = {
      // Basic Commands - 基础命令
      ...TouchCommands,
      ...ControlCommands,
      ...ColorCommands,
      ...OtherCommands,
      
      // Standard Library - 标准库函数
      ...MathFunctions,
      ...StringFunctions,
      ...TypeConversionFunctions,
      ...ArrayFunctions,
      
      // UI Commands - 界面命令
      ...UIControlCommands,
      ...UIPropertyCommands,
      ...FloatingWindowCommands,
      
      // Extension Commands - 扩展命令
      ...ElementCommands,
      ...DeviceCommands,
      ...PhoneCommands,
      ...SysCommands,
      
      // Plugin Commands - 插件命令
      ...CJsonCommands,
      ...DateTimeCommands,
      ...FileCommands,
      ...TuringCommands,
    };
  • src/index.ts:64-72 (registration)
    MCP ListTools handler that exposes the mqscript_findcolor tool's metadata from the ALL_TOOLS registry.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: Object.values(ALL_TOOLS).map(tool => ({
          name: tool.name,
          description: tool.description,
          inputSchema: tool.inputSchema,
        })),
      };
    });
  • src/index.ts:75-88 (registration)
    MCP CallTool handler that dynamically finds and invokes the handler for 'mqscript_findcolor' from the ALL_TOOLS registry.
    server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest) => {
      const { name, arguments: args } = request.params;
      
      const tool = Object.values(ALL_TOOLS).find(t => t.name === name);
      if (!tool) {
        throw new Error(`Unknown tool: ${name}`);
      }
      
      try {
        return await tool.handler(args as any || {});
      } catch (error) {
        throw new Error(`Error executing tool ${name}: ${error instanceof Error ? error.message : String(error)}`);
      }
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions capabilities like 'multiple colors, color deviation, and similarity' but fails to describe critical behaviors: what happens when no color is found (e.g., returns null, sets variables to default), whether the search is case-sensitive or screen-dependent, or any performance implications (e.g., slow for large regions). For a tool with 10 parameters and no annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. Every word earns its place by highlighting key features (region, multiple colors, deviation, similarity) without redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (10 parameters, no annotations, no output schema), the description is inadequate. It doesn't explain the return format (e.g., what 'result index' means, how coordinates are stored), error conditions, or practical use cases. For a screen-interaction tool with variable output storage, more context is needed to guide effective usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal value beyond the input schema, which has 100% coverage with detailed parameter descriptions. It hints at 'multiple colors, color deviation, and similarity'—concepts already covered in the 'colorValue' and 'similarity' parameter descriptions. Since schema coverage is high, the baseline is 3, and the description doesn't significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Find color in specified region with support for multiple colors, color deviation, and similarity.' It specifies the verb ('Find'), resource ('color'), and key capabilities (multiple colors, deviation, similarity). However, it doesn't explicitly differentiate from sibling tools like 'mqscript_cmpcolor' or 'mqscript_getpixelcolor', which appear to be related color operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'mqscript_cmpcolor' (which might compare colors) or 'mqscript_getpixelcolor' (which might retrieve a single pixel's color), leaving the agent to infer usage context from tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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