mqscript_cjson_set
Set values in JSON objects using property paths for mobile automation scripting with MQScript MCP Server.
Instructions
Set value in 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") | |
| value | Yes | Value to set |
Implementation Reference
- src/tools/plugin-commands.ts:130-141 (handler)Handler function that generates the MQScript 'CJson.Set' command based on input parameters: objectVariable, path, and value. Returns a formatted response with the generated script.handler: async (args: { objectVariable: string; path: string; value: string }) => { const { objectVariable, path, value } = args; const script = `CJson.Set(${objectVariable}, "${path}", "${value}")`; return { content: [ { type: 'text', text: `Generated MQScript CJson set command:\n\`\`\`\n${script}\n\`\`\`\n\nThis sets value "${value}" at path "${path}" in object "${objectVariable}".` } ] }; }
- src/tools/plugin-commands.ts:112-129 (schema)Input schema for the mqscript_cjson_set tool, specifying required string parameters: objectVariable (JSON object var), path (property path), value (value to set).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")' }, value: { type: 'string', description: 'Value to set' } }, required: ['objectVariable', 'path', 'value'] },
- src/index.ts:64-72 (registration)Registration of all tools including mqscript_cjson_set via the ListToolsRequestHandler, which exposes tools from the ALL_TOOLS object (populated with CJsonCommands containing this tool).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)CallToolRequestHandler that dynamically finds and executes the handler for mqscript_cjson_set by name from ALL_TOOLS.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)}`); } });
- src/index.ts:56-60 (registration)Inclusion of CJsonCommands (containing mqscript_cjson_set) into the ALL_TOOLS registry object used for tool listing and execution.// Plugin Commands - 插件命令 ...CJsonCommands, ...DateTimeCommands, ...FileCommands, ...TuringCommands,