Skip to content

Commit c1b6175

Browse files
committed
CLean up docs and prompt
1 parent c0fc81f commit c1b6175

File tree

4 files changed

+174
-25
lines changed

4 files changed

+174
-25
lines changed

.env.example

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ GITHUB_APP_PRIVATE_KEY_PATH=./private-key.pem
88
GITHUB_WEBHOOK_SECRET=your_webhook_secret
99
GITHUB_REDIRECT_URI=http://localhost:5053/github/callback
1010
GITHUB_BASE_URL=https://github.com
11+
GITHUB_APP_CWD=/Users/username/project/your-repo
12+
13+
# MCP Configuration
14+
MCP_AUTH_TOKEN=your_mcp_secret
15+
CRA_PUBLIC_URL=https://ngrok-your-url.app
1116

1217
# Server Configuration
13-
PORT=5053
14-
DEBUG=true
15-
APP_BASE_URL=http://localhost:5053
18+
APP_BASE_URL=https://ngrok-your-url.app
19+
SERVER_PORT=5053
20+
SERVER_DEBUG=true
1621

1722
# Amp Configuration
18-
AMP_TIMEOUT=60000
19-
AMP_SERVER_URL=ws://localhost:3001
20-
AMP_URL=http://localhost:3001
23+
AMP_TIMEOUT=300
24+
AMP_SERVER_URL=https://ampcode.com

README.md

Lines changed: 121 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ A GitHub App for automated code reviews using Hono.js and Amp.
99
- **Queue Management**: Efficient job queuing and processing
1010
- **Code Review**: AI-powered code analysis and feedback
1111
- **Check Runs**: Integration with GitHub's check runs API for status reporting
12+
- **MCP Server**: Model Context Protocol server for AI agent integration
13+
- **Dashboard**: Web interface for installation management
1214

1315
## Quick Start
1416

@@ -21,7 +23,6 @@ A GitHub App for automated code reviews using Hono.js and Amp.
2123
2. **Environment Setup**
2224
```bash
2325
cp .env.example .env
24-
# Edit .env with your GitHub app credentials
2526
```
2627

2728
3. **Start Development Server**
@@ -30,9 +31,10 @@ A GitHub App for automated code reviews using Hono.js and Amp.
3031
```
3132

3233
4. **Install the App**
33-
- Visit `http://localhost:5053/github/install`
34+
- Visit `{APP_BASE_URL}/github/install` (e.g., `https://your-ngrok-url.app/github/install`)
3435
- Follow the GitHub App installation flow
3536
- Select repositories to enable code reviews
37+
- Access dashboard at `{APP_BASE_URL}/github/dashboard/{installationId}`
3638

3739
## Configuration
3840

@@ -45,46 +47,66 @@ A GitHub App for automated code reviews using Hono.js and Amp.
4547
- Repository: Contents (Read)
4648
- Repository: Metadata (Read)
4749
3. **Configure webhook settings:**
48-
- Webhook URL: `https://your-domain.com/github/webhook`
49-
- Subscribe to: Pull request events
50+
- Webhook URL: `https://your-domain.com/github/webhook` (use your CRA_PUBLIC_URL)
51+
- Subscribe to: Pull request events and Installation events
5052
4. **Generate and download a private key** from the app settings page
5153

5254
### Environment Variables
5355

5456
#### GitHub App Configuration (Required)
5557
```env
5658
# GitHub App ID (found in app settings)
57-
GITHUB_APP_ID=123456
59+
GITHUB_APP_ID=your_github_app_id
5860
5961
# GitHub App name (used in installation URL)
6062
GITHUB_APP_NAME=your-app-name
6163
6264
# GitHub App Client ID and Secret
63-
GITHUB_APP_CLIENT_ID=Iv1.abc123def456
64-
GITHUB_APP_CLIENT_SECRET=your_app_client_secret
65+
GITHUB_APP_CLIENT_ID=your_github_app_client_id
66+
GITHUB_APP_CLIENT_SECRET=your_github_app_client_secret
6567
6668
# Private Key Setup (choose one option)
6769
# Option 1: Private key file path
6870
GITHUB_APP_PRIVATE_KEY_PATH=./private-key.pem
6971
7072
# Option 2: Private key as environment variable (base64 encoded)
71-
GITHUB_APP_PRIVATE_KEY=LS0tLS1CRUdJTi...your_base64_encoded_key
73+
GITHUB_APP_PRIVATE_KEY=your_github_app_private_key_base64_encoded
7274
73-
# Webhook secret (optional but recommended)
75+
# Webhook and redirect configuration
7476
GITHUB_WEBHOOK_SECRET=your_webhook_secret
77+
GITHUB_REDIRECT_URI=http://localhost:5053/github/callback
78+
GITHUB_BASE_URL=https://github.com
79+
80+
# Working directory for the app (used by MCP server)
81+
GITHUB_APP_CWD=/Users/username/project/your-repo
82+
```
83+
84+
#### MCP Configuration
85+
```env
86+
# MCP Server Authentication
87+
MCP_AUTH_TOKEN=your_mcp_secret
88+
89+
# Public URL for webhooks (use ngrok or similar for development)
90+
CRA_PUBLIC_URL=https://ngrok-your-url.app
7591
```
7692

7793
#### Server Configuration
7894
```env
95+
# Base URL for the application
96+
APP_BASE_URL=https://ngrok-your-url.app
97+
7998
# Server settings
80-
PORT=5053
81-
DEBUG=true
82-
APP_BASE_URL=http://localhost:5053
83-
84-
# Amp Configuration
85-
AMP_TIMEOUT=60000
86-
AMP_SERVER_URL=ws://localhost:3001
87-
AMP_URL=http://localhost:3001
99+
SERVER_PORT=5053
100+
SERVER_DEBUG=true
101+
```
102+
103+
#### Amp Configuration
104+
```env
105+
# Amp timeout (in seconds)
106+
AMP_TIMEOUT=300
107+
108+
# Amp server URL (use ampcode.com for hosted service)
109+
AMP_SERVER_URL=https://ampcode.com
88110
```
89111

90112
### Private Key Setup
@@ -110,18 +132,71 @@ The GitHub App requires a private key for authentication. You have two options:
110132
- Use secure secret management in production
111133
- Restrict file permissions: `chmod 600 private-key.pem`
112134

135+
### Configuration File (config.yml)
136+
137+
The app uses a `config.yml` file for core configuration including the AI system prompt and tool definitions. This file contains:
138+
139+
#### Key Configuration Sections:
140+
- **GitHub settings**: API endpoints, bot username, check run names
141+
- **Queue configuration**: Worker limits and retry settings
142+
- **Diff processing**: Chunk size limits for large diffs
143+
- **Amp integration**: Command settings and MCP server configuration
144+
- **System prompt**: The complete AI prompt template for code reviews
145+
- **Tool definitions**: Available MCP tools and their usage instructions
146+
147+
#### Important Notes:
148+
- The system prompt in `config.yml` defines how the AI reviews code
149+
- Tool definitions specify which GitHub operations are available to the AI
150+
- Environment variables are interpolated using `${VARIABLE_NAME}` syntax
151+
- Modify the prompt template to customize review behavior and focus areas
152+
- The configuration supports both development and production deployment modes
153+
154+
**Example customization:**
155+
To adjust review focus, modify the `prompt_template` section in `config.yml` to emphasize specific areas like security, performance, or coding standards.
156+
113157
## API Endpoints
114158

159+
### Core Endpoints
115160
- `GET /` - Service information
116161
- `GET /health` - Health check
162+
- `GET /queue/status` - Queue status information
163+
- `GET /jobs/:jobId` - Job status information
164+
- `POST /test/review` - Test endpoint for review functionality
165+
166+
### GitHub App Endpoints
117167
- `POST /github/webhook` - GitHub webhook endpoint
118168
- `GET /github/install` - Start GitHub App installation
119169
- `GET /github/callback` - GitHub App installation callback
120170
- `GET /github/dashboard/:installationId` - Installation dashboard
121-
- `GET /queue/status` - Queue status information
171+
172+
### MCP Server Endpoints
173+
- `GET /mcp/tools/list` - List available MCP tools
174+
- `POST /mcp/tools/call` - Call an MCP tool
175+
- `GET /mcp/health` - MCP server health check
122176

123177
## Development
124178

179+
### Local Development with ngrok
180+
181+
For development, you'll need to expose your local server to the internet for GitHub webhooks to work:
182+
183+
1. **Install ngrok**: `npm install -g ngrok` or download from [ngrok.com](https://ngrok.com)
184+
185+
2. **Start your local server**:
186+
```bash
187+
npm run dev
188+
```
189+
190+
3. **Expose with ngrok** (in a separate terminal):
191+
```bash
192+
ngrok http 5053
193+
```
194+
195+
4. **Update your environment**:
196+
- Copy the ngrok URL (e.g., `https://abc123.ngrok.io`)
197+
- Update `CRA_PUBLIC_URL` and `APP_BASE_URL` in your `.env` file
198+
- Update your GitHub App webhook URL to `{your-ngrok-url}/github/webhook`
199+
125200
### Build
126201
```bash
127202
npm run build
@@ -137,13 +212,41 @@ npm run type-check
137212
npm run lint
138213
```
139214

215+
### MCP Server
216+
Run the standalone MCP server:
217+
```bash
218+
npm run mcp
219+
```
220+
221+
Or build and run:
222+
```bash
223+
npm run mcp:build
224+
```
225+
226+
## MCP Integration
227+
228+
The app includes a Model Context Protocol (MCP) server that exposes GitHub operations as tools for AI agents and code editors like Cursor.
229+
230+
### Available MCP Tools
231+
- `leave_general_comment` - Leave general comments on pull requests
232+
- `leave_inline_comment` - Leave inline comments on specific lines
233+
- `create_check_run` - Create or update check run status
234+
- `get_pr_info` - Get pull request details and optionally the diff
235+
- `trigger_review` - Start the code review process
236+
- `get_pr_comments` - Get all comments on a pull request
237+
238+
### Usage with AI Agents
239+
The MCP server can be accessed via HTTP at `/mcp` endpoints or run as a standalone stdio server. See [`src/mcp/README.md`](src/mcp/README.md) for detailed configuration and usage instructions.
240+
140241
## Architecture
141242

142243
- **Hono.js**: Fast web framework for the server
143244
- **GitHub API**: Integration with GitHub's REST API
144245
- **GitHub Apps**: Secure app installation and JWT authentication
145246
- **Job Queue**: Background processing for code reviews
146247
- **Amp**: AI-powered code analysis engine
248+
- **MCP Server**: Model Context Protocol server for AI agent integration
249+
- **Installation Management**: Persistent storage for GitHub App installations
147250

148251
## License
149252

config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ amp:
6969
__TOOL_CONTENT__
7070
7171
After you have completed the code review process:
72+
73+
Leave a general comment summarizing the review, including:
74+
* A brief summary of the changes reviewed
75+
* List out critical issues and blockers that need to be addressed
76+
* Any high-level feedback or suggestions
77+
7278
IMPORTANT: If you find any issues, include all of them in a JSON block at the end with the following format:
7379
```json
7480
[

src/mcp/README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,15 @@ npm run mcp:build
104104

105105
The server uses the same configuration as the main application. Make sure your `config.yml` and environment variables are properly set:
106106

107+
### Environment Variables
108+
- `GITHUB_APP_ID` - GitHub App ID
109+
- `GITHUB_APP_PRIVATE_KEY` or `GITHUB_APP_PRIVATE_KEY_PATH` - GitHub App private key
107110
- `GITHUB_BASE_URL` - GitHub API URL (default: https://api.github.com)
108-
- `GITHUB_TOKEN` - GitHub access token
109111
- `MCP_AUTH_TOKEN` - Token for MCP server authentication (optional)
110112

113+
### GitHub App Integration
114+
The MCP server works with GitHub App installations for authentication. When accessing repositories, it uses the GitHub App's installation tokens rather than personal access tokens.
115+
111116
## Integration with AI Agents
112117

113118
### Cursor Configuration
@@ -131,6 +136,25 @@ Add to your Cursor settings:
131136
}
132137
```
133138

139+
### Amp Integration
140+
141+
The MCP server is automatically configured for use with Amp in `config.yml`:
142+
143+
```yaml
144+
amp:
145+
settings:
146+
amp.mcpServers:
147+
github:
148+
command: "sh"
149+
args: ["-c", "cd ${GITHUB_APP_CWD} && pnpm run mcp"]
150+
env:
151+
GITHUB_APP_CWD: "${GITHUB_APP_CWD}"
152+
GITHUB_APP_ID: "${GITHUB_APP_ID}"
153+
GITHUB_APP_PRIVATE_KEY_PATH: "${GITHUB_APP_PRIVATE_KEY_PATH}"
154+
```
155+
156+
This allows Amp to automatically use the GitHub MCP tools during code reviews.
157+
134158
### Example Usage in Prompts
135159
136160
```
@@ -146,6 +170,18 @@ Repo: Hello-World
146170
PR Number: 123
147171
```
148172
173+
### Code Review Workflow
174+
175+
The tools are designed to work together in a typical code review workflow:
176+
177+
1. **Get Context**: `get_pr_info` to fetch PR details and optionally the diff
178+
2. **Check Existing Feedback**: `get_pr_comments` to see what's already been discussed
179+
3. **Leave Feedback**:
180+
- `leave_inline_comment` for specific line-level issues
181+
- `leave_general_comment` for overall observations
182+
4. **Update Status**: `create_check_run` to mark the review as complete
183+
5. **Re-trigger if Needed**: `trigger_review` to restart the process
184+
149185
## Development
150186

151187
The tools are organized in the `/src/mcp/tools/` directory:

0 commit comments

Comments
 (0)