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.
Files changed (80) hide show
  1. package/.eslintrc.json +16 -0
  2. package/.prettierrc.json +8 -0
  3. package/ARCHITECTURE.md +269 -0
  4. package/CONTRIBUTING.md +136 -0
  5. package/GETTING_STARTED.md +310 -0
  6. package/IMPLEMENTATION.md +294 -0
  7. package/LICENSE +21 -0
  8. package/MIGRATION_TO_SDK.md +263 -0
  9. package/README.md +496 -0
  10. package/SDK_INTEGRATION_COMPLETE.md +300 -0
  11. package/STANDARD_SUBSCRIPTIONS.md +268 -0
  12. package/STANDARD_SUBSCRIPTIONS_COMPLETE.md +309 -0
  13. package/SUMMARY.md +272 -0
  14. package/Spec.md +2778 -0
  15. package/dist/errors/index.d.ts +52 -0
  16. package/dist/errors/index.d.ts.map +1 -0
  17. package/dist/errors/index.js +81 -0
  18. package/dist/errors/index.js.map +1 -0
  19. package/dist/index.d.ts +9 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +37 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/protocol/ProtocolHandler.d.ts +37 -0
  24. package/dist/protocol/ProtocolHandler.d.ts.map +1 -0
  25. package/dist/protocol/ProtocolHandler.js +172 -0
  26. package/dist/protocol/ProtocolHandler.js.map +1 -0
  27. package/dist/server.d.ts +6 -0
  28. package/dist/server.d.ts.map +1 -0
  29. package/dist/server.js +502 -0
  30. package/dist/server.js.map +1 -0
  31. package/dist/stores/InMemoryStore.d.ts +27 -0
  32. package/dist/stores/InMemoryStore.d.ts.map +1 -0
  33. package/dist/stores/InMemoryStore.js +73 -0
  34. package/dist/stores/InMemoryStore.js.map +1 -0
  35. package/dist/stores/RedisStore.d.ts +18 -0
  36. package/dist/stores/RedisStore.d.ts.map +1 -0
  37. package/dist/stores/RedisStore.js +45 -0
  38. package/dist/stores/RedisStore.js.map +1 -0
  39. package/dist/stores/index.d.ts +3 -0
  40. package/dist/stores/index.d.ts.map +1 -0
  41. package/dist/stores/index.js +9 -0
  42. package/dist/stores/index.js.map +1 -0
  43. package/dist/subscriptions/SubscriptionManager.d.ts +49 -0
  44. package/dist/subscriptions/SubscriptionManager.d.ts.map +1 -0
  45. package/dist/subscriptions/SubscriptionManager.js +181 -0
  46. package/dist/subscriptions/SubscriptionManager.js.map +1 -0
  47. package/dist/types/index.d.ts +271 -0
  48. package/dist/types/index.d.ts.map +1 -0
  49. package/dist/types/index.js +16 -0
  50. package/dist/types/index.js.map +1 -0
  51. package/dist/utils/index.d.ts +51 -0
  52. package/dist/utils/index.d.ts.map +1 -0
  53. package/dist/utils/index.js +154 -0
  54. package/dist/utils/index.js.map +1 -0
  55. package/dist/webhooks/WebhookManager.d.ts +27 -0
  56. package/dist/webhooks/WebhookManager.d.ts.map +1 -0
  57. package/dist/webhooks/WebhookManager.js +174 -0
  58. package/dist/webhooks/WebhookManager.js.map +1 -0
  59. package/examples/GITHUB_LIVE_EXAMPLE.md +308 -0
  60. package/examples/GITHUB_LIVE_SETUP.md +253 -0
  61. package/examples/QUICKSTART.md +130 -0
  62. package/examples/basic-setup.ts +142 -0
  63. package/examples/github-server-live.ts +690 -0
  64. package/examples/github-server.ts +223 -0
  65. package/examples/google-drive-server-live.ts +773 -0
  66. package/examples/start-github-live.sh +53 -0
  67. package/jest.config.js +20 -0
  68. package/package.json +58 -0
  69. package/src/errors/index.ts +81 -0
  70. package/src/index.ts +19 -0
  71. package/src/server.ts +595 -0
  72. package/src/stores/InMemoryStore.ts +87 -0
  73. package/src/stores/RedisStore.ts +51 -0
  74. package/src/stores/index.ts +2 -0
  75. package/src/subscriptions/SubscriptionManager.ts +240 -0
  76. package/src/types/index.ts +341 -0
  77. package/src/utils/index.ts +156 -0
  78. package/src/webhooks/WebhookManager.ts +230 -0
  79. package/test-sdk-integration.sh +157 -0
  80. package/tsconfig.json +21 -0
@@ -0,0 +1,263 @@
1
+ # Migration to Standard MCP SDK
2
+
3
+ This library has been updated to use the official `@modelcontextprotocol/sdk` while preserving all webhook subscription, authentication, and persistence features.
4
+
5
+ ## What Changed
6
+
7
+ ### ✅ Preserved Features
8
+ - **Webhook Subscriptions**: Still fully supported via `/mcp/resources/subscribe` and `/mcp/resources/unsubscribe`
9
+ - **Authentication**: All auth mechanisms work exactly the same
10
+ - **Persistence**: KV store abstraction (Redis, in-memory) unchanged
11
+ - **Resource Subscriptions**: Same subscription lifecycle management
12
+ - **Webhook Processing**: Same retry logic and notification system
13
+
14
+ ### 🔄 Updated Architecture
15
+
16
+ #### Before (Custom Protocol)
17
+ ```typescript
18
+ // Custom endpoints for each operation
19
+ POST /mcp/tools/call
20
+ POST /mcp/resources/read
21
+ POST /mcp/prompts/get
22
+ ```
23
+
24
+ #### After (Standard MCP)
25
+ ```typescript
26
+ // Single standard MCP endpoint
27
+ POST /mcp
28
+
29
+ // Webhook extensions preserved
30
+ POST /mcp/resources/subscribe
31
+ POST /mcp/resources/unsubscribe
32
+ ```
33
+
34
+ ### 📦 Dependency Changes
35
+
36
+ **Removed:**
37
+ - `ajv` - JSON Schema validation
38
+
39
+ **Added:**
40
+ - `zod` - Schema validation (required by MCP SDK)
41
+
42
+ **Required Peer Dependencies:**
43
+ - `@modelcontextprotocol/sdk@^1.0.0`
44
+ - `express@^4.18.0`
45
+
46
+ ## Migration Steps
47
+
48
+ ### 1. Update Dependencies
49
+
50
+ ```bash
51
+ npm install zod@^3.22.0
52
+ npm uninstall ajv
53
+ ```
54
+
55
+ ### 2. No Code Changes Required
56
+
57
+ Your existing server configuration works without changes:
58
+
59
+ ```typescript
60
+ import { createMCPServer, InMemoryStore } from 'mcp-http-webhook';
61
+
62
+ const server = createMCPServer({
63
+ name: 'my-server',
64
+ version: '1.0.0',
65
+ store: new InMemoryStore(),
66
+ publicUrl: 'https://api.example.com',
67
+
68
+ // All existing config works the same
69
+ tools: [...],
70
+ resources: [...],
71
+ prompts: [...],
72
+ webhooks: {...},
73
+ authentication: {...}
74
+ });
75
+
76
+ await server.start();
77
+ ```
78
+
79
+ ### 3. Client Integration Updates
80
+
81
+ #### MCP Inspector / Claude Desktop / VS Code
82
+
83
+ Your server now works with **all standard MCP clients** out of the box:
84
+
85
+ ```json
86
+ {
87
+ "mcpServers": {
88
+ "my-server": {
89
+ "command": "node",
90
+ "args": ["path/to/server.js"],
91
+ "env": {}
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ #### HTTP Clients
98
+
99
+ Update your endpoint from custom paths to the standard `/mcp` endpoint:
100
+
101
+ **Before:**
102
+ ```typescript
103
+ // Custom endpoints
104
+ POST https://api.example.com/mcp/tools/call
105
+ POST https://api.example.com/mcp/resources/read
106
+ ```
107
+
108
+ **After:**
109
+ ```typescript
110
+ // Standard MCP endpoint
111
+ POST https://api.example.com/mcp
112
+
113
+ // Webhook subscriptions still work the same
114
+ POST https://api.example.com/mcp/resources/subscribe
115
+ POST https://api.example.com/mcp/resources/unsubscribe
116
+ ```
117
+
118
+ ### 4. Schema Definition Updates
119
+
120
+ JSON Schema format remains the same, but it's now converted to Zod internally:
121
+
122
+ ```typescript
123
+ {
124
+ tools: [{
125
+ name: 'search',
126
+ inputSchema: {
127
+ type: 'object',
128
+ properties: {
129
+ query: { type: 'string' },
130
+ limit: { type: 'number' }
131
+ },
132
+ required: ['query']
133
+ },
134
+ handler: async (args, auth) => {
135
+ // Handler unchanged
136
+ return { results: [] };
137
+ }
138
+ }]
139
+ }
140
+ ```
141
+
142
+ ## Benefits of Migration
143
+
144
+ ### 🎯 Standard Compliance
145
+ - Works with all MCP clients (Inspector, Claude Desktop, VS Code, Cursor)
146
+ - Follows official MCP protocol specification
147
+ - Future-proof as MCP ecosystem evolves
148
+
149
+ ### 🔌 Better Interoperability
150
+ - Standard transport layer (`StreamableHTTPServerTransport`)
151
+ - Consistent error handling
152
+ - Standard message formats
153
+
154
+ ### 🚀 Enhanced Features
155
+ - Automatic JSON Schema to Zod conversion
156
+ - Better type safety with Zod
157
+ - Improved validation error messages
158
+
159
+ ### 🔄 Preserved Extensions
160
+ - All webhook functionality intact
161
+ - Resource subscriptions work as before
162
+ - Authentication mechanisms unchanged
163
+ - Storage abstraction untouched
164
+
165
+ ## Testing Your Migration
166
+
167
+ ### 1. Build and Run
168
+
169
+ ```bash
170
+ npm run build
171
+ node dist/examples/basic-setup.js
172
+ ```
173
+
174
+ ### 2. Test Standard MCP Endpoint
175
+
176
+ ```bash
177
+ curl -X POST http://localhost:3000/mcp \
178
+ -H "Content-Type: application/json" \
179
+ -d '{
180
+ "jsonrpc": "2.0",
181
+ "id": 1,
182
+ "method": "tools/list"
183
+ }'
184
+ ```
185
+
186
+ ### 3. Test Webhook Subscriptions
187
+
188
+ ```bash
189
+ # Subscribe to a resource
190
+ curl -X POST http://localhost:3000/mcp/resources/subscribe \
191
+ -H "Content-Type: application/json" \
192
+ -d '{
193
+ "uri": "resource://example/data",
194
+ "callbackUrl": "https://client.example.com/webhooks",
195
+ "callbackSecret": "secret123"
196
+ }'
197
+ ```
198
+
199
+ ### 4. Test with MCP Inspector
200
+
201
+ ```bash
202
+ npx @modelcontextprotocol/inspector http://localhost:3000/mcp
203
+ ```
204
+
205
+ ## Troubleshooting
206
+
207
+ ### Schema Conversion Issues
208
+
209
+ If you have complex nested schemas, verify the conversion:
210
+
211
+ ```typescript
212
+ // Complex nested object
213
+ {
214
+ type: 'object',
215
+ properties: {
216
+ user: {
217
+ type: 'object',
218
+ properties: {
219
+ name: { type: 'string' },
220
+ age: { type: 'number' }
221
+ }
222
+ },
223
+ tags: {
224
+ type: 'array',
225
+ items: { type: 'string' }
226
+ }
227
+ }
228
+ }
229
+ ```
230
+
231
+ This is automatically converted to proper Zod schemas.
232
+
233
+ ### Type Errors
234
+
235
+ If you encounter TypeScript errors, ensure you're using:
236
+ - `typescript@^5.0.0`
237
+ - `zod@^3.22.0`
238
+ - `@modelcontextprotocol/sdk@^1.0.0`
239
+
240
+ ### Client Connection Issues
241
+
242
+ If clients can't connect:
243
+
244
+ 1. Verify the endpoint is `/mcp` (not `/mcp/tools/call`)
245
+ 2. Check CORS settings if using browser clients
246
+ 3. Ensure authentication headers are passed correctly
247
+
248
+ ## Support
249
+
250
+ For issues or questions:
251
+ - Check the [README](./README.md) for updated examples
252
+ - Review [ARCHITECTURE.md](./ARCHITECTURE.md) for system design
253
+ - See [examples/](./examples/) for working code
254
+
255
+ ## Rollback (Not Recommended)
256
+
257
+ If you need to rollback temporarily, use version `0.9.x`:
258
+
259
+ ```bash
260
+ npm install mcp-http-webhook@0.9.0
261
+ ```
262
+
263
+ However, we strongly recommend migrating as the custom protocol implementation is deprecated.