pg_outliers
Identify and optimize resource-intensive database operations on Heroku MCP server. Analyze slow queries, track performance patterns, and improve database workload efficiency.
Instructions
Identify resource-intensive database operations. Use this tool when you need to: 1) Find slow or expensive queries, 2) Analyze query performance patterns, 3) Optimize database workload, 4) Track query statistics over time. The tool helps identify opportunities for performance optimization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app | Yes | The name of the Heroku app whose query statistics to analyze. | |
| database | No | Config 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. | |
| num | No | The number of queries to display. Defaults to 10. | |
| reset | No | When true, resets statistics gathered by pg_stat_statements. | |
| truncate | No | When true, truncates queries to 40 characters. |
Implementation Reference
- src/tools/data.ts:266-279 (handler)Handler function that constructs the 'heroku pg:outliers' command using CommandBuilder with options, executes it via HerokuREPL, and returns processed output.async (options: PgOutliersOptions): Promise<McpToolResponse> => { const command = new CommandBuilder(TOOL_COMMAND_MAP.PG_OUTLIERS) .addFlags({ app: options.app, num: options.num?.toString(), reset: options.reset, truncate: options.truncate }) .addPositionalArguments({ database: options.database }) .build(); const output = await herokuRepl.executeCommand(command); return handleCliOutput(output); }
- src/tools/data.ts:72-81 (schema)Zod schema defining the input parameters for the pg_outliers tool, including app, num, reset, truncate, and database.export const pgOutliersOptionsSchema = z.object({ app: z.string().describe('Target app name'), num: z.number().optional().describe('Number of queries to show. Default: 10'), reset: z.boolean().optional().describe('Reset pg_stat_statements stats'), truncate: z.boolean().optional().describe('Truncate queries to 40 chars'), database: z .string() .optional() .describe('Database identifier. Format: APP_NAME::DB for other apps. Default: DATABASE_URL') });
- src/tools/data.ts:261-281 (registration)Registration function that registers the 'pg_outliers' tool with the MCP server, providing name, description, schema, and handler.export const registerPgOutliersTool = (server: McpServer, herokuRepl: HerokuREPL): void => { server.tool( 'pg_outliers', 'Find resource-heavy queries: performance, patterns, optimization', pgOutliersOptionsSchema.shape, async (options: PgOutliersOptions): Promise<McpToolResponse> => { const command = new CommandBuilder(TOOL_COMMAND_MAP.PG_OUTLIERS) .addFlags({ app: options.app, num: options.num?.toString(), reset: options.reset, truncate: options.truncate }) .addPositionalArguments({ database: options.database }) .build(); const output = await herokuRepl.executeCommand(command); return handleCliOutput(output); } ); };
- src/index.ts:80-80 (registration)Invocation of the pg_outliers tool registration during server initialization.data.registerPgOutliersTool(server, herokuRepl);
- src/utils/tool-commands.ts:35-35 (helper)Constant mapping the PG_OUTLIERS key to the Heroku CLI command 'pg:outliers' used in the tool handler.PG_OUTLIERS: 'pg:outliers',