@mongodb-js/mcp-types 2.1.1 → 3.0.0-prerelease.3

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.
Files changed (53) hide show
  1. package/dist/apiClient.d.ts +4 -14
  2. package/dist/apiClient.d.ts.map +1 -1
  3. package/dist/config.d.ts +20 -0
  4. package/dist/config.d.ts.map +1 -0
  5. package/dist/config.js +2 -0
  6. package/dist/config.js.map +1 -0
  7. package/dist/connection.d.ts +46 -0
  8. package/dist/connection.d.ts.map +1 -0
  9. package/dist/connection.js +2 -0
  10. package/dist/connection.js.map +1 -0
  11. package/dist/elicitation.d.ts +79 -5
  12. package/dist/elicitation.d.ts.map +1 -1
  13. package/dist/index.d.ts +8 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/keychain.d.ts +20 -6
  18. package/dist/keychain.d.ts.map +1 -1
  19. package/dist/logging.d.ts +21 -13
  20. package/dist/logging.d.ts.map +1 -1
  21. package/dist/metrics.d.ts +48 -4
  22. package/dist/metrics.d.ts.map +1 -1
  23. package/dist/resources.d.ts +70 -0
  24. package/dist/resources.d.ts.map +1 -1
  25. package/dist/schemas.d.ts +2 -0
  26. package/dist/schemas.d.ts.map +1 -0
  27. package/dist/schemas.js +2 -0
  28. package/dist/schemas.js.map +1 -0
  29. package/dist/server.d.ts +23 -0
  30. package/dist/server.d.ts.map +1 -0
  31. package/dist/server.js +2 -0
  32. package/dist/server.js.map +1 -0
  33. package/dist/sessionStore.d.ts +43 -10
  34. package/dist/sessionStore.d.ts.map +1 -1
  35. package/dist/telemetry.d.ts +73 -0
  36. package/dist/telemetry.d.ts.map +1 -1
  37. package/dist/telemetry.js +6 -1
  38. package/dist/telemetry.js.map +1 -1
  39. package/dist/tool.d.ts +161 -4
  40. package/dist/tool.d.ts.map +1 -1
  41. package/dist/transport.d.ts +37 -1
  42. package/dist/transport.d.ts.map +1 -1
  43. package/dist/transports.d.ts +38 -0
  44. package/dist/transports.d.ts.map +1 -0
  45. package/dist/transports.js +2 -0
  46. package/dist/transports.js.map +1 -0
  47. package/dist/ui.d.ts +26 -2
  48. package/dist/ui.d.ts.map +1 -1
  49. package/package.json +9 -6
  50. package/dist/session.d.ts +0 -30
  51. package/dist/session.d.ts.map +0 -1
  52. package/dist/session.js +0 -2
  53. package/dist/session.js.map +0 -1
@@ -1,10 +1,27 @@
1
- import type { ILoggerBase } from "./logging.js";
2
- import type { IMetrics, MetricDefinitions } from "./metrics.js";
3
- import type { ISession } from "./session.js";
1
+ import type { ClientCapabilities, Implementation } from "@modelcontextprotocol/server";
2
+ import type { ILogger, ICompositeLogger } from "./logging.js";
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";
10
+ /**
11
+ * The client state negotiated during MCP initialization. Stores that persist
12
+ * it durably allow an implicitly re-initialized session (one restored on a
13
+ * pod that never saw the client's `initialize` request) to retain the
14
+ * client's capabilities -- e.g. whether it supports elicitation -- instead of
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.
19
+ */
20
+ export type NegotiatedClientState = {
21
+ clientCapabilities?: ClientCapabilities;
22
+ clientInfo?: Implementation;
23
+ };
24
+ /** @deprecated The per-client session concept is being removed; the 2025-era legacy path is the only remaining consumer. */
8
25
  export interface ISessionStore<T extends CloseableTransport = CloseableTransport> {
9
26
  /**
10
27
  * Returns the transport for the given session id or `undefined` if the
@@ -31,25 +48,42 @@ export interface ISessionStore<T extends CloseableTransport = CloseableTransport
31
48
  addSession(params: {
32
49
  sessionId: string;
33
50
  transport: T;
34
- /** TODO: Remove in v2 — redundant with `session.logger`. */
35
- logger: ILoggerBase;
36
- session: ISession;
51
+ logger: ILogger;
52
+ session?: {
53
+ logger: ICompositeLogger;
54
+ };
37
55
  headers?: Record<string, unknown>;
38
56
  }): Promise<void>;
57
+ /** Returns whether a session exists, without resetting its idle timeout (unlike {@link getSession}). */
58
+ hasSession(sessionId: string): boolean;
39
59
  closeSession(params: {
40
60
  sessionId: string;
41
61
  reason?: SessionCloseReason;
42
62
  }): Promise<void>;
43
63
  closeAllSessions(): Promise<void>;
64
+ /**
65
+ * Durably records the client state negotiated during a real MCP
66
+ * initialization, so it can be restored when the session is later
67
+ * implicitly re-initialized (only relevant with
68
+ * `externallyManagedSessions`). Stores without durable storage can
69
+ * implement this as a no-op.
70
+ */
71
+ saveNegotiatedClientState(sessionId: string, state: NegotiatedClientState, headers?: Record<string, unknown>): Promise<void>;
72
+ /**
73
+ * Returns the previously saved negotiated client state for the session,
74
+ * or `undefined` when unknown.
75
+ */
76
+ loadNegotiatedClientState(sessionId: string, headers?: Record<string, unknown>): Promise<NegotiatedClientState | undefined>;
44
77
  }
45
- export type SessionStoreConstructorArgs<TMetrics extends MetricDefinitions = MetricDefinitions> = {
78
+ /** @deprecated The per-client session concept is being removed; the 2025-era legacy path is the only remaining consumer. */
79
+ export type SessionStoreConstructorArgs<TMetrics extends DefaultMetricDefinitions = DefaultMetricDefinitions> = {
46
80
  options: {
47
81
  idleTimeoutMS: number;
48
82
  notificationTimeoutMS: number;
49
83
  maxSessions: number;
50
84
  /**
51
85
  * When the store is at `maxSessions` and a new session arrives, evict the
52
- * least-recently-used session instead of rejecting — but only if it has been
86
+ * least-recently-used session instead of rejecting -- but only if it has been
53
87
  * idle for at least this long (ms). Must be < `idleTimeoutMS` (the background
54
88
  * reaper already removes anything past that), or the valve never fires. If a
55
89
  * session idle >= this exists, it is closed locally to make room; otherwise
@@ -58,8 +92,7 @@ export type SessionStoreConstructorArgs<TMetrics extends MetricDefinitions = Met
58
92
  */
59
93
  evictionIdleGraceMS?: number;
60
94
  };
61
- logger: ILoggerBase;
95
+ logger: ILogger;
62
96
  metrics: IMetrics<TMetrics>;
63
97
  };
64
- export type CreateSessionStoreFn<TTransport extends CloseableTransport = CloseableTransport, TMetrics extends MetricDefinitions = MetricDefinitions> = (args: SessionStoreConstructorArgs<TMetrics>) => ISessionStore<TTransport>;
65
98
  //# 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,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,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,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB;IAC5E;;;;;;;;;;OAUG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACzF;;;;;;;;;OASG;IACH,UAAU,CAAC,MAAM,EAAE;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,CAAC,CAAC;QACb,4DAA4D;QAC5D,MAAM,EAAE,WAAW,CAAC;QACpB,OAAO,EAAE,QAAQ,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,C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,yBAAyB,CACrB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC;CACjD;AAED,4HAA4H;AAC5H,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"}
@@ -8,4 +8,77 @@ 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
+ hosting_mode?: string;
30
+ has_docker?: TelemetryBoolSet;
31
+ } & TelemetryCommonStaticProperties;
32
+ export type TelemetryEvent<T> = {
33
+ timestamp: string;
34
+ source: "mdbmcp";
35
+ properties: T & {
36
+ component: string;
37
+ duration_ms: number;
38
+ result: TelemetryResult;
39
+ category: string;
40
+ } & Record<string, string | number | string[]>;
41
+ };
42
+ export type TelemetryToolMetadataValue = string | number | boolean | undefined | string[];
43
+ export type TelemetryToolMetadataBase = {
44
+ [key: string]: TelemetryToolMetadataValue;
45
+ };
46
+ export type AtlasMetadata = TelemetryToolMetadataBase & {
47
+ project_id?: string;
48
+ org_id?: string;
49
+ };
50
+ export type AtlasLocalToolMetadata = TelemetryToolMetadataBase & {
51
+ atlas_local_deployment_id?: string;
52
+ };
53
+ export type SharedTierTier = "Free" | "Flex";
54
+ export declare const SHARED_TIER_METRIC_NAMES: readonly ["CONNECTIONS_PERCENT", "FLEX_CONNECTIONS_PERCENT", "FLEX_DATA_SIZE_TOTAL", "LOGICAL_SIZE"];
55
+ export type SharedTierMetricName = (typeof SHARED_TIER_METRIC_NAMES)[number];
56
+ export type ConnectionMetadata = AtlasMetadata & AtlasLocalToolMetadata & {
57
+ connection_auth_type?: string;
58
+ connection_host_type?: string;
59
+ /** Atlas cluster the connection points at, when it is an Atlas connection. */
60
+ cluster_name?: string;
61
+ cluster_id?: string;
62
+ shared_tier_alerts_detected?: TelemetryBoolSet;
63
+ shared_tier_tier?: SharedTierTier;
64
+ shared_tier_alerts?: SharedTierMetricName[];
65
+ };
66
+ export type PerfAdvisorToolMetadata = AtlasMetadata & ConnectionMetadata & {
67
+ operations: string[];
68
+ };
69
+ export type StreamsToolMetadata = AtlasMetadata & {
70
+ action?: string;
71
+ resource?: string;
72
+ };
73
+ export type IndexMetadata = ConnectionMetadata & {
74
+ index_type: "classic" | "vectorSearch" | "search";
75
+ };
76
+ export type TelemetryToolMetadata = AtlasMetadata | ConnectionMetadata | PerfAdvisorToolMetadata | StreamsToolMetadata | IndexMetadata;
77
+ export type ToolEventProperties = {
78
+ command: string;
79
+ error_code?: string;
80
+ error_type?: string;
81
+ is_atlas?: boolean;
82
+ } & TelemetryToolMetadata;
83
+ export type ToolEvent = TelemetryEvent<ToolEventProperties>;
11
84
  //# sourceMappingURL=telemetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],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5
+ "LOGICAL_SIZE",
6
+ ];
2
7
  //# sourceMappingURL=telemetry.js.map
@@ -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":"AAiEA,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACpC,qBAAqB;IACrB,0BAA0B;IAC1B,sBAAsB;IACtB,cAAc;CACR,CAAC"}
package/dist/tool.d.ts CHANGED
@@ -1,11 +1,167 @@
1
+ import type { CallToolResult, RequestMeta, ServerContext, McpServer } from "@modelcontextprotocol/server";
2
+ export type { CallToolResult };
3
+ import type { IToolConfig } from "./config.js";
4
+ import type { ElicitationInputResponses, IElicitation } from "./elicitation.js";
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";
10
+ /**
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.
20
+ */
21
+ export type ToolServices<TConfig extends IToolConfig = IToolConfig> = {
22
+ /** Configuration for the server */
23
+ readonly config: TConfig;
24
+ /** Logger for the server */
25
+ readonly logger: ICompositeLogger;
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
+ };
65
+ /**
66
+ * The type of operation the tool performs. This is used when evaluating if a tool is allowed to run based on
67
+ * the config's `disabledTools` and `readOnly` settings.
68
+ * - `metadata` is used for tools that read but do not access potentially user-generated
69
+ * data, such as listing databases, collections, or indexes, or inferring collection schema.
70
+ * - `read` is used for tools that read potentially user-generated data, such as finding documents or aggregating data.
71
+ * It is also used for tools that read non-user-generated data, such as listing clusters in Atlas.
72
+ * - `create` is used for tools that create resources, such as creating documents, collections, indexes, clusters, etc.
73
+ * - `update` is used for tools that update resources, such as updating documents, renaming collections, etc.
74
+ * - `delete` is used for tools that delete resources, such as deleting documents, dropping collections, etc.
75
+ * - `connect` is used for tools that allow you to connect or switch the connection to a MongoDB instance.
76
+ */
1
77
  export type OperationType = "metadata" | "read" | "create" | "delete" | "update" | "connect";
2
- export type ToolCategory = "mongodb" | "atlas" | "atlas-local" | "assistant";
3
- export type ToolExecutionContext = {
78
+ /**
79
+ * The category of the tool. This is used when evaluating if a tool is allowed to run based on
80
+ * the config's `disabledTools` setting.
81
+ * - `mongodb` is used for tools that interact with a MongoDB instance, such as finding documents,
82
+ * aggregating data, listing databases/collections/indexes, creating indexes, etc.
83
+ * - `atlas` is used for tools that interact with MongoDB Atlas, such as listing clusters, creating clusters, etc.
84
+ * - `atlas-local` is used for tools that interact with local Atlas deployments.
85
+ * - `assistant` is used for tools that interact with the Assistant, such as searching the public knowledge base.
86
+ * - `custom` is used for tools that are not part of the default tool categories.
87
+ */
88
+ export type ToolCategory = "mongodb" | "atlas" | "atlas-local" | "assistant" | "custom";
89
+ /**
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`).
98
+ */
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"];
109
+ /** AbortSignal for cancellation support */
4
110
  signal: AbortSignal;
5
- requestInfo?: {
6
- headers?: Record<string, unknown>;
111
+ /**
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.
115
+ */
116
+ headers?: Record<string, unknown>;
117
+ /** Metadata from the original MCP request (e.g. the client's progress token). */
118
+ _meta?: RequestMeta;
119
+ /** The request id, when invoked through an MCP server. */
120
+ id?: string | number;
121
+ /** Send an MCP server notification. */
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;
132
+ /**
133
+ * Total time spent waiting for the user to answer elicitation requests
134
+ * raised while handling this call. Accumulated by
135
+ * `ToolBase.requestConfirmation` and subtracted from the tool execution
136
+ * duration metric, so that the user's think-time is not reported as
137
+ * time the tool spent working.
138
+ */
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;
7
151
  };
8
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>;
164
+ };
9
165
  export type ToolClass<TParams extends unknown[] = unknown[]> = {
10
166
  new (params: TParams): {
11
167
  name: string;
@@ -16,6 +172,7 @@ export type ToolClass<TParams extends unknown[] = unknown[]> = {
16
172
  category: ToolCategory;
17
173
  operationType: OperationType;
18
174
  };
175
+ export type AnyToolClass = ToolClass<any>;
19
176
  export interface IToolRegistrar {
20
177
  register(tool: ToolClass): boolean;
21
178
  }
@@ -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;AAE7E,MAAM,MAAM,oBAAoB,GAAG;IAC/B,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,CAAC,EAAE;QACV,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;CACL,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;AAEF,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;CACtC"}
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,8BAA8B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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,13 +1,49 @@
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
+ };
1
32
  export type TransportRequestContext = {
2
33
  headers?: Record<string, string | string[] | undefined>;
3
34
  query?: Record<string, string | string[] | undefined>;
35
+ /**
36
+ * The explicit auth state of this request. When authenticated, shared state
37
+ * (connections) is scoped by `state.clientId`; unauthenticated requests are
38
+ * isolated from authenticated clients.
39
+ */
40
+ authInfo?: RequestAuthState;
4
41
  };
5
42
  export interface ITransportRunner {
6
43
  start(options: {
7
44
  serverOptions?: unknown;
8
45
  sessionOptions?: unknown;
9
46
  }): Promise<void>;
10
- closeTransport(): Promise<void>;
11
47
  close(): Promise<void>;
12
48
  }
13
49
  export interface IServerFactory {
@@ -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,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,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"}
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC1B,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CAAC;AAE/G,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;IACtD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC/B,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,38 @@
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
+ * 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";
28
+ };
29
+ /**
30
+ * Options for transport runners.
31
+ */
32
+ export type TransportRunnerOptions = {
33
+ /** Server name */
34
+ name: string;
35
+ /** Server version */
36
+ version: string;
37
+ };
38
+ //# 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;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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=transports.js.map
@@ -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 type UIRegistryOptions = {
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,MAAM,iBAAiB,GAAG;IAC5B,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC5E,CAAC;AAEF,MAAM,WAAW,WAAW;IACxB,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACjD"}
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": "2.1.1",
4
+ "version": "3.0.0-prerelease.3",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "author": "MongoDB <info@mongodb.com>",
@@ -18,19 +18,22 @@
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
  ],
25
+ "dependencies": {
26
+ "@modelcontextprotocol/server": "^2.0.0",
27
+ "mongodb-redact": "^1.4.6"
28
+ },
26
29
  "devDependencies": {
27
30
  "@types/node": "^25.6.0",
28
- "mongodb-log-writer": "^2.5.13",
29
31
  "typescript": "^5.9.2",
30
- "vitest": "^4.1.10"
32
+ "vitest": "^4.1.11"
31
33
  },
32
34
  "scripts": {
33
- "compile": "tsc --project tsconfig.json",
34
- "test": "vitest --run"
35
+ "build": "tsc --build tsconfig.build.json",
36
+ "test": "vitest --run",
37
+ "check": "tsc --noEmit --project tsconfig.json"
35
38
  }
36
39
  }
package/dist/session.d.ts DELETED
@@ -1,30 +0,0 @@
1
- import type { ICompositeLogger } from "./logging.js";
2
- export type SessionEvents = {
3
- connect: [];
4
- close: [];
5
- disconnect: [];
6
- "connection-error": [unknown];
7
- };
8
- export interface ISession {
9
- readonly sessionId: string;
10
- logger: ICompositeLogger;
11
- mcpClient?: {
12
- name?: string;
13
- version?: string;
14
- title?: string;
15
- };
16
- /** TODO: Consider removing if possible */
17
- setMcpClient(mcpClient: {
18
- name?: string;
19
- version?: string;
20
- title?: string;
21
- } | undefined): void;
22
- disconnect(): Promise<void>;
23
- close(): Promise<void>;
24
- readonly isConnectedToMongoDB: boolean;
25
- on<K extends keyof SessionEvents>(options: {
26
- event: K;
27
- listener: (...args: SessionEvents[K]) => void;
28
- }): this;
29
- }
30
- //# sourceMappingURL=session.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,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;IACrB,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,EAAE,CAAC,CAAC,SAAS,MAAM,aAAa,EAAE,OAAO,EAAE;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CACjH"}
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":""}