Skip to main content
Glama

Reviewer MCP

by jaggederest
exec-base.ts1.41 kB
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js'; import { exec } from 'child_process'; import { promisify } from 'util'; import { createErrorResult, createSuccessResult } from './base.js'; import { formatExecOutput } from '../utils/formatters.js'; const execAsync = promisify(exec); export abstract class BaseExecTool<T = unknown> { protected abstract getActionName(): string; protected abstract buildCommand(args: T): Promise<string> | string; async execute(args: T): Promise<CallToolResult> { try { const command = await this.buildCommand(args); let output = ''; let error = ''; let exitCode = 0; try { const result = await execAsync(command, { cwd: process.cwd(), env: process.env, maxBuffer: 1024 * 1024 * 10, }); output = result.stdout; error = result.stderr; } catch (execError) { const err = execError as { stdout?: string; stderr?: string; message?: string; code?: number }; output = err.stdout ?? ''; error = err.stderr ?? err.message ?? 'Unknown error'; exitCode = err.code ?? 1; } const formattedOutput = formatExecOutput(output, error, exitCode, this.getActionName()); return createSuccessResult(formattedOutput); } catch (error) { return createErrorResult(this.getActionName(), error); } } }

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/jaggederest/mcp_reviewer'

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