@mongodb-js/mcp-types 3.0.0-prerelease.2 → 3.0.0-prerelease.4

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.
@@ -1,15 +1,30 @@
1
1
  /**
2
2
  * Atlas cluster connection info containing details about the connected Atlas cluster.
3
3
  * When provided, indicates the connection is to an Atlas cluster.
4
+ *
5
+ * The cluster's projectId, name and id are required. A host that establishes the
6
+ * connection without minting a temporary database user — via its own credential
7
+ * issuance, X.509, a pre-provisioned user, a proxy — still knows which cluster it
8
+ * connected to and needs to be able to specify it: this field is what marks a
9
+ * connection as pointing at Atlas, and leaving it unset prevents cluster
10
+ * attribution on tool telemetry, the `atlas` host type, and the ability of
11
+ * `pause-resume-cluster` to find connections to the cluster it just paused.
12
+ * Hosts that only know the cluster name should resolve the id through the Atlas
13
+ * API before connecting.
4
14
  */
5
15
  export type AtlasClusterConnectionInfo = {
6
- username: string;
16
+ /** Which Atlas cluster this connection points at. */
7
17
  projectId: string;
8
18
  clusterName: string;
9
- instanceType: "FREE" | "FLEX" | "DEDICATED";
10
- provider?: string;
11
- region?: string;
12
- expiryDate: Date;
19
+ clusterId: string;
20
+ /**
21
+ * The temporary database user backing the connection. Set only by
22
+ * `connect-cluster`, which also schedules its deletion; absent when the
23
+ * host supplied its own credentials.
24
+ */
25
+ username?: string;
26
+ /** The cluster's tier, set when the host resolved it. */
27
+ instanceType?: "FREE" | "FLEX" | "DEDICATED";
13
28
  };
14
29
  /**
15
30
  * Connection string info describing the auth and host type of a MongoDB connection.
@@ -1 +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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C;IACZ,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,qBAAqB,CAAC,EAAE,0BAA0B,CAAC;CACtD,CAAC"}
@@ -1,4 +1,6 @@
1
- import type { ElicitRequestFormParams, ProgressToken, RequestId, ServerNotification } from "@modelcontextprotocol/sdk/types.js";
1
+ import type { ElicitRequestFormParams, InputRequiredResult, InputResponses } from "@modelcontextprotocol/server";
2
+ /** Values that can be read back from a retried request's `inputResponses`. */
3
+ export type ElicitationInputResponses = InputResponses | Record<string, unknown> | undefined;
2
4
  export type ElicitedInputResult = {
3
5
  accepted: true;
4
6
  fields: Record<string, string>;
@@ -6,21 +8,83 @@ export type ElicitedInputResult = {
6
8
  accepted: false;
7
9
  fields?: undefined;
8
10
  };
9
- /** The schema accepted by {@link IElicitation.requestInput}. */
11
+ /** The schema accepted by {@link IElicitation.inputRequired}. */
10
12
  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;
13
+ /** Parameters for {@link IElicitation.inputRequired}. */
14
+ export type ElicitInputRequiredParams = {
15
+ /** The identifier the answers arrive under in `inputResponses`. */
16
+ key: string;
17
+ /** The message/title to display in the form. */
18
+ message: string;
19
+ /** A JSON Schema describing the fields to collect. */
20
+ schema: ElicitRequestSchema;
20
21
  };
22
+ /**
23
+ * Elicitation service used by tools to request confirmation or structured
24
+ * input from the user.
25
+ *
26
+ * Protocol revision 2026-07-28 replaced push-style server→client requests
27
+ * with **multi-round-trip**: a handler that needs user input returns
28
+ * `inputRequired(...)` from the request handler and the client retries the
29
+ * original request carrying the answers (`inputResponses`). The MongoDB MCP
30
+ * server's handlers are written in that style once and serve both eras: on
31
+ * 2025-era connections the SDK's legacy shim turns the same `inputRequired`
32
+ * return into real server→client requests and re-enters the handler with the
33
+ * collected responses.
34
+ *
35
+ * Implementations therefore expose two complementary halves:
36
+ * - *builders* (`confirmationRequired`, `inputRequired`) that produce the
37
+ * `InputRequiredResult` a handler returns when the required input has not
38
+ * been provided yet;
39
+ * - *readers* (`readConfirmation`, `readInput`) that extract the answers from
40
+ * a retried request's `inputResponses` (resent by the client verbatim on
41
+ * re-entry, so they must be treated as untrusted input).
42
+ */
21
43
  export interface IElicitation {
44
+ /**
45
+ * Checks if the client supports elicitation capabilities.
46
+ * @returns True if the client supports elicitation, false otherwise.
47
+ */
22
48
  supportsElicitation(): boolean;
23
- requestConfirmation(message: string, options?: ElicitationOptions): Promise<boolean>;
24
- requestInput(message: string, schema: ElicitRequestSchema, options?: ElicitationOptions): Promise<ElicitedInputResult>;
49
+ /**
50
+ * Builds the `inputRequired` result asking the user to confirm an
51
+ * operation. The handler returns it on the first entry; on re-entry the
52
+ * answers are read back with {@link IElicitation.readConfirmation}.
53
+ *
54
+ * @param message - The message to display to the user.
55
+ * @returns The `InputRequiredResult` to return from the request handler.
56
+ */
57
+ confirmationRequired(message: string): InputRequiredResult;
58
+ /**
59
+ * Reads the user's answer to a {@link IElicitation.confirmationRequired}
60
+ * request from a retried request's `inputResponses`.
61
+ *
62
+ * @returns `true` when the user confirmed, `false` when they declined, and
63
+ * `undefined` when this round carries no answer yet (the handler should
64
+ * return {@link IElicitation.confirmationRequired} instead).
65
+ */
66
+ readConfirmation(inputResponses: ElicitationInputResponses): boolean | undefined;
67
+ /**
68
+ * Builds the `inputRequired` result asking the user for structured input
69
+ * via a form. The handler returns it on the first entry; on re-entry the
70
+ * answers are read back with {@link IElicitation.readInput}.
71
+ *
72
+ * @param params - The identifier the answers arrive under in `inputResponses`
73
+ * (`key`), the message/title to display in the form (`message`) and a JSON
74
+ * Schema describing the fields to collect (`schema`).
75
+ * @returns The `InputRequiredResult` to return from the request handler.
76
+ */
77
+ inputRequired(params: ElicitInputRequiredParams): InputRequiredResult;
78
+ /**
79
+ * Reads the accepted fields of a {@link IElicitation.inputRequired}
80
+ * request from a retried request's `inputResponses`.
81
+ *
82
+ * @returns `{ accepted: true, fields }` with the user-provided values keyed
83
+ * by field name, `{ accepted: false }` when the user declined or cancelled
84
+ * (or the client does not support elicitation), and `undefined` when this
85
+ * round carries no response for `key` yet (the handler should return
86
+ * {@link IElicitation.inputRequired} again).
87
+ */
88
+ readInput(inputResponses: ElicitationInputResponses, key: string): ElicitedInputResult | undefined;
25
89
  }
26
90
  //# sourceMappingURL=elicitation.d.ts.map
@@ -1 +1 @@
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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ACH,gBAAgB,CAAC,cAAc,EAAE,yBAAyB,GAAG,OAAO,GAAG,SAAS,CAAC;IAEjF;;;;;;;;;OASG;IACH,aAAa,CAAC,MAAM,EAAE,yBAAyB,GAAG,mBAAmB,CAAC;IAEtE;;;;;;;;;OASG;IACH,SAAS,CAAC,cAAc,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS,CAAC;CACtG"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  export type * from "./config.js";
2
2
  export type { AtlasClusterConnectionInfo, ConnectionStringInfo, SupportedConnectionState } from "./connection.js";
3
3
  export type * from "./schemas.js";
4
- export type * from "./session.js";
5
- export type * from "./sessionStore.js";
6
4
  export type * from "./transports.js";
7
5
  export type * from "./keychain.js";
8
6
  export type * from "./elicitation.js";
@@ -17,4 +15,5 @@ export type * from "./telemetry.js";
17
15
  export { SHARED_TIER_METRIC_NAMES } from "./telemetry.js";
18
16
  export type * from "./helpers.js";
19
17
  export type * from "./server.js";
18
+ export type * from "./sessionStore.js";
20
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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"}
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,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;AACjC,mBAAmB,mBAAmB,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,10 +1,23 @@
1
1
  import type { Secret } from "mongodb-redact";
2
- export interface IKeychain<TKey = Secret["value"], TKind = Secret["kind"]> {
3
- register(value: unknown, kind: string): void;
2
+ export type { Secret } from "mongodb-redact";
3
+ /**
4
+ * The redaction half of a keychain, for consumers that need to scrub secrets out of a value but
5
+ * have no business registering or clearing them - loggers and tools. Kept separate so those
6
+ * consumers are not coupled to secret management just to reach {@link IRedactor.redact}.
7
+ */
8
+ export interface IRedactor {
9
+ /**
10
+ * Redacts the registered secrets from the strings in `value`, returning a copy of the same
11
+ * shape. Arrays and own enumerable properties are visited recursively, and the prototype of
12
+ * any object descended into is preserved. Values that keep their contents behind an API
13
+ * rather than in own properties - `Map`, `Set` and the like - are returned untouched, as are
14
+ * non-string primitives, so not every string transitively reachable is guaranteed to be
15
+ * redacted. Never mutates `value`, and terminates on self-referencing input.
16
+ */
17
+ redact<T>(value: T): T;
18
+ }
19
+ export interface IKeychain extends IRedactor {
20
+ register(value: Secret["value"], kind: Secret["kind"]): void;
4
21
  clearAllSecrets(): void;
5
- readonly allSecrets: {
6
- value: TKey;
7
- kind: TKind;
8
- }[];
9
22
  }
10
23
  //# sourceMappingURL=keychain.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../src/keychain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACtB;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,SAAU,SAAQ,SAAS;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC7D,eAAe,IAAI,IAAI,CAAC;CAC3B"}
package/dist/logging.d.ts CHANGED
@@ -1,6 +1,6 @@
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";
1
+ import type { LoggingMessageNotification } from "@modelcontextprotocol/server";
2
+ import type { IRedactor } from "./keychain.js";
3
+ export type { McpServer } from "@modelcontextprotocol/server";
4
4
  export type LogLevel = LoggingMessageNotification["params"]["level"];
5
5
  export type LoggerType = "console" | "disk" | "mcp";
6
6
  export type EventMap<T> = Record<keyof T, any[]>;
@@ -33,7 +33,7 @@ export interface ILogger {
33
33
  flush(): Promise<PromiseSettledResult<void>[]>;
34
34
  }
35
35
  export type LoggerConfig = {
36
- keychain: IKeychain;
36
+ keychain: IRedactor;
37
37
  };
38
38
  export interface ICompositeLogger extends ILogger {
39
39
  addLogger(logger: ILogger): void;
@@ -1 +1 @@
1
- {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C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AAG,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
@@ -28,15 +28,6 @@ export interface IGauge {
28
28
  /**
29
29
  * Default metric definitions for MCP servers.
30
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
31
  */
41
32
  export type DefaultMetricDefinitions = {
42
33
  /** Counter for tracking created sessions */
@@ -1 +1 @@
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,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,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;;;GAGG;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"}
@@ -1,18 +1,22 @@
1
- import type { ResourceMetadata, ReadResourceCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import type { SessionEvents } from "./session.js";
1
+ import type { ResourceMetadata, ReadResourceCallback } from "@modelcontextprotocol/server";
3
2
  import type { ITelemetry } from "./telemetry.js";
4
3
  import type { IToolConfig } from "./config.js";
5
4
  import type { ICompositeLogger } from "./logging.js";
5
+ import type { IKeychain } from "./keychain.js";
6
+ import type { TransportRequestContext } from "./transport.js";
6
7
  /**
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.
8
+ * The minimal services resources read off the host server at construction,
9
+ * injected individually (no server-scoped "session" object exists). The server
10
+ * is deliberately stateless (connection state lives in the app-level registry),
11
+ * so resources read only the specific services they need from the server;
12
+ * host-specific extras (e.g. the connection registry) are read directly off
13
+ * the concrete server type by the resource implementation.
10
14
  */
11
- export interface IResourceSession {
15
+ export type ResourceServices = {
12
16
  readonly config: IToolConfig;
13
17
  readonly logger: ICompositeLogger;
14
- on(event: keyof SessionEvents, listener: (...args: unknown[]) => void): void;
15
- }
18
+ readonly keychain: IKeychain;
19
+ };
16
20
  export interface IResource {
17
21
  register(server: unknown): void;
18
22
  }
@@ -23,32 +27,49 @@ export type ResourceConfiguration = {
23
27
  uri: string;
24
28
  config: ResourceMetadata;
25
29
  };
26
- export type ReactiveResourceOptions<Value, RelevantEvents extends readonly (keyof SessionEvents)[]> = {
30
+ export type ReactiveResourceOptions<Value> = {
27
31
  initial: Value;
28
- events: RelevantEvents;
29
32
  };
30
- /** The host server surface resources register against. */
33
+ /**
34
+ * The host server surface resources register against and read services from.
35
+ * Resources are constructed with the server itself (`{ server }`) and derive
36
+ * the minimal services (config/logger/keychain) plus telemetry from it.
37
+ */
31
38
  export interface IResourceServer {
39
+ readonly config: ResourceServices["config"];
40
+ readonly logger: ResourceServices["logger"];
41
+ readonly keychain: ResourceServices["keychain"];
42
+ readonly telemetry: ITelemetry;
32
43
  mcpServer: {
33
44
  registerResource: (name: string, uri: string, config: ResourceMetadata, callback: ReadResourceCallback) => void;
34
45
  };
35
46
  sendResourceListChanged(): void;
36
47
  sendResourceUpdated(uri: string): void;
37
48
  }
49
+ /**
50
+ * The construction argument every resource class receives: the host server plus
51
+ * the transport request that drove server creation (undefined for non-HTTP
52
+ * constructions such as stdio / dry-run).
53
+ */
54
+ export type ResourceServerArg<TServer extends IResourceServer = IResourceServer> = {
55
+ server: TServer;
56
+ /** The transport request that drove server creation (undefined for stdio / dry-run). */
57
+ transportRequest?: TransportRequestContext;
58
+ };
38
59
  /**
39
60
  * The type that all resource classes must conform to when implementing custom resources
40
61
  * for the MongoDB MCP Server.
41
62
  *
42
63
  * This type enforces that resource classes have a constructor accepting
43
- * `(session, telemetry)`, matching the construction pattern used by
64
+ * `({ server })`, matching the construction pattern used by
44
65
  * {@link CliServer} (see `registerResources`). The resolved user
45
- * configuration is read from `session.config`.
66
+ * configuration is read from `server.config`.
46
67
  */
47
- export type ResourceClass<TSession extends IResourceSession = IResourceSession> = {
48
- new (session: TSession, telemetry: ITelemetry): {
68
+ export type ResourceClass<TServer extends IResourceServer = IResourceServer> = {
69
+ new (arg: ResourceServerArg<TServer>): {
49
70
  register(server: IResourceServer): void;
50
71
  };
51
72
  };
52
- /** Resource constructor type for registries that may include session-specific resource implementations. */
73
+ /** Resource constructor type for registries that may include resource-specific servers. */
53
74
  export type AnyResourceClass = ResourceClass<any>;
54
75
  //# sourceMappingURL=resources.d.ts.map
@@ -1 +1 @@
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,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,EAAE,CAAC,KAAK,EAAE,MAAM,aAAa,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CAChF;AAED,MAAM,WAAW,SAAS;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACnC;AAED,MAAM,MAA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C;IAChC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,eAAe,GAAG,eAAe,IAAI;IAC/E,MAAM,EAAE,OAAO,CAAC;IAChB,wFAAwF;IACxF,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;CAC9C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,CAAC,OAAO,SAAS,eAAe,GAAG,eAAe,IAAI;IAC3E,KAAK,GAAG,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG;QAAE,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAA;KAAE,CAAC;CACtF,CAAC;AAEF,2FAA2F;AAE3F,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC"}
package/dist/server.d.ts CHANGED
@@ -1,35 +1,23 @@
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";
1
+ import type { McpServer } from "@modelcontextprotocol/server";
4
2
  /**
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.
3
+ * Minimum server interface required by MCPHttpServer and the stdio runner:
4
+ * a request-scoped server instance that has been configured with tools,
5
+ * resources, capabilities and lifecycle hooks, ready to be handed to the
6
+ * protocol serving entry.
7
+ *
8
+ * The server is deliberately stateless and request-scoped: app-level services
9
+ * (connections, exports, API clients, telemetry) live once per process and
10
+ * are referenced by, not owned by, each request's server instance.
10
11
  */
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
- };
12
+ export type BaseServer = {
23
13
  /**
24
- * The protocol-level MCP server, required to capture/restore negotiated
25
- * client state across implicit re-initializations.
14
+ * Registers resources, capabilities, tools, request handlers and lifecycle
15
+ * hooks on the underlying MCP server without connecting it to a transport.
16
+ * Required by the 2026-07-28 serving entries (`serveStdio`,
17
+ * `createMcpHandler`), which build/register instances through a factory.
26
18
  */
27
- mcpServer: {
28
- server: {
29
- oninitialized?: (() => void) | undefined;
30
- getClientCapabilities(): ClientCapabilities | undefined;
31
- getClientVersion(): Implementation | undefined;
32
- };
33
- };
19
+ register(): Promise<void>;
20
+ /** The protocol-level MCP server handed to the serving entry. */
21
+ mcpServer: McpServer;
34
22
  };
35
23
  //# sourceMappingURL=server.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG;IACrB;;;;;OAKG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,iEAAiE;IACjE,SAAS,EAAE,SAAS,CAAC;CACxB,CAAC"}
@@ -1,9 +1,11 @@
1
- import type { ClientCapabilities, Implementation } from "@modelcontextprotocol/sdk/types.js";
1
+ import type { ClientCapabilities, Implementation } from "@modelcontextprotocol/server";
2
2
  import type { ILogger, ICompositeLogger } from "./logging.js";
3
3
  import type { IMetrics, DefaultMetricDefinitions } from "./metrics.js";
4
+ /** @deprecated The per-client session concept is being removed; the 2025-era legacy path is the only remaining consumer. */
4
5
  export type CloseableTransport = {
5
6
  close(): Promise<void>;
6
7
  };
8
+ /** @deprecated The per-client session concept is being removed; the 2025-era legacy path is the only remaining consumer. */
7
9
  export type SessionCloseReason = "idle_timeout" | "transport_closed" | "server_stop" | "unknown" | "evicted";
8
10
  /**
9
11
  * The client state negotiated during MCP initialization. Stores that persist
@@ -11,11 +13,15 @@ export type SessionCloseReason = "idle_timeout" | "transport_closed" | "server_s
11
13
  * pod that never saw the client's `initialize` request) to retain the
12
14
  * client's capabilities -- e.g. whether it supports elicitation -- instead of
13
15
  * treating the restored client as capability-less.
16
+ *
17
+ * @deprecated The per-client session concept is being removed; the 2025-era
18
+ * legacy path is the only remaining consumer.
14
19
  */
15
20
  export type NegotiatedClientState = {
16
21
  clientCapabilities?: ClientCapabilities;
17
22
  clientInfo?: Implementation;
18
23
  };
24
+ /** @deprecated The per-client session concept is being removed; the 2025-era legacy path is the only remaining consumer. */
19
25
  export interface ISessionStore<T extends CloseableTransport = CloseableTransport> {
20
26
  /**
21
27
  * Returns the transport for the given session id or `undefined` if the
@@ -48,6 +54,8 @@ export interface ISessionStore<T extends CloseableTransport = CloseableTransport
48
54
  };
49
55
  headers?: Record<string, unknown>;
50
56
  }): Promise<void>;
57
+ /** Returns whether a session exists, without resetting its idle timeout (unlike {@link getSession}). */
58
+ hasSession(sessionId: string): boolean;
51
59
  closeSession(params: {
52
60
  sessionId: string;
53
61
  reason?: SessionCloseReason;
@@ -67,6 +75,7 @@ export interface ISessionStore<T extends CloseableTransport = CloseableTransport
67
75
  */
68
76
  loadNegotiatedClientState(sessionId: string, headers?: Record<string, unknown>): Promise<NegotiatedClientState | undefined>;
69
77
  }
78
+ /** @deprecated The per-client session concept is being removed; the 2025-era legacy path is the only remaining consumer. */
70
79
  export type SessionStoreConstructorArgs<TMetrics extends DefaultMetricDefinitions = DefaultMetricDefinitions> = {
71
80
  options: {
72
81
  idleTimeoutMS: number;
@@ -1 +1 @@
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,kBAAkB,GAAG,cAAc,GAAG,kBAAkB,GAAG,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7G;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAChC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B,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { McpProtocol } from "./transport.js";
1
2
  export type TelemetryEvents = {
2
3
  "events-emitted": [];
3
4
  "events-send-failed": [];
@@ -26,9 +27,9 @@ export type TelemetryCommonProperties = {
26
27
  transport?: "stdio" | "http";
27
28
  config_atlas_auth?: TelemetryBoolSet;
28
29
  config_connection_string?: TelemetryBoolSet;
29
- session_id?: string;
30
30
  hosting_mode?: string;
31
31
  has_docker?: TelemetryBoolSet;
32
+ protocol?: McpProtocol;
32
33
  } & TelemetryCommonStaticProperties;
33
34
  export type TelemetryEvent<T> = {
34
35
  timestamp: string;
@@ -57,6 +58,9 @@ export type SharedTierMetricName = (typeof SHARED_TIER_METRIC_NAMES)[number];
57
58
  export type ConnectionMetadata = AtlasMetadata & AtlasLocalToolMetadata & {
58
59
  connection_auth_type?: string;
59
60
  connection_host_type?: string;
61
+ /** Atlas cluster the connection points at, when it is an Atlas connection. */
62
+ cluster_name?: string;
63
+ cluster_id?: string;
60
64
  shared_tier_alerts_detected?: TelemetryBoolSet;
61
65
  shared_tier_tier?: SharedTierTier;
62
66
  shared_tier_alerts?: SharedTierMetricName[];
@@ -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;AAED,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAC;AAE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Root":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAoEA,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACpC,qBAAqB;IACrB,0BAA0B;IAC1B,sBAAsB;IACtB,cAAc;CACR,CAAC"}
package/dist/tool.d.ts CHANGED
@@ -1,22 +1,67 @@
1
- import { type CallToolResult, type RequestMeta } from "@modelcontextprotocol/sdk/types.js";
1
+ import type { CallToolResult, RequestMeta, ServerContext, McpServer } from "@modelcontextprotocol/server";
2
2
  export type { CallToolResult };
3
- import type { Secret } from "mongodb-redact";
4
3
  import type { IToolConfig } from "./config.js";
4
+ import type { ElicitationInputResponses, IElicitation } from "./elicitation.js";
5
5
  import type { ICompositeLogger } from "./logging.js";
6
+ import type { IKeychain } from "./keychain.js";
7
+ import type { DefaultMetricDefinitions, IMetrics } from "./metrics.js";
8
+ import type { IUIRegistry } from "./ui.js";
9
+ import type { ITelemetry } from "./telemetry.js";
6
10
  /**
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
+ * The services every tool receives at construction, injected individually
12
+ * (no server-scoped "session" object exists). The server is deliberately
13
+ * stateless: MongoDB connection state lives in the app-level registry and is
14
+ * addressed per request by `connectionId`, and per-client identity travels on
15
+ * the tool request (see `ToolExecutionContext.request.clientInfo`).
16
+ *
17
+ * Tool categories extend this type with the specific app-level services they
18
+ * need (e.g. the connection registry); `TConfig` narrows the configuration
19
+ * subset a category reads.
11
20
  */
12
- export interface IToolSession {
13
- readonly config: IToolConfig;
21
+ export type ToolServices<TConfig extends IToolConfig = IToolConfig> = {
22
+ /** Configuration for the server */
23
+ readonly config: TConfig;
24
+ /** Logger for the server */
14
25
  readonly logger: ICompositeLogger;
15
- /** Secrets registered for redaction (used by ToolBase error handling). */
16
- readonly keychain: {
17
- readonly allSecrets: Secret[];
18
- };
19
- }
26
+ /** Redacts registered secrets from a value (used by ToolBase error handling). */
27
+ readonly keychain: IKeychain;
28
+ };
29
+ /**
30
+ * The service surface a tool reads from its server. Tool constructors receive
31
+ * exactly one argument — the server — which carries the individually-injected
32
+ * services ({@link ToolServices}) plus the shared infrastructure every tool
33
+ * needs (telemetry, elicitation, metrics and the UI registry). Category
34
+ * services (e.g. the connection registry) travel in `TServices`, so a server
35
+ * is structurally assignable to the `ToolServer` of each tool category it
36
+ * hosts.
37
+ */
38
+ /**
39
+ * The minimal surface of a registered tool that a host reads off `server.tools`.
40
+ * Kept structural (rather than referencing {@link AnyToolBase} from mcp-core) to
41
+ * avoid a circular dependency: `@mongodb-js/mcp-types` is a base package.
42
+ */
43
+ export type ToolServerTool = {
44
+ readonly name: string;
45
+ readonly category: ToolCategory;
46
+ readonly operationType: OperationType;
47
+ isEnabled(): boolean;
48
+ };
49
+ export type ToolServer<TServices extends ToolServices = ToolServices, TMetricsDefinitions extends DefaultMetricDefinitions = DefaultMetricDefinitions> = TServices & {
50
+ /** Telemetry for tracking tool usage. */
51
+ readonly telemetry: ITelemetry;
52
+ /** Elicitation for requesting user confirmation / input. */
53
+ readonly elicitation: IElicitation;
54
+ /** Metrics for tracking tool execution. */
55
+ readonly metrics: IMetrics<TMetricsDefinitions>;
56
+ /** UI registry for tools that embed interactive widget content. */
57
+ readonly uiRegistry?: IUIRegistry;
58
+ /** The SDK McpServer this tool is registered against. */
59
+ readonly mcpServer: McpServer;
60
+ /** The tools registered on this server (used to detect the export tool / list available tools). */
61
+ readonly tools: readonly ToolServerTool[];
62
+ /** Reports whether a tool category is enabled on this server. */
63
+ isToolCategoryAvailable(name: ToolCategory): boolean;
64
+ };
20
65
  /**
21
66
  * The type of operation the tool performs. This is used when evaluating if a tool is allowed to run based on
22
67
  * the config's `disabledTools` and `readOnly` settings.
@@ -42,24 +87,48 @@ export type OperationType = "metadata" | "read" | "create" | "delete" | "update"
42
87
  */
43
88
  export type ToolCategory = "mongodb" | "atlas" | "atlas-local" | "assistant" | "custom";
44
89
  /**
45
- * Context provided during tool execution.
90
+ * The request object passed to tool implementations: everything derived from
91
+ * the individual request being handled. It is built fresh for each tool call
92
+ * and deliberately lives nowhere else — the server holds no per-client or
93
+ * per-request state. The request-scoped server (and the effective,
94
+ * possibly request-overridden config it carries) is NOT on the request: tools
95
+ * read it off their construction-time `this.server` (the same instance). The
96
+ * per-request data (raw SDK request, signal, id, headers, client identity,
97
+ * ...) travels on the request itself (see `ToolExecutionContext.request`).
46
98
  */
47
- export type ToolExecutionContext = {
99
+ export type ToolRequest<TConfig extends IToolConfig = IToolConfig> = {
100
+ /**
101
+ * The original request this request object was built around: the SDK's
102
+ * per-request `mcpReq` object the tool call handler received. Undefined
103
+ * when the tool is invoked directly in unit tests without a real SDK
104
+ * request. Prefer the normalized fields (`headers`, `id`, `clientInfo`,
105
+ * ...); reach for `raw` only when the typed surface does not cover what
106
+ * you need.
107
+ */
108
+ readonly raw?: ServerContext["mcpReq"];
48
109
  /** AbortSignal for cancellation support */
49
110
  signal: AbortSignal;
50
111
  /**
51
- * Request context object available only when running atop
52
- * StreamableHttpTransport.
112
+ * HTTP request headers, available only when running atop
113
+ * StreamableHttpTransport. Used for request correlation (e.g.
114
+ * `x-request-id`) and forwarded to outgoing Atlas API requests.
53
115
  */
54
- requestInfo?: {
55
- headers?: Record<string, unknown>;
56
- };
116
+ headers?: Record<string, unknown>;
57
117
  /** Metadata from the original MCP request (e.g. the client's progress token). */
58
118
  _meta?: RequestMeta;
59
119
  /** The request id, when invoked through an MCP server. */
60
- requestId?: string | number;
120
+ id?: string | number;
61
121
  /** Send an MCP server notification. */
62
122
  sendNotification?: (notification: unknown) => Promise<void>;
123
+ /**
124
+ * Responses to a previous `input_required` round (protocol revision
125
+ * 2026-07-28 multi-round-trip requests). Present only when this request
126
+ * is a client retry carrying the answers to elicitation/sampling/roots
127
+ * requests the handler returned as `inputRequired(...)`. Keyed by the
128
+ * server-assigned identifiers of the embedded requests. Values are
129
+ * untrusted client input.
130
+ */
131
+ inputResponses?: ElicitationInputResponses;
63
132
  /**
64
133
  * Total time spent waiting for the user to answer elicitation requests
65
134
  * raised while handling this call. Accumulated by
@@ -68,6 +137,30 @@ export type ToolExecutionContext = {
68
137
  * time the tool spent working.
69
138
  */
70
139
  elicitationDurationMs?: number;
140
+ /**
141
+ * Identity of the MCP client that issued this request, as negotiated
142
+ * during initialization (or as declared on the request envelope in the
143
+ * 2026-07-28 protocol). Carried on the request — it is deliberately not
144
+ * stored on any server-scoped object, so the server holds no per-client
145
+ * state.
146
+ */
147
+ clientInfo?: {
148
+ name?: string;
149
+ version?: string;
150
+ title?: string;
151
+ };
152
+ };
153
+ /**
154
+ * Request-scoped context provided during tool execution. The request object
155
+ * ({@link ToolRequest}) holds everything derived from the individual request
156
+ * — the request-scoped `server` (which carries the effective config), the
157
+ * original `raw` request, signal, request id, client identity, elicitation
158
+ * state — and is built fresh per call by `toToolExecutionContext`. Tools
159
+ * receive it as the `request` argument.
160
+ */
161
+ export type ToolExecutionContext<TConfig extends IToolConfig = IToolConfig> = {
162
+ /** The request object this execution is built around. */
163
+ request: ToolRequest<TConfig>;
71
164
  };
72
165
  export type ToolClass<TParams extends unknown[] = unknown[]> = {
73
166
  new (params: TParams): {
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC3F,YAAY,EAAE,cAAc,EAAE,CAAC;AAC/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,gBAA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GAAG,MAAM,CAAC;IACrB,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,yBAAyB,CAAC;IAC3C;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACpE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,IAAI;IAC1E,yDAAyD;IACzD,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACjC,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"}
@@ -1,6 +1,45 @@
1
+ /**
2
+ * Verified identity of an authenticated HTTP client (mirrors the SDK's
3
+ * `AuthInfo`). Carried on the request context so per-request servers can scope
4
+ * shared state (e.g. connections) by verified identity rather than
5
+ * self-asserted headers.
6
+ */
7
+ export type RequestAuthInfo = {
8
+ /** The access token. */
9
+ token: string;
10
+ /** The client id associated with this token. */
11
+ clientId: string;
12
+ /** Scopes associated with this token. */
13
+ scopes: string[];
14
+ /** When the token expires (in seconds since epoch). */
15
+ expiresAt?: number;
16
+ };
17
+ /**
18
+ * The explicit authentication state of a request. Every HTTP request carries
19
+ * one or the other — there is no "unknown" — so per-request servers always
20
+ * know whether they are serving an authenticated client, and scope shared
21
+ * state (e.g. connections) by the verified `clientId` when authenticated.
22
+ * Identity is injected by the host (e.g. `req.auth` via the node adapter's
23
+ * pass-through, or directly on the request context); the server never
24
+ * authenticates on its own.
25
+ */
26
+ export type RequestAuthState = {
27
+ mode: "unauthenticated";
28
+ } | {
29
+ mode: "authenticated";
30
+ state: RequestAuthInfo;
31
+ };
32
+ export type McpProtocol = "legacy" | "2026-07-28";
1
33
  export type TransportRequestContext = {
2
34
  headers?: Record<string, string | string[] | undefined>;
3
35
  query?: Record<string, string | string[] | undefined>;
36
+ /**
37
+ * The explicit auth state of this request. When authenticated, shared state
38
+ * (connections) is scoped by `state.clientId`; unauthenticated requests are
39
+ * isolated from authenticated clients.
40
+ */
41
+ authInfo?: RequestAuthState;
42
+ protocol?: McpProtocol;
4
43
  };
5
44
  export interface ITransportRunner {
6
45
  start(options: {
@@ -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,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F,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"}
@@ -12,17 +12,19 @@ export type HttpServerOptions = {
12
12
  headers?: Record<string, string>;
13
13
  /** Response type: 'sse' for Server-Sent Events, 'json' for JSON responses */
14
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;
15
+ /**
16
+ * The HTTP entry's auth mode (required — there is no implicit default so a
17
+ * deployment's posture is always explicit):
18
+ *
19
+ * - `"authenticated"`: every request must carry a verified identity (hosts
20
+ * inject it via `req.auth`, which the node adapter forwards as the
21
+ * handler's authInfo; the server never authenticates on its own).
22
+ * Unauthenticated requests are rejected with 401 and the request
23
+ * context's authInfo is always `{ mode: "authenticated", state }`.
24
+ * - `"unauthenticated"`: authInfo carries whatever the host provides,
25
+ * defaulting to `{ mode: "unauthenticated" }`.
26
+ */
27
+ authMode: "authenticated" | "unauthenticated";
26
28
  };
27
29
  /**
28
30
  * Options for transport runners.
@@ -1 +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"}
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;IAC9B;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,eAAe,GAAG,iBAAiB,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACjC,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC"}
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": "3.0.0-prerelease.2",
4
+ "version": "3.0.0-prerelease.4",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "author": "MongoDB <info@mongodb.com>",
@@ -22,16 +22,18 @@
22
22
  "files": [
23
23
  "dist"
24
24
  ],
25
+ "dependencies": {
26
+ "@modelcontextprotocol/server": "^2.0.0",
27
+ "mongodb-redact": "^1.4.6"
28
+ },
25
29
  "devDependencies": {
26
- "@modelcontextprotocol/sdk": "^1.29.0",
27
- "mongodb-redact": "^1.4.6",
28
30
  "@types/node": "^25.6.0",
29
31
  "typescript": "^5.9.2",
30
- "vitest": "^4.1.10"
32
+ "vitest": "^4.1.11"
31
33
  },
32
34
  "scripts": {
33
35
  "build": "tsc --build tsconfig.build.json",
34
36
  "test": "vitest --run",
35
- "check": "tsc --build tsconfig.build.json --noEmit"
37
+ "check": "tsc --noEmit --project tsconfig.json"
36
38
  }
37
39
  }
package/dist/session.d.ts DELETED
@@ -1,44 +0,0 @@
1
- import type { ICompositeLogger } from "./logging.js";
2
- import type { IKeychain } from "./keychain.js";
3
- import type { IToolConfig } from "./config.js";
4
- export type SessionEvents = {
5
- connect: [];
6
- close: [];
7
- disconnect: [];
8
- "connection-error": [unknown];
9
- };
10
- export interface ISession<TConfig extends IToolConfig = IToolConfig> {
11
- readonly sessionId: string;
12
- logger: ICompositeLogger;
13
- mcpClient?: {
14
- name?: string;
15
- version?: string;
16
- title?: string;
17
- };
18
- /** TODO: Consider removing if possible */
19
- setMcpClient(mcpClient: {
20
- name?: string;
21
- version?: string;
22
- title?: string;
23
- } | undefined): void;
24
- disconnect(): Promise<void>;
25
- close(): Promise<void>;
26
- readonly isConnectedToMongoDB: boolean;
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
- cluster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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/session.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=session.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":""}