Skip to main content
Glama
allegiant

MQScript MCP Server

by allegiant

mqscript_file_read

Reads file content from specified paths for mobile automation scripts, supporting multiple encodings and storing results in variables for device control operations.

Instructions

Read file content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
encodingNoFile encodingUTF-8
filePathYesFile path to read
resultVariableNoVariable name to store file contentfileContent

Implementation Reference

  • The handler function that implements the core logic of the 'mqscript_file_read' tool by generating an MQScript command to read file content and formatting a response message.
    handler: async (args: { filePath: string; encoding?: string; resultVariable?: string }) => {
      const { filePath, encoding = 'UTF-8', resultVariable = 'fileContent' } = args;
      const script = `${resultVariable} = File.Read("${filePath}", "${encoding}")`;
      return {
        content: [
          {
            type: 'text',
            text: `Generated MQScript file read command:\n\`\`\`\n${script}\n\`\`\`\n\nThis reads file "${filePath}" with encoding "${encoding}" and stores content in "${resultVariable}".`
          }
        ]
      };
    }
  • The input schema defining the parameters for the 'mqscript_file_read' tool: filePath (required), encoding (optional, default UTF-8), resultVariable (optional, default 'fileContent').
    inputSchema: {
      type: 'object' as const,
      properties: {
        filePath: {
          type: 'string',
          description: 'File path to read'
        },
        encoding: {
          type: 'string',
          description: 'File encoding',
          enum: ['UTF-8', 'GBK', 'ASCII'],
          default: 'UTF-8'
        },
        resultVariable: {
          type: 'string',
          description: 'Variable name to store file content',
          default: 'fileContent'
        }
      },
      required: ['filePath']
    },
  • src/index.ts:32-61 (registration)
    The central tool registry ALL_TOOLS object that spreads FileCommands (containing 'mqscript_file_read') into the list of available tools for MCP requests.
    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)
    The MCP server request handler for listing tools, which includes 'mqscript_file_read' from ALL_TOOLS in the response.
    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)
    The MCP server request handler for calling tools, which dispatches to the 'mqscript_file_read' handler when invoked.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Read file content' implies a read-only operation, but it doesn't specify potential side effects (e.g., file locking, memory usage for large files), error handling (e.g., what happens if the file doesn't exist or lacks permissions), or output format (e.g., returns a string, may throw exceptions). This leaves critical behavioral traits undocumented.

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

Conciseness4/5

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

The description 'Read file content' is extremely concise—just three words—and front-loaded with the core action. It wastes no space on redundant details, but this brevity comes at the cost of completeness, as it omits necessary context for effective tool use. While efficient, it could benefit from a bit more elaboration to balance clarity with conciseness.

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 complexity of file operations (with potential errors, encoding issues, and sibling tools), no output schema, and no annotations, the description is incomplete. It doesn't cover what the tool returns (e.g., file content as a string, error messages), how it handles edge cases (e.g., large files, missing files), or how it integrates with other tools (e.g., using 'resultVariable' in subsequent steps). This leaves significant gaps for an agent to infer behavior.

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 input schema has 100% description coverage, with clear documentation for 'filePath', 'encoding', and 'resultVariable'. The description adds no additional meaning beyond the schema, such as explaining how 'filePath' is resolved (e.g., relative vs. absolute) or what 'resultVariable' does in the broader context. Given the high schema coverage, a baseline score of 3 is appropriate, as the schema does the heavy lifting.

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

Purpose3/5

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

The description 'Read file content' clearly states the verb ('Read') and resource ('file content'), making the purpose understandable. However, it doesn't distinguish this tool from its sibling 'mqscript_file_write' (which writes files) or other file-related tools like 'mqscript_file_copy' and 'mqscript_file_delete', leaving room for ambiguity about when to choose this specific read operation.

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. With siblings like 'mqscript_file_exists' (to check file presence) and 'mqscript_file_write' (for writing), there's no indication of prerequisites (e.g., file must exist), use cases (e.g., reading configuration vs. data), or exclusions (e.g., not for binary files). This lack of context makes it harder for an agent to select the right tool.

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