Skip to main content
Glama
tool.py2.95 kB
# chuk-motion/src/chuk_motion/components/animations/Counter/tool.py """Counter MCP tool.""" import asyncio from chuk_motion.generator.composition_builder import ComponentInstance from chuk_motion.models import CounterComponentResponse, ErrorResponse def register_tool(mcp, project_manager): """Register the Counter tool with the MCP server.""" @mcp.tool async def remotion_add_counter( end_value: float, start_value: float = 0, prefix: str | None = None, suffix: str | None = None, decimals: int = 0, animation: str | None = None, duration: float | str = 2.0, track: str = "main", gap_before: float | str | None = None, ) -> str: """ Add Counter to the composition. Animated number counter for statistics and metrics Args: end_value: Ending number start_value: Starting number (default: 0) prefix: Text before number (e.g., "$") suffix: Text after number (e.g., "%") decimals: Number of decimal places (integer) animation: Animation style duration: Duration in seconds or time string (e.g., "2s", "500ms") track: Track name (default: "main") gap_before: Gap before component in seconds or time string Returns: JSON with component info """ def _add(): if not project_manager.current_timeline: return ErrorResponse( error="No active project. Create a project first." ).model_dump_json() try: component = ComponentInstance( component_type="Counter", start_frame=0, duration_frames=0, props={ "start_value": start_value, "end_value": end_value, "prefix": prefix, "suffix": suffix, "decimals": decimals, "animation": animation, }, layer=0, ) component = project_manager.current_timeline.add_component( component, duration=duration, track=track, gap_before=gap_before ) return CounterComponentResponse( component="Counter", start_value=start_value, end_value=end_value, start_time=project_manager.current_timeline.frames_to_seconds( component.start_frame ), duration=duration, ).model_dump_json() except Exception as e: return ErrorResponse(error=str(e)).model_dump_json() return await asyncio.get_event_loop().run_in_executor(None, _add)

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/chrishayuk/chuk-mcp-remotion'

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