@leanmcp/core 0.3.14 → 0.3.16
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/LICENSE +21 -21
- package/README.md +474 -474
- package/dist/index.d.mts +145 -130
- package/dist/index.d.ts +145 -130
- package/package.json +77 -77
- package/dist/chunk-LPEX4YW6.mjs +0 -13
- package/dist/server-BEQUIEE2.mjs +0 -25808
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,133 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Simple configurable logger for LeanMCP SDK
|
|
5
|
+
*/
|
|
6
|
+
declare enum LogLevel {
|
|
7
|
+
DEBUG = 0,
|
|
8
|
+
INFO = 1,
|
|
9
|
+
WARN = 2,
|
|
10
|
+
ERROR = 3,
|
|
11
|
+
NONE = 4
|
|
12
|
+
}
|
|
13
|
+
interface LoggerOptions {
|
|
14
|
+
level?: LogLevel;
|
|
15
|
+
prefix?: string;
|
|
16
|
+
timestamps?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Enable or disable ANSI colors. Defaults to true.
|
|
19
|
+
*/
|
|
20
|
+
colorize?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Provide additional metadata context (e.g. module name)
|
|
23
|
+
*/
|
|
24
|
+
context?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional third-party handlers (PostHog, Sentry, etc.)
|
|
27
|
+
* They receive the structured payload for easy integration.
|
|
28
|
+
*/
|
|
29
|
+
handlers?: LoggerHandler[];
|
|
30
|
+
}
|
|
31
|
+
interface LogPayload {
|
|
32
|
+
level: LogLevel;
|
|
33
|
+
levelLabel: string;
|
|
34
|
+
message: string;
|
|
35
|
+
args: any[];
|
|
36
|
+
prefix?: string;
|
|
37
|
+
context?: string;
|
|
38
|
+
timestamp: string;
|
|
39
|
+
}
|
|
40
|
+
type LoggerHandler = (payload: LogPayload) => void;
|
|
41
|
+
declare class Logger {
|
|
42
|
+
private level;
|
|
43
|
+
private prefix;
|
|
44
|
+
private timestamps;
|
|
45
|
+
private colorize;
|
|
46
|
+
private context?;
|
|
47
|
+
private handlers;
|
|
48
|
+
constructor(options?: LoggerOptions);
|
|
49
|
+
private format;
|
|
50
|
+
private shouldLog;
|
|
51
|
+
private emit;
|
|
52
|
+
debug(message: string, ...args: any[]): void;
|
|
53
|
+
info(message: string, ...args: any[]): void;
|
|
54
|
+
warn(message: string, ...args: any[]): void;
|
|
55
|
+
error(message: string, ...args: any[]): void;
|
|
56
|
+
setLevel(level: LogLevel): void;
|
|
57
|
+
getLevel(): LogLevel;
|
|
58
|
+
}
|
|
59
|
+
declare const defaultLogger: Logger;
|
|
60
|
+
|
|
61
|
+
interface HTTPServerOptions {
|
|
62
|
+
port?: number;
|
|
63
|
+
cors?: boolean | {
|
|
64
|
+
origin?: string | string[];
|
|
65
|
+
credentials?: boolean;
|
|
66
|
+
};
|
|
67
|
+
logging?: boolean;
|
|
68
|
+
logger?: Logger;
|
|
69
|
+
sessionTimeout?: number;
|
|
70
|
+
stateless?: boolean;
|
|
71
|
+
dashboard?: boolean;
|
|
72
|
+
/** OAuth/Auth configuration (MCP authorization spec) */
|
|
73
|
+
auth?: HTTPServerAuthOptions;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* OAuth/Auth configuration for MCP server
|
|
77
|
+
*
|
|
78
|
+
* Enables MCP authorization spec compliance by exposing
|
|
79
|
+
* `/.well-known/oauth-protected-resource` (RFC 9728)
|
|
80
|
+
*/
|
|
81
|
+
interface HTTPServerAuthOptions {
|
|
82
|
+
/** Resource identifier (defaults to server URL) */
|
|
83
|
+
resource?: string;
|
|
84
|
+
/** Authorization servers (defaults to self) */
|
|
85
|
+
authorizationServers?: string[];
|
|
86
|
+
/** Supported OAuth scopes */
|
|
87
|
+
scopesSupported?: string[];
|
|
88
|
+
/** Documentation URL */
|
|
89
|
+
documentationUrl?: string;
|
|
90
|
+
/** Enable built-in OAuth authorization server */
|
|
91
|
+
enableOAuthServer?: boolean;
|
|
92
|
+
/** OAuth server options (when enableOAuthServer is true) */
|
|
93
|
+
oauthServerOptions?: {
|
|
94
|
+
/** Session secret for signing tokens/state */
|
|
95
|
+
sessionSecret: string;
|
|
96
|
+
/** JWT signing secret (defaults to sessionSecret if not provided) */
|
|
97
|
+
jwtSigningSecret?: string;
|
|
98
|
+
/** JWT encryption secret for encrypting upstream tokens */
|
|
99
|
+
jwtEncryptionSecret?: Buffer;
|
|
100
|
+
/** Issuer URL for JWTs */
|
|
101
|
+
issuer?: string;
|
|
102
|
+
/** Access token TTL in seconds (default: 3600) */
|
|
103
|
+
tokenTTL?: number;
|
|
104
|
+
/** Enable Dynamic Client Registration (DCR) */
|
|
105
|
+
enableDCR?: boolean;
|
|
106
|
+
/** Upstream OAuth provider configuration */
|
|
107
|
+
upstreamProvider?: {
|
|
108
|
+
id: string;
|
|
109
|
+
authorizationEndpoint: string;
|
|
110
|
+
tokenEndpoint: string;
|
|
111
|
+
clientId: string;
|
|
112
|
+
clientSecret: string;
|
|
113
|
+
scopes?: string[];
|
|
114
|
+
userInfoEndpoint?: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface MCPServerFactory {
|
|
119
|
+
(): Server | Promise<Server>;
|
|
120
|
+
}
|
|
121
|
+
type HTTPServerInput = MCPServerFactory | MCPServerConstructorOptions;
|
|
122
|
+
/**
|
|
123
|
+
* Create an HTTP server for MCP with Streamable HTTP transport
|
|
124
|
+
* Returns the HTTP server instance to keep the process alive
|
|
125
|
+
*
|
|
126
|
+
* @param serverInput - Either MCPServerConstructorOptions or a factory function that returns a Server
|
|
127
|
+
* @param options - HTTP server options (only used when serverInput is a factory function)
|
|
128
|
+
*/
|
|
129
|
+
declare function createHTTPServer(serverInput: HTTPServerInput, options?: HTTPServerOptions): Promise<any>;
|
|
130
|
+
|
|
3
131
|
/**
|
|
4
132
|
* Security scheme for MCP tools (per MCP authorization spec)
|
|
5
133
|
*
|
|
@@ -220,132 +348,6 @@ declare function SchemaConstraint(constraints: {
|
|
|
220
348
|
*/
|
|
221
349
|
declare function classToJsonSchemaWithConstraints(classConstructor: new () => any): any;
|
|
222
350
|
|
|
223
|
-
/**
|
|
224
|
-
* Simple configurable logger for LeanMCP SDK
|
|
225
|
-
*/
|
|
226
|
-
declare enum LogLevel {
|
|
227
|
-
DEBUG = 0,
|
|
228
|
-
INFO = 1,
|
|
229
|
-
WARN = 2,
|
|
230
|
-
ERROR = 3,
|
|
231
|
-
NONE = 4
|
|
232
|
-
}
|
|
233
|
-
interface LoggerOptions {
|
|
234
|
-
level?: LogLevel;
|
|
235
|
-
prefix?: string;
|
|
236
|
-
timestamps?: boolean;
|
|
237
|
-
/**
|
|
238
|
-
* Enable or disable ANSI colors. Defaults to true.
|
|
239
|
-
*/
|
|
240
|
-
colorize?: boolean;
|
|
241
|
-
/**
|
|
242
|
-
* Provide additional metadata context (e.g. module name)
|
|
243
|
-
*/
|
|
244
|
-
context?: string;
|
|
245
|
-
/**
|
|
246
|
-
* Optional third-party handlers (PostHog, Sentry, etc.)
|
|
247
|
-
* They receive the structured payload for easy integration.
|
|
248
|
-
*/
|
|
249
|
-
handlers?: LoggerHandler[];
|
|
250
|
-
}
|
|
251
|
-
interface LogPayload {
|
|
252
|
-
level: LogLevel;
|
|
253
|
-
levelLabel: string;
|
|
254
|
-
message: string;
|
|
255
|
-
args: any[];
|
|
256
|
-
prefix?: string;
|
|
257
|
-
context?: string;
|
|
258
|
-
timestamp: string;
|
|
259
|
-
}
|
|
260
|
-
type LoggerHandler = (payload: LogPayload) => void;
|
|
261
|
-
declare class Logger {
|
|
262
|
-
private level;
|
|
263
|
-
private prefix;
|
|
264
|
-
private timestamps;
|
|
265
|
-
private colorize;
|
|
266
|
-
private context?;
|
|
267
|
-
private handlers;
|
|
268
|
-
constructor(options?: LoggerOptions);
|
|
269
|
-
private format;
|
|
270
|
-
private shouldLog;
|
|
271
|
-
private emit;
|
|
272
|
-
debug(message: string, ...args: any[]): void;
|
|
273
|
-
info(message: string, ...args: any[]): void;
|
|
274
|
-
warn(message: string, ...args: any[]): void;
|
|
275
|
-
error(message: string, ...args: any[]): void;
|
|
276
|
-
setLevel(level: LogLevel): void;
|
|
277
|
-
getLevel(): LogLevel;
|
|
278
|
-
}
|
|
279
|
-
declare const defaultLogger: Logger;
|
|
280
|
-
|
|
281
|
-
interface HTTPServerOptions {
|
|
282
|
-
port?: number;
|
|
283
|
-
cors?: boolean | {
|
|
284
|
-
origin?: string | string[];
|
|
285
|
-
credentials?: boolean;
|
|
286
|
-
};
|
|
287
|
-
logging?: boolean;
|
|
288
|
-
logger?: Logger;
|
|
289
|
-
sessionTimeout?: number;
|
|
290
|
-
stateless?: boolean;
|
|
291
|
-
dashboard?: boolean;
|
|
292
|
-
/** OAuth/Auth configuration (MCP authorization spec) */
|
|
293
|
-
auth?: HTTPServerAuthOptions;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* OAuth/Auth configuration for MCP server
|
|
297
|
-
*
|
|
298
|
-
* Enables MCP authorization spec compliance by exposing
|
|
299
|
-
* `/.well-known/oauth-protected-resource` (RFC 9728)
|
|
300
|
-
*/
|
|
301
|
-
interface HTTPServerAuthOptions {
|
|
302
|
-
/** Resource identifier (defaults to server URL) */
|
|
303
|
-
resource?: string;
|
|
304
|
-
/** Authorization servers (defaults to self) */
|
|
305
|
-
authorizationServers?: string[];
|
|
306
|
-
/** Supported OAuth scopes */
|
|
307
|
-
scopesSupported?: string[];
|
|
308
|
-
/** Documentation URL */
|
|
309
|
-
documentationUrl?: string;
|
|
310
|
-
/** Enable built-in OAuth authorization server */
|
|
311
|
-
enableOAuthServer?: boolean;
|
|
312
|
-
/** OAuth server options (when enableOAuthServer is true) */
|
|
313
|
-
oauthServerOptions?: {
|
|
314
|
-
/** Session secret for signing tokens/state */
|
|
315
|
-
sessionSecret: string;
|
|
316
|
-
/** JWT signing secret (defaults to sessionSecret if not provided) */
|
|
317
|
-
jwtSigningSecret?: string;
|
|
318
|
-
/** JWT encryption secret for encrypting upstream tokens */
|
|
319
|
-
jwtEncryptionSecret?: Buffer;
|
|
320
|
-
/** Issuer URL for JWTs */
|
|
321
|
-
issuer?: string;
|
|
322
|
-
/** Access token TTL in seconds (default: 3600) */
|
|
323
|
-
tokenTTL?: number;
|
|
324
|
-
/** Upstream OAuth provider configuration */
|
|
325
|
-
upstreamProvider?: {
|
|
326
|
-
id: string;
|
|
327
|
-
authorizationEndpoint: string;
|
|
328
|
-
tokenEndpoint: string;
|
|
329
|
-
clientId: string;
|
|
330
|
-
clientSecret: string;
|
|
331
|
-
scopes?: string[];
|
|
332
|
-
userInfoEndpoint?: string;
|
|
333
|
-
};
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
interface MCPServerFactory {
|
|
337
|
-
(): Server | Promise<Server>;
|
|
338
|
-
}
|
|
339
|
-
type HTTPServerInput = MCPServerFactory | MCPServerConstructorOptions;
|
|
340
|
-
/**
|
|
341
|
-
* Create an HTTP server for MCP with Streamable HTTP transport
|
|
342
|
-
* Returns the HTTP server instance to keep the process alive
|
|
343
|
-
*
|
|
344
|
-
* @param serverInput - Either MCPServerConstructorOptions or a factory function that returns a Server
|
|
345
|
-
* @param options - HTTP server options (only used when serverInput is a factory function)
|
|
346
|
-
*/
|
|
347
|
-
declare function createHTTPServer(serverInput: HTTPServerInput, options?: HTTPServerOptions): Promise<any>;
|
|
348
|
-
|
|
349
351
|
/**
|
|
350
352
|
* Input validation utilities for LeanMCP
|
|
351
353
|
* Provides secure validation for common input types
|
|
@@ -549,6 +551,7 @@ interface MCPServerConstructorOptions {
|
|
|
549
551
|
};
|
|
550
552
|
sessionTimeout?: number;
|
|
551
553
|
stateless?: boolean;
|
|
554
|
+
auth?: HTTPServerAuthOptions;
|
|
552
555
|
}
|
|
553
556
|
interface RegisteredTool {
|
|
554
557
|
name: string;
|
|
@@ -668,10 +671,16 @@ declare class MCPServer {
|
|
|
668
671
|
method: string;
|
|
669
672
|
params?: {
|
|
670
673
|
[x: string]: unknown;
|
|
674
|
+
task?: {
|
|
675
|
+
[x: string]: unknown;
|
|
676
|
+
ttl?: number | null | undefined;
|
|
677
|
+
pollInterval?: number | undefined;
|
|
678
|
+
} | undefined;
|
|
671
679
|
_meta?: {
|
|
672
680
|
[x: string]: unknown;
|
|
673
681
|
progressToken?: string | number | undefined;
|
|
674
682
|
"io.modelcontextprotocol/related-task"?: {
|
|
683
|
+
[x: string]: unknown;
|
|
675
684
|
taskId: string;
|
|
676
685
|
} | undefined;
|
|
677
686
|
} | undefined;
|
|
@@ -682,8 +691,8 @@ declare class MCPServer {
|
|
|
682
691
|
[x: string]: unknown;
|
|
683
692
|
_meta?: {
|
|
684
693
|
[x: string]: unknown;
|
|
685
|
-
progressToken?: string | number | undefined;
|
|
686
694
|
"io.modelcontextprotocol/related-task"?: {
|
|
695
|
+
[x: string]: unknown;
|
|
687
696
|
taskId: string;
|
|
688
697
|
} | undefined;
|
|
689
698
|
} | undefined;
|
|
@@ -692,8 +701,8 @@ declare class MCPServer {
|
|
|
692
701
|
[x: string]: unknown;
|
|
693
702
|
_meta?: {
|
|
694
703
|
[x: string]: unknown;
|
|
695
|
-
progressToken?: string | number | undefined;
|
|
696
704
|
"io.modelcontextprotocol/related-task"?: {
|
|
705
|
+
[x: string]: unknown;
|
|
697
706
|
taskId: string;
|
|
698
707
|
} | undefined;
|
|
699
708
|
} | undefined;
|
|
@@ -723,10 +732,16 @@ declare class MCPServerRuntime {
|
|
|
723
732
|
method: string;
|
|
724
733
|
params?: {
|
|
725
734
|
[x: string]: unknown;
|
|
735
|
+
task?: {
|
|
736
|
+
[x: string]: unknown;
|
|
737
|
+
ttl?: number | null | undefined;
|
|
738
|
+
pollInterval?: number | undefined;
|
|
739
|
+
} | undefined;
|
|
726
740
|
_meta?: {
|
|
727
741
|
[x: string]: unknown;
|
|
728
742
|
progressToken?: string | number | undefined;
|
|
729
743
|
"io.modelcontextprotocol/related-task"?: {
|
|
744
|
+
[x: string]: unknown;
|
|
730
745
|
taskId: string;
|
|
731
746
|
} | undefined;
|
|
732
747
|
} | undefined;
|
|
@@ -737,8 +752,8 @@ declare class MCPServerRuntime {
|
|
|
737
752
|
[x: string]: unknown;
|
|
738
753
|
_meta?: {
|
|
739
754
|
[x: string]: unknown;
|
|
740
|
-
progressToken?: string | number | undefined;
|
|
741
755
|
"io.modelcontextprotocol/related-task"?: {
|
|
756
|
+
[x: string]: unknown;
|
|
742
757
|
taskId: string;
|
|
743
758
|
} | undefined;
|
|
744
759
|
} | undefined;
|
|
@@ -747,8 +762,8 @@ declare class MCPServerRuntime {
|
|
|
747
762
|
[x: string]: unknown;
|
|
748
763
|
_meta?: {
|
|
749
764
|
[x: string]: unknown;
|
|
750
|
-
progressToken?: string | number | undefined;
|
|
751
765
|
"io.modelcontextprotocol/related-task"?: {
|
|
766
|
+
[x: string]: unknown;
|
|
752
767
|
taskId: string;
|
|
753
768
|
} | undefined;
|
|
754
769
|
} | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,133 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Simple configurable logger for LeanMCP SDK
|
|
5
|
+
*/
|
|
6
|
+
declare enum LogLevel {
|
|
7
|
+
DEBUG = 0,
|
|
8
|
+
INFO = 1,
|
|
9
|
+
WARN = 2,
|
|
10
|
+
ERROR = 3,
|
|
11
|
+
NONE = 4
|
|
12
|
+
}
|
|
13
|
+
interface LoggerOptions {
|
|
14
|
+
level?: LogLevel;
|
|
15
|
+
prefix?: string;
|
|
16
|
+
timestamps?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Enable or disable ANSI colors. Defaults to true.
|
|
19
|
+
*/
|
|
20
|
+
colorize?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Provide additional metadata context (e.g. module name)
|
|
23
|
+
*/
|
|
24
|
+
context?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional third-party handlers (PostHog, Sentry, etc.)
|
|
27
|
+
* They receive the structured payload for easy integration.
|
|
28
|
+
*/
|
|
29
|
+
handlers?: LoggerHandler[];
|
|
30
|
+
}
|
|
31
|
+
interface LogPayload {
|
|
32
|
+
level: LogLevel;
|
|
33
|
+
levelLabel: string;
|
|
34
|
+
message: string;
|
|
35
|
+
args: any[];
|
|
36
|
+
prefix?: string;
|
|
37
|
+
context?: string;
|
|
38
|
+
timestamp: string;
|
|
39
|
+
}
|
|
40
|
+
type LoggerHandler = (payload: LogPayload) => void;
|
|
41
|
+
declare class Logger {
|
|
42
|
+
private level;
|
|
43
|
+
private prefix;
|
|
44
|
+
private timestamps;
|
|
45
|
+
private colorize;
|
|
46
|
+
private context?;
|
|
47
|
+
private handlers;
|
|
48
|
+
constructor(options?: LoggerOptions);
|
|
49
|
+
private format;
|
|
50
|
+
private shouldLog;
|
|
51
|
+
private emit;
|
|
52
|
+
debug(message: string, ...args: any[]): void;
|
|
53
|
+
info(message: string, ...args: any[]): void;
|
|
54
|
+
warn(message: string, ...args: any[]): void;
|
|
55
|
+
error(message: string, ...args: any[]): void;
|
|
56
|
+
setLevel(level: LogLevel): void;
|
|
57
|
+
getLevel(): LogLevel;
|
|
58
|
+
}
|
|
59
|
+
declare const defaultLogger: Logger;
|
|
60
|
+
|
|
61
|
+
interface HTTPServerOptions {
|
|
62
|
+
port?: number;
|
|
63
|
+
cors?: boolean | {
|
|
64
|
+
origin?: string | string[];
|
|
65
|
+
credentials?: boolean;
|
|
66
|
+
};
|
|
67
|
+
logging?: boolean;
|
|
68
|
+
logger?: Logger;
|
|
69
|
+
sessionTimeout?: number;
|
|
70
|
+
stateless?: boolean;
|
|
71
|
+
dashboard?: boolean;
|
|
72
|
+
/** OAuth/Auth configuration (MCP authorization spec) */
|
|
73
|
+
auth?: HTTPServerAuthOptions;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* OAuth/Auth configuration for MCP server
|
|
77
|
+
*
|
|
78
|
+
* Enables MCP authorization spec compliance by exposing
|
|
79
|
+
* `/.well-known/oauth-protected-resource` (RFC 9728)
|
|
80
|
+
*/
|
|
81
|
+
interface HTTPServerAuthOptions {
|
|
82
|
+
/** Resource identifier (defaults to server URL) */
|
|
83
|
+
resource?: string;
|
|
84
|
+
/** Authorization servers (defaults to self) */
|
|
85
|
+
authorizationServers?: string[];
|
|
86
|
+
/** Supported OAuth scopes */
|
|
87
|
+
scopesSupported?: string[];
|
|
88
|
+
/** Documentation URL */
|
|
89
|
+
documentationUrl?: string;
|
|
90
|
+
/** Enable built-in OAuth authorization server */
|
|
91
|
+
enableOAuthServer?: boolean;
|
|
92
|
+
/** OAuth server options (when enableOAuthServer is true) */
|
|
93
|
+
oauthServerOptions?: {
|
|
94
|
+
/** Session secret for signing tokens/state */
|
|
95
|
+
sessionSecret: string;
|
|
96
|
+
/** JWT signing secret (defaults to sessionSecret if not provided) */
|
|
97
|
+
jwtSigningSecret?: string;
|
|
98
|
+
/** JWT encryption secret for encrypting upstream tokens */
|
|
99
|
+
jwtEncryptionSecret?: Buffer;
|
|
100
|
+
/** Issuer URL for JWTs */
|
|
101
|
+
issuer?: string;
|
|
102
|
+
/** Access token TTL in seconds (default: 3600) */
|
|
103
|
+
tokenTTL?: number;
|
|
104
|
+
/** Enable Dynamic Client Registration (DCR) */
|
|
105
|
+
enableDCR?: boolean;
|
|
106
|
+
/** Upstream OAuth provider configuration */
|
|
107
|
+
upstreamProvider?: {
|
|
108
|
+
id: string;
|
|
109
|
+
authorizationEndpoint: string;
|
|
110
|
+
tokenEndpoint: string;
|
|
111
|
+
clientId: string;
|
|
112
|
+
clientSecret: string;
|
|
113
|
+
scopes?: string[];
|
|
114
|
+
userInfoEndpoint?: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
interface MCPServerFactory {
|
|
119
|
+
(): Server | Promise<Server>;
|
|
120
|
+
}
|
|
121
|
+
type HTTPServerInput = MCPServerFactory | MCPServerConstructorOptions;
|
|
122
|
+
/**
|
|
123
|
+
* Create an HTTP server for MCP with Streamable HTTP transport
|
|
124
|
+
* Returns the HTTP server instance to keep the process alive
|
|
125
|
+
*
|
|
126
|
+
* @param serverInput - Either MCPServerConstructorOptions or a factory function that returns a Server
|
|
127
|
+
* @param options - HTTP server options (only used when serverInput is a factory function)
|
|
128
|
+
*/
|
|
129
|
+
declare function createHTTPServer(serverInput: HTTPServerInput, options?: HTTPServerOptions): Promise<any>;
|
|
130
|
+
|
|
3
131
|
/**
|
|
4
132
|
* Security scheme for MCP tools (per MCP authorization spec)
|
|
5
133
|
*
|
|
@@ -220,132 +348,6 @@ declare function SchemaConstraint(constraints: {
|
|
|
220
348
|
*/
|
|
221
349
|
declare function classToJsonSchemaWithConstraints(classConstructor: new () => any): any;
|
|
222
350
|
|
|
223
|
-
/**
|
|
224
|
-
* Simple configurable logger for LeanMCP SDK
|
|
225
|
-
*/
|
|
226
|
-
declare enum LogLevel {
|
|
227
|
-
DEBUG = 0,
|
|
228
|
-
INFO = 1,
|
|
229
|
-
WARN = 2,
|
|
230
|
-
ERROR = 3,
|
|
231
|
-
NONE = 4
|
|
232
|
-
}
|
|
233
|
-
interface LoggerOptions {
|
|
234
|
-
level?: LogLevel;
|
|
235
|
-
prefix?: string;
|
|
236
|
-
timestamps?: boolean;
|
|
237
|
-
/**
|
|
238
|
-
* Enable or disable ANSI colors. Defaults to true.
|
|
239
|
-
*/
|
|
240
|
-
colorize?: boolean;
|
|
241
|
-
/**
|
|
242
|
-
* Provide additional metadata context (e.g. module name)
|
|
243
|
-
*/
|
|
244
|
-
context?: string;
|
|
245
|
-
/**
|
|
246
|
-
* Optional third-party handlers (PostHog, Sentry, etc.)
|
|
247
|
-
* They receive the structured payload for easy integration.
|
|
248
|
-
*/
|
|
249
|
-
handlers?: LoggerHandler[];
|
|
250
|
-
}
|
|
251
|
-
interface LogPayload {
|
|
252
|
-
level: LogLevel;
|
|
253
|
-
levelLabel: string;
|
|
254
|
-
message: string;
|
|
255
|
-
args: any[];
|
|
256
|
-
prefix?: string;
|
|
257
|
-
context?: string;
|
|
258
|
-
timestamp: string;
|
|
259
|
-
}
|
|
260
|
-
type LoggerHandler = (payload: LogPayload) => void;
|
|
261
|
-
declare class Logger {
|
|
262
|
-
private level;
|
|
263
|
-
private prefix;
|
|
264
|
-
private timestamps;
|
|
265
|
-
private colorize;
|
|
266
|
-
private context?;
|
|
267
|
-
private handlers;
|
|
268
|
-
constructor(options?: LoggerOptions);
|
|
269
|
-
private format;
|
|
270
|
-
private shouldLog;
|
|
271
|
-
private emit;
|
|
272
|
-
debug(message: string, ...args: any[]): void;
|
|
273
|
-
info(message: string, ...args: any[]): void;
|
|
274
|
-
warn(message: string, ...args: any[]): void;
|
|
275
|
-
error(message: string, ...args: any[]): void;
|
|
276
|
-
setLevel(level: LogLevel): void;
|
|
277
|
-
getLevel(): LogLevel;
|
|
278
|
-
}
|
|
279
|
-
declare const defaultLogger: Logger;
|
|
280
|
-
|
|
281
|
-
interface HTTPServerOptions {
|
|
282
|
-
port?: number;
|
|
283
|
-
cors?: boolean | {
|
|
284
|
-
origin?: string | string[];
|
|
285
|
-
credentials?: boolean;
|
|
286
|
-
};
|
|
287
|
-
logging?: boolean;
|
|
288
|
-
logger?: Logger;
|
|
289
|
-
sessionTimeout?: number;
|
|
290
|
-
stateless?: boolean;
|
|
291
|
-
dashboard?: boolean;
|
|
292
|
-
/** OAuth/Auth configuration (MCP authorization spec) */
|
|
293
|
-
auth?: HTTPServerAuthOptions;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* OAuth/Auth configuration for MCP server
|
|
297
|
-
*
|
|
298
|
-
* Enables MCP authorization spec compliance by exposing
|
|
299
|
-
* `/.well-known/oauth-protected-resource` (RFC 9728)
|
|
300
|
-
*/
|
|
301
|
-
interface HTTPServerAuthOptions {
|
|
302
|
-
/** Resource identifier (defaults to server URL) */
|
|
303
|
-
resource?: string;
|
|
304
|
-
/** Authorization servers (defaults to self) */
|
|
305
|
-
authorizationServers?: string[];
|
|
306
|
-
/** Supported OAuth scopes */
|
|
307
|
-
scopesSupported?: string[];
|
|
308
|
-
/** Documentation URL */
|
|
309
|
-
documentationUrl?: string;
|
|
310
|
-
/** Enable built-in OAuth authorization server */
|
|
311
|
-
enableOAuthServer?: boolean;
|
|
312
|
-
/** OAuth server options (when enableOAuthServer is true) */
|
|
313
|
-
oauthServerOptions?: {
|
|
314
|
-
/** Session secret for signing tokens/state */
|
|
315
|
-
sessionSecret: string;
|
|
316
|
-
/** JWT signing secret (defaults to sessionSecret if not provided) */
|
|
317
|
-
jwtSigningSecret?: string;
|
|
318
|
-
/** JWT encryption secret for encrypting upstream tokens */
|
|
319
|
-
jwtEncryptionSecret?: Buffer;
|
|
320
|
-
/** Issuer URL for JWTs */
|
|
321
|
-
issuer?: string;
|
|
322
|
-
/** Access token TTL in seconds (default: 3600) */
|
|
323
|
-
tokenTTL?: number;
|
|
324
|
-
/** Upstream OAuth provider configuration */
|
|
325
|
-
upstreamProvider?: {
|
|
326
|
-
id: string;
|
|
327
|
-
authorizationEndpoint: string;
|
|
328
|
-
tokenEndpoint: string;
|
|
329
|
-
clientId: string;
|
|
330
|
-
clientSecret: string;
|
|
331
|
-
scopes?: string[];
|
|
332
|
-
userInfoEndpoint?: string;
|
|
333
|
-
};
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
interface MCPServerFactory {
|
|
337
|
-
(): Server | Promise<Server>;
|
|
338
|
-
}
|
|
339
|
-
type HTTPServerInput = MCPServerFactory | MCPServerConstructorOptions;
|
|
340
|
-
/**
|
|
341
|
-
* Create an HTTP server for MCP with Streamable HTTP transport
|
|
342
|
-
* Returns the HTTP server instance to keep the process alive
|
|
343
|
-
*
|
|
344
|
-
* @param serverInput - Either MCPServerConstructorOptions or a factory function that returns a Server
|
|
345
|
-
* @param options - HTTP server options (only used when serverInput is a factory function)
|
|
346
|
-
*/
|
|
347
|
-
declare function createHTTPServer(serverInput: HTTPServerInput, options?: HTTPServerOptions): Promise<any>;
|
|
348
|
-
|
|
349
351
|
/**
|
|
350
352
|
* Input validation utilities for LeanMCP
|
|
351
353
|
* Provides secure validation for common input types
|
|
@@ -549,6 +551,7 @@ interface MCPServerConstructorOptions {
|
|
|
549
551
|
};
|
|
550
552
|
sessionTimeout?: number;
|
|
551
553
|
stateless?: boolean;
|
|
554
|
+
auth?: HTTPServerAuthOptions;
|
|
552
555
|
}
|
|
553
556
|
interface RegisteredTool {
|
|
554
557
|
name: string;
|
|
@@ -668,10 +671,16 @@ declare class MCPServer {
|
|
|
668
671
|
method: string;
|
|
669
672
|
params?: {
|
|
670
673
|
[x: string]: unknown;
|
|
674
|
+
task?: {
|
|
675
|
+
[x: string]: unknown;
|
|
676
|
+
ttl?: number | null | undefined;
|
|
677
|
+
pollInterval?: number | undefined;
|
|
678
|
+
} | undefined;
|
|
671
679
|
_meta?: {
|
|
672
680
|
[x: string]: unknown;
|
|
673
681
|
progressToken?: string | number | undefined;
|
|
674
682
|
"io.modelcontextprotocol/related-task"?: {
|
|
683
|
+
[x: string]: unknown;
|
|
675
684
|
taskId: string;
|
|
676
685
|
} | undefined;
|
|
677
686
|
} | undefined;
|
|
@@ -682,8 +691,8 @@ declare class MCPServer {
|
|
|
682
691
|
[x: string]: unknown;
|
|
683
692
|
_meta?: {
|
|
684
693
|
[x: string]: unknown;
|
|
685
|
-
progressToken?: string | number | undefined;
|
|
686
694
|
"io.modelcontextprotocol/related-task"?: {
|
|
695
|
+
[x: string]: unknown;
|
|
687
696
|
taskId: string;
|
|
688
697
|
} | undefined;
|
|
689
698
|
} | undefined;
|
|
@@ -692,8 +701,8 @@ declare class MCPServer {
|
|
|
692
701
|
[x: string]: unknown;
|
|
693
702
|
_meta?: {
|
|
694
703
|
[x: string]: unknown;
|
|
695
|
-
progressToken?: string | number | undefined;
|
|
696
704
|
"io.modelcontextprotocol/related-task"?: {
|
|
705
|
+
[x: string]: unknown;
|
|
697
706
|
taskId: string;
|
|
698
707
|
} | undefined;
|
|
699
708
|
} | undefined;
|
|
@@ -723,10 +732,16 @@ declare class MCPServerRuntime {
|
|
|
723
732
|
method: string;
|
|
724
733
|
params?: {
|
|
725
734
|
[x: string]: unknown;
|
|
735
|
+
task?: {
|
|
736
|
+
[x: string]: unknown;
|
|
737
|
+
ttl?: number | null | undefined;
|
|
738
|
+
pollInterval?: number | undefined;
|
|
739
|
+
} | undefined;
|
|
726
740
|
_meta?: {
|
|
727
741
|
[x: string]: unknown;
|
|
728
742
|
progressToken?: string | number | undefined;
|
|
729
743
|
"io.modelcontextprotocol/related-task"?: {
|
|
744
|
+
[x: string]: unknown;
|
|
730
745
|
taskId: string;
|
|
731
746
|
} | undefined;
|
|
732
747
|
} | undefined;
|
|
@@ -737,8 +752,8 @@ declare class MCPServerRuntime {
|
|
|
737
752
|
[x: string]: unknown;
|
|
738
753
|
_meta?: {
|
|
739
754
|
[x: string]: unknown;
|
|
740
|
-
progressToken?: string | number | undefined;
|
|
741
755
|
"io.modelcontextprotocol/related-task"?: {
|
|
756
|
+
[x: string]: unknown;
|
|
742
757
|
taskId: string;
|
|
743
758
|
} | undefined;
|
|
744
759
|
} | undefined;
|
|
@@ -747,8 +762,8 @@ declare class MCPServerRuntime {
|
|
|
747
762
|
[x: string]: unknown;
|
|
748
763
|
_meta?: {
|
|
749
764
|
[x: string]: unknown;
|
|
750
|
-
progressToken?: string | number | undefined;
|
|
751
765
|
"io.modelcontextprotocol/related-task"?: {
|
|
766
|
+
[x: string]: unknown;
|
|
752
767
|
taskId: string;
|
|
753
768
|
} | undefined;
|
|
754
769
|
} | undefined;
|