feat: LLM-Agnostic MCP Server with Peer Review Integration#18
Merged
Conversation
This commit completes the comprehensive refactoring to make ALL AI-powered analysis work in PROMPT_ONLY mode for MCP servers, while preserving full EXECUTE mode functionality for CLI, GitHub Actions, and Probot. Changes: - Unified AnalysisPrompt interface in agent.types.ts for both main analysis and peer review - Updated jira-sub-agent.ts to import AnalysisPrompt from agent.types.ts - Added 'instructions' field to all AnalysisPrompt objects in peer review - Removed unused StubChatModel and MCPChatModel classes - Fixed type compatibility issues between different AnalysisPrompt definitions - Cleaned up MCP server to use PROMPT_ONLY mode throughout The architecture now supports two execution modes: 1. EXECUTE mode (CLI/GitHub Action/Probot): Executes prompts with API keys 2. PROMPT_ONLY mode (MCP): Returns prompts for calling LLM to execute All 7 LLM invocation points are now LLM-agnostic: - Main PR Analysis: 4 points (file analysis, risk detection, summary, refinement) - Peer Review: 3 points (ticket quality, AC validation, peer review) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added streaming:true to Anthropic and Zhipu providers to prevent timeout errors on long operations (>10 minutes). Changes: - anthropic.provider.ts: Enable streaming - zhipu.provider.ts: Enable streaming for GLM-4.7 - Increases all provider maxTokens defaults to 50,000 This fixes AnthropicError: "Streaming is required for operations that may take longer than 10 minutes" Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Enable peer review by default in DEFAULT_CONFIG - Auto-open dashboard at http://localhost:3000 after analysis completes - Update .pr-analyzer.yml with latest model (claude-sonnet-4-5-20250929) - Increase max_tokens to 50000 for large PR analysis - Add C# (.cs) and C/C++ file patterns to configuration - Fix dashboard routing pattern from '*' to '/' to prevent path-to-regexp errors - Add peer review configuration section to .pr-analyzer.yml Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Auto-start dashboard server in background on analysis complete - Enhanced peer review with proper Jira configuration - Add *.db to .gitignore to prevent committing sensitive data - Update dist files with latest build Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…rver Fixes MCP server to match CLI behavior: - Auto-starts dashboard after analysis completes - Opens browser automatically with dashboard URL - Adds saveAnalysisResults MCP tool for LLM to persist analysis data - Dashboard now accessible immediately after running analysis Changes: - Added startDashboardInBackground() function - Auto-start dashboard after returning prompts (non-blocking) - New MCP tool: saveAnalysisResults (saves peer review data to DB) - Matches CLI behavior from analyze.command.ts lines 645-672 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fixes missing parameter error when saving analysis results - Adds defaults for devops fields in database record preparation
Working on refactoring MCP server to execute LLM analysis internally instead of returning prompts. Goal is to match CLI behavior with unified Markdown output, auto-save to database, and dashboard auto-start. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 LLM-Agnostic MCP Server with Peer Review Integration
📋 Overview
This PR implements a comprehensive MCP (Model Context Protocol) server for PR Agent that enables AI-powered PR analysis directly in Claude Code, Cursor, and other MCP-compatible editors without requiring API keys.
✨ Key Features
🤖 LLM-Agnostic Architecture
🎯 Peer Review Integration
📊 Auto-Start Dashboard
🔧 Installation Instructions for Team Members
Prerequisites
Step 1: Install PR Agent Package
Step 2: Configure MCP Server in Claude Code
Add the PR Agent MCP server to your Claude Code configuration:
Location:
~/.claude/config.json(or%APPDATA%\Claude\config.jsonon Windows){ "mcpServers": { "pr-agent": { "command": "npx", "args": ["@techdebtgpt/pr-agent", "mcp"] } } }Alternative: If installed globally:
{ "mcpServers": { "pr-agent": { "command": "pr-agent", "args": ["mcp"] } } }Note: No API keys needed! The MCP server leverages the calling LLM (Claude Code) to execute prompts.
Step 3: Create Configuration File
In your repository root, create
.pragent.config.json:{ "git": { "defaultBranch": "main" }, "analysis": { "enableStaticAnalysis": true, "language": "typescript", "framework": "react" }, "peerReview": { "enabled": true, "useMcp": true, "instanceUrl": "https://your-org.atlassian.net", "defaultProject": "PROJ" } }Note: No
ai.providerorapiKeysneeded for MCP mode - the calling LLM handles execution.Step 4: Restart Claude Code
After adding the MCP server configuration:
Step 5: Test the Integration
In Claude Code, try these commands:
or in any repository:
📖 Usage Examples
Basic Analysis
With Peer Review (Jira Integration)
View Results Dashboard
🎯 Available MCP Tools
The MCP server exposes three tools:
1.
analyzeAnalyzes PR/branch changes with static analysis and generates LLM prompts.
Parameters:
branch(optional): Base branch to compare againststaged(optional): Analyze staged changes insteadtitle(optional): PR title (auto-detected from git)cwd(optional): Working directoryverbose(optional): Include debug informationpeerReview(optional): Enable Jira peer reviewarchDocs(optional): Include architecture docs2.
saveAnalysisResultsSaves analysis results to the database after LLM execution.
Parameters:
title,complexity,risks,recommendations(required)peerReviewEnabled,ticketKey,ticketQualityScore(optional)3.
dashboardStarts the web dashboard on localhost.
Parameters:
port(optional): Port to run on (default: 3000)🏗️ Architecture
MCP Server (PROMPT_ONLY Mode)
Key Benefits:
🧪 Testing
Thoroughly tested and working:
📊 Output Format
Static Analysis (Immediate, No LLM)
LLM Analysis Prompts
🚧 TODO: Output Format Consistency
Remaining Work: The MCP server output format needs to be standardized to match the CLI output format.
Current State:
Target State:
Example Target Format (matching CLI):
This ensures consistency between CLI and MCP user experiences.
🔗 Related Links
📝 Breaking Changes
None. This is a new feature addition that does not affect existing CLI functionality.
🚀 Next Steps
🤝 For Reviewers
Key Files to Review
src/mcp/server.ts- Main MCP server implementation (PROMPT_ONLY mode)src/types/agent.types.ts- Type definitions for execution modessrc/agents/base-pr-agent-workflow.ts- PROMPT_ONLY mode supportsrc/issue-tracker/peer-review-integration.ts- Peer review in PROMPT_ONLY modeTesting Checklist
📞 Support
For issues or questions:
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com