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,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.
|