Skip to main content
Glama

set_avatar

Change to a specific avatar in VRChat using its unique ID, enabling AI-driven avatar control within virtual reality environments through the MCP server.

Instructions

Change to a specific avatar.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
avatar_idYesID of the avatar to change to

Implementation Reference

  • Core handler function in AvatarTools class that executes the avatar change logic, including validation, logging, retry mechanism (up to 3 attempts), and delegation to wsClient.setAvatar.
    public async setAvatar(
      avatarId: string,
      ctx?: ToolContext
    ): Promise<string> {
      if (!avatarId) {
        const errorMsg = 'Missing avatar ID';
        logger.error(errorMsg);
        if (ctx) await ctx.error(errorMsg);
        return errorMsg;
      }
    
      if (ctx) {
        await ctx.info(`Changing avatar to ${avatarId}`);
      }
    
      try {
        // Multiple retry attempts
        let attempts = 0;
        const maxAttempts = 3;
    
        while (attempts < maxAttempts) {
          attempts++;
          logger.info(`Changing avatar to ${avatarId} (attempt ${attempts}/${maxAttempts})`);
    
          try {
          //   // Get available avatars
          //   const avatars = await this.wsClient.getAvatarlist();
          //   if (!avatars || !avatars[avatarId]) {
          //     throw new Error(`Avatar ${avatarId} not found in available avatars`);
          //   }
    
            // Send avatar change request using the new method
            const success = await this.wsClient.setAvatar(avatarId);
    
            if (success) {
              // const successMsg = `Successfully changed avatar to ${avatars[avatarId]} (${avatarId})`;
              const successMsg = `Successfully changed avatar to (${avatarId})`;
              logger.info(successMsg);
              return successMsg;
            } else {
              logger.warn(`Failed to change avatar (attempt ${attempts})`);
    
              // Try again if we have attempts left
              if (attempts < maxAttempts) {
                const delay = 300 * attempts;
                logger.info(`Retrying in ${delay}ms...`);
                await new Promise(resolve => setTimeout(resolve, delay));
              }
            }
          } catch (error) {
            logger.warn(`Error changing avatar (attempt ${attempts}): ${error instanceof Error ? error.message : String(error)}`);
    
            // Try again if we have attempts left
            if (attempts < maxAttempts) {
              const delay = 300 * attempts;
              logger.info(`Retrying in ${delay}ms...`);
              await new Promise(resolve => setTimeout(resolve, delay));
            }
          }
        }
    
        // All attempts failed
        const failMsg = `Failed to change avatar after ${maxAttempts} attempts`;
        logger.error(failMsg);
        return failMsg;
      } catch (error) {
        const errorMsg = `Error changing avatar: ${error instanceof Error ? error.message : String(error)}`;
        logger.error(errorMsg);
        return errorMsg;
      }
    }
  • MCP server.tool() registration for the 'set_avatar' tool, including description, input schema validation with Zod, and thin async handler that creates context and delegates to avatarTools.setAvatar with error handling.
    server.tool(
      'set_avatar',
      'Change to a specific avatar.',
      {
        avatar_id: z.string().describe('ID of the avatar to change to')
      },
      async ({ avatar_id }, extra) => {
        try {
          const ctx = createToolContext(extra);
          const result = await avatarTools.setAvatar(avatar_id, ctx);
          return { content: [{ type: 'text', text: result }] };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `Error changing avatar: ${error instanceof Error ? error.message : String(error)}`
            }],
            isError: true
          };
        }
      }
    );
  • Zod input schema for the set_avatar tool, defining the required 'avatar_id' parameter as a string.
    {
      avatar_id: z.string().describe('ID of the avatar to change to')
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden. 'Change to a specific avatar' implies a mutation but does not disclose behavioral traits such as permissions required, whether the change is reversible, effects on other avatar states, or error handling. This is inadequate for a mutation tool with zero annotation coverage.

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, efficient sentence with no wasted words. It is front-loaded and directly states the tool's purpose, making it easy to parse quickly.

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 the tool's complexity (a mutation with no annotations and no output schema), the description is insufficient. It lacks details on behavioral aspects, usage context, and expected outcomes, failing to compensate for the absence of structured data. This leaves significant gaps for an agent to understand and invoke the tool correctly.

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?

Schema description coverage is 100%, with the parameter 'avatar_id' documented as 'ID of the avatar to change to'. The description adds no additional meaning beyond this, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the schema handles parameter documentation adequately.

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 'Change to a specific avatar' clearly states the action (change) and resource (avatar), distinguishing it from sibling tools like get_avatar_list (list) or move_avatar (move). However, it lacks specificity about what 'change' entails compared to set_avatar_parameter, which might adjust avatar attributes rather than switching avatars entirely.

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. It does not mention prerequisites (e.g., needing an avatar list first), exclusions, or comparisons to siblings like set_avatar_parameter or move_avatar, leaving the agent to infer usage context.

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