Skip to main content
Glama

github_secrets_set

Securely set GitHub Actions secrets to manage sensitive data in CI/CD pipelines. This tool helps configure environment variables and authentication tokens for automated workflows.

Instructions

Set a GitHub Actions secret (value will be securely stored)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main execution logic for the github_secrets_set tool. Validates the secret name format, masks the value for logging, constructs the gh secret set command, executes it using runCommand, and returns success/error messages with guidance.
      async ({ name, value, repo, env }) => {
        // Validate secret name
        if (!/^[A-Z][A-Z0-9_]*$/.test(name)) {
          return {
            content: [{
              type: "text",
              text: `Invalid secret name: "${name}"
    
    Rules:
    - Must be UPPERCASE
    - Must start with a letter
    - Can only contain A-Z, 0-9, and _
    
    Examples: API_KEY, DATABASE_URL, AWS_ACCESS_KEY_ID`
            }]
          };
        }
    
        // Warn about potentially sensitive values being logged
        const maskedValue = value.substring(0, 3) + "***" + value.substring(value.length - 3);
    
        const repoFlag = repo ? `-R ${repo}` : "";
        const envFlag = env ? `--env ${env}` : "";
    
        // Use echo with pipe to avoid showing value in process list
        const result = await runCommand(
          `echo "${value.replace(/"/g, '\\"')}" | gh secret set ${name} ${repoFlag} ${envFlag}`,
          { timeout: 30000 }
        );
    
        if (!result.success) {
          let help = "";
          if (result.stderr?.includes("unauthorized") || result.stderr?.includes("401")) {
            help = "\n\nAuthentication issue. Try: gh auth login";
          } else if (result.stderr?.includes("404") || result.stderr?.includes("not found")) {
            help = "\n\nRepository not found. Check the repo name or make sure you have access.";
          }
    
          return {
            content: [{
              type: "text",
              text: `Failed to set secret!\n\nError: ${result.stderr || result.error}${help}`
            }]
          };
        }
    
        const location = env ? `environment "${env}"` : "repository";
    
        return {
          content: [{
            type: "text",
            text: `Secret set successfully!
    
    Name: ${name}
    Value: ${maskedValue}
    Location: ${location}${repo ? ` (${repo})` : ""}
    
    TO USE IN GITHUB ACTIONS:
    \`\`\`yaml
    env:
      MY_VAR: \${{ secrets.${name} }}
    
    # Or in a step:
    - name: Use secret
      run: echo "Using secret"
      env:
        ${name}: \${{ secrets.${name} }}
    \`\`\`
    
    SECURITY NOTES:
    - Secrets are encrypted and never shown in logs
    - Secrets are not passed to workflows from forks
    - Use environment secrets for production credentials`
          }]
        };
      }
  • Input schema defining the parameters for the github_secrets_set tool: name (required string), value (required string), repo (optional string), env (optional string).
    {
      name: { type: "string", description: "Secret name (uppercase with underscores, e.g., API_KEY)" },
      value: { type: "string", description: "Secret value" },
      repo: { type: "string", description: "Repository (owner/repo format)", default: "" },
      env: { type: "string", description: "Environment name (optional, for environment-specific secrets)", default: "" }
    },
  • src/index.js:1878-1964 (registration)
    MCP server.tool registration for the github_secrets_set tool, including name, description, input schema, and handler function.
    server.tool(
      "github_secrets_set",
      "Set a GitHub Actions secret (value will be securely stored)",
      {
        name: { type: "string", description: "Secret name (uppercase with underscores, e.g., API_KEY)" },
        value: { type: "string", description: "Secret value" },
        repo: { type: "string", description: "Repository (owner/repo format)", default: "" },
        env: { type: "string", description: "Environment name (optional, for environment-specific secrets)", default: "" }
      },
      async ({ name, value, repo, env }) => {
        // Validate secret name
        if (!/^[A-Z][A-Z0-9_]*$/.test(name)) {
          return {
            content: [{
              type: "text",
              text: `Invalid secret name: "${name}"
    
    Rules:
    - Must be UPPERCASE
    - Must start with a letter
    - Can only contain A-Z, 0-9, and _
    
    Examples: API_KEY, DATABASE_URL, AWS_ACCESS_KEY_ID`
            }]
          };
        }
    
        // Warn about potentially sensitive values being logged
        const maskedValue = value.substring(0, 3) + "***" + value.substring(value.length - 3);
    
        const repoFlag = repo ? `-R ${repo}` : "";
        const envFlag = env ? `--env ${env}` : "";
    
        // Use echo with pipe to avoid showing value in process list
        const result = await runCommand(
          `echo "${value.replace(/"/g, '\\"')}" | gh secret set ${name} ${repoFlag} ${envFlag}`,
          { timeout: 30000 }
        );
    
        if (!result.success) {
          let help = "";
          if (result.stderr?.includes("unauthorized") || result.stderr?.includes("401")) {
            help = "\n\nAuthentication issue. Try: gh auth login";
          } else if (result.stderr?.includes("404") || result.stderr?.includes("not found")) {
            help = "\n\nRepository not found. Check the repo name or make sure you have access.";
          }
    
          return {
            content: [{
              type: "text",
              text: `Failed to set secret!\n\nError: ${result.stderr || result.error}${help}`
            }]
          };
        }
    
        const location = env ? `environment "${env}"` : "repository";
    
        return {
          content: [{
            type: "text",
            text: `Secret set successfully!
    
    Name: ${name}
    Value: ${maskedValue}
    Location: ${location}${repo ? ` (${repo})` : ""}
    
    TO USE IN GITHUB ACTIONS:
    \`\`\`yaml
    env:
      MY_VAR: \${{ secrets.${name} }}
    
    # Or in a step:
    - name: Use secret
      run: echo "Using secret"
      env:
        ${name}: \${{ secrets.${name} }}
    \`\`\`
    
    SECURITY NOTES:
    - Secrets are encrypted and never shown in logs
    - Secrets are not passed to workflows from forks
    - Use environment secrets for production credentials`
          }]
        };
      }
    );
  • Helper function runCommand used by the tool to execute shell commands safely, including timeout and error handling.
    async function runCommand(cmd, options = {}) {
      try {
        const { stdout, stderr } = await execAsync(cmd, { timeout: 30000, ...options });
        return { success: true, stdout: stdout.trim(), stderr: stderr.trim() };
      } catch (error) {
        return { success: false, error: error.message, stdout: error.stdout?.trim(), stderr: error.stderr?.trim() };
      }
    }
  • Exported handler function in tools.js (noted for testing), identical logic to the main handler.
    export async function githubSecretsSet({ name, value, repo, env }) {
      if (!/^[A-Z][A-Z0-9_]*$/.test(name)) {
        return {
          content: [{
            type: "text",
            text: `Invalid secret name: "${name}"\n\nRules:\n- Must be UPPERCASE\n- Must start with a letter\n- Can only contain A-Z, 0-9, and _`
          }]
        };
      }
    
      const maskedValue = value.substring(0, 3) + "***" + value.substring(value.length - 3);
      const repoFlag = repo ? `-R ${repo}` : "";
      const envFlag = env ? `--env ${env}` : "";
    
      const result = await commandRunner(
        `echo "${value.replace(/"/g, '\\"')}" | gh secret set ${name} ${repoFlag} ${envFlag}`,
        { timeout: 30000 }
      );
    
      if (!result.success) {
        return {
          content: [{
            type: "text",
            text: `Failed to set secret!\n\nError: ${result.stderr || result.error}`
          }]
        };
      }
    
      const location = env ? `environment "${env}"` : "repository";
    
      return {
        content: [{
          type: "text",
          text: `Secret set successfully!\n\nName: ${name}\nValue: ${maskedValue}\nLocation: ${location}`
        }]
      };
    }
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It mentions secure storage, which is useful, but lacks details on permissions needed, whether the operation is idempotent, error handling, or any rate limits. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any unnecessary words, making it well-structured and front-loaded.

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

Completeness2/5

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

For a mutation tool with no annotations, no output schema, and no parameters, the description is incomplete. It lacks critical details such as required authentication, scope of the secret (e.g., repository or organization level), and what happens on success or failure, leaving significant gaps for an AI agent.

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?

Since there are 0 parameters and schema description coverage is 100%, the baseline is 4. The description adds no parameter-specific information, but this is acceptable as no parameters exist to document.

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 ('Set') and resource ('GitHub Actions secret'), specifying that the value will be securely stored. However, it does not explicitly differentiate from its sibling 'github_secrets_delete' or 'github_secrets_list', which would require mentioning deletion or listing as alternatives.

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 like 'github_secrets_delete' or 'github_secrets_list', nor does it mention prerequisites or context for setting secrets in GitHub Actions workflows.

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/rideRTD/RTD-DevOps'

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