Skip to main content
Glama

fix_commands

Apply targeted fixes to test commands by updating, removing, or inserting commands at specific indexes to resolve automation issues.

Instructions

Apply targeted fixes to commands in a test: update, remove, or insert at specific indexes. Indexes refer to the current command list BEFORE any fixes are applied.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
test_idYesThe test ID
fixesYes

Implementation Reference

  • Tool definition for 'fix_commands', including its name, description, and input schema.
      name: 'fix_commands',
      description:
        'Apply targeted fixes to commands in a test: update, remove, or insert at specific indexes. Indexes refer to the current command list BEFORE any fixes are applied.',
      inputSchema: {
        type: 'object' as const,
        properties: {
          test_id: {
            type: 'string',
            description: 'The test ID',
          },
          fixes: {
            type: 'array',
            items: {
              type: 'object',
              properties: {
                action: {
                  type: 'string',
                  enum: ['update', 'remove', 'insert'],
                },
                index: {
                  type: 'number',
                  description: '0-based command index',
                },
                command: { type: 'string' },
                target: { type: 'string' },
                value: { type: 'string' },
              },
              required: ['action', 'index'],
            },
          },
        },
        required: ['test_id', 'fixes'],
      },
    },
  • The server request handler which dispatches MCP tool calls to the BridgeClient. 'fix_commands' is handled generically here.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params
    
      try {
        const result = (await bridge.call(name, (args as Record<string, unknown>) || {})) as Record<string, unknown>
    
        // Check for bridge-level errors
        if (result && typeof result === 'object' && 'error' in result) {
          return {
            content: [
              { type: 'text' as const, text: `Error: ${result.error}` },
            ],
            isError: true,
          }
        }
    
        // Special handling for screenshot — return as image content
        if (name === 'get_screenshot' && result.screenshot) {
          const screenshotStr = result.screenshot as string
          const base64Data = screenshotStr.replace(
            /^data:image\/\w+;base64,/,
            ''
          )
          return {
            content: [
              {
                type: 'image' as const,
                data: base64Data,
                mimeType: 'image/jpeg',
              },
              {
                type: 'text' as const,
                text: `Screenshot of: ${result.title || 'unknown'} (${result.url || 'unknown'})`,
              },
            ],
          }
        }
    
        // All other tools return text/JSON
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(result, null, 2),
            },
          ],
        }
      } catch (error) {
        return {
          content: [
            {
              type: 'text' as const,
              text: `Error: ${(error as Error).message}`,
            },
          ],
          isError: true,
        }
      }
    })
  • The bridge client that performs the actual network request to the Selenix API backend, which executes the 'fix_commands' logic.
    export class BridgeClient {
      async call(endpoint: string, body: Record<string, unknown> = {}): Promise<unknown> {
        // Re-read config on every call so we pick up new tokens after Selenix restarts
        const config = readConfig()
    
        return new Promise((resolve, reject) => {
          const data = JSON.stringify(body)
          const req = http.request(
            {
              hostname: '127.0.0.1',
              port: config.port,
              path: `/api/${endpoint}`,
              method: 'POST',
              headers: {
                'Content-Type': 'application/json',
                Authorization: `Bearer ${config.token}`,
                'Content-Length': Buffer.byteLength(data),
              },
              timeout: 180000, // 3 minutes for long-running operations like run_test
            },
            (res) => {
              let responseData = ''
              res.on('data', (chunk: string) => (responseData += chunk))
              res.on('end', () => {
                try {
                  resolve(JSON.parse(responseData))
                } catch {
                  resolve({ raw: responseData })
                }
              })
            }
          )
          req.on('error', (err) =>
            reject(
              new Error(
                `Cannot connect to Selenix bridge at 127.0.0.1:${config.port}. ` +
                  `Is Selenix running with MCP Server enabled? (${err.message})`
              )
            )
          )
          req.on('timeout', () => {
            req.destroy()
            reject(new Error('Request timed out after 180 seconds'))
          })
          req.write(data)
          req.end()
        })
      }
    }

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/markmircea/Selenix-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server