mqscript_cstr
Convert values to strings for use in MQScript mobile automation, enabling proper data handling in device control operations.
Instructions
Convert value to string
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resultVariable | No | Variable name to store result | result |
| value | Yes | Value to convert to string |
Implementation Reference
- src/tools/standard-library.ts:571-582 (handler)The main handler function for the 'mqscript_cstr' tool. It generates MQScript code that converts a given value to a string using the CStr function and returns a formatted response.handler: async (args: { value: string; resultVariable?: string }) => { const { value, resultVariable = 'result' } = args; const script = `${resultVariable} = CStr(${value})`; return { content: [ { type: 'text', text: `Generated MQScript string conversion:\n\`\`\`\n${script}\n\`\`\`\n\nThis converts ${value} to string.` } ] }; }
- The input schema for the 'mqscript_cstr' tool, defining the expected arguments: a required 'value' string and an optional 'resultVariable'.inputSchema: { type: 'object' as const, properties: { value: { type: 'string', description: 'Value to convert to string' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['value'] },
- src/index.ts:32-61 (registration)The ALL_TOOLS registry that spreads in TypeConversionFunctions (containing mqscript_cstr) from standard-library.ts, making it available for MCP tool listing and execution.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:75-88 (registration)The MCP server request handler for CallToolRequestSchema. It locates the tool by name from ALL_TOOLS and invokes its handler function, effectively registering mqscript_cstr for execution.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)}`); } });