Skip to main content
Glama

MQScript MCP Server

by allegiant
standard-library.ts22.1 kB
// Standard Library Functions - 标准库函数 // Math Functions - 数学函数 export const MathFunctions = { // Abs - 绝对值 abs: { name: 'mqscript_abs', description: 'Get absolute value of a number', inputSchema: { type: 'object' as const, properties: { number: { type: 'number', description: 'Number to get absolute value of' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['number'] }, handler: async (args: { number: number; resultVariable?: string }) => { const { number, resultVariable = 'result' } = args; const script = `${resultVariable} = Abs(${number})`; return { content: [ { type: 'text', text: `Generated MQScript absolute value function:\n\`\`\`\n${script}\n\`\`\`\n\nThis calculates the absolute value of ${number}.` } ] }; } }, // Sin - 正弦 sin: { name: 'mqscript_sin', description: 'Calculate sine of an angle (in radians)', 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'] }, handler: async (args: { angle: number; resultVariable?: string }) => { const { angle, resultVariable = 'result' } = args; const script = `${resultVariable} = Sin(${angle})`; return { content: [ { type: 'text', text: `Generated MQScript sine function:\n\`\`\`\n${script}\n\`\`\`\n\nThis calculates the sine of ${angle} radians.` } ] }; } }, // Cos - 余弦 cos: { name: 'mqscript_cos', description: 'Calculate cosine of an angle (in radians)', 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'] }, 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.` } ] }; } }, // Tan - 正切 tan: { name: 'mqscript_tan', description: 'Calculate tangent of an angle (in radians)', 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'] }, handler: async (args: { angle: number; resultVariable?: string }) => { const { angle, resultVariable = 'result' } = args; const script = `${resultVariable} = Tan(${angle})`; return { content: [ { type: 'text', text: `Generated MQScript tangent function:\n\`\`\`\n${script}\n\`\`\`\n\nThis calculates the tangent of ${angle} radians.` } ] }; } }, // Sqr - 平方根 sqr: { name: 'mqscript_sqr', description: 'Calculate square root of a number', inputSchema: { type: 'object' as const, properties: { number: { type: 'number', description: 'Number to get square root of' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['number'] }, handler: async (args: { number: number; resultVariable?: string }) => { const { number, resultVariable = 'result' } = args; const script = `${resultVariable} = Sqr(${number})`; return { content: [ { type: 'text', text: `Generated MQScript square root function:\n\`\`\`\n${script}\n\`\`\`\n\nThis calculates the square root of ${number}.` } ] }; } }, // Rnd - 随机数 rnd: { name: 'mqscript_rnd', description: 'Generate random number between 0 and specified maximum', inputSchema: { type: 'object' as const, properties: { max: { type: 'number', description: 'Maximum value (exclusive)', default: 1 }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: [] }, handler: async (args: { max?: number; resultVariable?: string }) => { const { max = 1, resultVariable = 'result' } = args; const script = `${resultVariable} = Rnd(${max})`; return { content: [ { type: 'text', text: `Generated MQScript random number function:\n\`\`\`\n${script}\n\`\`\`\n\nThis generates a random number between 0 and ${max}.` } ] }; } } }; // String Functions - 字符串函数 export const StringFunctions = { // Len - 字符串长度 len: { name: 'mqscript_len', description: 'Get length of a string', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'String to get length of' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['text'] }, handler: async (args: { text: string; resultVariable?: string }) => { const { text, resultVariable = 'result' } = args; const script = `${resultVariable} = Len("${text}")`; return { content: [ { type: 'text', text: `Generated MQScript string length function:\n\`\`\`\n${script}\n\`\`\`\n\nThis gets the length of string "${text}".` } ] }; } }, // Left - 左侧字符 left: { name: 'mqscript_left', description: 'Get specified number of characters from left side of string', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'Source string' }, count: { type: 'number', description: 'Number of characters to extract' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['text', 'count'] }, handler: async (args: { text: string; count: number; resultVariable?: string }) => { const { text, count, resultVariable = 'result' } = args; const script = `${resultVariable} = Left("${text}", ${count})`; return { content: [ { type: 'text', text: `Generated MQScript left string function:\n\`\`\`\n${script}\n\`\`\`\n\nThis extracts ${count} characters from the left of "${text}".` } ] }; } }, // Right - 右侧字符 right: { name: 'mqscript_right', description: 'Get specified number of characters from right side of string', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'Source string' }, count: { type: 'number', description: 'Number of characters to extract' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['text', 'count'] }, handler: async (args: { text: string; count: number; resultVariable?: string }) => { const { text, count, resultVariable = 'result' } = args; const script = `${resultVariable} = Right("${text}", ${count})`; return { content: [ { type: 'text', text: `Generated MQScript right string function:\n\`\`\`\n${script}\n\`\`\`\n\nThis extracts ${count} characters from the right of "${text}".` } ] }; } }, // Mid - 中间字符 mid: { name: 'mqscript_mid', description: 'Get substring from specified position', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'Source string' }, start: { type: 'number', description: 'Starting position (1-based)' }, length: { type: 'number', description: 'Length of substring (optional)', default: -1 }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['text', 'start'] }, handler: async (args: { text: string; start: number; length?: number; resultVariable?: string }) => { const { text, start, length = -1, resultVariable = 'result' } = args; const script = length > 0 ? `${resultVariable} = Mid("${text}", ${start}, ${length})` : `${resultVariable} = Mid("${text}", ${start})`; return { content: [ { type: 'text', text: `Generated MQScript mid string function:\n\`\`\`\n${script}\n\`\`\`\n\nThis extracts substring from position ${start}${length > 0 ? ` with length ${length}` : ''} of "${text}".` } ] }; } }, // InStr - 查找字符 inStr: { name: 'mqscript_instr', description: 'Find position of substring in string', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'String to search in' }, searchText: { type: 'string', description: 'Text to search for' }, startPos: { type: 'number', description: 'Starting position (optional, 1-based)', default: 1 }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['text', 'searchText'] }, handler: async (args: { text: string; searchText: string; startPos?: number; resultVariable?: string }) => { const { text, searchText, startPos = 1, resultVariable = 'result' } = args; const script = startPos === 1 ? `${resultVariable} = InStr("${text}", "${searchText}")` : `${resultVariable} = InStr(${startPos}, "${text}", "${searchText}")`; return { content: [ { type: 'text', text: `Generated MQScript find string function:\n\`\`\`\n${script}\n\`\`\`\n\nThis finds the position of "${searchText}" in "${text}"${startPos > 1 ? ` starting from position ${startPos}` : ''}.` } ] }; } }, // Replace - 替换字符串 replace: { name: 'mqscript_replace', description: 'Replace occurrences of substring with new text', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'Source string' }, searchText: { type: 'string', description: 'Text to search for' }, replaceText: { type: 'string', description: 'Replacement text' }, count: { type: 'number', description: 'Number of replacements (optional, -1 for all)', default: -1 }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['text', 'searchText', 'replaceText'] }, handler: async (args: { text: string; searchText: string; replaceText: string; count?: number; resultVariable?: string }) => { const { text, searchText, replaceText, count = -1, resultVariable = 'result' } = args; const script = count === -1 ? `${resultVariable} = Replace("${text}", "${searchText}", "${replaceText}")` : `${resultVariable} = Replace("${text}", "${searchText}", "${replaceText}", , ${count})`; return { content: [ { type: 'text', text: `Generated MQScript replace string function:\n\`\`\`\n${script}\n\`\`\`\n\nThis replaces "${searchText}" with "${replaceText}" in "${text}"${count > 0 ? ` (${count} times)` : ''}.` } ] }; } }, // UCase - 转换为大写 uCase: { name: 'mqscript_ucase', description: 'Convert string to uppercase', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'String to convert' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['text'] }, handler: async (args: { text: string; resultVariable?: string }) => { const { text, resultVariable = 'result' } = args; const script = `${resultVariable} = UCase("${text}")`; return { content: [ { type: 'text', text: `Generated MQScript uppercase conversion:\n\`\`\`\n${script}\n\`\`\`\n\nThis converts "${text}" to uppercase.` } ] }; } }, // LCase - 转换为小写 lCase: { name: 'mqscript_lcase', description: 'Convert string to lowercase', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'String to convert' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['text'] }, handler: async (args: { text: string; resultVariable?: string }) => { const { text, resultVariable = 'result' } = args; const script = `${resultVariable} = LCase("${text}")`; return { content: [ { type: 'text', text: `Generated MQScript lowercase conversion:\n\`\`\`\n${script}\n\`\`\`\n\nThis converts "${text}" to lowercase.` } ] }; } } }; // Type Conversion Functions - 类型转换函数 export const TypeConversionFunctions = { // CInt - 转换为整数 cInt: { name: 'mqscript_cint', description: 'Convert value to integer', inputSchema: { type: 'object' as const, properties: { value: { type: 'string', description: 'Value to convert to integer' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['value'] }, handler: async (args: { value: string; resultVariable?: string }) => { const { value, resultVariable = 'result' } = args; const script = `${resultVariable} = CInt(${value})`; return { content: [ { type: 'text', text: `Generated MQScript integer conversion:\n\`\`\`\n${script}\n\`\`\`\n\nThis converts ${value} to integer.` } ] }; } }, // CStr - 转换为字符串 cStr: { name: 'mqscript_cstr', description: 'Convert value to string', 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'] }, 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.` } ] }; } }, // CBool - 转换为布尔值 cBool: { name: 'mqscript_cbool', description: 'Convert value to boolean', inputSchema: { type: 'object' as const, properties: { value: { type: 'string', description: 'Value to convert to boolean' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['value'] }, handler: async (args: { value: string; resultVariable?: string }) => { const { value, resultVariable = 'result' } = args; const script = `${resultVariable} = CBool(${value})`; return { content: [ { type: 'text', text: `Generated MQScript boolean conversion:\n\`\`\`\n${script}\n\`\`\`\n\nThis converts ${value} to boolean.` } ] }; } }, // IsNumeric - 判断是否为数字 isNumeric: { name: 'mqscript_isnumeric', description: 'Check if value is numeric', inputSchema: { type: 'object' as const, properties: { value: { type: 'string', description: 'Value to check' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['value'] }, handler: async (args: { value: string; resultVariable?: string }) => { const { value, resultVariable = 'result' } = args; const script = `${resultVariable} = IsNumeric(${value})`; return { content: [ { type: 'text', text: `Generated MQScript numeric check:\n\`\`\`\n${script}\n\`\`\`\n\nThis checks if ${value} is numeric.` } ] }; } } }; // Array Functions - 数组函数 export const ArrayFunctions = { // UBound - 获取数组上界 uBound: { name: 'mqscript_ubound', description: 'Get upper bound of array', inputSchema: { type: 'object' as const, properties: { arrayName: { type: 'string', description: 'Name of the array' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['arrayName'] }, handler: async (args: { arrayName: string; resultVariable?: string }) => { const { arrayName, resultVariable = 'result' } = args; const script = `${resultVariable} = UBound(${arrayName})`; return { content: [ { type: 'text', text: `Generated MQScript array upper bound:\n\`\`\`\n${script}\n\`\`\`\n\nThis gets the upper bound of array ${arrayName}.` } ] }; } }, // Split - 分割字符串为数组 split: { name: 'mqscript_split', description: 'Split string into array using delimiter', inputSchema: { type: 'object' as const, properties: { text: { type: 'string', description: 'String to split' }, delimiter: { type: 'string', description: 'Delimiter character(s)', default: ',' }, arrayVariable: { type: 'string', description: 'Array variable name to store result', default: 'arr' } }, required: ['text'] }, handler: async (args: { text: string; delimiter?: string; arrayVariable?: string }) => { const { text, delimiter = ',', arrayVariable = 'arr' } = args; const script = `Dim ${arrayVariable}()\n${arrayVariable} = Split("${text}", "${delimiter}")`; return { content: [ { type: 'text', text: `Generated MQScript string split:\n\`\`\`\n${script}\n\`\`\`\n\nThis splits "${text}" using delimiter "${delimiter}" into array ${arrayVariable}.` } ] }; } }, // Join - 连接数组为字符串 join: { name: 'mqscript_join', description: 'Join array elements into string using delimiter', inputSchema: { type: 'object' as const, properties: { arrayName: { type: 'string', description: 'Name of the array to join' }, delimiter: { type: 'string', description: 'Delimiter character(s)', default: ',' }, resultVariable: { type: 'string', description: 'Variable name to store result', default: 'result' } }, required: ['arrayName'] }, handler: async (args: { arrayName: string; delimiter?: string; resultVariable?: string }) => { const { arrayName, delimiter = ',', resultVariable = 'result' } = args; const script = `${resultVariable} = Join(${arrayName}, "${delimiter}")`; return { content: [ { type: 'text', text: `Generated MQScript array join:\n\`\`\`\n${script}\n\`\`\`\n\nThis joins array ${arrayName} with delimiter "${delimiter}".` } ] }; } } };

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