Skip to main content
Glama

cocos_add_physics_body2d

Add a physics body with a collider shape to a Cocos Creator 2D node in a single call, replacing the two-step process for attaching rigid bodies and colliders separately.

Instructions

Attach cc.RigidBody2D + a shape collider in one call.

Replaces the 2-call pattern every Bird / Pipe / Enemy needed:

rb = cocos_add_rigidbody2d(scene, node, body_type=2, ...)
col = cocos_add_box_collider2d(scene, node, width=W, ...)

shape picks the collider: "box" / "circle" / "polygon". The relevant shape knobs (width×height / radius / points) are read based on the choice; the others are ignored. Raises ValueError on unknown shape rather than silently attaching a default.

body_type: 0=Static, 1=Kinematic, 2=Dynamic (default).

Returns {rigidbody_id, collider_id, shape}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scene_pathYes
node_idYes
shapeNobox
body_typeNo
gravity_scaleNo
linear_dampingNo
angular_dampingNo
fixed_rotationNo
bulletNo
awake_on_loadNo
densityNo
frictionNo
restitutionNo
is_sensorNo
tagNo
offset_xNo
offset_yNo
widthNo
heightNo
radiusNo
pointsNo
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: it's a creation/mutation tool (implied by 'attach'), specifies error handling ('Raises ValueError on unknown shape'), explains parameter interaction ('relevant shape knobs are read based on the choice; the others are ignored'), and details the return value. However, it doesn't cover aspects like side effects, performance, or permission requirements, which could be relevant for a physics body 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 front-loaded with the core purpose, followed by usage context, parameter details, and return value. Every sentence adds value: the first states the purpose, the second provides usage context, the third explains shape parameter, the fourth covers body_type, the fifth adds error behavior, and the sixth specifies the return. There is no wasted text.

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?

For a complex tool with 21 parameters, no annotations, and no output schema, the description does a very good job. It covers purpose, usage, key parameters, error handling, and return value. However, given the high parameter count, it doesn't explain all parameters (e.g., gravity_scale, linear_damping), leaving some semantics undocumented, which is a minor gap in completeness.

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

Parameters5/5

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

Given the schema description coverage is 0%, the description must compensate, which it does excellently. It explains the 'shape' parameter with specific values ('box', 'circle', 'polygon') and how they affect other parameters. It details 'body_type' with numeric mappings (0=Static, 1=Kinematic, 2=Dynamic). It also clarifies parameter dependencies and defaults, adding significant meaning beyond the bare schema.

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: 'Attach cc.RigidBody2D + a shape collider in one call.' It specifies the verb ('attach'), the resources (RigidBody2D and collider), and distinguishes it from sibling tools by explicitly contrasting with the 2-call pattern using cocos_add_rigidbody2d and cocos_add_box_collider2d, which are listed as siblings.

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

Usage Guidelines5/5

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

The description provides explicit usage guidelines: it states when to use this tool ('Replaces the 2-call pattern every Bird / Pipe / Enemy needed') and names specific alternatives (cocos_add_rigidbody2d and cocos_add_box_collider2d). It also implies when not to use it by suggesting the separate tools for more granular control.

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