Skip to main content
Glama

propagate_orbit_j2

Calculate orbital trajectories with J2 gravitational perturbations using numerical integration for aerospace analysis and flight planning.

Instructions

Propagate orbit with J2 perturbations using numerical integration.

Args: initial_state: Initial orbital state (elements or state vector) propagation_time_s: Propagation time in seconds time_step_s: Integration time step in seconds

Returns: JSON string with propagated state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
initial_stateYes
propagation_time_sYes
time_step_sNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler: wrapper function that imports and calls the core propagation logic from integrations, serializes result to JSON.
    def propagate_orbit_j2(
        initial_state: dict, propagation_time_s: float, time_step_s: float = 60.0
    ) -> str:
        """Propagate orbit with J2 perturbations using numerical integration.
    
        Args:
            initial_state: Initial orbital state (elements or state vector)
            propagation_time_s: Propagation time in seconds
            time_step_s: Integration time step in seconds
    
        Returns:
            JSON string with propagated state
        """
        try:
            from ..integrations.orbits import propagate_orbit_j2 as _propagate
    
            result = _propagate(initial_state, propagation_time_s, time_step_s)
    
            return json.dumps(result, indent=2)
    
        except ImportError:
            return "Orbit propagation not available - install orbital packages"
        except Exception as e:
            logger.error(f"Orbit propagation error: {str(e)}", exc_info=True)
            return f"Orbit propagation error: {str(e)}"
  • Core implementation: performs Runge-Kutta 4th order numerical integration of orbit propagation including J2 oblateness perturbation.
    def propagate_orbit_j2(
        initial_state: StateVector, time_span_s: float, time_step_s: float = 60.0
    ) -> list[StateVector]:
        """
        Propagate orbit with J2 perturbations using numerical integration.
    
        Args:
            initial_state: Initial state vector
            time_span_s: Propagation time span (seconds)
            time_step_s: Integration time step (seconds)
    
        Returns:
            List of state vectors over time
        """
    
        def acceleration_j2(r_vec: list[float]) -> list[float]:
            """Calculate acceleration including J2 perturbations."""
            r = vector_magnitude(r_vec)
    
            # Central body acceleration
            a_central = [-MU_EARTH * r_vec[i] / r**3 for i in range(3)]
    
            # J2 perturbation
            factor = 1.5 * J2_EARTH * MU_EARTH * R_EARTH**2 / r**5
            z2_r2 = (r_vec[2] / r) ** 2
    
            a_j2 = [
                factor * r_vec[0] * (1 - 5 * z2_r2),
                factor * r_vec[1] * (1 - 5 * z2_r2),
                factor * r_vec[2] * (3 - 5 * z2_r2),
            ]
    
            return [a_central[i] + a_j2[i] for i in range(3)]
    
        # Initialize
        states = [initial_state]
        r = initial_state.position_m.copy()
        v = initial_state.velocity_ms.copy()
    
        # Parse initial epoch
        try:
            epoch = datetime.fromisoformat(initial_state.epoch_utc.replace("Z", "+00:00"))
        except (ValueError, TypeError):
            epoch = datetime.now(UTC)
    
        # Numerical integration (RK4)
        t = 0.0
        while t < time_span_s:
            dt = min(time_step_s, time_span_s - t)
    
            # RK4 integration
            k1_r = v
            k1_v = acceleration_j2(r)
    
            r2 = [r[i] + 0.5 * dt * k1_r[i] for i in range(3)]
            v2 = [v[i] + 0.5 * dt * k1_v[i] for i in range(3)]
            k2_r = v2
            k2_v = acceleration_j2(r2)
    
            r3 = [r[i] + 0.5 * dt * k2_r[i] for i in range(3)]
            v3 = [v[i] + 0.5 * dt * k2_v[i] for i in range(3)]
            k3_r = v3
            k3_v = acceleration_j2(r3)
    
            r4 = [r[i] + dt * k3_r[i] for i in range(3)]
            v4 = [v[i] + dt * k3_v[i] for i in range(3)]
            k4_r = v4
            k4_v = acceleration_j2(r4)
    
            # Update state
            r = [
                r[i] + dt / 6 * (k1_r[i] + 2 * k2_r[i] + 2 * k3_r[i] + k4_r[i])
                for i in range(3)
            ]
            v = [
                v[i] + dt / 6 * (k1_v[i] + 2 * k2_v[i] + 2 * k3_v[i] + k4_v[i])
                for i in range(3)
            ]
    
            t += dt
    
            # Create new state
            new_epoch = epoch.replace(microsecond=0) + type(epoch - epoch)(seconds=int(t))
    
            states.append(
                StateVector(
                    position_m=r.copy(),
                    velocity_ms=v.copy(),
                    epoch_utc=new_epoch.isoformat(),
                    frame=initial_state.frame,
                )
            )
    
        return states
  • Registers the propagate_orbit_j2 tool with the FastMCP server.
    mcp.tool(propagate_orbit_j2)
  • Tool schema definition including parameters, description, and usage example for LLM agent integration.
    name="propagate_orbit_j2",
    description="Propagate satellite orbit with J2 perturbations",
    parameters={
        "initial_state": "dict - Initial orbital elements or state vector",
        "time_span_s": "float - Propagation time span in seconds",
        "time_step_s": "float - Time step for propagation in seconds (default 300)",
    },
    examples=[
        'propagate_orbit_j2({"semi_major_axis_m": 6793000, "eccentricity": 0.001, "inclination_deg": 51.6, "raan_deg": 0.0, "arg_periapsis_deg": 0.0, "true_anomaly_deg": 0.0, "epoch_utc": "2024-01-01T12:00:00"}, 86400, 600)'
    ],
  • Imports the propagate_orbit_j2 function from tools.orbits for registration in FastMCP server.
    from .tools.orbits import (
        calculate_ground_track,
        elements_to_state_vector,
        hohmann_transfer,
        orbital_rendezvous_planning,
        propagate_orbit_j2,
        state_vector_to_elements,
    )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'numerical integration' and 'J2 perturbations', which gives some technical context, but doesn't disclose critical behavioral traits such as computational intensity, accuracy limitations, error handling, or what 'propagated state' includes. For a complex orbital propagation tool with zero annotation coverage, this is a significant gap.

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 appropriately sized and front-loaded, with the purpose stated first, followed by a structured 'Args' and 'Returns' section. Each sentence earns its place, though the 'Returns' line could be more informative. There's minimal waste, but it could be slightly more detailed without losing conciseness.

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

Completeness3/5

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

Given the complexity of orbital propagation, no annotations, and an output schema (which reduces the need to explain return values), the description is moderately complete. It covers the basic purpose and parameters but lacks behavioral context, error handling, and detailed usage scenarios. The presence of an output schema helps, but more context is needed for a tool of this nature.

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?

Schema description coverage is 0%, so the description must compensate. It lists and briefly describes the three parameters ('initial_state', 'propagation_time_s', 'time_step_s'), adding meaning beyond the schema's minimal titles. However, it doesn't provide details on formats (e.g., what 'elements or state vector' means for 'initial_state'), units beyond seconds, or constraints, leaving gaps in parameter understanding.

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

Purpose4/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: 'Propagate orbit with J2 perturbations using numerical integration.' It specifies the verb ('propagate'), resource ('orbit'), and method ('with J2 perturbations using numerical integration'), which distinguishes it from other orbital tools like 'hohmann_transfer' or 'orbital_rendezvous_planning'. However, it doesn't explicitly differentiate from potential siblings with similar functionality, though none are listed.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, typical use cases, or comparisons to other tools like 'rocket_3dof_trajectory' or 'trajectory_sensitivity_analysis'. The context is implied through the tool's name and description, but explicit usage guidelines are absent.

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/cheesejaguar/aerospace-mcp'

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