Skip to main content
Glama
sdiehl
by sdiehl

create_vector_field

Generate vector fields in a specified coordinate system by defining x, y, and z components, aiding in symbolic mathematics and computational algebra workflows.

Instructions

Creates a vector field in the specified coordinate system.

Args:
    coord_sys_name: The name of the coordinate system to use.
    component_x: String expression for the x-component of the vector field.
    component_y: String expression for the y-component of the vector field.
    component_z: String expression for the z-component of the vector field.

Example:
    # First create a coordinate system
    create_coordinate_system("R")

    # Create a vector field F = (y, -x, z)
    vector_field = create_vector_field("R", "R_y", "-R_x", "R_z")

Returns:
    A key for the vector field expression.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
component_xYes
component_yYes
component_zYes
coord_sys_nameYes

Implementation Reference

  • The core handler function for the 'create_vector_field' MCP tool. It parses string expressions for vector components using SymPy, constructs the vector field in the given coordinate system by scaling base vectors, stores it in the global expressions dictionary with a generated key, and returns the key. The @mcp.tool() decorator registers it as an MCP tool, implicitly defining the input schema via type hints.
    @mcp.tool()
    def create_vector_field(
        coord_sys_name: str, component_x: str, component_y: str, component_z: str
    ) -> str:
        """Creates a vector field in the specified coordinate system.
    
        Args:
            coord_sys_name: The name of the coordinate system to use.
            component_x: String expression for the x-component of the vector field.
            component_y: String expression for the y-component of the vector field.
            component_z: String expression for the z-component of the vector field.
    
        Example:
            # First create a coordinate system
            create_coordinate_system("R")
    
            # Create a vector field F = (y, -x, z)
            vector_field = create_vector_field("R", "R_y", "-R_x", "R_z")
    
        Returns:
            A key for the vector field expression.
        """
        global expression_counter
    
        if coord_sys_name not in coordinate_systems:
            return f"Error: Coordinate system '{coord_sys_name}' not found. Create it first using create_coordinate_system."
    
        try:
            cs = coordinate_systems[coord_sys_name]
    
            # Parse the component expressions
            parse_dict = {**local_vars, **functions, coord_sys_name: cs}
            x_comp = parse_expr(component_x, local_dict=parse_dict)
            y_comp = parse_expr(component_y, local_dict=parse_dict)
            z_comp = parse_expr(component_z, local_dict=parse_dict)
    
            # Create the vector field
            vector_field = (
                x_comp * cs.base_vectors()[0]
                + y_comp * cs.base_vectors()[1]
                + z_comp * cs.base_vectors()[2]
            )
    
            # Store the vector field
            result_key = f"vector_{expression_counter}"
            expressions[result_key] = vector_field
            expression_counter += 1
    
            return result_key
        except Exception as e:
            return f"Error creating vector field: {str(e)}"
Behavior2/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 mentions that the tool returns 'A key for the vector field expression,' which provides some behavioral context about the output format. However, it doesn't disclose important behavioral traits like whether this is a state-modifying operation (likely yes, given 'creates'), what happens if the coordinate system doesn't exist, or whether there are any constraints on the string expressions. The example helps but doesn't cover all behavioral aspects.

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 clear sections (purpose, args, example, returns) and appropriately sized. Every sentence earns its place by adding value. The example is particularly helpful. It could be slightly more concise by integrating the example more tightly, but overall it's efficient and well-organized.

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 creating mathematical objects and the complete lack of annotations and output schema, the description does a reasonable job. It explains the purpose, parameters, provides an example, and mentions the return format. However, for a tool that likely modifies system state and has mathematical constraints, it could benefit from more behavioral context about error conditions, expression validation, or how the created vector field integrates with other tools in the system.

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 description provides excellent parameter semantics beyond the input schema. With 0% schema description coverage, the schema only provides titles and types. The description adds crucial meaning: it explains that 'coord_sys_name' is 'The name of the coordinate system to use' and that the component parameters are 'String expression for the x/y/z-component of the vector field.' The example further clarifies how these expressions relate to coordinate system variables. This fully compensates for the lack of schema descriptions.

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: 'Creates a vector field in the specified coordinate system.' This is a specific verb+resource combination that tells the agent exactly what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'create_matrix' or 'create_custom_metric' beyond the obvious difference in resource type.

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 implied usage guidance through the example, showing that a coordinate system must be created first and demonstrating the relationship between coordinate system variables and vector components. However, it doesn't explicitly state when to use this tool versus alternatives like 'create_matrix' or when vector fields are appropriate versus other mathematical constructs.

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

Related 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/sdiehl/sympy-mcp'

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