Skip to main content
Glama
IBM

Physics MCP Server

by IBM

calculate_jerk

Calculate jerk, the rate of change of acceleration, from time series acceleration data. Useful for assessing ride comfort and mechanical stress.

Instructions

Calculate jerk (rate of change of acceleration).

Jerk = da/dt is important for comfort in vehicles and mechanical design.

Args:
    times: Time values in seconds (or JSON string)
    accelerations: Acceleration vectors [[x,y,z], ...] in m/s² (or JSON string)

Returns:
    Dict containing:
        - jerks: Jerk vectors [[x,y,z], ...] in m/s³
        - average_jerk: Average jerk [x,y,z] in m/s³
        - max_jerk_magnitude: Maximum jerk magnitude in m/s³

Example:
    result = await calculate_jerk(
        times=[0, 1, 2, 3],
        accelerations=[[0,0,0], [2,0,0], [4,0,0], [6,0,0]]
    )
    # jerk_x ≈ 2 m/s³ (constant)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timesYes
accelerationsYes

Implementation Reference

  • Core handler function that calculates jerk (da/dt) from acceleration data. Uses _numerical_derivative for differentiation and _vector_magnitude for max jerk calculation. Returns JerkCalculationResponse with jerks, average_jerk, and max_jerk_magnitude.
    def calculate_jerk(request: JerkCalculationRequest) -> JerkCalculationResponse:
        """Calculate jerk (da/dt) from acceleration data.
    
        Jerk is the rate of change of acceleration.
    
        Args:
            request: Acceleration and time data
    
        Returns:
            Jerk values
        """
        if len(request.accelerations) != len(request.times):
            raise ValueError("Number of accelerations must equal number of times")
    
        if len(request.accelerations) < 2:
            raise ValueError("Need at least 2 data points for jerk calculation")
    
        # Calculate jerks
        jerks = _numerical_derivative(request.accelerations, request.times)
    
        # Calculate average and max
        avg_jerk = [sum(j[i] for j in jerks) / len(jerks) for i in range(3)]
        max_jerk = max(_vector_magnitude(j) for j in jerks)
    
        return JerkCalculationResponse(
            jerks=jerks,
            average_jerk=avg_jerk,
            max_jerk_magnitude=max_jerk,
        )
  • JerkCalculationRequest schema: accepts accelerations (list of 3D vectors) and times (list of floats) as input fields.
    class JerkCalculationRequest(BaseModel):
        """Request for jerk (rate of change of acceleration) calculation."""
    
        accelerations: list[list[float]] = Field(
            ..., description="List of acceleration vectors [x, y, z] in m/s²"
        )
        times: list[float] = Field(..., description="Time values in seconds")
  • JerkCalculationResponse schema: returns jerks (list of 3D vectors), average_jerk (3D vector), and max_jerk_magnitude (float).
    class JerkCalculationResponse(BaseModel):
        """Response for jerk calculation."""
    
        jerks: list[list[float]] = Field(..., description="Calculated jerk vectors [x, y, z] in m/s³")
        average_jerk: list[float] = Field(..., description="Average jerk [x, y, z] in m/s³")
        max_jerk_magnitude: float = Field(..., description="Maximum jerk magnitude in m/s³")
  • MCP tool wrapper for calculate_jerk. Handles JSON string parsing, delegates to core function in kinematics.py. Decorated with @tool for MCP registration.
    @tool  # type: ignore[arg-type]
    async def calculate_jerk(
        times: Union[list[float], str],
        accelerations: Union[list[list[float]], str],
    ) -> dict:
        """Calculate jerk (rate of change of acceleration).
    
        Jerk = da/dt is important for comfort in vehicles and mechanical design.
    
        Args:
            times: Time values in seconds (or JSON string)
            accelerations: Acceleration vectors [[x,y,z], ...] in m/s² (or JSON string)
    
        Returns:
            Dict containing:
                - jerks: Jerk vectors [[x,y,z], ...] in m/s³
                - average_jerk: Average jerk [x,y,z] in m/s³
                - max_jerk_magnitude: Maximum jerk magnitude in m/s³
    
        Example:
            result = await calculate_jerk(
                times=[0, 1, 2, 3],
                accelerations=[[0,0,0], [2,0,0], [4,0,0], [6,0,0]]
            )
            # jerk_x ≈ 2 m/s³ (constant)
        """
        from ..kinematics import JerkCalculationRequest, calculate_jerk as calc_jerk
    
        # Parse inputs
        parsed_times = json.loads(times) if isinstance(times, str) else times
        parsed_accelerations = (
            json.loads(accelerations) if isinstance(accelerations, str) else accelerations
        )
    
        request = JerkCalculationRequest(
            times=parsed_times,
            accelerations=parsed_accelerations,
        )
        response = calc_jerk(request)
        return response.model_dump()
  • _numerical_derivative helper: computes numerical derivatives using central differences (forward/backward at boundaries). Used by calculate_jerk to compute da/dt.
    def _numerical_derivative(values: list[list[float]], times: list[float]) -> list[list[float]]:
        """Calculate numerical derivative using central differences."""
        if len(values) < 2:
            return [[0.0] * len(values[0])]
    
        derivatives = []
    
        for i in range(len(values)):
            if i == 0:
                # Forward difference for first point
                dt = times[1] - times[0]
                deriv = [(values[1][j] - values[0][j]) / dt for j in range(len(values[0]))]
            elif i == len(values) - 1:
                # Backward difference for last point
                dt = times[-1] - times[-2]
                deriv = [(values[-1][j] - values[-2][j]) / dt for j in range(len(values[0]))]
            else:
                # Central difference for interior points
                dt = times[i + 1] - times[i - 1]
                deriv = [(values[i + 1][j] - values[i - 1][j]) / dt for j in range(len(values[0]))]
    
            derivatives.append(deriv)
    
        return derivatives
Behavior4/5

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

With no annotations, the description does well by explaining the calculation formula, input requirements (times in seconds, accelerations in m/s²), and the detailed return structure. However, it does not disclose potential error conditions or input validation.

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 well-structured with a concise definition, parameter explanation, return format, and a clear code example. Every sentence adds value without redundancy.

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?

The description covers purpose, parameters, and returns in sufficient detail for a pure calculation tool. It lacks output schema but compensates by explicitly listing returned fields. Minor omission: no mention of error handling or input constraints.

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 only specifies type 'string' for both parameters, leaving 0% coverage. The description adds essential meaning: times are in seconds, accelerations are vector arrays in m/s², and both can be passed as JSON strings. This vastly compensates for 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 'Calculate jerk (rate of change of acceleration)' with a specific verb and resource. It explains the physical importance and differentiates from sibling tools like calculate_angular_acceleration by focusing on linear jerk in 3D.

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

Usage Guidelines3/5

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

The description provides context with an example but lacks explicit guidance on when to use this tool versus alternatives like calculate_acceleration_from_position. No exclusions or prerequisites are mentioned.

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