Skip to main content
Glama

cocos_scaffold_input_abstraction

Generate a unified keyboard and touch input manager for Cocos Creator games, providing stable runtime APIs for movement, jumping, and firing actions.

Instructions

Generate InputManager.ts + meta - unified keyboard/touch input singleton.

The generated script exposes a stable runtime API that other game scripts read each frame::

InputManager.I.moveDir       // cc.Vec2, normalized, x/y in -1..1
                             //   WASD + arrows; diagonals scaled 0.707
InputManager.I.jumpPressed   // boolean, true for exactly one frame
                             //   after SPACE press; reset in lateUpdate
InputManager.I.firePressed   // boolean, true for one frame after
                             //   KEY_J or any touch-start

Singleton pattern: attach to exactly one persistent GameManager-like node. Extra instances self-destroy in onLoad.

Typical flow::

r = cocos_scaffold_input_abstraction(project)
# r["uuid_compressed"] is the 23-char form the scene needs
cocos_add_script(scene, gm_node_id, r["uuid_compressed"])

Returns {path, rel_path, uuid_standard, uuid_compressed}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYes
rel_pathNoInputManager.ts
Behavior4/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 effectively describes key behaviors: the generated script exposes a runtime API with specific properties (e.g., moveDir, jumpPressed), follows a singleton pattern with self-destruction for extra instances, and returns a structured object with paths and UUIDs. It covers essential traits like mutation (generation), integration flow, and output format, though it lacks details on error handling or permissions.

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

Conciseness4/5

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

The description is well-structured and front-loaded with the core purpose, followed by API details, behavioral notes, and a usage example. Each sentence adds value, such as explaining the singleton pattern and return values. It could be slightly more concise by reducing repetition in the API examples, but overall, it avoids unnecessary fluff and is efficiently organized.

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

Completeness4/5

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

Given the complexity of generating a script with runtime behavior, no annotations, and no output schema, the description is largely complete. It covers the tool's purpose, behavioral traits, parameters in context, and integration steps. However, it lacks explicit error handling, performance considerations, or detailed output schema explanation, which would enhance completeness for a scaffolding tool.

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 description coverage is 0%, but the description compensates by explaining the parameters in context. It mentions 'project' in the typical flow example, implying 'project_path', and 'rel_path' is shown with a default value ('InputManager.ts'). However, it does not fully detail parameter meanings, such as what 'project_path' expects or constraints on 'rel_path', leaving some ambiguity beyond the schema's basic types.

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

Purpose5/5

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

The description clearly states the tool's purpose: 'Generate InputManager.ts + meta - unified keyboard/touch input singleton.' It specifies the verb ('Generate'), resource ('InputManager.ts + meta'), and distinguishes it from siblings by focusing on input abstraction rather than UI components or other scaffolding tools like 'cocos_scaffold_audio_controller' or 'cocos_scaffold_player_controller'.

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

Usage Guidelines4/5

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

The description provides clear usage context with a 'Typical flow' section, showing how to integrate the generated script into a scene using sibling tools like 'cocos_add_script'. However, it does not explicitly state when not to use this tool or mention alternatives, such as other input handling methods or sibling tools like 'cocos_add_button' for UI input.

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

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/chenShengBiao/cocos-mcp'

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