Skip to main content
Glama
heroku

Heroku MCP server

Official
by heroku

deploy_to_heroku

Deploy applications to Heroku by automating git push workflows. Use to create or update apps, configure team or private space deployments, and set environment-specific settings. Requires valid app.json for dynamic configurations.

Instructions

Deploy projects to Heroku, replaces manual git push workflows. Use this tool when you need to: 1) Deploy a new application with specific app.json configuration, 2) Update an existing application with new code, 3) Configure team or private space deployments, or 4) Set up environment-specific configurations. The tool handles app creation, source code deployment, and environment setup. Requires valid app.json in workspace or provided via configuration. Supports team deployments, private spaces, and custom environment variables.Use apps_list tool with the "all" param to get a list of apps for the user to choose from when deploying to an existing app and the app name was not provided.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appJsonNoStringified app.json configuration for deployment. Used for dynamic configurations or converted projects. The app.json string must be valid and conform to the following schema: {"default":{"$schema":"http://json-schema.org/draft-07/schema#","title":"Heroku app.json Schema","description":"app.json is a manifest format for describing web apps. It declares environment variables, add-ons, and other information required to run an app on Heroku. Used for dynamic configurations or converted projects","type":"object","properties":{"name":{"type":"string","pattern":"^[a-zA-Z-_\\.]+","maxLength":300},"description":{"type":"string"},"keywords":{"type":"array","items":{"type":"string"}},"website":{"$ref":"#/definitions/uriString"},"repository":{"$ref":"#/definitions/uriString"},"logo":{"$ref":"#/definitions/uriString"},"success_url":{"type":"string"},"scripts":{"$ref":"#/definitions/scripts"},"env":{"$ref":"#/definitions/env"},"formation":{"$ref":"#/definitions/formation"},"addons":{"$ref":"#/definitions/addons"},"buildpacks":{"$ref":"#/definitions/buildpacks"},"environments":{"$ref":"#/definitions/environments"},"stack":{"$ref":"#/definitions/stack"},"image":{"type":"string"}},"additionalProperties":false,"definitions":{"uriString":{"type":"string","format":"uri"},"scripts":{"type":"object","properties":{"postdeploy":{"type":"string"},"pr-predestroy":{"type":"string"}},"additionalProperties":false},"env":{"type":"object","patternProperties":{"^[A-Z][A-Z0-9_]*$":{"type":"object","properties":{"description":{"type":"string"},"value":{"type":"string"},"required":{"type":"boolean"},"generator":{"type":"string","enum":["secret"]}},"additionalProperties":false}}},"dynoSize":{"type":"string","enum":["free","eco","hobby","basic","standard-1x","standard-2x","performance-m","performance-l","private-s","private-m","private-l","shield-s","shield-m","shield-l"]},"formation":{"type":"object","patternProperties":{"^[a-zA-Z0-9_-]+$":{"type":"object","properties":{"quantity":{"type":"integer","minimum":0},"size":{"$ref":"#/definitions/dynoSize"}},"required":["quantity"],"additionalProperties":false}}},"addons":{"type":"array","items":{"oneOf":[{"type":"string"},{"type":"object","properties":{"plan":{"type":"string"},"as":{"type":"string"},"options":{"type":"object"}},"required":["plan"],"additionalProperties":false}]}},"buildpacks":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"}},"required":["url"],"additionalProperties":false}},"environmentConfig":{"type":"object","properties":{"env":{"type":"object"},"formation":{"type":"object"},"addons":{"type":"array"},"buildpacks":{"type":"array"}}},"environments":{"type":"object","properties":{"test":{"allOf":[{"$ref":"#/definitions/environmentConfig"},{"type":"object","properties":{"scripts":{"type":"object","properties":{"test":{"type":"string"}},"additionalProperties":false}}}]},"review":{"$ref":"#/definitions/environmentConfig"},"production":{"$ref":"#/definitions/environmentConfig"}},"additionalProperties":false},"stack":{"type":"string","enum":["heroku-18","heroku-20","heroku-22","heroku-24"]}}}}
envNoKey-value pairs of environment variables for the deployment that override the ones in app.json
internalRoutingNoEnables internal routing within private spaces. Use this flag when you need to configure private spaces for internal routing.
nameYesHeroku application name for deployment target. If omitted, a new app will be created with a random name. If supplied and the app does not exist, the tool will create a new app with the given name.
rootUriYesThe absolute path of the user's workspace unless otherwise specified by the user. Must be a string that can be resolved to a valid directory using node's path module.
spaceIdNoHeroku private space identifier for space-scoped deployments. Use spaces_list tool to get a list of spaces if needed.
tarballUriNoThe URL of the tarball to deploy. If not provided, the rootUri must be provided and the tool will create a new tarball from the contents of the rootUri.
teamIdNoHeroku team identifier for team-scoped deployments. Use teams_list tool to get a list of teams if needed.

Implementation Reference

  • The handler function registered for the 'deploy_to_heroku' tool. It processes input parameters, instantiates DeployToHeroku class, executes the deployment, and returns MCP tool response.
    async (options: DeployToHerokuParams): Promise<McpToolResponse> => {
      const deployToHeroku = new DeployToHeroku();
      const result = await deployToHeroku.run({
        rootUri: options.rootUri,
        tarballUri: options.tarballUri,
        name: options.name,
        teamId: options.teamId,
        spaceId: options.spaceId,
        internalRouting: options.internalRouting,
        env: options.env as EnvironmentVariables,
        appJson: options.appJson ? new TextEncoder().encode(options.appJson) : undefined
      });
    
      if (result?.errorMessage) {
        return {
          success: false,
          message: result.errorMessage,
          content: [{ type: 'text', text: result.errorMessage }]
        };
      }
    
      const successMessage = `Successfully deployed to ${result?.name ?? 'Heroku'}`;
      return {
        success: true,
        message: successMessage,
        content: [{ type: 'text', text: successMessage }],
        data: result
      };
    }
  • Zod schema defining the input parameters for the deploy_to_heroku tool, including app name, workspace path, tarball URI, team/space IDs, routing, env vars, and app.json config.
    export const deployToHerokuSchema = z
      .object({
        name: z.string().min(5).max(30).describe('App name for deployment. Creates new app if not exists.'),
        rootUri: z.string().min(1).describe('Workspace root directory path.'),
        tarballUri: z.string().optional().describe('URL of deployment tarball. Creates from rootUri if not provided.'),
        teamId: z.string().optional().describe('Team ID for team deployments.'),
        spaceId: z.string().optional().describe('Private space ID for space deployments.'),
        internalRouting: z.boolean().optional().describe('Enable internal routing in private spaces.'),
        env: z.record(z.string(), z.any()).optional().describe('Environment variables overriding app.json values'),
        appJson: z
          .string()
          .describe(`App.json config for deployment. Must follow schema: ${JSON.stringify(appJsonSchema, null, 0)}`)
      })
      .strict();
  • Registration function for the deploy_to_heroku tool that calls server.tool() with name, description, schema, and handler.
    export const registerDeployToHerokuTool = (server: McpServer): void => {
      server.tool(
        'deploy_to_heroku',
        'Use for all deployments. Deploys new/existing apps, with or without teams/spaces, and env vars to Heroku. ' +
          'Ask for app name if missing. Requires valid app.json via appJson param.',
        deployToHerokuSchema.shape,
        async (options: DeployToHerokuParams): Promise<McpToolResponse> => {
          const deployToHeroku = new DeployToHeroku();
          const result = await deployToHeroku.run({
            rootUri: options.rootUri,
            tarballUri: options.tarballUri,
            name: options.name,
            teamId: options.teamId,
            spaceId: options.spaceId,
            internalRouting: options.internalRouting,
            env: options.env as EnvironmentVariables,
            appJson: options.appJson ? new TextEncoder().encode(options.appJson) : undefined
          });
    
          if (result?.errorMessage) {
            return {
              success: false,
              message: result.errorMessage,
              content: [{ type: 'text', text: result.errorMessage }]
            };
          }
    
          const successMessage = `Successfully deployed to ${result?.name ?? 'Heroku'}`;
          return {
            success: true,
            message: successMessage,
            content: [{ type: 'text', text: successMessage }],
            data: result
          };
        }
      );
    };
  • src/index.ts:99-99 (registration)
    Invocation of the registerDeployToHerokuTool function to register the tool with the main MCP server.
    deployToHeroku.registerDeployToHerokuTool(server);
  • Core handler method in DeployToHeroku class that performs the actual Heroku deployment: tarball handling, app setup/build creation, git remote addition.
    protected async deployToHeroku(): Promise<(Build & { name: string }) | null> {
      const { tarballUri, rootUri, appJson } = this.deploymentOptions;
    
      let blobUrl = tarballUri?.toString();
    
      // Create and use an amazon s3 bucket and
      // then upload the newly created tarball
      // from the local sources if no tarballUri was provided.
      if (!blobUrl) {
        const generatedAppJson = appJson ? [{ relativePath: './app.json', contents: appJson }] : [];
        const tarball = await packSources(rootUri!, generatedAppJson);
        const { source_blob: sourceBlob } = await this.sourcesService.create(this.requestInit);
        blobUrl = sourceBlob!.get_url!;
        try {
          const response = await fetch(sourceBlob!.put_url!, {
            method: 'PUT',
            body: tarball
          });
    
          if (!response.ok) {
            const uploadErrorMessage = `Error uploading tarball to S3 bucket. The server responded with: ${response.status} - ${response.statusText}`;
            throw new Error(uploadErrorMessage);
          }
        } catch (error) {
          throw new DeploymentError((error as Error).message);
        }
      }
      // The user has right-clicked on a
      // Procfile or app.json or has used
      // the deploy to heroku decorator button
      // and we have apps in the remote. Ask
      // the user where to deploy.
    
      const result = this.isExistingDeployment
        ? await this.createNewBuildForExistingApp(blobUrl, this.deploymentOptions.name ?? '')
        : await this.setupNewApp(blobUrl);
    
      // This is a new app setup and needs a git remote
      // added to the workspace.
      if (!this.isExistingDeployment && result) {
        // Add the new remote to the workspace
        const app = await this.appService.info(result.name, this.requestInit);
        try {
          execSync(`git remote add heroku-${result.name} ${app.git_url!}`, { cwd: rootUri! });
        } catch {
          // Ignore
        }
      }
      return result;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden and does well by disclosing key behavioral traits: it 'replaces manual git push workflows,' 'handles app creation, source code deployment, and environment setup,' and specifies requirements like 'Requires valid app.json in workspace or provided via configuration.' It mentions support for 'team deployments, private spaces, and custom environment variables,' but lacks details on error handling, rate limits, or authentication needs, keeping it from a perfect score.

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, starting with the core purpose and key use cases. However, the last sentence about apps_list is slightly redundant with parameter descriptions in the schema, and some phrasing could be tighter (e.g., 'Use this tool when you need to:' list is verbose). Overall, it's efficient with minimal waste.

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 tool's complexity (8 parameters, no output schema, no annotations), the description is fairly complete. It covers purpose, usage scenarios, behavioral context, and references to sibling tools. However, it lacks details on output format, error cases, or authentication requirements, which would enhance completeness for such a multifaceted deployment tool.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal parameter semantics beyond the schema, such as implying app.json usage and referencing sibling tools for parameter values (e.g., apps_list for app name). This meets the baseline of 3, as the schema does the heavy lifting without significant added value from the description.

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 the tool's purpose with specific verbs and resources: 'Deploy projects to Heroku, replaces manual git push workflows' and 'handles app creation, source code deployment, and environment setup.' It distinguishes from siblings by focusing on deployment rather than listing, creating, or managing resources like create_app or list_apps.

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 provides explicit usage scenarios: 'Use this tool when you need to: 1) Deploy a new application..., 2) Update an existing application..., 3) Configure team or private space deployments, or 4) Set up environment-specific configurations.' It also references sibling tools (apps_list, spaces_list, teams_list) for prerequisites, offering clear alternatives and 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

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/heroku/heroku-mcp-server'

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