Skip to main content
Glama

move_avatar

Direct avatar movement in VRChat by specifying direction (forward, backward, left, right) and duration using the VRChat MCP OSC server.

Instructions

Move the avatar in a specific direction.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directionYesDirection to move
durationNoDuration in seconds

Implementation Reference

  • Registers the 'move_avatar' MCP tool with input schema (direction: enum['forward','backward','left','right'], duration: number default 1.0) and thin handler delegating to InputTools.move via ToolContext.
    server.tool(
      'move_avatar',
      'Move the avatar in a specific direction.',
      {
        direction: z.enum(['forward', 'backward', 'left', 'right']).describe('Direction to move'),
        duration: z.number().default(1.0).describe('Duration in seconds')
      },
      async ({ direction, duration }, extra) => {
        try {
          const ctx = createToolContext(extra);
          const result = await inputTools.move(direction as MovementDirection, duration, ctx);
          return { content: [{ type: 'text', text: result }] };
        } catch (error) {
          return { 
            content: [{ 
              type: 'text', 
              text: `Error moving avatar: ${error instanceof Error ? error.message : String(error)}` 
            }],
            isError: true
          };
        }
      }
    );
  • Core handler logic: Maps direction to OSC input (MoveForward/Backward/left/right), sends value=1 via wsClient.sendInput with retries, delays for duration, releases to 0 with safety timeout and multiple retry attempts to ensure input release.
    public async move(
      direction: MovementDirection,
      duration: number,
      ctx?: ToolContext
    ): Promise<string> {
      if (ctx) {
        await ctx.info(`Moving ${direction} for ${duration} seconds`);
      }
      
      let inputName: string;
      let value: number;
      let releaseTimer: NodeJS.Timeout | null = null;
      
      try {
        // Map direction to input name and value
        switch (direction) {
          case 'forward':
            inputName = 'MoveForward';
            value = 1;
            break;
          case 'backward':
            inputName = 'MoveBackward';
            value = 1;
            break;
          case 'left':
            inputName = 'Moveleft';
            value = 1;
            break;
          case 'right':
            inputName = 'MoveRight';
            value = 1;
            break;
          default:
            return `Unknown direction: ${direction}`;
        }
        
        // Log the action
        logger.info(`Starting movement: ${direction} (${inputName}=${value}) for ${duration} seconds`);
        
        // Helper function to ensure input release
        const ensureInputRelease = async (): Promise<boolean> => {
          // Try up to 3 times to release the input
          for (let attempt = 1; attempt <= 3; attempt++) {
            try {
              logger.debug(`Releasing input ${inputName} (attempt ${attempt})`);
              const success = await this.wsClient.sendInput(inputName, 0.0);
              if (success) {
                logger.info(`Successfully released input ${inputName}`);
                return true;
              } else {
                logger.warn(`Failed to release input ${inputName} (attempt ${attempt})`);
                // Wait a short time before retry
                if (attempt < 3) await delay(100);
              }
            } catch (error) {
              logger.error(`Error releasing input ${inputName} (attempt ${attempt}): ${error instanceof Error ? error.message : String(error)}`);
              // Wait a short time before retry
              if (attempt < 3) await delay(200);
            }
          }
          return false;
        };
        
        // Always ensure input is released, even if there's an error
        const cleanupAndExit = async (message: string): Promise<string> => {
          if (releaseTimer) {
            clearTimeout(releaseTimer);
            releaseTimer = null;
          }
          
          await ensureInputRelease();
          return message;
        };
        
        // Set up a safety release timer that's longer than the requested duration
        // This ensures movement stops even if there's a problem during the normal flow
        releaseTimer = setTimeout(async () => {
          logger.warn(`Safety timeout for ${inputName} movement triggered`);
          await ensureInputRelease();
        }, (duration + 0.5) * 1000);
        
        // Send input press - use a retry mechanism
        let pressSuccess = false;
        for (let attempt = 1; attempt <= 3; attempt++) {
          try {
            logger.debug(`Sending input ${inputName}=${value} (attempt ${attempt})`);
            pressSuccess = await this.wsClient.sendInput(inputName, value);
            if (pressSuccess) {
              logger.info(`Successfully sent input ${inputName}=${value}`);
              break;
            } else {
              logger.warn(`Failed to send input ${inputName}=${value} (attempt ${attempt})`);
              if (attempt < 3) await delay(100);
            }
          } catch (error) {
            logger.error(`Error sending input ${inputName}=${value} (attempt ${attempt}): ${error instanceof Error ? error.message : String(error)}`);
            if (attempt < 3) await delay(200);
          }
        }
        
        if (!pressSuccess) {
          return await cleanupAndExit(`Failed to start movement: ${direction}`);
        }
        
        // Wait for duration
        logger.debug(`Waiting for ${duration} seconds before releasing ${inputName}`);
        await delay(duration * 1000);
        
        // Send input release
        const releaseSuccess = await ensureInputRelease();
        
        // Clean up the safety timer
        if (releaseTimer) {
          clearTimeout(releaseTimer);
          releaseTimer = null;
        }
        
        if (!releaseSuccess) {
          return `Started moving ${direction} but failed to stop completely`;
        }
        
        return `Moved ${direction} for ${duration} seconds`;
      } catch (error) {
        const errorMsg = `Error during ${direction} movement: ${error instanceof Error ? error.message : String(error)}`;
        logger.error(errorMsg);
        
        // Ensure cleanup happens even on error
        if (releaseTimer) {
          clearTimeout(releaseTimer);
        }
        
        // Try to release the input if we got far enough to define inputName
        if (inputName!) {
          try {
            await this.wsClient.sendInput(inputName, 0.0);
            logger.info(`Emergency release of ${inputName} after error`);
          } catch (releaseError) {
            logger.error(`Failed emergency release: ${releaseError instanceof Error ? releaseError.message : String(releaseError)}`);
          }
        }
        
        return errorMsg;
      }
    }
  • Zod input schema validation for move_avatar tool parameters.
    {
      direction: z.enum(['forward', 'backward', 'left', 'right']).describe('Direction to move'),
      duration: z.number().default(1.0).describe('Duration in seconds')
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action is to move the avatar, implying a mutation, but doesn't cover aspects like whether this requires specific permissions, if it's reversible, what happens on collision, or any rate limits. This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words, making it highly efficient and easy to parse. It's appropriately sized for the tool's apparent simplicity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns, potential side effects, or error conditions, leaving the agent with insufficient information for reliable invocation in a complex environment.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% description coverage, fully documenting both parameters (direction with enum values and duration with default). The description adds no additional meaning beyond implying direction is involved, so it meets the baseline of 3 without compensating for any schema gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Move') and the resource ('the avatar'), specifying it's in a direction. However, it doesn't distinguish this from sibling tools like 'jump' or 'look_direction', which might involve similar movement concepts, leaving some ambiguity about unique functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'jump' or 'set_avatar_parameter', nor does it mention any prerequisites or exclusions. This lack of context makes it hard for an agent to choose appropriately among similar tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/Krekun/vrchat-mcp-osc'

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