mcp-http-webhook 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +16 -0
- package/.prettierrc.json +8 -0
- package/ARCHITECTURE.md +269 -0
- package/CONTRIBUTING.md +136 -0
- package/GETTING_STARTED.md +310 -0
- package/IMPLEMENTATION.md +294 -0
- package/LICENSE +21 -0
- package/MIGRATION_TO_SDK.md +263 -0
- package/README.md +496 -0
- package/SDK_INTEGRATION_COMPLETE.md +300 -0
- package/STANDARD_SUBSCRIPTIONS.md +268 -0
- package/STANDARD_SUBSCRIPTIONS_COMPLETE.md +309 -0
- package/SUMMARY.md +272 -0
- package/Spec.md +2778 -0
- package/dist/errors/index.d.ts +52 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +81 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol/ProtocolHandler.d.ts +37 -0
- package/dist/protocol/ProtocolHandler.d.ts.map +1 -0
- package/dist/protocol/ProtocolHandler.js +172 -0
- package/dist/protocol/ProtocolHandler.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +502 -0
- package/dist/server.js.map +1 -0
- package/dist/stores/InMemoryStore.d.ts +27 -0
- package/dist/stores/InMemoryStore.d.ts.map +1 -0
- package/dist/stores/InMemoryStore.js +73 -0
- package/dist/stores/InMemoryStore.js.map +1 -0
- package/dist/stores/RedisStore.d.ts +18 -0
- package/dist/stores/RedisStore.d.ts.map +1 -0
- package/dist/stores/RedisStore.js +45 -0
- package/dist/stores/RedisStore.js.map +1 -0
- package/dist/stores/index.d.ts +3 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +9 -0
- package/dist/stores/index.js.map +1 -0
- package/dist/subscriptions/SubscriptionManager.d.ts +49 -0
- package/dist/subscriptions/SubscriptionManager.d.ts.map +1 -0
- package/dist/subscriptions/SubscriptionManager.js +181 -0
- package/dist/subscriptions/SubscriptionManager.js.map +1 -0
- package/dist/types/index.d.ts +271 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +51 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +154 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/webhooks/WebhookManager.d.ts +27 -0
- package/dist/webhooks/WebhookManager.d.ts.map +1 -0
- package/dist/webhooks/WebhookManager.js +174 -0
- package/dist/webhooks/WebhookManager.js.map +1 -0
- package/examples/GITHUB_LIVE_EXAMPLE.md +308 -0
- package/examples/GITHUB_LIVE_SETUP.md +253 -0
- package/examples/QUICKSTART.md +130 -0
- package/examples/basic-setup.ts +142 -0
- package/examples/github-server-live.ts +690 -0
- package/examples/github-server.ts +223 -0
- package/examples/google-drive-server-live.ts +773 -0
- package/examples/start-github-live.sh +53 -0
- package/jest.config.js +20 -0
- package/package.json +58 -0
- package/src/errors/index.ts +81 -0
- package/src/index.ts +19 -0
- package/src/server.ts +595 -0
- package/src/stores/InMemoryStore.ts +87 -0
- package/src/stores/RedisStore.ts +51 -0
- package/src/stores/index.ts +2 -0
- package/src/subscriptions/SubscriptionManager.ts +240 -0
- package/src/types/index.ts +341 -0
- package/src/utils/index.ts +156 -0
- package/src/webhooks/WebhookManager.ts +230 -0
- package/test-sdk-integration.sh +157 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# GitHub Live Webhook Integration Example
|
|
2
|
+
|
|
3
|
+
This example demonstrates a **real, working integration** between MCP and GitHub using live webhooks.
|
|
4
|
+
|
|
5
|
+
## What This Does
|
|
6
|
+
|
|
7
|
+
1. **Connects to GitHub API** - Uses your personal access token to interact with real repositories
|
|
8
|
+
2. **Auto-configures ngrok** - Sets up a public URL automatically for webhook delivery
|
|
9
|
+
3. **Creates Real Webhooks** - Registers actual GitHub webhooks on your repository
|
|
10
|
+
4. **Live Updates** - Receives real-time notifications when issues are created, updated, or closed
|
|
11
|
+
5. **Resource Subscriptions** - Demonstrates MCP's webhook-based resource subscription pattern
|
|
12
|
+
|
|
13
|
+
## Prerequisites
|
|
14
|
+
|
|
15
|
+
### 1. GitHub Personal Access Token
|
|
16
|
+
|
|
17
|
+
Create a token at: https://github.com/settings/tokens/new
|
|
18
|
+
|
|
19
|
+
**Required Scopes:**
|
|
20
|
+
- `repo` - Full control of private repositories
|
|
21
|
+
- `admin:repo_hook` - Full control of repository hooks
|
|
22
|
+
|
|
23
|
+
**Steps:**
|
|
24
|
+
1. Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
|
|
25
|
+
2. Click "Generate new token (classic)"
|
|
26
|
+
3. Set expiration (for testing, 30 days is fine)
|
|
27
|
+
4. Select scopes: `repo` and `admin:repo_hook`
|
|
28
|
+
5. Click "Generate token"
|
|
29
|
+
6. **Copy the token immediately** (you won't see it again!)
|
|
30
|
+
|
|
31
|
+
### 2. Test Repository
|
|
32
|
+
|
|
33
|
+
You'll need a GitHub repository you own for testing. You can:
|
|
34
|
+
- Use an existing test repository
|
|
35
|
+
- Create a new one at: https://github.com/new
|
|
36
|
+
- Recommended: Create a dedicated test repo like `mcp-webhook-test`
|
|
37
|
+
|
|
38
|
+
### 3. ngrok (Optional Account)
|
|
39
|
+
|
|
40
|
+
The example works without an ngrok account, but you can:
|
|
41
|
+
- Sign up for free at: https://ngrok.com
|
|
42
|
+
- Get your auth token from: https://dashboard.ngrok.com/get-started/your-authtoken
|
|
43
|
+
- Set it: `export NGROK_AUTH_TOKEN="your_token_here"`
|
|
44
|
+
|
|
45
|
+
## Running the Example
|
|
46
|
+
|
|
47
|
+
### Step 1: Start the Server
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
cd /data/work/kaman3.0/packages/plugins/mcp-proxy
|
|
51
|
+
npx tsx examples/github-server-live.ts
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Step 2: Provide Information
|
|
55
|
+
|
|
56
|
+
The script will ask you for:
|
|
57
|
+
|
|
58
|
+
1. **GitHub Personal Access Token**: Paste your token (input is hidden)
|
|
59
|
+
2. **Repository Owner**: Your GitHub username
|
|
60
|
+
3. **Repository Name**: The repository to monitor
|
|
61
|
+
4. **Webhook Secret**: Press Enter for random, or provide your own
|
|
62
|
+
|
|
63
|
+
Example interaction:
|
|
64
|
+
```
|
|
65
|
+
Enter your GitHub Personal Access Token: ghp_xxxxxxxxxxxxx
|
|
66
|
+
Enter repository owner (your GitHub username): yourusername
|
|
67
|
+
Enter repository name: test-repo
|
|
68
|
+
Enter webhook secret (or press enter for random): [Enter]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Step 3: Server Starts
|
|
72
|
+
|
|
73
|
+
You'll see output like:
|
|
74
|
+
```
|
|
75
|
+
✅ Authenticated as: yourusername
|
|
76
|
+
✅ Repository found: yourusername/test-repo
|
|
77
|
+
🌐 Starting ngrok tunnel...
|
|
78
|
+
✅ Public URL: https://abc123.ngrok.io
|
|
79
|
+
|
|
80
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
81
|
+
║ 🎉 GitHub MCP Server is LIVE! ║
|
|
82
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
83
|
+
|
|
84
|
+
📍 MCP Endpoint:
|
|
85
|
+
https://abc123.ngrok.io/mcp
|
|
86
|
+
|
|
87
|
+
🔍 Test with MCP Inspector:
|
|
88
|
+
npx @modelcontextprotocol/inspector https://abc123.ngrok.io/mcp
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Testing the Integration
|
|
92
|
+
|
|
93
|
+
### Method 1: MCP Inspector (Recommended)
|
|
94
|
+
|
|
95
|
+
1. **Open MCP Inspector:**
|
|
96
|
+
```bash
|
|
97
|
+
npx @modelcontextprotocol/inspector https://your-ngrok-url.ngrok.io/mcp
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
2. **List Resources:**
|
|
101
|
+
- Click "List Resources"
|
|
102
|
+
- You'll see your repository issues resource
|
|
103
|
+
|
|
104
|
+
3. **Subscribe to Issues:**
|
|
105
|
+
- Go to the Resources tab
|
|
106
|
+
- Click on the GitHub resource
|
|
107
|
+
- Click "Subscribe" (if available in Inspector)
|
|
108
|
+
- Or use curl (see Method 2)
|
|
109
|
+
|
|
110
|
+
4. **Create an Issue:**
|
|
111
|
+
- Use the "create_issue" tool in Inspector
|
|
112
|
+
- Fill in title and body
|
|
113
|
+
- Execute
|
|
114
|
+
- Watch the console for webhook delivery!
|
|
115
|
+
|
|
116
|
+
### Method 2: Manual API Calls
|
|
117
|
+
|
|
118
|
+
**List Issues:**
|
|
119
|
+
```bash
|
|
120
|
+
curl -X POST https://your-ngrok-url.ngrok.io/mcp \
|
|
121
|
+
-H "Content-Type: application/json" \
|
|
122
|
+
-d '{
|
|
123
|
+
"jsonrpc": "2.0",
|
|
124
|
+
"id": 1,
|
|
125
|
+
"method": "tools/call",
|
|
126
|
+
"params": {
|
|
127
|
+
"name": "list_issues",
|
|
128
|
+
"arguments": {
|
|
129
|
+
"state": "open"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Create an Issue:**
|
|
136
|
+
```bash
|
|
137
|
+
curl -X POST https://your-ngrok-url.ngrok.io/mcp \
|
|
138
|
+
-H "Content-Type: application/json" \
|
|
139
|
+
-d '{
|
|
140
|
+
"jsonrpc": "2.0",
|
|
141
|
+
"id": 2,
|
|
142
|
+
"method": "tools/call",
|
|
143
|
+
"params": {
|
|
144
|
+
"name": "create_issue",
|
|
145
|
+
"arguments": {
|
|
146
|
+
"title": "Test issue from MCP",
|
|
147
|
+
"body": "This was created via MCP webhook integration!"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Subscribe to Resource:**
|
|
154
|
+
```bash
|
|
155
|
+
curl -X POST https://your-ngrok-url.ngrok.io/mcp/resources/subscribe \
|
|
156
|
+
-H "Content-Type: application/json" \
|
|
157
|
+
-d '{
|
|
158
|
+
"uri": "github://repo/yourusername/yourrepo/issues",
|
|
159
|
+
"callbackUrl": "https://your-client-url.com/webhook",
|
|
160
|
+
"callbackSecret": "your-secret"
|
|
161
|
+
}'
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Method 3: GitHub UI
|
|
165
|
+
|
|
166
|
+
1. **Go to your repository on GitHub**
|
|
167
|
+
2. **Create a new issue manually**
|
|
168
|
+
3. **Watch your server console** - you'll see the webhook notification!
|
|
169
|
+
|
|
170
|
+
Example output:
|
|
171
|
+
```
|
|
172
|
+
📬 Received GitHub webhook
|
|
173
|
+
Event: issues
|
|
174
|
+
Subscription: sub_abc123
|
|
175
|
+
Action: opened
|
|
176
|
+
Issue: #42 - Test issue from MCP
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## How It Works
|
|
180
|
+
|
|
181
|
+
### Architecture
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
┌─────────────────┐ ┌──────────────┐ ┌─────────────┐
|
|
185
|
+
│ MCP Client │ │ Your MCP │ │ GitHub │
|
|
186
|
+
│ (Inspector) │◄───────►│ Server │◄───────►│ API │
|
|
187
|
+
└─────────────────┘ └──────────────┘ └─────────────┘
|
|
188
|
+
│ │
|
|
189
|
+
│ │
|
|
190
|
+
┌──────▼───────┐ ┌──────▼──────┐
|
|
191
|
+
│ ngrok │ │ Webhook │
|
|
192
|
+
│ Tunnel │◄────────│ Delivery │
|
|
193
|
+
└──────────────┘ └─────────────┘
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Subscription Flow
|
|
197
|
+
|
|
198
|
+
1. **Client subscribes** to `github://repo/owner/repo/issues`
|
|
199
|
+
2. **Server receives** subscription request
|
|
200
|
+
3. **Server calls GitHub API** to create webhook pointing to ngrok URL
|
|
201
|
+
4. **GitHub confirms** webhook creation
|
|
202
|
+
5. **Server stores** webhook ID and subscription mapping
|
|
203
|
+
6. **When issue changes**, GitHub sends webhook to ngrok URL
|
|
204
|
+
7. **ngrok forwards** to your local server
|
|
205
|
+
8. **Server processes** webhook, extracts issue data
|
|
206
|
+
9. **Server notifies** original MCP client via their callback URL
|
|
207
|
+
|
|
208
|
+
### Resource Template Pattern
|
|
209
|
+
|
|
210
|
+
The URI `github://repo/{owner}/{repo}/issues` is a **resource template**:
|
|
211
|
+
- `{owner}` and `{repo}` are variables
|
|
212
|
+
- The `list()` function returns specific instances
|
|
213
|
+
- The `read()` function fetches data for a specific instance
|
|
214
|
+
- The `subscription` object handles webhook lifecycle
|
|
215
|
+
|
|
216
|
+
## Webhook Security
|
|
217
|
+
|
|
218
|
+
### Incoming (from GitHub)
|
|
219
|
+
|
|
220
|
+
GitHub signs webhooks with HMAC-SHA256:
|
|
221
|
+
```typescript
|
|
222
|
+
X-Hub-Signature-256: sha256=<signature>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
The server verifies this signature using your webhook secret.
|
|
226
|
+
|
|
227
|
+
### Outgoing (to Client)
|
|
228
|
+
|
|
229
|
+
When notifying your MCP client, the server signs the payload:
|
|
230
|
+
```typescript
|
|
231
|
+
X-Webhook-Signature: sha256=<signature>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Your client should verify this using the `callbackSecret` they provided.
|
|
235
|
+
|
|
236
|
+
## Monitoring
|
|
237
|
+
|
|
238
|
+
Watch the console for real-time logs:
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
📝 Creating GitHub issue: Test issue
|
|
242
|
+
✅ Issue created: #42
|
|
243
|
+
|
|
244
|
+
🔔 Setting up GitHub webhook...
|
|
245
|
+
Resource: github://repo/owner/repo/issues
|
|
246
|
+
Subscription ID: sub_abc123def
|
|
247
|
+
✅ GitHub webhook created: ID 12345
|
|
248
|
+
|
|
249
|
+
📬 Received GitHub webhook
|
|
250
|
+
Event: issues
|
|
251
|
+
Subscription: sub_abc123def
|
|
252
|
+
Action: opened
|
|
253
|
+
Issue: #42 - Test issue
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Cleanup
|
|
257
|
+
|
|
258
|
+
**Press Ctrl+C** to stop the server.
|
|
259
|
+
|
|
260
|
+
The server will automatically:
|
|
261
|
+
1. Delete all GitHub webhooks it created
|
|
262
|
+
2. Stop ngrok tunnel
|
|
263
|
+
3. Clean up resources
|
|
264
|
+
|
|
265
|
+
Output:
|
|
266
|
+
```
|
|
267
|
+
🧹 Shutting down...
|
|
268
|
+
✅ Deleted webhook: 12345
|
|
269
|
+
👋 Goodbye!
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Troubleshooting
|
|
273
|
+
|
|
274
|
+
### "Failed to verify GitHub access"
|
|
275
|
+
- Check your personal access token is correct
|
|
276
|
+
- Ensure token has `repo` and `admin:repo_hook` scopes
|
|
277
|
+
- Verify the repository owner/name are correct
|
|
278
|
+
|
|
279
|
+
### "Failed to create webhook"
|
|
280
|
+
- Ensure you have admin access to the repository
|
|
281
|
+
- Check your GitHub token scopes
|
|
282
|
+
- Verify ngrok tunnel is working
|
|
283
|
+
|
|
284
|
+
### Webhooks not arriving
|
|
285
|
+
- Check GitHub webhook delivery page: `https://github.com/owner/repo/settings/hooks`
|
|
286
|
+
- Click on the webhook and view "Recent Deliveries"
|
|
287
|
+
- Check for error messages
|
|
288
|
+
- Verify ngrok tunnel is still active
|
|
289
|
+
|
|
290
|
+
### ngrok connection issues
|
|
291
|
+
- Free ngrok URLs expire after 2 hours
|
|
292
|
+
- Restart the server to get a new URL
|
|
293
|
+
- Consider creating an ngrok account for longer sessions
|
|
294
|
+
|
|
295
|
+
## Next Steps
|
|
296
|
+
|
|
297
|
+
- **Add more event types**: Handle PR events, comments, etc.
|
|
298
|
+
- **Multiple repositories**: Monitor multiple repos with one server
|
|
299
|
+
- **Client implementation**: Build a client that receives webhook notifications
|
|
300
|
+
- **Production deployment**: Deploy to a real server (no ngrok needed)
|
|
301
|
+
- **Database storage**: Replace InMemoryStore with Redis for persistence
|
|
302
|
+
|
|
303
|
+
## Learning Resources
|
|
304
|
+
|
|
305
|
+
- [MCP Specification](https://spec.modelcontextprotocol.io/)
|
|
306
|
+
- [GitHub Webhooks Docs](https://docs.github.com/en/webhooks)
|
|
307
|
+
- [Octokit REST API](https://octokit.github.io/rest.js/)
|
|
308
|
+
- [ngrok Documentation](https://ngrok.com/docs)
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# GitHub Live Integration Setup Guide
|
|
2
|
+
|
|
3
|
+
This guide will help you set up the GitHub MCP server with real webhooks.
|
|
4
|
+
|
|
5
|
+
## 🎯 Quick Start Checklist
|
|
6
|
+
|
|
7
|
+
- [ ] GitHub Personal Access Token
|
|
8
|
+
- [ ] Test GitHub Repository
|
|
9
|
+
- [ ] ngrok Account (free)
|
|
10
|
+
- [ ] Run the example
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 📋 Step-by-Step Setup
|
|
15
|
+
|
|
16
|
+
### 1. Create GitHub Personal Access Token
|
|
17
|
+
|
|
18
|
+
1. Go to: https://github.com/settings/tokens/new
|
|
19
|
+
2. **Token Name**: `MCP GitHub Test`
|
|
20
|
+
3. **Expiration**: 30 days (for testing)
|
|
21
|
+
4. **Select Scopes**:
|
|
22
|
+
- ✅ `repo` - Full control of private repositories
|
|
23
|
+
- ✅ `admin:repo_hook` - Full control of repository hooks
|
|
24
|
+
5. Click **Generate token**
|
|
25
|
+
6. **Copy the token** - you won't see it again!
|
|
26
|
+
|
|
27
|
+
Example token format: `ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
|
|
28
|
+
|
|
29
|
+
### 2. Prepare a Test Repository
|
|
30
|
+
|
|
31
|
+
You need a GitHub repository you own for testing webhooks.
|
|
32
|
+
|
|
33
|
+
**Option A: Use Existing Repo**
|
|
34
|
+
- Any repository you own
|
|
35
|
+
- Example: `your-username/test-repo`
|
|
36
|
+
|
|
37
|
+
**Option B: Create New Test Repo**
|
|
38
|
+
```bash
|
|
39
|
+
# Via GitHub CLI
|
|
40
|
+
gh repo create mcp-webhook-test --public
|
|
41
|
+
|
|
42
|
+
# Or manually at:
|
|
43
|
+
# https://github.com/new
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 3. Get ngrok Auth Token (FREE)
|
|
47
|
+
|
|
48
|
+
ngrok is required to expose your localhost to GitHub's webhooks.
|
|
49
|
+
|
|
50
|
+
1. **Sign up** (free): https://dashboard.ngrok.com/signup
|
|
51
|
+
2. **Get your auth token**: https://dashboard.ngrok.com/get-started/your-authtoken
|
|
52
|
+
3. **Copy the token**
|
|
53
|
+
|
|
54
|
+
Example token format: `2abc123def456ghi789jkl_0MnOpQrStUvWxYz`
|
|
55
|
+
|
|
56
|
+
**Set as environment variable** (optional):
|
|
57
|
+
```bash
|
|
58
|
+
export NGROK_AUTH_TOKEN="your_ngrok_token_here"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 4. Run the Example
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
cd packages/plugins/mcp-proxy
|
|
65
|
+
npx tsx examples/github-server-live.ts
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
You'll be prompted for:
|
|
69
|
+
|
|
70
|
+
1. **GitHub Personal Access Token**: `ghp_...` (from step 1)
|
|
71
|
+
2. **Repository owner**: Your GitHub username
|
|
72
|
+
3. **Repository name**: Your test repo name
|
|
73
|
+
4. **ngrok auth token**: Your ngrok token (or press Enter if set in env)
|
|
74
|
+
5. **Webhook secret**: Press Enter for auto-generated
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 🧪 Testing the Integration
|
|
79
|
+
|
|
80
|
+
### Step 1: Server Starts
|
|
81
|
+
|
|
82
|
+
You should see:
|
|
83
|
+
```
|
|
84
|
+
✅ Authenticated as: your-username
|
|
85
|
+
✅ Repository found: your-username/test-repo
|
|
86
|
+
✅ Public URL: https://abc123.ngrok.io
|
|
87
|
+
🚀 MCP Server started on port 3000
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Step 2: Test with MCP Inspector
|
|
91
|
+
|
|
92
|
+
Open in browser:
|
|
93
|
+
```
|
|
94
|
+
http://localhost:3000/mcp
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Or use MCP Inspector:
|
|
98
|
+
```bash
|
|
99
|
+
npx @modelcontextprotocol/inspector http://localhost:3000/mcp
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Step 3: Subscribe to Issues
|
|
103
|
+
|
|
104
|
+
In MCP Inspector or via curl:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
curl -X POST http://localhost:3000/mcp/resources/subscribe \
|
|
108
|
+
-H "Content-Type: application/json" \
|
|
109
|
+
-H "Authorization: Bearer test-token" \
|
|
110
|
+
-d '{
|
|
111
|
+
"uri": "github://repo/your-username/test-repo/issues",
|
|
112
|
+
"callbackUrl": "https://your-client.com/webhook",
|
|
113
|
+
"callbackSecret": "client-secret-123"
|
|
114
|
+
}'
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
This will:
|
|
118
|
+
1. Create a real GitHub webhook in your repository
|
|
119
|
+
2. Subscribe to issue events
|
|
120
|
+
3. Return a subscription ID
|
|
121
|
+
|
|
122
|
+
### Step 4: Create a Test Issue
|
|
123
|
+
|
|
124
|
+
Create an issue in your GitHub repo:
|
|
125
|
+
|
|
126
|
+
1. Go to: `https://github.com/your-username/test-repo/issues/new`
|
|
127
|
+
2. Title: "Test MCP Webhook"
|
|
128
|
+
3. Click **Submit new issue**
|
|
129
|
+
|
|
130
|
+
### Step 5: Verify Webhook Received
|
|
131
|
+
|
|
132
|
+
Check the server logs - you should see:
|
|
133
|
+
```
|
|
134
|
+
📥 Received GitHub webhook for subscription: sub_abc123
|
|
135
|
+
📤 Notifying client at: https://your-client.com/webhook
|
|
136
|
+
✅ Successfully notified client
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 🔍 Troubleshooting
|
|
142
|
+
|
|
143
|
+
### ngrok Error: "failed to start tunnel"
|
|
144
|
+
|
|
145
|
+
**Problem**: ngrok requires authentication
|
|
146
|
+
|
|
147
|
+
**Solution**:
|
|
148
|
+
1. Sign up at https://dashboard.ngrok.com/signup
|
|
149
|
+
2. Get auth token from https://dashboard.ngrok.com/get-started/your-authtoken
|
|
150
|
+
3. Provide it when prompted, or set environment variable:
|
|
151
|
+
```bash
|
|
152
|
+
export NGROK_AUTH_TOKEN="your_token"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### GitHub API Error: "Bad credentials"
|
|
156
|
+
|
|
157
|
+
**Problem**: Invalid or expired token
|
|
158
|
+
|
|
159
|
+
**Solution**:
|
|
160
|
+
1. Verify token hasn't expired
|
|
161
|
+
2. Regenerate token with correct scopes: `repo`, `admin:repo_hook`
|
|
162
|
+
3. Copy the full token including `ghp_` prefix
|
|
163
|
+
|
|
164
|
+
### GitHub API Error: "Not Found"
|
|
165
|
+
|
|
166
|
+
**Problem**: Repository doesn't exist or token doesn't have access
|
|
167
|
+
|
|
168
|
+
**Solution**:
|
|
169
|
+
1. Verify repository exists: `https://github.com/owner/repo`
|
|
170
|
+
2. Ensure you own the repository
|
|
171
|
+
3. Check token has `repo` scope
|
|
172
|
+
|
|
173
|
+
### Webhook Not Received
|
|
174
|
+
|
|
175
|
+
**Problem**: GitHub can't reach your localhost
|
|
176
|
+
|
|
177
|
+
**Checks**:
|
|
178
|
+
1. ✅ ngrok tunnel is running
|
|
179
|
+
2. ✅ Server is running on port 3000
|
|
180
|
+
3. ✅ GitHub webhook was created (check repo settings)
|
|
181
|
+
4. ✅ Check GitHub webhook deliveries
|
|
182
|
+
|
|
183
|
+
**View webhook deliveries**:
|
|
184
|
+
1. Go to: `https://github.com/owner/repo/settings/hooks`
|
|
185
|
+
2. Click on the webhook
|
|
186
|
+
3. Check **Recent Deliveries** tab
|
|
187
|
+
4. Look for errors
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 🎓 Advanced Usage
|
|
192
|
+
|
|
193
|
+
### Using Multiple Repositories
|
|
194
|
+
|
|
195
|
+
Subscribe to multiple repos:
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
// Subscribe to repo 1
|
|
199
|
+
POST /mcp/resources/subscribe
|
|
200
|
+
{
|
|
201
|
+
"uri": "github://repo/owner1/repo1/issues",
|
|
202
|
+
"callbackUrl": "https://client.com/webhook",
|
|
203
|
+
"callbackSecret": "secret1"
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Subscribe to repo 2
|
|
207
|
+
POST /mcp/resources/subscribe
|
|
208
|
+
{
|
|
209
|
+
"uri": "github://repo/owner2/repo2/issues",
|
|
210
|
+
"callbackUrl": "https://client.com/webhook",
|
|
211
|
+
"callbackSecret": "secret2"
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Custom Webhook Events
|
|
216
|
+
|
|
217
|
+
Modify the example to subscribe to different events:
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
events: ['issues', 'pull_request', 'push', 'release']
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Production Deployment
|
|
224
|
+
|
|
225
|
+
For production, replace ngrok with:
|
|
226
|
+
|
|
227
|
+
1. **Deploy to cloud** (AWS, GCP, Azure)
|
|
228
|
+
2. **Use real domain** with SSL
|
|
229
|
+
3. **Store webhook IDs** in database (not in-memory)
|
|
230
|
+
4. **Add rate limiting**
|
|
231
|
+
5. **Add monitoring**
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## 📚 Resources
|
|
236
|
+
|
|
237
|
+
- **MCP Specification**: https://spec.modelcontextprotocol.io/
|
|
238
|
+
- **GitHub Webhooks**: https://docs.github.com/en/webhooks
|
|
239
|
+
- **Octokit REST API**: https://octokit.github.io/rest.js/
|
|
240
|
+
- **ngrok Documentation**: https://ngrok.com/docs
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## ❓ Need Help?
|
|
245
|
+
|
|
246
|
+
If you encounter issues:
|
|
247
|
+
|
|
248
|
+
1. Check the server logs for errors
|
|
249
|
+
2. Verify all prerequisites are met
|
|
250
|
+
3. Check GitHub webhook deliveries for errors
|
|
251
|
+
4. Review this troubleshooting guide
|
|
252
|
+
|
|
253
|
+
Happy testing! 🚀
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# 🚀 Quick Start - GitHub MCP Live Integration
|
|
2
|
+
|
|
3
|
+
## What You Need (5 minutes setup)
|
|
4
|
+
|
|
5
|
+
### 1️⃣ GitHub Personal Access Token
|
|
6
|
+
```
|
|
7
|
+
🔗 Create at: https://github.com/settings/tokens/new
|
|
8
|
+
|
|
9
|
+
✅ Scopes to select:
|
|
10
|
+
- repo
|
|
11
|
+
- admin:repo_hook
|
|
12
|
+
|
|
13
|
+
📋 Format: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### 2️⃣ ngrok Auth Token (FREE)
|
|
17
|
+
```
|
|
18
|
+
🔗 Sign up: https://dashboard.ngrok.com/signup
|
|
19
|
+
🔗 Get token: https://dashboard.ngrok.com/get-started/your-authtoken
|
|
20
|
+
|
|
21
|
+
📋 Format: 2abc123def456ghi789jkl_0MnOpQrStUvWxYz
|
|
22
|
+
|
|
23
|
+
💡 Set as env variable (optional):
|
|
24
|
+
export NGROK_AUTH_TOKEN="your_token"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 3️⃣ Test Repository
|
|
28
|
+
```
|
|
29
|
+
Use any GitHub repo you own, or create one:
|
|
30
|
+
|
|
31
|
+
gh repo create mcp-webhook-test --public
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Run the Example
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
cd packages/plugins/mcp-proxy
|
|
40
|
+
npx tsx examples/github-server-live.ts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### You'll be prompted for:
|
|
44
|
+
1. **GitHub Token**: Paste your `ghp_...` token
|
|
45
|
+
2. **Repo Owner**: Your GitHub username
|
|
46
|
+
3. **Repo Name**: Your test repo name
|
|
47
|
+
4. **ngrok Token**: Your ngrok token (or Enter if in env)
|
|
48
|
+
5. **Webhook Secret**: Just press Enter (auto-generated)
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## What Happens
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
✅ Connects to GitHub API
|
|
56
|
+
✅ Verifies repo access
|
|
57
|
+
✅ Starts ngrok tunnel (gets public URL)
|
|
58
|
+
✅ Starts MCP server on port 3000
|
|
59
|
+
✅ Ready to create webhooks!
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Test It
|
|
65
|
+
|
|
66
|
+
### Option 1: Use MCP Inspector
|
|
67
|
+
```bash
|
|
68
|
+
# In browser, open:
|
|
69
|
+
http://localhost:3000/mcp
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Option 2: Subscribe to Issues
|
|
73
|
+
```bash
|
|
74
|
+
curl -X POST http://localhost:3000/mcp/resources/subscribe \
|
|
75
|
+
-H "Content-Type: application/json" \
|
|
76
|
+
-d '{
|
|
77
|
+
"uri": "github://repo/YOUR_USERNAME/YOUR_REPO/issues",
|
|
78
|
+
"callbackUrl": "https://webhook.site/unique-url",
|
|
79
|
+
"callbackSecret": "test123"
|
|
80
|
+
}'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
This creates a REAL GitHub webhook!
|
|
84
|
+
|
|
85
|
+
### Option 3: Create Test Issue
|
|
86
|
+
```
|
|
87
|
+
1. Go to: https://github.com/YOUR_USERNAME/YOUR_REPO/issues/new
|
|
88
|
+
2. Create a new issue
|
|
89
|
+
3. Watch the server logs - you'll see the webhook arrive! 🎉
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Expected Output
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
98
|
+
║ GitHub MCP Server - Live Integration with Webhooks ║
|
|
99
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
100
|
+
|
|
101
|
+
✅ Authenticated as: your-username
|
|
102
|
+
✅ Repository found: your-username/test-repo
|
|
103
|
+
✅ Public URL: https://abc123.ngrok.io
|
|
104
|
+
🚀 MCP Server started on port 3000
|
|
105
|
+
|
|
106
|
+
📡 Ready to receive webhooks!
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Troubleshooting
|
|
112
|
+
|
|
113
|
+
**ngrok Error "failed to start tunnel"**
|
|
114
|
+
→ You need an ngrok auth token. Sign up at ngrok.com (it's free!)
|
|
115
|
+
|
|
116
|
+
**GitHub "Bad credentials"**
|
|
117
|
+
→ Check your token hasn't expired and has the right scopes
|
|
118
|
+
|
|
119
|
+
**GitHub "Not Found"**
|
|
120
|
+
→ Verify repo exists and you own it
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 🎓 Learn More
|
|
125
|
+
|
|
126
|
+
Full setup guide: `examples/GITHUB_LIVE_SETUP.md`
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
**Ready? Let's do this! 🚀**
|