Skip to main content
Glama
heroku

Heroku MCP server

Official
by heroku

pg_upgrade

Upgrade PostgreSQL database versions safely for Heroku apps. Plan migration paths, verify compatibility, and execute controlled upgrades with confirmation protection to ensure a secure transition.

Instructions

Upgrade PostgreSQL database version. Use this tool when you need to: 1) Migrate to a newer PostgreSQL version, 2) Plan version upgrade paths, 3) Execute controlled version migrations, 4) Verify upgrade compatibility. The tool manages safe database version upgrades with confirmation protection.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appYesThe name of the Heroku app whose database to upgrade.
confirmNoConfirmation string required for this potentially destructive operation.
databaseNoConfig var containing the connection string, unique name, ID, or alias of the database. To access another app's database, prepend the app name to the config var or alias with `APP_NAME::`. If omitted, DATABASE_URL is used.
versionNoPostgreSQL version to upgrade to

Implementation Reference

  • The async handler function for the 'pg_upgrade' tool. It builds a CommandBuilder for 'pg:upgrade', adds flags for app, version, confirm, positional database, executes via herokuRepl, and returns handled CLI output.
    async (options: PgUpgradeOptions): Promise<McpToolResponse> => { const command = new CommandBuilder(TOOL_COMMAND_MAP.PG_UPGRADE) .addFlags({ app: options.app, version: options.version, confirm: options.confirm }) .addPositionalArguments({ database: options.database }) .build(); const output = await herokuRepl.executeCommand(command); return handleCliOutput(output); }
  • Zod schema pgUpgradeOptionsSchema defining input parameters for the pg_upgrade tool (app, optional version, confirm, database) and the inferred PgUpgradeOptions type.
    export const pgUpgradeOptionsSchema = z.object({ app: z.string().describe('Target app name'), version: z.string().optional().describe('PostgreSQL version target'), confirm: z.string().optional().describe('Confirmation for destructive operation'), database: z .string() .optional() .describe('Database identifier. Format: APP_NAME::DB for other apps. Default: DATABASE_URL') }); export type PgUpgradeOptions = z.infer<typeof pgUpgradeOptionsSchema>;
  • The registerPgUpgradeTool function that registers the 'pg_upgrade' tool on the MCP server with name, description, input schema shape, and handler function.
    export const registerPgUpgradeTool = (server: McpServer, herokuRepl: HerokuREPL): void => { server.tool( 'pg_upgrade', 'Upgrade PostgreSQL: version migration, compatibility, safety', pgUpgradeOptionsSchema.shape, async (options: PgUpgradeOptions): Promise<McpToolResponse> => { const command = new CommandBuilder(TOOL_COMMAND_MAP.PG_UPGRADE) .addFlags({ app: options.app, version: options.version, confirm: options.confirm }) .addPositionalArguments({ database: options.database }) .build(); const output = await herokuRepl.executeCommand(command); return handleCliOutput(output); } ); };
  • TOOL_COMMAND_MAP.PG_UPGRADE constant providing the Heroku CLI command string 'pg:upgrade' used by the handler's CommandBuilder.
    PG_UPGRADE: 'pg:upgrade',
  • src/index.ts:85-85 (registration)
    Call to registerPgUpgradeTool during MCP server initialization to add the pg_upgrade tool.
    data.registerPgUpgradeTool(server, herokuRepl);

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