UNPKG

@entro314labs/ai-changelog-generator

Version:

AI-powered changelog generator with MCP server support - works with most providers, online and local models

203 lines (202 loc) 7.87 kB
#!/usr/bin/env node /** * AI Changelog Generator MCP Server * Provides Model Context Protocol interface for changelog generation */ import * as z from 'zod'; import { ApplicationService } from '../../application/services/application.service.js'; export declare function normalizeChangelogResult(result: any, metadata?: Record<string, any>): { content: any; metadata: any; } | null; /** * Per-tool server-side time budgets, in milliseconds. Composed with the client's * own cancellation signal at dispatch. */ export declare const TOOL_TIMEOUTS: Record<string, number>; /** * Single source of truth for the tool surface: `registerTools` builds the server * from this, and the manifest-alignment test reads the same object, so the * advertised tools and the packaged manifest cannot drift apart. * * Schemas are Zod (SDK v2 derives the JSON Schema clients see, and validates * arguments before a handler runs). */ export declare const TOOL_DEFINITIONS: { readonly generate_changelog: { readonly title: 'Generate changelog'; readonly description: 'Generate AI-powered changelog from commits or working directory changes'; readonly inputSchema: z.ZodObject<{ repositoryPath: z.ZodOptional<z.ZodString>; source: z.ZodDefault<z.ZodEnum<{ auto: "auto"; commits: "commits"; "working-dir": "working-dir"; }>>; since: z.ZodOptional<z.ZodString>; tagRange: z.ZodOptional<z.ZodString>; author: z.ZodOptional<z.ZodString>; version: z.ZodOptional<z.ZodString>; analysisMode: z.ZodDefault<z.ZodEnum<{ detailed: "detailed"; enterprise: "enterprise"; standard: "standard"; }>>; format: z.ZodDefault<z.ZodEnum<{ html: "html"; json: "json"; markdown: "markdown"; }>>; template: z.ZodOptional<z.ZodEnum<{ github: "github"; "keep-a-changelog": "keep-a-changelog"; semantic: "semantic"; simple: "simple"; standard: "standard"; }>>; model: z.ZodOptional<z.ZodString>; includeAIAnalysis: z.ZodDefault<z.ZodBoolean>; includeAttribution: z.ZodDefault<z.ZodBoolean>; writeFile: z.ZodDefault<z.ZodBoolean>; }, z.core.$strip>; readonly outputSchema: z.ZodObject<{ version: z.ZodOptional<z.ZodString>; source: z.ZodOptional<z.ZodString>; since: z.ZodOptional<z.ZodString>; format: z.ZodOptional<z.ZodString>; analyzedCommits: z.ZodOptional<z.ZodNumber>; workingDirectoryChanges: z.ZodOptional<z.ZodNumber>; outputFile: z.ZodOptional<z.ZodString>; }, z.core.$strip>; }; readonly analyze_repository: { readonly title: 'Analyze repository'; readonly description: 'Comprehensive repository analysis including health, commits, and branches'; readonly inputSchema: z.ZodObject<{ repositoryPath: z.ZodOptional<z.ZodString>; analysisType: z.ZodDefault<z.ZodEnum<{ branches: "branches"; commits: "commits"; comprehensive: "comprehensive"; health: "health"; "working-dir": "working-dir"; }>>; includeRecommendations: z.ZodDefault<z.ZodBoolean>; commitLimit: z.ZodDefault<z.ZodNumber>; since: z.ZodOptional<z.ZodString>; author: z.ZodOptional<z.ZodString>; tagRange: z.ZodOptional<z.ZodString>; }, z.core.$strip>; }; readonly analyze_current_changes: { readonly title: 'Analyze current changes'; readonly description: 'Analyze staged and unstaged changes in working directory'; readonly inputSchema: z.ZodObject<{ repositoryPath: z.ZodOptional<z.ZodString>; includeAIAnalysis: z.ZodDefault<z.ZodBoolean>; includeAttribution: z.ZodDefault<z.ZodBoolean>; }, z.core.$strip>; }; readonly configure_providers: { readonly title: 'Configure providers'; readonly description: 'Manage AI providers - list, switch, test, and configure'; readonly inputSchema: z.ZodObject<{ action: z.ZodDefault<z.ZodEnum<{ configure: "configure"; list: "list"; switch: "switch"; test: "test"; validate: "validate"; }>>; provider: z.ZodOptional<z.ZodEnum<{ anthropic: "anthropic"; auto: "auto"; azure: "azure"; bedrock: "bedrock"; "github-copilot": "github-copilot"; google: "google"; huggingface: "huggingface"; lmstudio: "lmstudio"; ollama: "ollama"; openai: "openai"; "vercel-gateway": "vercel-gateway"; vertex: "vertex"; }>>; testConnection: z.ZodDefault<z.ZodBoolean>; }, z.core.$strip>; }; }; declare class AIChangelogMCPServer { [key: string]: any; constructor(); initializeServer(): void; initializeServices(): void; redirectStdoutLoggingToStderr(): void; /** * Register every tool on the McpServer. * * The SDK derives the advertised JSON Schema from these Zod schemas and * validates arguments BEFORE the handler runs, so handlers no longer hand-check * their inputs. `outputSchema` additionally makes the result machine-readable: * clients get `structuredContent` alongside the human-facing text block. */ registerTools(): void; /** * Shared execution wrapper: applies the per-tool time budget, resolves the * repository path, and converts thrown errors into MCP error results. * * Cancellation composes two sources — the client's own cancellation * (`ctx.mcpReq.signal`) and a server-side time budget. Passing the combined * signal down means a timed-out or cancelled call stops before performing * durable side effects, rather than completing a write after the caller has * already been told it failed and possibly retried. */ runTool(name: any, args?: Record<string, any>, ctx?: any): Promise<any>; createApplicationService(repositoryPath: any): Promise<ApplicationService>; generateChangelog(args: any, signal?: AbortSignal): Promise<{ content: { type: string; text: any; }[]; structuredContent: { version?: any; source?: any; since?: any; format: any; analyzedCommits?: any; workingDirectoryChanges?: any; outputFile?: any; }; }>; analyzeRepository(args: any): Promise<{ content: { type: string; text: string; }[]; }>; analyzeCurrentChanges(args: any): Promise<{ content: { type: string; text: string; }[]; }>; configureProviders(args: any): Promise<{ content: { type: string; text: string; }[]; }>; hasWorkingDirectoryChanges(repositoryPath?: string): Promise<boolean>; formatError(error: any, toolName: any): { content: { type: string; text: string; }[]; isError: boolean; }; createShutdownPromise(): any; finishShutdown(exitCode?: number): void; gracefulShutdown(signal: any, exitCode?: number): Promise<void>; run(): Promise<void>; } export default AIChangelogMCPServer;