create_coordinate_system
Define and generate a 3D coordinate system for vector calculus operations, allowing custom coordinate names or default labels for x, y, z axes.
Instructions
Creates a 3D coordinate system for vector calculus operations.
Args:
name: The name for the coordinate system.
coord_names: Optional list of coordinate names (3 names for x, y, z).
If not provided, defaults to [name+'_x', name+'_y', name+'_z'].
Example:
# Create a coordinate system
coord_sys = create_coordinate_system("R")
# Creates a coordinate system R with coordinates R_x, R_y, R_z
# Create a coordinate system with custom coordinate names
coord_sys = create_coordinate_system("C", ["rho", "phi", "z"])
Returns:
The name of the created coordinate system.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coord_names | No | ||
| name | Yes |
Implementation Reference
- server.py:1079-1131 (handler)Handler function for the 'create_coordinate_system' MCP tool. Creates a SymPy CoordSys3D object, stores it in coordinate_systems dict, adds to expressions and local_vars.@mcp.tool() def create_coordinate_system(name: str, coord_names: Optional[List[str]] = None) -> str: """Creates a 3D coordinate system for vector calculus operations. Args: name: The name for the coordinate system. coord_names: Optional list of coordinate names (3 names for x, y, z). If not provided, defaults to [name+'_x', name+'_y', name+'_z']. Example: # Create a coordinate system coord_sys = create_coordinate_system("R") # Creates a coordinate system R with coordinates R_x, R_y, R_z # Create a coordinate system with custom coordinate names coord_sys = create_coordinate_system("C", ["rho", "phi", "z"]) Returns: The name of the created coordinate system. """ if name in coordinate_systems: return f"Warning: Overwriting existing coordinate system '{name}'." try: if coord_names and len(coord_names) != 3: return "Error: coord_names must contain exactly 3 names for x, y, z coordinates." if coord_names: # Create a CoordSys3D with custom coordinate names cs = CoordSys3D(name, variable_names=coord_names) else: # Create a CoordSys3D with default coordinate naming cs = CoordSys3D(name) coordinate_systems[name] = cs # Add the coordinate system to the expressions dict to make it accessible # in expressions through parsing expressions[name] = cs # Add the coordinate variables to local_vars for easier access for i, base_vector in enumerate(cs.base_vectors()): vector_name = ( f"{name}_{['x', 'y', 'z'][i]}" if not coord_names else f"{name}_{coord_names[i]}" ) local_vars[vector_name] = base_vector return name except Exception as e: return f"Error creating coordinate system: {str(e)}"