Skip to main content
Glama
IBM

Physics MCP Server

by IBM

calculate_torque

Calculates torque as the cross product of force and position vectors. Find the rotational force magnitude and direction in N⋅m.

Instructions

Calculate torque from force and position: τ = r × F (cross product).

Torque is the rotational equivalent of force. It causes angular acceleration
and depends on both the force magnitude and the distance from the pivot point.

Args:
    force_x: X component of force in Newtons
    force_y: Y component of force in Newtons
    force_z: Z component of force in Newtons
    position_x: X component of position vector from pivot to force application (meters)
    position_y: Y component of position vector from pivot to force application (meters)
    position_z: Z component of position vector from pivot to force application (meters)

Returns:
    Dict containing:
        - torque: Torque vector [x, y, z] in N⋅m
        - magnitude: Torque magnitude in N⋅m

Tips for LLMs:
    - Torque direction follows right-hand rule (perpendicular to force and position)
    - Maximum torque when force is perpendicular to position vector
    - Zero torque when force is parallel to position vector
    - Use for: wrenches, door hinges, motors, gears

Example - Opening a door:
    result = await calculate_torque(
        force_x=50.0,  # Push perpendicular to door
        force_y=0.0,
        force_z=0.0,
        position_x=0.0,
        position_y=0.0,
        position_z=0.8  # 0.8m from hinge
    )
    # Torque = 40 N⋅m

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
force_xYes
force_yYes
force_zYes
position_xYes
position_yYes
position_zYes

Implementation Reference

  • Core torque calculation logic: computes cross product r × F and magnitude
    def calculate_torque(request: TorqueRequest) -> TorqueResponse:
        """Calculate torque from force and position: τ = r × F (cross product).
    
        Args:
            request: Torque calculation request
    
        Returns:
            Torque vector and magnitude
        """
        r = request.position
        f = request.force
    
        # Cross product: r × F
        torque = [
            r[1] * f[2] - r[2] * f[1],  # x component
            r[2] * f[0] - r[0] * f[2],  # y component
            r[0] * f[1] - r[1] * f[0],  # z component
        ]
    
        magnitude = math.sqrt(sum(t * t for t in torque))
    
        return TorqueResponse(torque=torque, magnitude=magnitude)
  • Pydantic models for torque request (force + position vectors) and response (torque vector + magnitude)
    class TorqueRequest(BaseModel):
        """Request for torque calculation."""
    
        force: list[float] = Field(..., description="Force vector [x, y, z] in Newtons")
        position: list[float] = Field(
            ..., description="Position vector from pivot to force application [x, y, z] in meters"
        )
    
    
    class TorqueResponse(BaseModel):
        """Response for torque calculation."""
    
        torque: list[float] = Field(..., description="Torque vector [x, y, z] in N⋅m")
        magnitude: float = Field(..., description="Torque magnitude in N⋅m")
  • MCP tool endpoint: wraps the core calculate_torque with individual float params, decorated with @tool
    @tool  # type: ignore[arg-type]
    async def calculate_torque(
        force_x: float,
        force_y: float,
        force_z: float,
        position_x: float,
        position_y: float,
        position_z: float,
    ) -> dict:
        """Calculate torque from force and position: τ = r × F (cross product).
    
        Torque is the rotational equivalent of force. It causes angular acceleration
        and depends on both the force magnitude and the distance from the pivot point.
    
        Args:
            force_x: X component of force in Newtons
            force_y: Y component of force in Newtons
            force_z: Z component of force in Newtons
            position_x: X component of position vector from pivot to force application (meters)
            position_y: Y component of position vector from pivot to force application (meters)
            position_z: Z component of position vector from pivot to force application (meters)
    
        Returns:
            Dict containing:
                - torque: Torque vector [x, y, z] in N⋅m
                - magnitude: Torque magnitude in N⋅m
    
        Tips for LLMs:
            - Torque direction follows right-hand rule (perpendicular to force and position)
            - Maximum torque when force is perpendicular to position vector
            - Zero torque when force is parallel to position vector
            - Use for: wrenches, door hinges, motors, gears
    
        Example - Opening a door:
            result = await calculate_torque(
                force_x=50.0,  # Push perpendicular to door
                force_y=0.0,
                force_z=0.0,
                position_x=0.0,
                position_y=0.0,
                position_z=0.8  # 0.8m from hinge
            )
            # Torque = 40 N⋅m
        """
        from ..rotational import TorqueRequest, calculate_torque as calc_torque
    
        request = TorqueRequest(
            force=[force_x, force_y, force_z],
            position=[position_x, position_y, position_z],
        )
        response = calc_torque(request)
        return response.model_dump()
  • Tools package imports rotational module, which registers the @tool decorated calculate_torque via server.py's import
    from . import (
        basic,
        circular_motion,
        collisions,
        conservation,
        fluid,
        kinematics_tools,
        oscillations,
        rotational,
        statics,
    )
    
    __all__ = [
        "rotational",
        "oscillations",
        "circular_motion",
        "collisions",
        "conservation",
        "kinematics_tools",
        "statics",
        "fluid",
        "basic",
    ]
  • server.py imports tools.rotational module, triggering @tool registration of calculate_torque as an MCP tool
    from .tools import (
        basic,
        rotational,
        oscillations,
        circular_motion,
        collisions,
        conservation,
        fluid as fluid_tools,
        kinematics_tools,
        statics,
        convert_units as unit_conversion_tools,
    )
Behavior4/5

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

No annotations are provided, so the description carries the burden. It explains the math, return values (torque vector and magnitude), and physical conditions (right-hand rule, max/zero torque). It does not mention side effects or permissions, but for a pure calculation tool this is sufficient.

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 with a formula, explanation, Args, Returns, Tips, and Example. It is slightly verbose (e.g., listing all vector components in Args), but the organization is clear and front-loaded.

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

Completeness5/5

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

Given the simplicity of the tool (vector cross product), the description covers the calculation, parameter meanings, return format, and usage context comprehensively. No gaps are apparent.

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?

The schema has 0% description coverage, but the description provides full parameter explanations with units (Newtons, meters) and implicit meaning (force components, position vector components). This compensates completely.

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 'Calculate torque from force and position: τ = r × F (cross product).' It specifies the exact operation and distinguishes it from sibling tools by focusing on torque specifically.

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 includes tips and an example for common use (opening a door) but does not explicitly exclude alternative tools for related concepts like angular momentum or rotational inertia.

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/IBM/chuk-mcp-physics'

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