Skip to main content
Glama

create_variable

Create and store variables in Prefect workflows by specifying a name, value, and optional tags for data persistence and reuse across automation tasks.

Instructions

Create a variable.

Args: name: The variable name value: The variable value (can be string, dict, list, etc.) tags: Optional tags

Returns: Details of the created variable

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
tagsNo
valueYes

Implementation Reference

  • The main handler function for the 'create_variable' MCP tool. It is decorated with @mcp.tool, which handles both registration and schema inference from the type hints and docstring. The function creates a Prefect variable using the Prefect client and returns the result as MCP TextContent.
    @mcp.tool
    async def create_variable(
        name: str,
        value: Any,
        tags: Optional[List[str]] = None,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        """
        Create a variable.
        
        Args:
            name: The variable name
            value: The variable value (can be string, dict, list, etc.)
            tags: Optional tags
            
        Returns:
            Details of the created variable or error message
        """
        try:
            async with get_client() as client:
                from prefect.client.schemas.actions import VariableCreate
                
                # Create the proper variable object
                variable_create = VariableCreate(
                    name=name,
                    value=value,
                    tags=tags or []
                )
                
                variable = await client.create_variable(variable=variable_create)
                
                variable_result = {"variable": variable.model_dump()}
                return [types.TextContent(type="text", text=json.dumps(variable_result, indent=2, default=str))]
        except Exception as e:
            return [types.TextContent(type="text", text=json.dumps({"error": str(e)}, indent=2))]
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 states 'Create a variable' which implies a write/mutation operation, but doesn't disclose any behavioral traits such as permissions required, whether creation is idempotent, what happens on duplicate names, rate limits, or error conditions. The return statement mentions 'Details of the created variable' but doesn't specify format or content.

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 core purpose in the first sentence. The Args/Returns structure is clear and organized, though slightly verbose for such a simple tool. Every sentence earns its place by explaining parameters and return value, but could be more tightly integrated into a single paragraph.

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 3 parameters with 0% schema coverage and no annotations or output schema, the description provides adequate basics but lacks depth. It covers what the tool does and parameter meanings, but misses behavioral context (permissions, idempotency, errors) and doesn't fully explain the return value format. For a creation tool with no structured support, this is minimally viable but incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/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 provides meaningful semantics for all three parameters: 'name' as the variable name, 'value' with type examples (string, dict, list, etc.), and 'tags' as optional tags. This adds significant value beyond the bare schema, though it doesn't specify constraints like name format or tag structure. With 0% schema coverage, this is strong compensation.

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 action ('Create') and resource ('a variable'), making the purpose immediately understandable. It distinguishes from siblings like 'get_variable', 'update_variable', and 'delete_variable' by specifying creation rather than retrieval, modification, or deletion. However, it doesn't explicitly contrast with 'get_variables' or specify what type of variable system this is (e.g., workflow variables vs. environment variables).

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?

No guidance is provided on when to use this tool versus alternatives. While the name implies creation, there's no mention of prerequisites (e.g., whether variables must be unique), when not to use it (e.g., if a variable already exists), or explicit alternatives like 'update_variable' for modifications. The description assumes the context is obvious without providing usage context.

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/allen-munsch/mcp-prefect'

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