Skip to main content
Glama

variable_set

Create or update an environment variable to set configuration values, update connection strings, or manage service secrets.

Instructions

[API] Create or update an environment variable

⚡️ Best for: ✓ Setting configuration values ✓ Updating connection strings ✓ Managing service secrets

⚠️ Not for: × Bulk variable updates (use variable_bulk_set) × Temporary configuration changes

→ Prerequisites: service_list

→ Alternatives: variable_bulk_set

→ Next steps: deployment_trigger, service_restart

→ Related: variable_list, variable_delete

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesID of the project containing the service
environmentIdYesID of the environment for the variable (usually obtained from service_list)
nameYesName of the environment variable
valueYesValue to set for the variable
serviceIdNoOptional: ID of the service for the variable, if omitted creates/updates a shared variable

Implementation Reference

  • The handler function for the 'variable_set' tool. It calls variableService.upsertVariable() with projectId, environmentId, name, value, and optional serviceId.
    async ({ projectId, environmentId, name, value, serviceId }) => {
      return variableService.upsertVariable(projectId, environmentId, name, value, serviceId);
    }
  • The Zod schema defining input parameters for variable_set: projectId, environmentId, name, value (all required strings), and serviceId (optional string).
    {
      projectId: z.string().describe("ID of the project containing the service"),
      environmentId: z.string().describe("ID of the environment for the variable (usually obtained from service_list)"),
      name: z.string().describe("Name of the environment variable"),
      value: z.string().describe("Value to set for the variable"),
      serviceId: z.string().optional().describe("Optional: ID of the service for the variable, if omitted creates/updates a shared variable")
    },
  • Registration of all tools (including variable_set) with the MCP server via server.tool().
    allTools.forEach((tool) => {
      server.tool(
        ...tool
      );
    });
  • The upsertVariable() method in VariableService that executes the actual API call to set/update a variable.
    async upsertVariable(projectId: string, environmentId: string, name: string, value: string, serviceId?: string) {
      try {
        await this.client.variables.upsertVariable({
          projectId,
          environmentId,
          name,
          value,
          serviceId
        });
    
        const variableType = serviceId ? "service variable" : "shared environment variable";
        return createSuccessResponse({
          text: `Successfully set ${variableType} "${name}"`
        });
      } catch (error) {
        return createErrorResponse(`Error setting variable: ${formatError(error)}`);
      }
    }
  • The createTool() function from utils/tools.ts that wraps the name, description, schema, and handler into a tuple.
    createTool(
      "list_service_variables",
      formatToolDescription({
        type: 'API',
        description: "List all environment variables for a service",
        bestFor: [
          "Viewing service configuration",
          "Auditing environment variables",
          "Checking connection strings"
        ],
        relations: {
          prerequisites: ["service_list"],
          nextSteps: ["variable_set", "variable_delete"],
          related: ["service_info", "variable_bulk_set"]
Behavior3/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. It indicates a mutable operation (create/update) but does not detail whether the update is idempotent, if it overwrites existing values, or any permission/rate limit constraints. While not misleading, more behavioral context would be beneficial.

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 using bullet points and arrows, making it scannable. Every sentence adds value (best for, not for, prerequisites, etc.). It is slightly long but justified given the guidance it provides.

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?

Given the 5 parameters, no output schema, and no annotations, the description provides good contextual completeness: it explains when to use vs not, prerequisites, and related tools. It does not cover return values but that is acceptable without an output schema. Some behavioral details are missing (e.g., overwrite behavior) but overall it's fairly complete.

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 coverage is 100%, so the baseline is 3. The description does not add parameter-level details beyond what the schema already provides. For example, it mentions 'serviceId' is optional but doesn't clarify when to use it over a shared variable.

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 'Create or update an environment variable', providing a specific verb and resource. It also explicitly distinguishes from sibling tool 'variable_bulk_set' in the 'Not for' section, eliminating ambiguity.

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

Usage Guidelines5/5

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

The description includes explicit 'Best for' and 'Not for' sections, a prerequisite ('service_list'), alternatives ('variable_bulk_set'), and even next steps ('deployment_trigger', 'service_restart'), giving clear guidance on when and how to use the tool.

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/jason-tan-swe/railway-mcp'

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