mcp-http-webhook 1.0.5 → 1.0.7
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/COMPLETION_IMPLEMENTATION.md +280 -0
- package/PAGINATION_IMPLEMENTATION.md +221 -0
- package/README.md +194 -6
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +159 -9
- package/dist/server.js.map +1 -1
- package/dist/types/index.d.ts +76 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/examples/completion-example.ts +339 -0
- package/examples/pagination-example.ts +261 -0
- package/package.json +5 -4
- package/src/__tests__/pagination.test.ts +323 -0
- package/src/server.ts +203 -15
- package/src/types/index.ts +112 -1
package/src/types/index.ts
CHANGED
|
@@ -10,6 +10,42 @@ export interface JSONSchema {
|
|
|
10
10
|
[key: string]: any;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
export type CredentialFieldType =
|
|
14
|
+
| 'string'
|
|
15
|
+
| 'number'
|
|
16
|
+
| 'boolean'
|
|
17
|
+
| 'object'
|
|
18
|
+
| 'array'
|
|
19
|
+
| 'date'
|
|
20
|
+
| 'file'
|
|
21
|
+
| 'binary';
|
|
22
|
+
|
|
23
|
+
export type CredentialFieldConfigType =
|
|
24
|
+
| 'jwt'
|
|
25
|
+
| 'bearer'
|
|
26
|
+
| 'basic'
|
|
27
|
+
| 'oauth'
|
|
28
|
+
| 'oidc'
|
|
29
|
+
| 'keyValue';
|
|
30
|
+
|
|
31
|
+
export interface CredentialFieldConfig {
|
|
32
|
+
type?: CredentialFieldConfigType;
|
|
33
|
+
inject?: any;
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CredentialFieldDefinition {
|
|
38
|
+
name: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
type: CredentialFieldType;
|
|
41
|
+
required?: boolean;
|
|
42
|
+
default?: any;
|
|
43
|
+
innerFields?: CredentialFieldDefinition[];
|
|
44
|
+
or?: CredentialFieldDefinition[];
|
|
45
|
+
config?: CredentialFieldConfig;
|
|
46
|
+
metadata?: Record<string, any>;
|
|
47
|
+
}
|
|
48
|
+
|
|
13
49
|
/**
|
|
14
50
|
* Authentication context passed to handlers
|
|
15
51
|
*/
|
|
@@ -161,9 +197,33 @@ export interface ResourceListItem {
|
|
|
161
197
|
/**
|
|
162
198
|
* Resource read result
|
|
163
199
|
*/
|
|
200
|
+
/**
|
|
201
|
+
* Pagination metadata for responses
|
|
202
|
+
*/
|
|
203
|
+
export interface PaginationMetadata {
|
|
204
|
+
page: number;
|
|
205
|
+
limit: number;
|
|
206
|
+
total?: number;
|
|
207
|
+
hasMore?: boolean;
|
|
208
|
+
nextCursor?: string;
|
|
209
|
+
prevCursor?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Resource read result with optional pagination
|
|
214
|
+
*/
|
|
164
215
|
export interface ResourceReadResult<TData = any> {
|
|
165
216
|
contents: TData;
|
|
166
217
|
metadata?: ResourceMetadata;
|
|
218
|
+
pagination?: PaginationMetadata;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Resource list result with optional pagination
|
|
223
|
+
*/
|
|
224
|
+
export interface ResourceListResult {
|
|
225
|
+
resources: ResourceListItem[];
|
|
226
|
+
pagination?: PaginationMetadata;
|
|
167
227
|
}
|
|
168
228
|
|
|
169
229
|
/**
|
|
@@ -173,6 +233,7 @@ export interface ResourceReadOptions {
|
|
|
173
233
|
pagination?: {
|
|
174
234
|
page?: number;
|
|
175
235
|
limit?: number;
|
|
236
|
+
cursor?: string;
|
|
176
237
|
};
|
|
177
238
|
}
|
|
178
239
|
|
|
@@ -244,11 +305,52 @@ export interface ResourceDefinition<TData = any> {
|
|
|
244
305
|
options?: ResourceReadOptions
|
|
245
306
|
) => Promise<ResourceReadResult<TData>>;
|
|
246
307
|
|
|
247
|
-
list?: (
|
|
308
|
+
list?: (
|
|
309
|
+
context: AuthContext,
|
|
310
|
+
options?: ResourceReadOptions
|
|
311
|
+
) => Promise<ResourceListResult | ResourceListItem[]>;
|
|
248
312
|
|
|
249
313
|
subscription?: ResourceSubscription;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Optional completion handler for resource URI parameters
|
|
317
|
+
*/
|
|
318
|
+
completion?: CompletionHandler;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Completion item returned by completion handlers
|
|
323
|
+
*/
|
|
324
|
+
export interface CompletionItem {
|
|
325
|
+
value: string;
|
|
326
|
+
label?: string;
|
|
327
|
+
description?: string;
|
|
328
|
+
type?: 'value' | 'function' | 'variable' | 'constant' | 'other';
|
|
250
329
|
}
|
|
251
330
|
|
|
331
|
+
/**
|
|
332
|
+
* Completion reference - identifies what to complete
|
|
333
|
+
*/
|
|
334
|
+
export type CompletionRef =
|
|
335
|
+
| {
|
|
336
|
+
type: 'ref/prompt';
|
|
337
|
+
name: string;
|
|
338
|
+
arguments?: Record<string, string>;
|
|
339
|
+
}
|
|
340
|
+
| {
|
|
341
|
+
type: 'ref/resource';
|
|
342
|
+
uri: string;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Completion handler function
|
|
347
|
+
*/
|
|
348
|
+
export type CompletionHandler = (
|
|
349
|
+
ref: CompletionRef,
|
|
350
|
+
argument: string,
|
|
351
|
+
context: AuthContext
|
|
352
|
+
) => Promise<CompletionItem[]>;
|
|
353
|
+
|
|
252
354
|
/**
|
|
253
355
|
* Prompt definition
|
|
254
356
|
*/
|
|
@@ -266,6 +368,10 @@ export interface PromptDefinition {
|
|
|
266
368
|
content: string;
|
|
267
369
|
}>;
|
|
268
370
|
}>;
|
|
371
|
+
/**
|
|
372
|
+
* Optional completion handler for prompt arguments
|
|
373
|
+
*/
|
|
374
|
+
completion?: CompletionHandler;
|
|
269
375
|
}
|
|
270
376
|
|
|
271
377
|
/**
|
|
@@ -355,6 +461,9 @@ export interface MCPServerConfig {
|
|
|
355
461
|
tools: ToolDefinition[];
|
|
356
462
|
resources: ResourceDefinition[];
|
|
357
463
|
prompts?: PromptDefinition[];
|
|
464
|
+
|
|
465
|
+
// Completions
|
|
466
|
+
completions?: CompletionHandler;
|
|
358
467
|
|
|
359
468
|
// Storage
|
|
360
469
|
store: KeyValueStore;
|
|
@@ -372,6 +481,8 @@ export interface MCPServerConfig {
|
|
|
372
481
|
// Logging
|
|
373
482
|
logger?: Logger;
|
|
374
483
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
484
|
+
|
|
485
|
+
credentials?: CredentialFieldDefinition[];
|
|
375
486
|
}
|
|
376
487
|
|
|
377
488
|
/**
|