mqscript_cjson_get
Extract specific values from JSON objects using property paths for use in mobile automation scripts, enabling precise data retrieval during device control operations.
Instructions
Get value from JSON object
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| objectVariable | Yes | JSON object variable name | |
| path | Yes | Property path (e.g., "data.items[0].name") | |
| resultVariable | No | Variable name to store result | value |
Implementation Reference
- src/tools/plugin-commands.ts:94-105 (handler)The handler function that implements the core logic of the mqscript_cjson_get tool. It constructs an MQScript command to retrieve a value from a JSON object at the specified path and returns a formatted response.handler: async (args: { objectVariable: string; path: string; resultVariable?: string }) => { const { objectVariable, path, resultVariable = 'value' } = args; const script = `${resultVariable} = CJson.Get(${objectVariable}, "${path}")`; return { content: [ { type: 'text', text: `Generated MQScript CJson get command:\n\`\`\`\n${script}\n\`\`\`\n\nThis gets value at path "${path}" from object "${objectVariable}".` } ] }; }
- src/tools/plugin-commands.ts:75-93 (schema)The input schema defining the parameters for the mqscript_cjson_get tool: required objectVariable and path, optional resultVariable.inputSchema: { type: 'object' as const, properties: { objectVariable: { type: 'string', description: 'JSON object variable name' }, path: { type: 'string', description: 'Property path (e.g., "data.items[0].name")' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'value' } }, required: ['objectVariable', 'path'] },
- src/tools/plugin-commands.ts:72-106 (registration)The complete tool object definition for mqscript_cjson_get as part of CJsonCommands.get object.get: { name: 'mqscript_cjson_get', description: 'Get value from JSON object', inputSchema: { type: 'object' as const, properties: { objectVariable: { type: 'string', description: 'JSON object variable name' }, path: { type: 'string', description: 'Property path (e.g., "data.items[0].name")' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'value' } }, required: ['objectVariable', 'path'] }, handler: async (args: { objectVariable: string; path: string; resultVariable?: string }) => { const { objectVariable, path, resultVariable = 'value' } = args; const script = `${resultVariable} = CJson.Get(${objectVariable}, "${path}")`; return { content: [ { type: 'text', text: `Generated MQScript CJson get command:\n\`\`\`\n${script}\n\`\`\`\n\nThis gets value at path "${path}" from object "${objectVariable}".` } ] }; } },
- src/index.ts:56-60 (registration)Registration of mqscript_cjson_get by spreading CJsonCommands into the central ALL_TOOLS registry used by the MCP server for tool listing and execution.// Plugin Commands - 插件命令 ...CJsonCommands, ...DateTimeCommands, ...FileCommands, ...TuringCommands,