@mongodb-js/mcp-types 2.0.1-alpha.5 → 3.0.0-prerelease.2
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/dist/apiClient.d.ts +4 -14
- package/dist/apiClient.d.ts.map +1 -1
- package/dist/config.d.ts +20 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -0
- package/dist/connection.d.ts +31 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +2 -0
- package/dist/connection.js.map +1 -0
- package/dist/elicitation.d.ts +15 -5
- package/dist/elicitation.d.ts.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/keychain.d.ts +7 -6
- package/dist/keychain.d.ts.map +1 -1
- package/dist/logging.d.ts +21 -13
- package/dist/logging.d.ts.map +1 -1
- package/dist/metrics.d.ts +57 -4
- package/dist/metrics.d.ts.map +1 -1
- package/dist/resources.d.ts +49 -0
- package/dist/resources.d.ts.map +1 -1
- package/dist/schemas.d.ts +2 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +2 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -0
- package/dist/session.d.ts +19 -5
- package/dist/session.d.ts.map +1 -1
- package/dist/sessionStore.d.ts +34 -10
- package/dist/sessionStore.d.ts.map +1 -1
- package/dist/telemetry.d.ts +71 -0
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +6 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/tool.d.ts +65 -1
- package/dist/tool.d.ts.map +1 -1
- package/dist/transport.d.ts +0 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/transports.d.ts +36 -0
- package/dist/transports.d.ts.map +1 -0
- package/dist/transports.js +2 -0
- package/dist/transports.js.map +1 -0
- package/dist/ui.d.ts +26 -2
- package/dist/ui.d.ts.map +1 -1
- package/package.json +6 -5
package/dist/apiClient.d.ts
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TelemetryCommonProperties, TelemetryEvent } from "./telemetry.js";
|
|
2
|
+
export interface IApiClient<TEvent extends unknown[] = TelemetryEvent<TelemetryCommonProperties>[]> {
|
|
2
3
|
isAuthConfigured(): boolean;
|
|
3
4
|
close(): Promise<void>;
|
|
4
|
-
|
|
5
|
+
validateAuthConfig(): Promise<void>;
|
|
6
|
+
sendEvents(events: TEvent, options?: {
|
|
5
7
|
signal?: AbortSignal;
|
|
6
|
-
events: TEvent;
|
|
7
8
|
}): Promise<void>;
|
|
8
9
|
}
|
|
9
|
-
export type ApiClientOptions = {
|
|
10
|
-
baseUrl: string;
|
|
11
|
-
userAgent?: string;
|
|
12
|
-
credentials?: {
|
|
13
|
-
clientId: string;
|
|
14
|
-
clientSecret: string;
|
|
15
|
-
};
|
|
16
|
-
requestContext?: {
|
|
17
|
-
headers?: Record<string, string | string[] | undefined>;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
10
|
//# sourceMappingURL=apiClient.d.ts.map
|
package/dist/apiClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../src/apiClient.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"apiClient.d.ts","sourceRoot":"","sources":["../src/apiClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhF,MAAM,WAAW,UAAU,CAAC,MAAM,SAAS,OAAO,EAAE,GAAG,cAAc,CAAC,yBAAyB,CAAC,EAAE;IAC9F,gBAAgB,IAAI,OAAO,CAAC;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjF"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PreviewFeature } from "./schemas.js";
|
|
2
|
+
export type TransportType = "stdio" | "http";
|
|
3
|
+
export interface IToolConfig {
|
|
4
|
+
transport: TransportType;
|
|
5
|
+
httpBodyLimit?: number;
|
|
6
|
+
httpResponseType: "sse" | "json";
|
|
7
|
+
readOnly: boolean;
|
|
8
|
+
disabledTools: string[];
|
|
9
|
+
confirmationRequiredTools: string[];
|
|
10
|
+
previewFeatures: PreviewFeature[];
|
|
11
|
+
}
|
|
12
|
+
/** Server metadata for the server. */
|
|
13
|
+
export type ServerMetadata = {
|
|
14
|
+
version: string;
|
|
15
|
+
mcpServerName: string;
|
|
16
|
+
engines?: {
|
|
17
|
+
node: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;AAE7C,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,aAAa,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,KAAK,GAAG,MAAM,CAAC;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,yBAAyB,EAAE,MAAM,EAAE,CAAC;IACpC,eAAe,EAAE,cAAc,EAAE,CAAC;CACrC;AAED,sCAAsC;AACtC,MAAM,MAAM,cAAc,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9B,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atlas cluster connection info containing details about the connected Atlas cluster.
|
|
3
|
+
* When provided, indicates the connection is to an Atlas cluster.
|
|
4
|
+
*/
|
|
5
|
+
export type AtlasClusterConnectionInfo = {
|
|
6
|
+
username: string;
|
|
7
|
+
projectId: string;
|
|
8
|
+
clusterName: string;
|
|
9
|
+
instanceType: "FREE" | "FLEX" | "DEDICATED";
|
|
10
|
+
provider?: string;
|
|
11
|
+
region?: string;
|
|
12
|
+
expiryDate: Date;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Connection string info describing the auth and host type of a MongoDB connection.
|
|
16
|
+
*/
|
|
17
|
+
export type ConnectionStringInfo = {
|
|
18
|
+
authType: "scram" | "ldap" | "kerberos" | "oidc-auth-flow" | "oidc-device-flow" | "x.509" | "unknown";
|
|
19
|
+
hostType: "unknown" | "atlas" | "local" | "atlas_local" | "other";
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Structural subset of a MongoDB connection's state used by tool telemetry
|
|
23
|
+
* (kept dependency-free in mcp-types so core can describe it without
|
|
24
|
+
* importing the tools-mongodb connection model).
|
|
25
|
+
*/
|
|
26
|
+
export type SupportedConnectionState = {
|
|
27
|
+
tag: string;
|
|
28
|
+
connectionStringInfo?: ConnectionStringInfo;
|
|
29
|
+
connectedAtlasCluster?: AtlasClusterConnectionInfo;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,OAAO,GAAG,SAAS,CAAC;IACtG,QAAQ,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,GAAG,OAAO,CAAC;CACrE,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,qBAAqB,CAAC,EAAE,0BAA0B,CAAC;CACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":""}
|
package/dist/elicitation.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ElicitRequestFormParams, ProgressToken, RequestId, ServerNotification } from "@modelcontextprotocol/sdk/types.js";
|
|
1
2
|
export type ElicitedInputResult = {
|
|
2
3
|
accepted: true;
|
|
3
4
|
fields: Record<string, string>;
|
|
@@ -5,12 +6,21 @@ export type ElicitedInputResult = {
|
|
|
5
6
|
accepted: false;
|
|
6
7
|
fields?: undefined;
|
|
7
8
|
};
|
|
9
|
+
/** The schema accepted by {@link IElicitation.requestInput}. */
|
|
10
|
+
export type ElicitRequestSchema = ElicitRequestFormParams["requestedSchema"];
|
|
11
|
+
export type ElicitationOptions = {
|
|
12
|
+
/** The id of the in-flight client request this elicitation belongs to. */
|
|
13
|
+
relatedRequestId?: RequestId;
|
|
14
|
+
/** The progress token supplied by the client on the in-flight request. */
|
|
15
|
+
progressToken?: ProgressToken;
|
|
16
|
+
/** Sends a notification related to the in-flight request. */
|
|
17
|
+
sendNotification?: (notification: ServerNotification) => Promise<void>;
|
|
18
|
+
/** The abort signal of the in-flight request. */
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
};
|
|
8
21
|
export interface IElicitation {
|
|
9
22
|
supportsElicitation(): boolean;
|
|
10
|
-
requestConfirmation(message: string): Promise<boolean>;
|
|
11
|
-
requestInput(options:
|
|
12
|
-
message: string;
|
|
13
|
-
schema: unknown;
|
|
14
|
-
}): Promise<ElicitedInputResult>;
|
|
23
|
+
requestConfirmation(message: string, options?: ElicitationOptions): Promise<boolean>;
|
|
24
|
+
requestInput(message: string, schema: ElicitRequestSchema, options?: ElicitationOptions): Promise<ElicitedInputResult>;
|
|
15
25
|
}
|
|
16
26
|
//# sourceMappingURL=elicitation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GACzB;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAClD;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAE9C,MAAM,WAAW,YAAY;IACzB,mBAAmB,IAAI,OAAO,CAAC;IAC/B,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,uBAAuB,EACvB,aAAa,EACb,SAAS,EACT,kBAAkB,EACrB,MAAM,oCAAoC,CAAC;AAE5C,MAAM,MAAM,mBAAmB,GACzB;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAClD;IAAE,QAAQ,EAAE,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAE9C,gEAAgE;AAChE,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;AAE7E,MAAM,MAAM,kBAAkB,GAAG;IAC7B,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,0EAA0E;IAC1E,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,iDAAiD;IACjD,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,YAAY;IACzB,mBAAmB,IAAI,OAAO,CAAC;IAC/B,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrF,YAAY,CACR,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,mBAAmB,EAC3B,OAAO,CAAC,EAAE,kBAAkB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACnC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
export type * from "./config.js";
|
|
2
|
+
export type { AtlasClusterConnectionInfo, ConnectionStringInfo, SupportedConnectionState } from "./connection.js";
|
|
3
|
+
export type * from "./schemas.js";
|
|
1
4
|
export type * from "./session.js";
|
|
2
5
|
export type * from "./sessionStore.js";
|
|
6
|
+
export type * from "./transports.js";
|
|
3
7
|
export type * from "./keychain.js";
|
|
4
8
|
export type * from "./elicitation.js";
|
|
5
9
|
export type * from "./logging.js";
|
|
6
10
|
export type * from "./tool.js";
|
|
7
11
|
export type * from "./transport.js";
|
|
8
12
|
export type * from "./apiClient.js";
|
|
9
|
-
export type
|
|
13
|
+
export type { IObservable, ICounter, IGauge, DefaultMetricDefinitions, IMetrics } from "./metrics.js";
|
|
10
14
|
export type * from "./ui.js";
|
|
11
15
|
export type * from "./resources.js";
|
|
12
16
|
export type * from "./telemetry.js";
|
|
17
|
+
export { SHARED_TIER_METRIC_NAMES } from "./telemetry.js";
|
|
13
18
|
export type * from "./helpers.js";
|
|
19
|
+
export type * from "./server.js";
|
|
14
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,gBAAgB,CAAC;AACpC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,aAAa,CAAC;AACjC,YAAY,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAClH,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,iBAAiB,CAAC;AACrC,mBAAmB,eAAe,CAAC;AACnC,mBAAmB,kBAAkB,CAAC;AACtC,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,WAAW,CAAC;AAC/B,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,gBAAgB,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtG,mBAAmB,SAAS,CAAC;AAC7B,mBAAmB,gBAAgB,CAAC;AACpC,mBAAmB,gBAAgB,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,mBAAmB,cAAc,CAAC;AAClC,mBAAmB,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { SHARED_TIER_METRIC_NAMES } from "./telemetry.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/keychain.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
kind: string;
|
|
5
|
-
}): void;
|
|
1
|
+
import type { Secret } from "mongodb-redact";
|
|
2
|
+
export interface IKeychain<TKey = Secret["value"], TKind = Secret["kind"]> {
|
|
3
|
+
register(value: unknown, kind: string): void;
|
|
6
4
|
clearAllSecrets(): void;
|
|
7
|
-
readonly allSecrets:
|
|
5
|
+
readonly allSecrets: {
|
|
6
|
+
value: TKey;
|
|
7
|
+
kind: TKind;
|
|
8
|
+
}[];
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=keychain.d.ts.map
|
package/dist/keychain.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../src/keychain.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS
|
|
1
|
+
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../src/keychain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,WAAW,SAAS,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IACrE,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,eAAe,IAAI,IAAI,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,IAAI,EAAE,KAAK,CAAA;KAAE,EAAE,CAAC;CACvD"}
|
package/dist/logging.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { LoggingMessageNotification } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import type { IKeychain } from "./keychain.js";
|
|
3
|
+
export type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
export type LogLevel = LoggingMessageNotification["params"]["level"];
|
|
3
5
|
export type LoggerType = "console" | "disk" | "mcp";
|
|
4
6
|
export type EventMap<T> = Record<keyof T, any[]>;
|
|
5
7
|
export type DefaultEventMap = Record<string, never[]>;
|
|
8
|
+
export type MongoDBLogLevel = "info" | "warn" | "error" | "debug" | "fatal";
|
|
9
|
+
export type LogWriteFunction = (component: string, id: MongoLogId, context: string, message: string, attr?: unknown) => void;
|
|
10
|
+
export type LogWriter = Record<MongoDBLogLevel, LogWriteFunction> & {
|
|
11
|
+
flush(): Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export type MongoLogId = {
|
|
14
|
+
__value: number;
|
|
15
|
+
};
|
|
6
16
|
export type LogPayload = {
|
|
7
17
|
id: MongoLogId;
|
|
8
18
|
context: string;
|
|
@@ -10,11 +20,8 @@ export type LogPayload = {
|
|
|
10
20
|
noRedaction?: boolean | LoggerType | LoggerType[];
|
|
11
21
|
attributes?: Record<string, string>;
|
|
12
22
|
};
|
|
13
|
-
export interface
|
|
14
|
-
log(
|
|
15
|
-
level: LogLevel;
|
|
16
|
-
payload: LogPayload;
|
|
17
|
-
}): void;
|
|
23
|
+
export interface ILogger {
|
|
24
|
+
log(level: LogLevel, payload: LogPayload): void;
|
|
18
25
|
info(payload: LogPayload): void;
|
|
19
26
|
error(payload: LogPayload): void;
|
|
20
27
|
debug(payload: LogPayload): void;
|
|
@@ -23,12 +30,13 @@ export interface ILoggerBase {
|
|
|
23
30
|
critical(payload: LogPayload): void;
|
|
24
31
|
alert(payload: LogPayload): void;
|
|
25
32
|
emergency(payload: LogPayload): void;
|
|
33
|
+
flush(): Promise<PromiseSettledResult<void>[]>;
|
|
26
34
|
}
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
export type LoggerConfig = {
|
|
36
|
+
keychain: IKeychain;
|
|
37
|
+
};
|
|
38
|
+
export interface ICompositeLogger extends ILogger {
|
|
39
|
+
addLogger(logger: ILogger): void;
|
|
40
|
+
setAttribute(key: string, value: string): void;
|
|
33
41
|
}
|
|
34
42
|
//# sourceMappingURL=logging.d.ts.map
|
package/dist/logging.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AA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F,MAAM,WAAW,OAAO;IACpB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAClC,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IACrC,KAAK,IAAI,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;CAClD;AAED,MAAM,MAAM,YAAY,GAAG;IACvB,QAAQ,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,gBAAiB,SAAQ,OAAO;IAC7C,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAClD"}
|
package/dist/metrics.d.ts
CHANGED
|
@@ -1,8 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Labels type for metrics.
|
|
3
|
+
*/
|
|
4
|
+
export type MetricLabels = Partial<Record<string, string | number>>;
|
|
5
|
+
/**
|
|
6
|
+
* Interface for observable metrics (like histograms).
|
|
7
|
+
* Used for recording values that can be observed over time.
|
|
8
|
+
*/
|
|
9
|
+
export interface IObservable {
|
|
10
|
+
observe(labels: MetricLabels, value: number): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interface for counter metrics.
|
|
14
|
+
* Used for counting events, can be incremented.
|
|
15
|
+
*/
|
|
16
|
+
export interface ICounter {
|
|
17
|
+
inc(labels?: MetricLabels, value?: number): void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface for gauge metrics.
|
|
21
|
+
* Used for metrics that can go up and down (e.g. currently active sessions).
|
|
22
|
+
*/
|
|
23
|
+
export interface IGauge {
|
|
24
|
+
set(value: number): void;
|
|
25
|
+
inc(labels?: MetricLabels, value?: number): void;
|
|
26
|
+
dec(labels?: MetricLabels, value?: number): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Default metric definitions for MCP servers.
|
|
30
|
+
* These are the standard metrics used across the MCP packages.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // Usage with session store
|
|
35
|
+
* const store = new SessionStore({
|
|
36
|
+
* metrics: myMetrics,
|
|
37
|
+
* ...
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export type DefaultMetricDefinitions = {
|
|
42
|
+
/** Counter for tracking created sessions */
|
|
43
|
+
sessionCreated: ICounter;
|
|
44
|
+
/** Counter for tracking closed sessions with reason label */
|
|
45
|
+
sessionClosed: ICounter;
|
|
46
|
+
/** Histogram for tracking tool execution duration in seconds */
|
|
47
|
+
toolExecutionDuration: IObservable;
|
|
48
|
+
/** Gauge for tracking currently active sessions */
|
|
49
|
+
sessionsActive: IGauge;
|
|
3
50
|
};
|
|
4
|
-
|
|
5
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Interface for accessing metrics.
|
|
53
|
+
* @template TMetricsDefinitions - The type of metric definitions this metrics instance uses
|
|
54
|
+
*/
|
|
55
|
+
export interface IMetrics<TMetricsDefinitions extends DefaultMetricDefinitions = DefaultMetricDefinitions> {
|
|
56
|
+
/** Get a specific metric by name */
|
|
57
|
+
get<K extends keyof TMetricsDefinitions>(key: K): TMetricsDefinitions[K];
|
|
58
|
+
/** Get all metrics as a formatted string (e.g., Prometheus format) */
|
|
6
59
|
getMetrics(): Promise<string>;
|
|
7
60
|
}
|
|
8
61
|
//# sourceMappingURL=metrics.d.ts.map
|
package/dist/metrics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,WAAW;IACxB,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpD;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACnB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpD;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC,4CAA4C;IAC5C,cAAc,EAAE,QAAQ,CAAC;IACzB,6DAA6D;IAC7D,aAAa,EAAE,QAAQ,CAAC;IACxB,gEAAgE;IAChE,qBAAqB,EAAE,WAAW,CAAC;IACnC,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,mBAAmB,SAAS,wBAAwB,GAAG,wBAAwB;IACrG,oCAAoC;IACpC,GAAG,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAAE,GAAG,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC;IACzE,sEAAsE;IACtE,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACjC"}
|
package/dist/resources.d.ts
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
|
+
import type { ResourceMetadata, ReadResourceCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { SessionEvents } from "./session.js";
|
|
3
|
+
import type { ITelemetry } from "./telemetry.js";
|
|
4
|
+
import type { IToolConfig } from "./config.js";
|
|
5
|
+
import type { ICompositeLogger } from "./logging.js";
|
|
6
|
+
/**
|
|
7
|
+
* The minimal session surface resources may rely on. The CLI's session is
|
|
8
|
+
* deliberately stateless (connection state lives in the app-level registry),
|
|
9
|
+
* so resources are not constrained to the full {@link ISession} shape.
|
|
10
|
+
*/
|
|
11
|
+
export interface IResourceSession {
|
|
12
|
+
readonly config: IToolConfig;
|
|
13
|
+
readonly logger: ICompositeLogger;
|
|
14
|
+
on(event: keyof SessionEvents, listener: (...args: unknown[]) => void): void;
|
|
15
|
+
}
|
|
1
16
|
export interface IResource {
|
|
2
17
|
register(server: unknown): void;
|
|
3
18
|
}
|
|
4
19
|
export type IResources = readonly IResource[];
|
|
20
|
+
/** Static resource metadata (name/uri/description). Mirrors `resourceConfiguration` from v2-move. */
|
|
21
|
+
export type ResourceConfiguration = {
|
|
22
|
+
name: string;
|
|
23
|
+
uri: string;
|
|
24
|
+
config: ResourceMetadata;
|
|
25
|
+
};
|
|
26
|
+
export type ReactiveResourceOptions<Value, RelevantEvents extends readonly (keyof SessionEvents)[]> = {
|
|
27
|
+
initial: Value;
|
|
28
|
+
events: RelevantEvents;
|
|
29
|
+
};
|
|
30
|
+
/** The host server surface resources register against. */
|
|
31
|
+
export interface IResourceServer {
|
|
32
|
+
mcpServer: {
|
|
33
|
+
registerResource: (name: string, uri: string, config: ResourceMetadata, callback: ReadResourceCallback) => void;
|
|
34
|
+
};
|
|
35
|
+
sendResourceListChanged(): void;
|
|
36
|
+
sendResourceUpdated(uri: string): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The type that all resource classes must conform to when implementing custom resources
|
|
40
|
+
* for the MongoDB MCP Server.
|
|
41
|
+
*
|
|
42
|
+
* This type enforces that resource classes have a constructor accepting
|
|
43
|
+
* `(session, telemetry)`, matching the construction pattern used by
|
|
44
|
+
* {@link CliServer} (see `registerResources`). The resolved user
|
|
45
|
+
* configuration is read from `session.config`.
|
|
46
|
+
*/
|
|
47
|
+
export type ResourceClass<TSession extends IResourceSession = IResourceSession> = {
|
|
48
|
+
new (session: TSession, telemetry: ITelemetry): {
|
|
49
|
+
register(server: IResourceServer): void;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/** Resource constructor type for registries that may include session-specific resource implementations. */
|
|
53
|
+
export type AnyResourceClass = ResourceClass<any>;
|
|
5
54
|
//# sourceMappingURL=resources.d.ts.map
|
package/dist/resources.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,SAAS,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AACtG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,c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ACH,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,gBAAgB,GAAG,gBAAgB,IAAI;IAC9E,KAAK,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,GAAG;QAAE,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAA;KAAE,CAAC;CAC/F,CAAC;AAEF,2GAA2G;AAE3G,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":""}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport";
|
|
2
|
+
import type { ClientCapabilities, Implementation } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { ICompositeLogger } from "./logging.js";
|
|
4
|
+
/**
|
|
5
|
+
* Minimum server interface required by MCPHttpServer.
|
|
6
|
+
* Servers must have connect/close methods, a session with a logger (and a
|
|
7
|
+
* `setMcpClient` hook) for HTTP transport functionality, and expose the
|
|
8
|
+
* protocol-level MCP server so negotiated client state can be captured and
|
|
9
|
+
* restored across implicit re-initializations.
|
|
10
|
+
*/
|
|
11
|
+
export type SessionServer<TTransport extends Transport = Transport> = {
|
|
12
|
+
connect(transport: TTransport): Promise<void>;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
session: {
|
|
15
|
+
logger: ICompositeLogger;
|
|
16
|
+
/**
|
|
17
|
+
* Records the MCP client that negotiated this session's
|
|
18
|
+
* initialization. Required to restore negotiated client state on
|
|
19
|
+
* implicitly re-initialized sessions.
|
|
20
|
+
*/
|
|
21
|
+
setMcpClient(mcpClient: unknown): void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The protocol-level MCP server, required to capture/restore negotiated
|
|
25
|
+
* client state across implicit re-initializations.
|
|
26
|
+
*/
|
|
27
|
+
mcpServer: {
|
|
28
|
+
server: {
|
|
29
|
+
oninitialized?: (() => void) | undefined;
|
|
30
|
+
getClientCapabilities(): ClientCapabilities | undefined;
|
|
31
|
+
getClientVersion(): Implementation | undefined;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC7F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,CAAC,UAAU,SAAS,SAAS,GAAG,SAAS,IAAI;IAClE,OAAO,CAAC,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,EAAE;QACL,MAAM,EAAE,gBAAgB,CAAC;QACzB;;;;WAIG;QACH,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;KAC1C,CAAC;IACF;;;OAGG;IACH,SAAS,EAAE;QACP,MAAM,EAAE;YACJ,aAAa,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;YACzC,qBAAqB,IAAI,kBAAkB,GAAG,SAAS,CAAC;YACxD,gBAAgB,IAAI,cAAc,GAAG,SAAS,CAAC;SAClD,CAAC;KACL,CAAC;CACL,CAAC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":""}
|
package/dist/session.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ICompositeLogger } from "./logging.js";
|
|
2
|
+
import type { IKeychain } from "./keychain.js";
|
|
3
|
+
import type { IToolConfig } from "./config.js";
|
|
2
4
|
export type SessionEvents = {
|
|
3
5
|
connect: [];
|
|
4
6
|
close: [];
|
|
5
7
|
disconnect: [];
|
|
6
8
|
"connection-error": [unknown];
|
|
7
9
|
};
|
|
8
|
-
export interface ISession {
|
|
10
|
+
export interface ISession<TConfig extends IToolConfig = IToolConfig> {
|
|
9
11
|
readonly sessionId: string;
|
|
10
12
|
logger: ICompositeLogger;
|
|
11
13
|
mcpClient?: {
|
|
@@ -22,9 +24,21 @@ export interface ISession {
|
|
|
22
24
|
disconnect(): Promise<void>;
|
|
23
25
|
close(): Promise<void>;
|
|
24
26
|
readonly isConnectedToMongoDB: boolean;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
/** Event emitter method for reactive resources */
|
|
28
|
+
on(event: "connect" | "disconnect" | "close" | "connection-error", listener: (...args: unknown[]) => void): void;
|
|
29
|
+
/** Keychain for secret management */
|
|
30
|
+
readonly keychain: IKeychain;
|
|
31
|
+
/** Configuration for the session */
|
|
32
|
+
readonly config: TConfig;
|
|
33
|
+
/** Optional connection string info */
|
|
34
|
+
readonly connectionStringInfo?: {
|
|
35
|
+
authType?: string;
|
|
36
|
+
hostType?: string;
|
|
37
|
+
};
|
|
38
|
+
/** Optional connected Atlas cluster info */
|
|
39
|
+
readonly connectedAtlasCluster?: {
|
|
40
|
+
projectId?: string;
|
|
41
|
+
clusterName?: string;
|
|
42
|
+
};
|
|
29
43
|
}
|
|
30
44
|
//# sourceMappingURL=session.d.ts.map
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,aAAa,GAAG;IACxB,OAAO,EAAE,EAAE,CAAC;IACZ,KAAK,EAAE,EAAE,CAAC;IACV,UAAU,EAAE,EAAE,CAAC;IACf,kBAAkB,EAAE,CAAC,OAAO,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,QAAQ,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,0CAA0C;IAC1C,YAAY,CAAC,SAAS,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAAG,IAAI,CAAC;IAC/F,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IACvC,kDAAkD;IAClD,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,YAAY,GAAG,OAAO,GAAG,kBAAkB,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IACjH,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,sCAAsC;IACtC,QAAQ,CAAC,oBAAoB,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzE,4CAA4C;IAC5C,QAAQ,CAAC,qBAAqB,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjF"}
|
package/dist/sessionStore.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { ClientCapabilities, Implementation } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import type { ILogger, ICompositeLogger } from "./logging.js";
|
|
3
|
+
import type { IMetrics, DefaultMetricDefinitions } from "./metrics.js";
|
|
4
4
|
export type CloseableTransport = {
|
|
5
5
|
close(): Promise<void>;
|
|
6
6
|
};
|
|
7
7
|
export type SessionCloseReason = "idle_timeout" | "transport_closed" | "server_stop" | "unknown" | "evicted";
|
|
8
|
+
/**
|
|
9
|
+
* The client state negotiated during MCP initialization. Stores that persist
|
|
10
|
+
* it durably allow an implicitly re-initialized session (one restored on a
|
|
11
|
+
* pod that never saw the client's `initialize` request) to retain the
|
|
12
|
+
* client's capabilities -- e.g. whether it supports elicitation -- instead of
|
|
13
|
+
* treating the restored client as capability-less.
|
|
14
|
+
*/
|
|
15
|
+
export type NegotiatedClientState = {
|
|
16
|
+
clientCapabilities?: ClientCapabilities;
|
|
17
|
+
clientInfo?: Implementation;
|
|
18
|
+
};
|
|
8
19
|
export interface ISessionStore<T extends CloseableTransport = CloseableTransport> {
|
|
9
20
|
/**
|
|
10
21
|
* Returns the transport for the given session id or `undefined` if the
|
|
@@ -31,9 +42,10 @@ export interface ISessionStore<T extends CloseableTransport = CloseableTransport
|
|
|
31
42
|
addSession(params: {
|
|
32
43
|
sessionId: string;
|
|
33
44
|
transport: T;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
logger: ILogger;
|
|
46
|
+
session?: {
|
|
47
|
+
logger: ICompositeLogger;
|
|
48
|
+
};
|
|
37
49
|
headers?: Record<string, unknown>;
|
|
38
50
|
}): Promise<void>;
|
|
39
51
|
closeSession(params: {
|
|
@@ -41,15 +53,28 @@ export interface ISessionStore<T extends CloseableTransport = CloseableTransport
|
|
|
41
53
|
reason?: SessionCloseReason;
|
|
42
54
|
}): Promise<void>;
|
|
43
55
|
closeAllSessions(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Durably records the client state negotiated during a real MCP
|
|
58
|
+
* initialization, so it can be restored when the session is later
|
|
59
|
+
* implicitly re-initialized (only relevant with
|
|
60
|
+
* `externallyManagedSessions`). Stores without durable storage can
|
|
61
|
+
* implement this as a no-op.
|
|
62
|
+
*/
|
|
63
|
+
saveNegotiatedClientState(sessionId: string, state: NegotiatedClientState, headers?: Record<string, unknown>): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the previously saved negotiated client state for the session,
|
|
66
|
+
* or `undefined` when unknown.
|
|
67
|
+
*/
|
|
68
|
+
loadNegotiatedClientState(sessionId: string, headers?: Record<string, unknown>): Promise<NegotiatedClientState | undefined>;
|
|
44
69
|
}
|
|
45
|
-
export type SessionStoreConstructorArgs<TMetrics extends
|
|
70
|
+
export type SessionStoreConstructorArgs<TMetrics extends DefaultMetricDefinitions = DefaultMetricDefinitions> = {
|
|
46
71
|
options: {
|
|
47
72
|
idleTimeoutMS: number;
|
|
48
73
|
notificationTimeoutMS: number;
|
|
49
74
|
maxSessions: number;
|
|
50
75
|
/**
|
|
51
76
|
* When the store is at `maxSessions` and a new session arrives, evict the
|
|
52
|
-
* least-recently-used session instead of rejecting
|
|
77
|
+
* least-recently-used session instead of rejecting -- but only if it has been
|
|
53
78
|
* idle for at least this long (ms). Must be < `idleTimeoutMS` (the background
|
|
54
79
|
* reaper already removes anything past that), or the valve never fires. If a
|
|
55
80
|
* session idle >= this exists, it is closed locally to make room; otherwise
|
|
@@ -58,8 +83,7 @@ export type SessionStoreConstructorArgs<TMetrics extends MetricDefinitions = Met
|
|
|
58
83
|
*/
|
|
59
84
|
evictionIdleGraceMS?: number;
|
|
60
85
|
};
|
|
61
|
-
logger:
|
|
86
|
+
logger: ILogger;
|
|
62
87
|
metrics: IMetrics<TMetrics>;
|
|
63
88
|
};
|
|
64
|
-
export type CreateSessionStoreFn<TTransport extends CloseableTransport = CloseableTransport, TMetrics extends MetricDefinitions = MetricDefinitions> = (args: SessionStoreConstructorArgs<TMetrics>) => ISessionStore<TTransport>;
|
|
65
89
|
//# sourceMappingURL=sessionStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionStore.d.ts","sourceRoot":"","sources":["../src/sessionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sessionStore.d.ts","sourceRoot":"","sources":["../src/sessionStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC7F,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,kB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OAAO,CAAC,GAClC,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC;CACjD;AAED,MAAM,MAAM,2BAA2B,CAAC,QAAQ,SAAS,wBAAwB,GAAG,wBAAwB,IAAI;IAC5G,OAAO,EAAE;QACL,aAAa,EAAE,MAAM,CAAC;QACtB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,WAAW,EAAE,MAAM,CAAC;QACpB;;;;;;;;WAQG;QACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAChC,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CAC/B,CAAC"}
|
package/dist/telemetry.d.ts
CHANGED
|
@@ -8,4 +8,75 @@ export interface ITelemetry {
|
|
|
8
8
|
emitEvents(events: unknown[]): void;
|
|
9
9
|
close(): Promise<void>;
|
|
10
10
|
}
|
|
11
|
+
export type TelemetryResult = "success" | "failure";
|
|
12
|
+
export type TelemetryBoolSet = "true" | "false";
|
|
13
|
+
export type TelemetryCommonStaticProperties = {
|
|
14
|
+
mcp_server_version: string;
|
|
15
|
+
mcp_server_name: string;
|
|
16
|
+
platform: string;
|
|
17
|
+
arch: string;
|
|
18
|
+
os_type: string;
|
|
19
|
+
os_version?: string;
|
|
20
|
+
};
|
|
21
|
+
export type TelemetryCommonProperties = {
|
|
22
|
+
device_id?: string;
|
|
23
|
+
is_container_env?: TelemetryBoolSet;
|
|
24
|
+
mcp_client_version?: string;
|
|
25
|
+
mcp_client_name?: string;
|
|
26
|
+
transport?: "stdio" | "http";
|
|
27
|
+
config_atlas_auth?: TelemetryBoolSet;
|
|
28
|
+
config_connection_string?: TelemetryBoolSet;
|
|
29
|
+
session_id?: string;
|
|
30
|
+
hosting_mode?: string;
|
|
31
|
+
has_docker?: TelemetryBoolSet;
|
|
32
|
+
} & TelemetryCommonStaticProperties;
|
|
33
|
+
export type TelemetryEvent<T> = {
|
|
34
|
+
timestamp: string;
|
|
35
|
+
source: "mdbmcp";
|
|
36
|
+
properties: T & {
|
|
37
|
+
component: string;
|
|
38
|
+
duration_ms: number;
|
|
39
|
+
result: TelemetryResult;
|
|
40
|
+
category: string;
|
|
41
|
+
} & Record<string, string | number | string[]>;
|
|
42
|
+
};
|
|
43
|
+
export type TelemetryToolMetadataValue = string | number | boolean | undefined | string[];
|
|
44
|
+
export type TelemetryToolMetadataBase = {
|
|
45
|
+
[key: string]: TelemetryToolMetadataValue;
|
|
46
|
+
};
|
|
47
|
+
export type AtlasMetadata = TelemetryToolMetadataBase & {
|
|
48
|
+
project_id?: string;
|
|
49
|
+
org_id?: string;
|
|
50
|
+
};
|
|
51
|
+
export type AtlasLocalToolMetadata = TelemetryToolMetadataBase & {
|
|
52
|
+
atlas_local_deployment_id?: string;
|
|
53
|
+
};
|
|
54
|
+
export type SharedTierTier = "Free" | "Flex";
|
|
55
|
+
export declare const SHARED_TIER_METRIC_NAMES: readonly ["CONNECTIONS_PERCENT", "FLEX_CONNECTIONS_PERCENT", "FLEX_DATA_SIZE_TOTAL", "LOGICAL_SIZE"];
|
|
56
|
+
export type SharedTierMetricName = (typeof SHARED_TIER_METRIC_NAMES)[number];
|
|
57
|
+
export type ConnectionMetadata = AtlasMetadata & AtlasLocalToolMetadata & {
|
|
58
|
+
connection_auth_type?: string;
|
|
59
|
+
connection_host_type?: string;
|
|
60
|
+
shared_tier_alerts_detected?: TelemetryBoolSet;
|
|
61
|
+
shared_tier_tier?: SharedTierTier;
|
|
62
|
+
shared_tier_alerts?: SharedTierMetricName[];
|
|
63
|
+
};
|
|
64
|
+
export type PerfAdvisorToolMetadata = AtlasMetadata & ConnectionMetadata & {
|
|
65
|
+
operations: string[];
|
|
66
|
+
};
|
|
67
|
+
export type StreamsToolMetadata = AtlasMetadata & {
|
|
68
|
+
action?: string;
|
|
69
|
+
resource?: string;
|
|
70
|
+
};
|
|
71
|
+
export type IndexMetadata = ConnectionMetadata & {
|
|
72
|
+
index_type: "classic" | "vectorSearch" | "search";
|
|
73
|
+
};
|
|
74
|
+
export type TelemetryToolMetadata = AtlasMetadata | ConnectionMetadata | PerfAdvisorToolMetadata | StreamsToolMetadata | IndexMetadata;
|
|
75
|
+
export type ToolEventProperties = {
|
|
76
|
+
command: string;
|
|
77
|
+
error_code?: string;
|
|
78
|
+
error_type?: string;
|
|
79
|
+
is_atlas?: boolean;
|
|
80
|
+
} & TelemetryToolMetadata;
|
|
81
|
+
export type ToolEvent = TelemetryEvent<ToolEventProperties>;
|
|
11
82
|
//# sourceMappingURL=telemetry.d.ts.map
|
package/dist/telemetry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC1B,gBAAgB,EAAE,EAAE,CAAC;IACrB,oBAAoB,EAAE,EAAE,CAAC;IACzB,gBAAgB,EAAE,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,UAAU;IACvB,kBAAkB,IAAI,OAAO,CAAC;IAC9B,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACpC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B"}
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC1B,gBAAgB,EAAE,EAAE,CAAC;IACrB,oBAAoB,EAAE,EAAE,CAAC;IACzB,gBAAgB,EAAE,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,UAAU;IACvB,kBAAkB,IAAI,OAAO,CAAC;IAC9B,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACpC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,CAAC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AmB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,qBAAqB,CAAC;AAE1B,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC,mBAAmB,CAAC,CAAC"}
|
package/dist/telemetry.js
CHANGED
package/dist/telemetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAkEA,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACpC,qBAAqB;IACrB,0BAA0B;IAC1B,sBAAsB;IACtB,cAAc;CACR,CAAC"}
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,10 +1,73 @@
|
|
|
1
|
+
import { type CallToolResult, type RequestMeta } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
export type { CallToolResult };
|
|
3
|
+
import type { Secret } from "mongodb-redact";
|
|
4
|
+
import type { IToolConfig } from "./config.js";
|
|
5
|
+
import type { ICompositeLogger } from "./logging.js";
|
|
6
|
+
/**
|
|
7
|
+
* The minimal session surface tools rely on: config and logging. The CLI's
|
|
8
|
+
* session is deliberately stateless (connection state lives in the app-level
|
|
9
|
+
* registry and is addressed by connectionId), so tools are not constrained to
|
|
10
|
+
* the full {@link ISession} shape.
|
|
11
|
+
*/
|
|
12
|
+
export interface IToolSession {
|
|
13
|
+
readonly config: IToolConfig;
|
|
14
|
+
readonly logger: ICompositeLogger;
|
|
15
|
+
/** Secrets registered for redaction (used by ToolBase error handling). */
|
|
16
|
+
readonly keychain: {
|
|
17
|
+
readonly allSecrets: Secret[];
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The type of operation the tool performs. This is used when evaluating if a tool is allowed to run based on
|
|
22
|
+
* the config's `disabledTools` and `readOnly` settings.
|
|
23
|
+
* - `metadata` is used for tools that read but do not access potentially user-generated
|
|
24
|
+
* data, such as listing databases, collections, or indexes, or inferring collection schema.
|
|
25
|
+
* - `read` is used for tools that read potentially user-generated data, such as finding documents or aggregating data.
|
|
26
|
+
* It is also used for tools that read non-user-generated data, such as listing clusters in Atlas.
|
|
27
|
+
* - `create` is used for tools that create resources, such as creating documents, collections, indexes, clusters, etc.
|
|
28
|
+
* - `update` is used for tools that update resources, such as updating documents, renaming collections, etc.
|
|
29
|
+
* - `delete` is used for tools that delete resources, such as deleting documents, dropping collections, etc.
|
|
30
|
+
* - `connect` is used for tools that allow you to connect or switch the connection to a MongoDB instance.
|
|
31
|
+
*/
|
|
1
32
|
export type OperationType = "metadata" | "read" | "create" | "delete" | "update" | "connect";
|
|
2
|
-
|
|
33
|
+
/**
|
|
34
|
+
* The category of the tool. This is used when evaluating if a tool is allowed to run based on
|
|
35
|
+
* the config's `disabledTools` setting.
|
|
36
|
+
* - `mongodb` is used for tools that interact with a MongoDB instance, such as finding documents,
|
|
37
|
+
* aggregating data, listing databases/collections/indexes, creating indexes, etc.
|
|
38
|
+
* - `atlas` is used for tools that interact with MongoDB Atlas, such as listing clusters, creating clusters, etc.
|
|
39
|
+
* - `atlas-local` is used for tools that interact with local Atlas deployments.
|
|
40
|
+
* - `assistant` is used for tools that interact with the Assistant, such as searching the public knowledge base.
|
|
41
|
+
* - `custom` is used for tools that are not part of the default tool categories.
|
|
42
|
+
*/
|
|
43
|
+
export type ToolCategory = "mongodb" | "atlas" | "atlas-local" | "assistant" | "custom";
|
|
44
|
+
/**
|
|
45
|
+
* Context provided during tool execution.
|
|
46
|
+
*/
|
|
3
47
|
export type ToolExecutionContext = {
|
|
48
|
+
/** AbortSignal for cancellation support */
|
|
4
49
|
signal: AbortSignal;
|
|
50
|
+
/**
|
|
51
|
+
* Request context object available only when running atop
|
|
52
|
+
* StreamableHttpTransport.
|
|
53
|
+
*/
|
|
5
54
|
requestInfo?: {
|
|
6
55
|
headers?: Record<string, unknown>;
|
|
7
56
|
};
|
|
57
|
+
/** Metadata from the original MCP request (e.g. the client's progress token). */
|
|
58
|
+
_meta?: RequestMeta;
|
|
59
|
+
/** The request id, when invoked through an MCP server. */
|
|
60
|
+
requestId?: string | number;
|
|
61
|
+
/** Send an MCP server notification. */
|
|
62
|
+
sendNotification?: (notification: unknown) => Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Total time spent waiting for the user to answer elicitation requests
|
|
65
|
+
* raised while handling this call. Accumulated by
|
|
66
|
+
* `ToolBase.requestConfirmation` and subtracted from the tool execution
|
|
67
|
+
* duration metric, so that the user's think-time is not reported as
|
|
68
|
+
* time the tool spent working.
|
|
69
|
+
*/
|
|
70
|
+
elicitationDurationMs?: number;
|
|
8
71
|
};
|
|
9
72
|
export type ToolClass<TParams extends unknown[] = unknown[]> = {
|
|
10
73
|
new (params: TParams): {
|
|
@@ -16,6 +79,7 @@ export type ToolClass<TParams extends unknown[] = unknown[]> = {
|
|
|
16
79
|
category: ToolCategory;
|
|
17
80
|
operationType: OperationType;
|
|
18
81
|
};
|
|
82
|
+
export type AnyToolClass = ToolClass<any>;
|
|
19
83
|
export interface IToolRegistrar {
|
|
20
84
|
register(tool: ToolClass): boolean;
|
|
21
85
|
}
|
package/dist/tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7F,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"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,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,OAAO,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI;IAC3D,KAAK,MAAM,EAAE,OAAO,GAAG;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,YAAY,CAAC;QACvB,aAAa,EAAE,aAAa,CAAC;KAChC,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;CAChC,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;CACtC"}
|
package/dist/transport.d.ts
CHANGED
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,OAAO,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAC;QAAC,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,OAAO,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAC;QAAC,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC3B,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for configuring the HTTP server (host, port, etc).
|
|
3
|
+
*/
|
|
4
|
+
export type HttpServerOptions = {
|
|
5
|
+
/** Host to bind the HTTP server to */
|
|
6
|
+
host: string;
|
|
7
|
+
/** Port to bind the HTTP server to */
|
|
8
|
+
port: number;
|
|
9
|
+
/** Maximum HTTP body size in bytes */
|
|
10
|
+
bodyLimit?: number;
|
|
11
|
+
/** Headers to validate */
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
/** Response type: 'sse' for Server-Sent Events, 'json' for JSON responses */
|
|
14
|
+
responseType?: "sse" | "json";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Options for session management.
|
|
18
|
+
*/
|
|
19
|
+
export type SessionManagementOptions = {
|
|
20
|
+
/** Idle timeout in milliseconds */
|
|
21
|
+
idleTimeoutMs: number;
|
|
22
|
+
/** Notification timeout in milliseconds */
|
|
23
|
+
notificationTimeoutMs: number;
|
|
24
|
+
/** Whether to allow externally managed sessions */
|
|
25
|
+
externallyManagedSessions: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Options for transport runners.
|
|
29
|
+
*/
|
|
30
|
+
export type TransportRunnerOptions = {
|
|
31
|
+
/** Server name */
|
|
32
|
+
name: string;
|
|
33
|
+
/** Server version */
|
|
34
|
+
version: string;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=transports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transports.d.ts","sourceRoot":"","sources":["../src/transports.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC5B,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,6EAA6E;IAC7E,YAAY,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC,mCAAmC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mDAAmD;IACnD,yBAAyB,EAAE,OAAO,CAAC;CACtC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACjC,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transports.js","sourceRoot":"","sources":["../src/transports.ts"],"names":[],"mappings":""}
|
package/dist/ui.d.ts
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface UIRegistryOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Custom UIs for tools. Function that returns HTML strings for tool names.
|
|
4
|
+
* Use this to add UIs to tools or replace the default bundled UIs.
|
|
5
|
+
* The function is called lazily when a UI is requested, allowing you to
|
|
6
|
+
* defer loading large HTML files until needed.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { readFileSync } from 'fs';
|
|
10
|
+
* const server = new Server({
|
|
11
|
+
* // ... other options
|
|
12
|
+
* customUIs: (toolName) => {
|
|
13
|
+
* if (toolName === 'list-databases') {
|
|
14
|
+
* return readFileSync('./my-custom-ui.html', 'utf-8');
|
|
15
|
+
* }
|
|
16
|
+
* return null;
|
|
17
|
+
* }
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
2
21
|
customUIs?: (toolName: string) => string | null | Promise<string | null>;
|
|
3
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Lazy loaders for bundled UI HTML strings, keyed by tool name.
|
|
24
|
+
* Each loader returns a Promise that resolves to the HTML string.
|
|
25
|
+
*/
|
|
26
|
+
loaders?: Record<string, (() => Promise<string>) | undefined>;
|
|
27
|
+
}
|
|
4
28
|
export interface IUIRegistry {
|
|
5
29
|
get(toolName: string): Promise<string | null>;
|
|
6
30
|
}
|
package/dist/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAC9B;;;;;;;;;;;;;;;;;;OAkBG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAEzE;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CACjE;AAED,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACjD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mongodb-js/mcp-types",
|
|
3
3
|
"description": "Shared TypeScript types and interfaces for MongoDB MCP server packages",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0-prerelease.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "MongoDB <info@mongodb.com>",
|
|
@@ -18,19 +18,20 @@
|
|
|
18
18
|
"default": "./dist/index.js"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"main": "./dist/index.js",
|
|
22
21
|
"types": "./dist/index.d.ts",
|
|
23
22
|
"files": [
|
|
24
23
|
"dist"
|
|
25
24
|
],
|
|
26
25
|
"devDependencies": {
|
|
26
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
27
|
+
"mongodb-redact": "^1.4.6",
|
|
27
28
|
"@types/node": "^25.6.0",
|
|
28
|
-
"mongodb-log-writer": "^2.5.13",
|
|
29
29
|
"typescript": "^5.9.2",
|
|
30
30
|
"vitest": "^4.1.10"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
|
-
"
|
|
34
|
-
"test": "vitest --run"
|
|
33
|
+
"build": "tsc --build tsconfig.build.json",
|
|
34
|
+
"test": "vitest --run",
|
|
35
|
+
"check": "tsc --build tsconfig.build.json --noEmit"
|
|
35
36
|
}
|
|
36
37
|
}
|