mcp-http-webhook 1.0.29 โ†’ 1.0.30

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/SUMMARY.md DELETED
@@ -1,272 +0,0 @@
1
- # โœ… MCP HTTP Webhook Library - SDK Integration Complete
2
-
3
- ## ๐ŸŽฏ What Was Accomplished
4
-
5
- Successfully refactored the MCP HTTP Webhook server library to use the **official `@modelcontextprotocol/sdk`** while preserving all webhook subscription, authentication, and persistence features.
6
-
7
- ## ๐Ÿ“‹ Summary of Changes
8
-
9
- ### Core Architecture
10
-
11
- **Before:**
12
- - Custom `ProtocolHandler` implementing MCP protocol from scratch
13
- - Custom endpoints: `/mcp/tools/call`, `/mcp/resources/read`, `/mcp/prompts/get`
14
- - AJV for JSON Schema validation
15
-
16
- **After:**
17
- - Official `McpServer` from `@modelcontextprotocol/sdk`
18
- - Standard endpoint: `POST /mcp` using `StreamableHTTPServerTransport`
19
- - Zod for schema validation (SDK requirement)
20
- - Webhook extensions preserved: `/mcp/resources/subscribe`, `/mcp/resources/unsubscribe`
21
-
22
- ### Files Modified
23
-
24
- 1. **`src/server.ts`** - Integrated MCP SDK
25
- - Replaced ProtocolHandler with McpServer
26
- - Added `convertToZodSchema()` helper
27
- - Integrated StreamableHTTPServerTransport
28
- - Preserved webhook subscription endpoints
29
-
30
- 2. **`src/index.ts`** - Updated exports
31
- - Removed ProtocolHandler export
32
- - Added store exports
33
-
34
- 3. **`package.json`** - Updated dependencies
35
- - Added: `zod@^3.22.0`
36
- - Removed: `ajv@^8.12.0`
37
-
38
- 4. **`examples/basic-setup.ts`** - Updated documentation
39
-
40
- ### Files Removed
41
-
42
- - **`src/protocol/ProtocolHandler.ts`** - Replaced by SDK
43
-
44
- ### Files Created
45
-
46
- 1. **`MIGRATION_TO_SDK.md`** - Comprehensive migration guide
47
- 2. **`SDK_INTEGRATION_COMPLETE.md`** - Technical summary
48
- 3. **`test-sdk-integration.sh`** - Integration test script
49
- 4. **`SUMMARY.md`** - This file
50
-
51
- ### Files Unchanged (All Features Preserved)
52
-
53
- โœ… `src/subscriptions/SubscriptionManager.ts`
54
- โœ… `src/webhooks/WebhookManager.ts`
55
- โœ… `src/stores/InMemoryStore.ts`
56
- โœ… `src/stores/RedisStore.ts`
57
- โœ… `src/types/index.ts`
58
- โœ… `src/errors/index.ts`
59
- โœ… `src/utils/index.ts`
60
-
61
- ## ๐ŸŽ‰ Benefits
62
-
63
- ### โœ… Standard Compliance
64
- - Works with **all MCP clients** (Inspector, Claude Desktop, VS Code, Cursor)
65
- - Follows official MCP protocol specification
66
- - Future-proof with SDK updates
67
-
68
- ### โœ… No Breaking Changes
69
- - Existing server configurations work without modification
70
- - Tool/resource/prompt handlers unchanged
71
- - Authentication mechanism preserved
72
- - Storage abstraction intact
73
-
74
- ### โœ… Enhanced Developer Experience
75
- - Automatic JSON Schema โ†’ Zod conversion
76
- - Better type safety with Zod validation
77
- - Clear migration path
78
- - Comprehensive documentation
79
-
80
- ### โœ… Preserved Innovations
81
- - Webhook subscription system fully functional
82
- - Third-party webhook integration (GitHub, Slack, etc.)
83
- - Stateless, horizontally scalable design
84
- - Flexible KV storage (Redis, in-memory, custom)
85
-
86
- ## ๐Ÿงช Testing
87
-
88
- ### Build Status
89
- ```bash
90
- โœ… TypeScript compilation successful
91
- โœ… No type errors
92
- โœ… All dependencies resolved
93
- ```
94
-
95
- ### Test Script
96
- ```bash
97
- cd /data/work/kaman3.0/packages/plugins/mcp-proxy
98
- ./test-sdk-integration.sh
99
- ```
100
-
101
- This tests:
102
- 1. Health check endpoint
103
- 2. Standard MCP tools/list
104
- 3. Tool calling via /mcp
105
- 4. Resource listing
106
- 5. Resource reading
107
- 6. Webhook subscriptions (extension)
108
-
109
- ## ๐Ÿš€ Usage
110
-
111
- ### Start the Example Server
112
-
113
- ```bash
114
- cd /data/work/kaman3.0/packages/plugins/mcp-proxy
115
- npm run build
116
- node dist/examples/basic-setup.js
117
- ```
118
-
119
- ### Test with MCP Inspector
120
-
121
- ```bash
122
- npx @modelcontextprotocol/inspector http://localhost:3000/mcp
123
- ```
124
-
125
- ### Test with curl
126
-
127
- ```bash
128
- # List available tools
129
- curl -X POST http://localhost:3000/mcp \
130
- -H "Content-Type: application/json" \
131
- -d '{
132
- "jsonrpc": "2.0",
133
- "id": 1,
134
- "method": "tools/list"
135
- }'
136
-
137
- # Call a tool
138
- curl -X POST http://localhost:3000/mcp \
139
- -H "Content-Type: application/json" \
140
- -d '{
141
- "jsonrpc": "2.0",
142
- "id": 2,
143
- "method": "tools/call",
144
- "params": {
145
- "name": "echo",
146
- "arguments": {"message": "Hello"}
147
- }
148
- }'
149
-
150
- # Subscribe to resource changes (webhook extension)
151
- curl -X POST http://localhost:3000/mcp/resources/subscribe \
152
- -H "Content-Type: application/json" \
153
- -d '{
154
- "uri": "example://greeting/world",
155
- "callbackUrl": "https://client.com/webhooks",
156
- "callbackSecret": "secret123"
157
- }'
158
- ```
159
-
160
- ### Configure Claude Desktop
161
-
162
- Add to your Claude Desktop config:
163
-
164
- ```json
165
- {
166
- "mcpServers": {
167
- "example-server": {
168
- "url": "http://localhost:3000/mcp"
169
- }
170
- }
171
- }
172
- ```
173
-
174
- ## ๐Ÿ“š Documentation
175
-
176
- All documentation has been updated:
177
-
178
- - **[README.md](./README.md)** - Main documentation with SDK usage
179
- - **[MIGRATION_TO_SDK.md](./MIGRATION_TO_SDK.md)** - Migration guide for users
180
- - **[SDK_INTEGRATION_COMPLETE.md](./SDK_INTEGRATION_COMPLETE.md)** - Technical details
181
- - **[ARCHITECTURE.md](./ARCHITECTURE.md)** - System architecture
182
- - **[GETTING_STARTED.md](./GETTING_STARTED.md)** - Quick start guide
183
- - **[examples/](./examples/)** - Working code examples
184
-
185
- ## ๐ŸŽฏ User Migration Path
186
-
187
- For users upgrading from the custom protocol:
188
-
189
- 1. **Update dependencies:**
190
- ```bash
191
- npm install zod@^3.22.0
192
- npm uninstall ajv
193
- ```
194
-
195
- 2. **No code changes required** - existing configs work!
196
-
197
- 3. **Update client endpoints:**
198
- - Change from `/mcp/tools/call` โ†’ `/mcp`
199
-
200
- 4. **Test:**
201
- ```bash
202
- npm run build
203
- npm start
204
- npx @modelcontextprotocol/inspector http://localhost:3000/mcp
205
- ```
206
-
207
- See [MIGRATION_TO_SDK.md](./MIGRATION_TO_SDK.md) for complete details.
208
-
209
- ## โœจ Key Technical Achievements
210
-
211
- ### 1. Schema Conversion System
212
-
213
- Created automatic JSON Schema โ†’ Zod conversion:
214
-
215
- ```typescript
216
- function convertToZodSchema(jsonSchema: JSONSchema): Record<string, z.ZodTypeAny>
217
- ```
218
-
219
- Handles:
220
- - Primitive types (string, number, boolean)
221
- - Complex types (arrays, objects)
222
- - Nested schemas
223
- - Required/optional fields
224
-
225
- ### 2. Standard MCP Integration
226
-
227
- ```typescript
228
- // Create SDK server
229
- const sdkServer = new McpServer({ name, version });
230
-
231
- // Register capabilities
232
- sdkServer.registerTool(/* ... */);
233
- sdkServer.registerResource(/* ... */);
234
- sdkServer.registerPrompt(/* ... */);
235
-
236
- // Handle requests with standard transport
237
- app.post('/mcp', async (req, res) => {
238
- const transport = new StreamableHTTPServerTransport();
239
- await sdkServer.connect(transport);
240
- await transport.handleRequest(req, res, req.body);
241
- });
242
- ```
243
-
244
- ### 3. Webhook Extensions Preserved
245
-
246
- Standard MCP + custom webhook endpoints coexist:
247
-
248
- - **Standard**: `POST /mcp` (all MCP operations)
249
- - **Extensions**:
250
- - `POST /mcp/resources/subscribe`
251
- - `POST /mcp/resources/unsubscribe`
252
- - `POST /webhooks/incoming/{subscriptionId}`
253
-
254
- ## ๐Ÿ† Result
255
-
256
- A production-ready MCP server library that:
257
-
258
- โœ… Uses official `@modelcontextprotocol/sdk`
259
- โœ… Works with all standard MCP clients
260
- โœ… Preserves webhook subscription features
261
- โœ… Maintains backward compatibility
262
- โœ… Provides clear documentation
263
- โœ… Includes comprehensive tests
264
-
265
- **Status: Production Ready** ๐Ÿš€
266
-
267
- ---
268
-
269
- **Next Steps:**
270
- 1. Run `./test-sdk-integration.sh` to verify
271
- 2. Test with MCP Inspector
272
- 3. Deploy and enjoy universal MCP client compatibility!
@@ -1,308 +0,0 @@
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)