@easbot/mcp 0.2.21

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.
@@ -0,0 +1,408 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
2
+ import z from 'zod';
3
+
4
+ interface McpLocalConfig {
5
+ type: 'local';
6
+ command: string[];
7
+ environment?: Record<string, string>;
8
+ enabled?: boolean;
9
+ timeout?: number;
10
+ }
11
+ interface McpOAuthConfig {
12
+ clientId?: string;
13
+ clientSecret?: string;
14
+ scope?: string;
15
+ }
16
+ interface McpRemoteConfig {
17
+ type: 'remote';
18
+ url: string;
19
+ enabled?: boolean;
20
+ headers?: Record<string, string>;
21
+ oauth?: McpOAuthConfig | false;
22
+ timeout?: number;
23
+ }
24
+ type McpConfig = McpLocalConfig | McpRemoteConfig;
25
+ declare const ServerTransportType: {
26
+ readonly STDIO: "stdio";
27
+ readonly HTTP: "http";
28
+ };
29
+ type ServerTransportType = (typeof ServerTransportType)[keyof typeof ServerTransportType];
30
+ declare const ServerStatus: {
31
+ readonly STOPPED: "stopped";
32
+ readonly STARTING: "starting";
33
+ readonly RUNNING: "running";
34
+ readonly STOPPING: "stopping";
35
+ readonly ERROR: "error";
36
+ };
37
+ type ServerStatus = (typeof ServerStatus)[keyof typeof ServerStatus];
38
+ interface ServerInfo {
39
+ id: string;
40
+ name: string;
41
+ version: string;
42
+ transportType: ServerTransportType;
43
+ status: ServerStatus;
44
+ createdAt: number;
45
+ lastActivityAt: number;
46
+ enabled?: boolean;
47
+ }
48
+ interface StdioServerConfig {
49
+ id: string;
50
+ name: string;
51
+ version: string;
52
+ transportType: typeof ServerTransportType.STDIO;
53
+ command: string;
54
+ args?: string[];
55
+ env?: Record<string, string>;
56
+ cwd?: string;
57
+ enabled?: boolean;
58
+ timeout?: number;
59
+ }
60
+ interface HttpServerConfig {
61
+ id: string;
62
+ name: string;
63
+ version: string;
64
+ transportType: typeof ServerTransportType.HTTP;
65
+ url: string;
66
+ headers?: Record<string, string>;
67
+ enabled?: boolean;
68
+ timeout?: number;
69
+ }
70
+ interface ServerInstance$2 {
71
+ info: ServerInfo;
72
+ get server(): McpServer | null;
73
+ start(): Promise<void>;
74
+ stop(): Promise<void>;
75
+ restart(): Promise<void>;
76
+ }
77
+
78
+ interface ServerInstance$1 {
79
+ info: ServerInfo;
80
+ get server(): McpServer | null;
81
+ start(): Promise<void>;
82
+ stop(): Promise<void>;
83
+ restart(): Promise<void>;
84
+ }
85
+ declare class StdioServerAdapter {
86
+ private config;
87
+ private server;
88
+ private info;
89
+ private isStarting;
90
+ private isStopping;
91
+ private toolEventCleanup;
92
+ constructor(config: StdioServerConfig);
93
+ getInfo(): ServerInfo;
94
+ getConfig(): StdioServerConfig;
95
+ createInstance(): ServerInstance$1;
96
+ private loadTools;
97
+ private subscribeToolEvents;
98
+ private handleToolRegistered;
99
+ private adaptToolHandler;
100
+ private unsubscribeToolEvents;
101
+ private convertToZodSchema;
102
+ private jsonSchemaToZod;
103
+ start(): Promise<void>;
104
+ stop(): Promise<void>;
105
+ restart(): Promise<void>;
106
+ }
107
+ declare function createStdioServer(config: StdioServerConfig): StdioServerAdapter;
108
+ declare function createAndStartStdioServer(config: StdioServerConfig): Promise<ServerInstance$1>;
109
+
110
+ interface ServerInstance {
111
+ info: ServerInfo;
112
+ get server(): McpServer | null;
113
+ start(): Promise<void>;
114
+ stop(): Promise<void>;
115
+ restart(): Promise<void>;
116
+ }
117
+ declare class HttpServerAdapter {
118
+ private config;
119
+ private server;
120
+ private transport;
121
+ private httpServer;
122
+ private info;
123
+ private isStarting;
124
+ private isStopping;
125
+ private toolCleanup;
126
+ constructor(config: HttpServerConfig);
127
+ getInfo(): ServerInfo;
128
+ getConfig(): HttpServerConfig;
129
+ createInstance(): ServerInstance;
130
+ private loadTools;
131
+ private subscribeTools;
132
+ private handleTool;
133
+ private convertToZodSchema;
134
+ private jsonSchemaToZod;
135
+ private adaptToolHandler;
136
+ private unsubscribeTools;
137
+ start(): Promise<void>;
138
+ stop(): Promise<void>;
139
+ restart(): Promise<void>;
140
+ }
141
+ declare function createHttpServer(config: HttpServerConfig): HttpServerAdapter;
142
+ declare function createAndStartHttpServer(config: HttpServerConfig): Promise<ServerInstance>;
143
+
144
+ interface OAuthConfig {
145
+ clientId?: string;
146
+ clientSecret?: string;
147
+ scope?: string;
148
+ metadataUrl?: string;
149
+ }
150
+ interface LocalMCPConfig {
151
+ type: 'local';
152
+ command: string[];
153
+ environment?: Record<string, string>;
154
+ timeout?: number;
155
+ }
156
+ interface RemoteMCPConfig {
157
+ type: 'remote';
158
+ url: string;
159
+ headers?: Record<string, string>;
160
+ transport?: 'streamable-http' | 'sse';
161
+ oauth?: OAuthConfig | false;
162
+ timeout?: number;
163
+ }
164
+ type MCPConfig = LocalMCPConfig | RemoteMCPConfig;
165
+ declare const Status: z.ZodDiscriminatedUnion<[z.ZodObject<{
166
+ status: z.ZodLiteral<"connected">;
167
+ }, z.core.$strip>, z.ZodObject<{
168
+ status: z.ZodLiteral<"disconnected">;
169
+ }, z.core.$strip>, z.ZodObject<{
170
+ status: z.ZodLiteral<"failed">;
171
+ error: z.ZodString;
172
+ }, z.core.$strip>, z.ZodObject<{
173
+ status: z.ZodLiteral<"needs_auth">;
174
+ }, z.core.$strip>, z.ZodObject<{
175
+ status: z.ZodLiteral<"needs_client_registration">;
176
+ error: z.ZodString;
177
+ }, z.core.$strip>], "status">;
178
+ type Status = z.infer<typeof Status>;
179
+ interface ToolMetadata {
180
+ name: string;
181
+ description?: string;
182
+ inputSchema: unknown;
183
+ }
184
+ interface ResourceMetadata {
185
+ name: string;
186
+ uri: string;
187
+ description?: string;
188
+ mimeType?: string;
189
+ }
190
+ interface PromptMetadata {
191
+ name: string;
192
+ description?: string;
193
+ arguments?: Array<{
194
+ name: string;
195
+ description?: string;
196
+ required?: boolean;
197
+ }>;
198
+ }
199
+ interface ClientInfo {
200
+ id: string;
201
+ name: string;
202
+ status: Status;
203
+ connectedAt?: number;
204
+ serverVersion?: string;
205
+ protocolVersion?: string;
206
+ tools: ToolMetadata[];
207
+ resources: ResourceMetadata[];
208
+ prompts: PromptMetadata[];
209
+ error?: string;
210
+ }
211
+ interface ToolCallResult {
212
+ toolName: string;
213
+ args: Record<string, unknown>;
214
+ result: unknown;
215
+ success: boolean;
216
+ error?: string;
217
+ duration: number;
218
+ }
219
+ interface AuthResult {
220
+ authorizationUrl: string;
221
+ state?: string;
222
+ }
223
+ declare class MCPClient {
224
+ private id;
225
+ private client;
226
+ private _info;
227
+ private notificationCleanup;
228
+ private pendingTransport;
229
+ private oauthState;
230
+ private toolListChangedHandler;
231
+ constructor();
232
+ get info(): ClientInfo;
233
+ get status(): Status;
234
+ get tools(): ToolMetadata[];
235
+ connect(id: string, config: MCPConfig): Promise<void>;
236
+ startAuth(): Promise<AuthResult>;
237
+ finishAuth(authorizationCode?: string): Promise<void>;
238
+ disconnect(): Promise<void>;
239
+ listTools(): Promise<Record<string, unknown>>;
240
+ callTool(toolName: string, args: Record<string, unknown>, timeout?: number): Promise<ToolCallResult>;
241
+ listResources(): Promise<ResourceMetadata[]>;
242
+ readResource(uri: string): Promise<{
243
+ [x: string]: unknown;
244
+ contents: ({
245
+ uri: string;
246
+ text: string;
247
+ mimeType?: string | undefined;
248
+ _meta?: Record<string, unknown> | undefined;
249
+ } | {
250
+ uri: string;
251
+ blob: string;
252
+ mimeType?: string | undefined;
253
+ _meta?: Record<string, unknown> | undefined;
254
+ })[];
255
+ _meta?: {
256
+ [x: string]: unknown;
257
+ progressToken?: string | number | undefined;
258
+ "io.modelcontextprotocol/related-task"?: {
259
+ taskId: string;
260
+ } | undefined;
261
+ } | undefined;
262
+ } | undefined>;
263
+ listPrompts(): Promise<PromptMetadata[]>;
264
+ getPrompt(name: string, args?: Record<string, string>): Promise<{
265
+ [x: string]: unknown;
266
+ messages: {
267
+ role: "user" | "assistant";
268
+ content: {
269
+ type: "text";
270
+ text: string;
271
+ annotations?: {
272
+ audience?: ("user" | "assistant")[] | undefined;
273
+ priority?: number | undefined;
274
+ lastModified?: string | undefined;
275
+ } | undefined;
276
+ _meta?: Record<string, unknown> | undefined;
277
+ } | {
278
+ type: "image";
279
+ data: string;
280
+ mimeType: string;
281
+ annotations?: {
282
+ audience?: ("user" | "assistant")[] | undefined;
283
+ priority?: number | undefined;
284
+ lastModified?: string | undefined;
285
+ } | undefined;
286
+ _meta?: Record<string, unknown> | undefined;
287
+ } | {
288
+ type: "audio";
289
+ data: string;
290
+ mimeType: string;
291
+ annotations?: {
292
+ audience?: ("user" | "assistant")[] | undefined;
293
+ priority?: number | undefined;
294
+ lastModified?: string | undefined;
295
+ } | undefined;
296
+ _meta?: Record<string, unknown> | undefined;
297
+ } | {
298
+ type: "resource";
299
+ resource: {
300
+ uri: string;
301
+ text: string;
302
+ mimeType?: string | undefined;
303
+ _meta?: Record<string, unknown> | undefined;
304
+ } | {
305
+ uri: string;
306
+ blob: string;
307
+ mimeType?: string | undefined;
308
+ _meta?: Record<string, unknown> | undefined;
309
+ };
310
+ annotations?: {
311
+ audience?: ("user" | "assistant")[] | undefined;
312
+ priority?: number | undefined;
313
+ lastModified?: string | undefined;
314
+ } | undefined;
315
+ _meta?: Record<string, unknown> | undefined;
316
+ } | {
317
+ uri: string;
318
+ name: string;
319
+ type: "resource_link";
320
+ description?: string | undefined;
321
+ mimeType?: string | undefined;
322
+ size?: number | undefined;
323
+ annotations?: {
324
+ audience?: ("user" | "assistant")[] | undefined;
325
+ priority?: number | undefined;
326
+ lastModified?: string | undefined;
327
+ } | undefined;
328
+ _meta?: {
329
+ [x: string]: unknown;
330
+ } | undefined;
331
+ icons?: {
332
+ src: string;
333
+ mimeType?: string | undefined;
334
+ sizes?: string[] | undefined;
335
+ theme?: "light" | "dark" | undefined;
336
+ }[] | undefined;
337
+ title?: string | undefined;
338
+ };
339
+ }[];
340
+ _meta?: {
341
+ [x: string]: unknown;
342
+ progressToken?: string | number | undefined;
343
+ "io.modelcontextprotocol/related-task"?: {
344
+ taskId: string;
345
+ } | undefined;
346
+ } | undefined;
347
+ description?: string | undefined;
348
+ } | undefined>;
349
+ refreshTools(): Promise<void>;
350
+ private createClient;
351
+ private fetchCapabilities;
352
+ private createLocalClient;
353
+ private createRemoteClient;
354
+ private connectWithTransport;
355
+ registerToolListChangedHandler(handler: () => void | Promise<void>): void;
356
+ private registerNotificationHandler;
357
+ private createInitialInfo;
358
+ }
359
+ declare function createMCPClient(): MCPClient;
360
+
361
+ declare namespace Log {
362
+ const Level: z.ZodEnum<{
363
+ DEBUG: "DEBUG";
364
+ INFO: "INFO";
365
+ WARN: "WARN";
366
+ ERROR: "ERROR";
367
+ }>;
368
+ type Level = z.infer<typeof Level>;
369
+ function getLevel(): Level;
370
+ type Logger = {
371
+ debug(message?: any, extra?: Record<string, any>): void;
372
+ info(message?: any, extra?: Record<string, any>): void;
373
+ error(message?: any, extra?: Record<string, any>): void;
374
+ warn(message?: any, extra?: Record<string, any>): void;
375
+ tag(key: string, value: string): Logger;
376
+ clone(): Logger;
377
+ time(message: string, extra?: Record<string, any>): {
378
+ stop(): void;
379
+ [Symbol.dispose](): void;
380
+ };
381
+ };
382
+ const Default: Logger;
383
+ interface Options {
384
+ print: boolean;
385
+ logDir: string;
386
+ logFile?: string;
387
+ dev?: boolean;
388
+ level?: Level;
389
+ }
390
+ function file(): string;
391
+ function init(options: Options): Promise<void>;
392
+ function close(): Promise<void>;
393
+ function create(tags?: Record<string, any>): Logger;
394
+ }
395
+
396
+ declare function getVersion(): string;
397
+
398
+ declare const VERSION = "0.2.20";
399
+ declare const NAME = "@easbot/mcp";
400
+ declare function initLog(options: {
401
+ print: boolean;
402
+ logDir?: string;
403
+ logFile?: string;
404
+ dev?: boolean;
405
+ level?: 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
406
+ }): Promise<void>;
407
+
408
+ export { type AuthResult, type ClientInfo, HttpServerAdapter, type HttpServerConfig, type LocalMCPConfig, Log, MCPClient, type MCPConfig, type McpConfig, type McpLocalConfig, type McpOAuthConfig, type McpRemoteConfig, NAME, type OAuthConfig, type PromptMetadata, type RemoteMCPConfig, type ResourceMetadata, type ServerInfo, type ServerInstance$2 as ServerInstance, ServerStatus, ServerTransportType, Status, StdioServerAdapter, type StdioServerConfig, type ToolCallResult, type ToolMetadata, VERSION, createAndStartHttpServer, createAndStartStdioServer, createHttpServer, createMCPClient, createStdioServer, getVersion, initLog };