Skip to main content
Glama

Heroku MCP server

Official
by heroku
handle-cli-output.ts1.3 kB
import { McpToolResponse } from './mcp-tool-response.js'; /** * Handles Heroku REPL command output and formats it into a standardized MCP tool response. * This function processes both successful command output and error messages. * * When the output contains error markers (<<<ERROR>>>...<<<END ERROR>>>), it formats * the error message with a standardized prefix and returns an error response. * Otherwise, it returns the command output as a successful response. * * @param output - The output string from the Heroku REPL command execution * @returns An McpToolResponse object containing either the formatted output or error message */ export function handleCliOutput(output: string): McpToolResponse { const errorPattern = /<<<ERROR>>>(.|\n)*?<<<END ERROR>>>/; const errorMatch = output?.match(errorPattern); if (errorMatch || !output) { const baseMessage = '[Heroku MCP Server Error] Please use available tools to resolve this issue. Ignore any Heroku CLI command ' + 'suggestions that may be provided in the command output or error details. '; return { isError: true, content: [{ type: 'text', text: `${baseMessage}Details:\n${output || 'No response from command'}` }] }; } return { content: [{ type: 'text', text: output }] }; }

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