set_emote_parameter
Set VRCEmote on the current avatar by defining a specific value, enabling AI-driven avatar interaction and control in VRChat using the Model Context Protocol.
Instructions
Set VRCEmote on the current avatar.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| value | Yes | Value to set |
Implementation Reference
- packages/mcp-server/src/server.ts:448-484 (registration)Registration of the 'set_emote_parameter' tool, including Zod input schema for 'value' (number or string) and the handler function that parses the value to number and delegates to avatarTools.setParameter('VRCEmote', ...) with context.// Register avatar parameter tools server.tool( 'set_emote_parameter', 'Set VRCEmote on the current avatar.', { value: z.union([z.number(),z.string()]).describe('Value to set') }, async ({value }, extra) => { try { const ctx = createToolContext(extra); // 文字列が数値として解析可能な場合は数値に変換 let value_con: number; if (typeof value === 'string') { // 数値として解析を試みる value_con = Number(value); // 変換できなかった場合(NaNの場合)はエラーを投げる if (isNaN(value_con)) { throw new Error(`文字列 "${value}" を数値に変換できませんでした`); } } else { value_con = value; } const result = await avatarTools.setParameter('VRCEmote', value_con, ctx); return { content: [{ type: 'text', text: result }] }; } catch (error) { return { content: [{ type: 'text', text: `Error setting parameter: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- Core handler logic for setting avatar parameters (including VRCEmote for set_emote_parameter). Performs validation, logging via context, up to 3 retry attempts with exponential backoff when calling wsClient.setAvatarParameter, and returns success/error messages.public async setParameter( parameterName: string, value: ParameterValue, ctx?: ToolContext ): Promise<string> { if (!parameterName) { const errorMsg = 'Missing parameter name'; logger.error(errorMsg); if (ctx) await ctx.error(errorMsg); return errorMsg; } // // Validate value type // if (typeof value !== 'number' && typeof value !== 'boolean') { // const errorMsg = `Invalid parameter value type: ${typeof value} (must be number or boolean)`; // logger.error(errorMsg); // if (ctx) await ctx.error(errorMsg); // return errorMsg; // } if (ctx) { await ctx.info(`Setting avatar parameter ${parameterName} to ${value}`); } try { // Multiple retry attempts let attempts = 0; const maxAttempts = 3; while (attempts < maxAttempts) { attempts++; logger.info(`Setting parameter ${parameterName}=${value} (attempt ${attempts}/${maxAttempts})`); try { // Set parameter with timeout const success = await this.wsClient.setAvatarParameter(parameterName, value); if (success) { const successMsg = `Successfully set ${parameterName} to ${value}`; logger.info(successMsg); return successMsg; } else { logger.warn(`Failed to set parameter ${parameterName} (attempt ${attempts})`); // Try again if we have attempts left if (attempts < maxAttempts) { const delay = 300 * attempts; // Increasing delay for each retry logger.info(`Retrying in ${delay}ms...`); await new Promise(resolve => setTimeout(resolve, delay)); } } } catch (error) { logger.warn(`Error setting parameter ${parameterName} (attempt ${attempts}): ${error instanceof Error ? error.message : String(error)}`); // Try again if we have attempts left if (attempts < maxAttempts) { const delay = 300 * attempts; // Increasing delay for each retry logger.info(`Retrying in ${delay}ms...`); await new Promise(resolve => setTimeout(resolve, delay)); } } } // All attempts failed const failMsg = `Failed to set ${parameterName} after ${maxAttempts} attempts`; logger.error(failMsg); return failMsg; } catch (error) { const errorMsg = `Error setting parameter ${parameterName}: ${error instanceof Error ? error.message : String(error)}`; logger.error(errorMsg); return errorMsg; } }
- Reference to 'VRCEmote' parameter in fallback list of common VRChat avatar parameters.'VRCEmote',