mqscript_cos
Calculate the cosine of an angle in radians for use in mobile automation scripts, with options to store the result in a specified variable.
Instructions
Calculate cosine of an angle (in radians)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| angle | Yes | Angle in radians | |
| resultVariable | No | Variable name to store result | result |
Implementation Reference
- src/tools/standard-library.ts:90-101 (handler)The handler function for the mqscript_cos tool. It generates MQScript code to compute the cosine of the given angle in radians and returns a formatted text response with the code snippet.handler: async (args: { angle: number; resultVariable?: string }) => { const { angle, resultVariable = 'result' } = args; const script = `${resultVariable} = Cos(${angle})`; return { content: [ { type: 'text', text: `Generated MQScript cosine function:\n\`\`\`\n${script}\n\`\`\`\n\nThis calculates the cosine of ${angle} radians.` } ] }; }
- src/tools/standard-library.ts:75-89 (schema)The input schema for mqscript_cos tool, defining required 'angle' parameter (number) and optional 'resultVariable' (string).inputSchema: { type: 'object' as const, properties: { angle: { type: 'number', description: 'Angle in radians' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['angle'] },
- src/index.ts:64-72 (registration)Registration of all tools including mqscript_cos via the ListToolsRequest handler, which exposes tools from ALL_TOOLS by their name, description, and inputSchema.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 CallToolRequest handler that dispatches to the specific tool handler by matching the tool name 'mqscript_cos' and executes its handler function.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)}`); } });