@cyanheads/mcp-ts-core 0.12.0 → 0.12.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/AGENTS.md +7 -3
- package/CLAUDE.md +7 -3
- package/README.md +1 -1
- package/changelog/0.12.x/0.12.1.md +26 -0
- package/changelog/0.12.x/0.12.2.md +29 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +21 -3
- package/dist/config/index.js.map +1 -1
- package/dist/core/app.d.ts +45 -1
- package/dist/core/app.d.ts.map +1 -1
- package/dist/core/app.js +18 -3
- package/dist/core/app.js.map +1 -1
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/serverManifest.d.ts +11 -2
- package/dist/core/serverManifest.d.ts.map +1 -1
- package/dist/core/serverManifest.js +30 -12
- package/dist/core/serverManifest.js.map +1 -1
- package/dist/core/worker.d.ts.map +1 -1
- package/dist/core/worker.js +2 -2
- package/dist/core/worker.js.map +1 -1
- package/dist/linter/rules/enrichment-rules.d.ts.map +1 -1
- package/dist/linter/rules/enrichment-rules.js +5 -2
- package/dist/linter/rules/enrichment-rules.js.map +1 -1
- package/dist/linter/rules/portability-rules.d.ts +4 -2
- package/dist/linter/rules/portability-rules.d.ts.map +1 -1
- package/dist/linter/rules/portability-rules.js +33 -4
- package/dist/linter/rules/portability-rules.js.map +1 -1
- package/dist/linter/rules/schema-rules.d.ts +28 -3
- package/dist/linter/rules/schema-rules.d.ts.map +1 -1
- package/dist/linter/rules/schema-rules.js +87 -25
- package/dist/linter/rules/schema-rules.js.map +1 -1
- package/dist/linter/rules/tool-rules.d.ts.map +1 -1
- package/dist/linter/rules/tool-rules.js +9 -3
- package/dist/linter/rules/tool-rules.js.map +1 -1
- package/dist/linter/types.d.ts +2 -1
- package/dist/linter/types.d.ts.map +1 -1
- package/dist/logs/combined.log +10 -10
- package/dist/logs/error.log +6 -6
- package/dist/mcp-server/cacheHints.d.ts +35 -0
- package/dist/mcp-server/cacheHints.d.ts.map +1 -0
- package/dist/mcp-server/cacheHints.js +43 -0
- package/dist/mcp-server/cacheHints.js.map +1 -0
- package/dist/mcp-server/notifications.d.ts +68 -1
- package/dist/mcp-server/notifications.d.ts.map +1 -1
- package/dist/mcp-server/notifications.js +67 -0
- package/dist/mcp-server/notifications.js.map +1 -1
- package/dist/mcp-server/resources/resource-registration.d.ts +2 -2
- package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
- package/dist/mcp-server/resources/resource-registration.js +6 -2
- package/dist/mcp-server/resources/resource-registration.js.map +1 -1
- package/dist/mcp-server/resources/utils/resourceDefinition.d.ts +14 -1
- package/dist/mcp-server/resources/utils/resourceDefinition.d.ts.map +1 -1
- package/dist/mcp-server/resources/utils/resourceDefinition.js.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +13 -5
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +28 -26
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
- package/dist/mcp-server/server.d.ts +16 -1
- package/dist/mcp-server/server.d.ts.map +1 -1
- package/dist/mcp-server/server.js +7 -2
- package/dist/mcp-server/server.js.map +1 -1
- package/dist/mcp-server/tools/tool-registration.d.ts +2 -2
- package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
- package/dist/mcp-server/tools/tool-registration.js +2 -1
- package/dist/mcp-server/tools/tool-registration.js.map +1 -1
- package/dist/mcp-server/tools/utils/headerParam.d.ts +113 -0
- package/dist/mcp-server/tools/utils/headerParam.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/headerParam.js +280 -0
- package/dist/mcp-server/tools/utils/headerParam.js.map +1 -0
- package/dist/mcp-server/tools/utils/schemaShape.d.ts +27 -0
- package/dist/mcp-server/tools/utils/schemaShape.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/schemaShape.js +43 -0
- package/dist/mcp-server/tools/utils/schemaShape.js.map +1 -0
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts +28 -5
- package/dist/mcp-server/tools/utils/toolDefinition.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolDefinition.js +22 -3
- package/dist/mcp-server/tools/utils/toolDefinition.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +13 -5
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +35 -28
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
- package/dist/mcp-server/transports/http/eventStore.d.ts +57 -0
- package/dist/mcp-server/transports/http/eventStore.d.ts.map +1 -0
- package/dist/mcp-server/transports/http/eventStore.js +114 -0
- package/dist/mcp-server/transports/http/eventStore.js.map +1 -0
- package/dist/mcp-server/transports/http/httpServer.d.ts +2 -1
- package/dist/mcp-server/transports/http/httpServer.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/httpServer.js +2 -2
- package/dist/mcp-server/transports/http/httpServer.js.map +1 -1
- package/dist/mcp-server/transports/http/httpTransport.d.ts +8 -3
- package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/httpTransport.js +30 -5
- package/dist/mcp-server/transports/http/httpTransport.js.map +1 -1
- package/dist/mcp-server/transports/http/landing-page/sections/tools.js +22 -2
- package/dist/mcp-server/transports/http/landing-page/sections/tools.js.map +1 -1
- package/dist/mcp-server/transports/manager.d.ts +10 -1
- package/dist/mcp-server/transports/manager.d.ts.map +1 -1
- package/dist/mcp-server/transports/manager.js +6 -2
- package/dist/mcp-server/transports/manager.js.map +1 -1
- package/dist/mcp-server/types.d.ts +20 -1
- package/dist/mcp-server/types.d.ts.map +1 -1
- package/dist/mcp-server/types.js +14 -0
- package/dist/mcp-server/types.js.map +1 -1
- package/dist/testing/fuzz.d.ts +7 -4
- package/dist/testing/fuzz.d.ts.map +1 -1
- package/dist/testing/fuzz.js +13 -5
- package/dist/testing/fuzz.js.map +1 -1
- package/dist/utils/internal/performance.d.ts +12 -4
- package/dist/utils/internal/performance.d.ts.map +1 -1
- package/dist/utils/internal/performance.js +23 -8
- package/dist/utils/internal/performance.js.map +1 -1
- package/dist/utils/internal/requestContext.d.ts +13 -0
- package/dist/utils/internal/requestContext.d.ts.map +1 -1
- package/dist/utils/internal/requestContext.js +43 -8
- package/dist/utils/internal/requestContext.js.map +1 -1
- package/package.json +2 -2
- package/skills/add-resource/SKILL.md +31 -1
- package/skills/add-tool/SKILL.md +70 -1
- package/skills/api-config/SKILL.md +30 -3
- package/skills/api-context/SKILL.md +47 -15
- package/skills/api-linter/SKILL.md +39 -3
- package/skills/api-telemetry/SKILL.md +3 -1
- package/skills/api-workers/SKILL.md +9 -1
- package/skills/tool-defs-analysis/SKILL.md +15 -5
- package/templates/.env.example +4 -0
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
* import the wrapper from the same `/tools` subpath as the builder.
|
|
8
8
|
* @module src/mcp-server/tools/utils/toolDefinition
|
|
9
9
|
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { assertHeaderDesignations } from './headerParam.js';
|
|
12
|
+
import { isDiscriminatedUnionSchema } from './schemaShape.js';
|
|
10
13
|
export { disabledTool } from './disabled-tool.js';
|
|
14
|
+
export { headerParam } from './headerParam.js';
|
|
11
15
|
// ---------------------------------------------------------------------------
|
|
12
16
|
// Builder
|
|
13
17
|
// ---------------------------------------------------------------------------
|
|
@@ -60,7 +64,9 @@ export { disabledTool } from './disabled-tool.js';
|
|
|
60
64
|
*/
|
|
61
65
|
export function tool(name, options) {
|
|
62
66
|
assertErrorKeyUnreserved(name, options.output, options.enrichment);
|
|
63
|
-
|
|
67
|
+
const input = strictenInput(options.input);
|
|
68
|
+
assertHeaderDesignations(name, input);
|
|
69
|
+
return { name, ...options, input };
|
|
64
70
|
}
|
|
65
71
|
/**
|
|
66
72
|
* Rejects a definition whose success payload declares a field named `error`.
|
|
@@ -98,13 +104,26 @@ function assertErrorKeyUnreserved(name, output, enrichment) {
|
|
|
98
104
|
*
|
|
99
105
|
* Only the default (strip) mode is upgraded. A definition that explicitly
|
|
100
106
|
* declared `.passthrough()` or `.catchall(...)` asked for an open object, and
|
|
101
|
-
* that intent wins — Zod records it as a catchall type
|
|
102
|
-
* checks for.
|
|
107
|
+
* that intent wins — Zod records it as a catchall type (a `ZodNever` catchall
|
|
108
|
+
* for `.strict()` itself), which is what this checks for.
|
|
109
|
+
*
|
|
110
|
+
* A discriminated-union root is strictened per variant, since the branch is
|
|
111
|
+
* where the properties live and `additionalProperties` is emitted. The union is
|
|
112
|
+
* rebuilt from the strictened options rather than mutated: Zod indexes variants
|
|
113
|
+
* by discriminator value at construction time, so replacing the options on a
|
|
114
|
+
* built union would leave the index pointing at the loose ones.
|
|
103
115
|
*
|
|
104
116
|
* Root-level only, matching `.strict()` itself: a nested `z.object()` inside
|
|
105
117
|
* the input still strips unless it is strict in its own right.
|
|
106
118
|
*/
|
|
107
119
|
function strictenInput(input) {
|
|
120
|
+
if (isDiscriminatedUnionSchema(input)) {
|
|
121
|
+
const options = input.options;
|
|
122
|
+
const strictened = options.map((option) => option.def.catchall === undefined ? option.strict() : option);
|
|
123
|
+
if (strictened.every((option, i) => option === options[i]))
|
|
124
|
+
return input;
|
|
125
|
+
return z.discriminatedUnion(input.def.discriminator, strictened);
|
|
126
|
+
}
|
|
108
127
|
const declaresCatchall = input.def.catchall !== undefined;
|
|
109
128
|
return declaresCatchall ? input : input.strict();
|
|
110
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolDefinition.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/toolDefinition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"toolDefinition.js","sourceRoot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;;;;;;;;;;;GAsBG;AACH,SAAS,aAAa,CAAiC,KAAa;IAClE,IAAI,0BAA0B,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,KAAK,CAAC,OAA4C,CAAC;QACnE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACxC,MAAM,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAC7D,CAAC;QACF,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QACzE,OAAO,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,UAAmB,CAAsB,CAAC;IACjG,CAAC;IACD,MAAM,gBAAgB,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC;IAC1D,OAAO,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,KAAK,CAAC,MAAM,EAAa,CAAC;AAC/D,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Constructs Context, checks inline auth, measures execution, formats response.
|
|
4
4
|
* @module src/mcp-server/tools/utils/toolHandlerFactory
|
|
5
5
|
*/
|
|
6
|
-
import type { CallToolResult, ContentBlock, InputRequiredResult, ServerContext } from '@modelcontextprotocol/server';
|
|
6
|
+
import type { CallToolResult, ContentBlock, InputRequiredResult, ServerContext, ServerNotifier } from '@modelcontextprotocol/server';
|
|
7
7
|
import { type ZodObject, type ZodRawShape } from 'zod';
|
|
8
8
|
import type { Context } from '../../../core/context.js';
|
|
9
9
|
import { type ResourceSubscriptions } from '../../../mcp-server/notifications.js';
|
|
@@ -32,16 +32,24 @@ export interface HandlerFactoryServices {
|
|
|
32
32
|
* overwriting an in-flight handler's notifier target (and potentially
|
|
33
33
|
* notifying the wrong server).
|
|
34
34
|
*
|
|
35
|
-
* The handler factory
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* The handler factory picks a delivery path per era via
|
|
36
|
+
* {@link selectNotifiers}, and uses these closures only as a fallback for
|
|
37
|
+
* scopes with neither a bus nor a request sender (stdio, test harnesses).
|
|
38
38
|
*/
|
|
39
39
|
export interface HandlerNotifiers {
|
|
40
|
+
/**
|
|
41
|
+
* Publish facade for the modern era's `subscriptions/listen` bus, supplied
|
|
42
|
+
* only for `modern` instances. Takes precedence over the request-scoped path:
|
|
43
|
+
* on 2026-07-28 the client opts into notification types through its listen
|
|
44
|
+
* stream, and only what reaches the bus is filtered against that opt-in
|
|
45
|
+
* (#193).
|
|
46
|
+
*/
|
|
47
|
+
bus?: ServerNotifier;
|
|
40
48
|
notifyPromptListChanged?: () => void;
|
|
41
49
|
notifyResourceListChanged?: () => void;
|
|
42
50
|
notifyResourceUpdated?: (uri: string) => void;
|
|
43
51
|
notifyToolListChanged?: () => void;
|
|
44
|
-
/** Per-connection `resources/subscribe` registry (#354). */
|
|
52
|
+
/** Per-connection `resources/subscribe` registry (#354). Legacy era only. */
|
|
45
53
|
subscriptions?: ResourceSubscriptions;
|
|
46
54
|
}
|
|
47
55
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolHandlerFactory.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/toolHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,aAAa,
|
|
1
|
+
{"version":3,"file":"toolHandlerFactory.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/toolHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,mBAAmB,E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AAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAO9E;AAMD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,CAAC,WAAW,CAAC,CAGpF;AAmDD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,CAAC,WAAW,CAAC,CAkCrF;AA0GD;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,iBAAiB,EACtB,GAAG,EAAE,OAAO,EACZ,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,aAAa,EAAE,YAAY,EAAE,GAC5B,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,mBAAmB,CAAC,CAkBvD;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,iBAAiB,EACtB,QAAQ,EAAE,sBAAsB,EAChC,SAAS,EAAE,gBAAgB,GAC1B,CACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,EAAE,aAAa,KACf,OAAO,CAAC,cAAc,GAAG,mBAAmB,CAAC,CA2IjD"}
|
|
@@ -7,8 +7,9 @@ import { ZodError, z } from 'zod';
|
|
|
7
7
|
import { config } from '../../../config/index.js';
|
|
8
8
|
import { attachTypedFail, createContext, readContentStore, readEnrichmentStore, } from '../../../core/context.js';
|
|
9
9
|
import { createContextInputs, createRequestInput, isInputRequiredSignal, } from '../../../mcp-server/inputRequired.js';
|
|
10
|
-
import {
|
|
10
|
+
import { selectNotifiers } from '../../../mcp-server/notifications.js';
|
|
11
11
|
import { withRequiredScopes } from '../../../mcp-server/transports/auth/lib/authUtils.js';
|
|
12
|
+
import { resolveSessionMode } from '../../../mcp-server/types.js';
|
|
12
13
|
import { McpError } from '../../../types-global/errors.js';
|
|
13
14
|
import { ErrorHandler } from '../../../utils/internal/error-handler/errorHandler.js';
|
|
14
15
|
import { measureToolExecution } from '../../../utils/internal/performance.js';
|
|
@@ -349,11 +350,7 @@ export function createToolHandler(def, services, notifiers) {
|
|
|
349
350
|
return async (input, serverContext) => {
|
|
350
351
|
const mcpReq = serverContext?.mcpReq;
|
|
351
352
|
const signal = mcpReq?.signal ?? new AbortController().signal;
|
|
352
|
-
|
|
353
|
-
// this request's `ctx.mcpReq.notify` so they carry `relatedRequestId` and
|
|
354
|
-
// reach the client under per-request serving (#135). Fall back to the
|
|
355
|
-
// server-level notifiers when the scope exposes no sender.
|
|
356
|
-
const effectiveNotifiers = buildRequestScopedNotifiers(mcpReq ?? {}, notifiers.subscriptions) ?? notifiers;
|
|
353
|
+
const effectiveNotifiers = selectNotifiers(notifiers, mcpReq);
|
|
357
354
|
const sdkSessionId = typeof serverContext?.sessionId === 'string' ? serverContext.sessionId : undefined;
|
|
358
355
|
// Surface sessionId on `Context` only when it has request-spanning
|
|
359
356
|
// lifetime — stateful HTTP (or `auto`, which resolves to stateful for
|
|
@@ -361,7 +358,7 @@ export function createToolHandler(def, services, notifiers) {
|
|
|
361
358
|
// pass it through only when the consumer opted in via
|
|
362
359
|
// `createApp({ context: { exposeStatelessSessionId: true } })`. Stdio
|
|
363
360
|
// gives no sessionId at the SDK layer, so the gate is moot there.
|
|
364
|
-
const isStatefulMode = config.mcpSessionMode === 'stateful'
|
|
361
|
+
const isStatefulMode = resolveSessionMode(config.mcpSessionMode) === 'stateful';
|
|
365
362
|
const handlerSessionId = sdkSessionId && (isStatefulMode || services.exposeStatelessSessionId === true)
|
|
366
363
|
? sdkSessionId
|
|
367
364
|
: undefined;
|
|
@@ -387,31 +384,41 @@ export function createToolHandler(def, services, notifiers) {
|
|
|
387
384
|
}
|
|
388
385
|
// Validate input
|
|
389
386
|
const validatedInput = def.input.parse(input);
|
|
390
|
-
// Construct Context with detected capabilities
|
|
391
|
-
//
|
|
392
|
-
//
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
inputs: createContextInputs(mcpReq),
|
|
400
|
-
requestInput: createRequestInput(),
|
|
401
|
-
...(mcpReq?.log && { wireLog: mcpReq.log }),
|
|
402
|
-
notifyPromptListChanged: effectiveNotifiers.notifyPromptListChanged,
|
|
403
|
-
notifyResourceListChanged: effectiveNotifiers.notifyResourceListChanged,
|
|
404
|
-
notifyResourceUpdated: effectiveNotifiers.notifyResourceUpdated,
|
|
405
|
-
notifyToolListChanged: effectiveNotifiers.notifyToolListChanged,
|
|
406
|
-
}), def.errors);
|
|
387
|
+
// Construct Context with detected capabilities, from inside the execution
|
|
388
|
+
// span so `ctx.traceId` / `ctx.spanId` — and the child logger built from
|
|
389
|
+
// them — name the `tool_execution:*` span the handler runs in rather than
|
|
390
|
+
// the enclosing request span (#296). When the definition declares an error
|
|
391
|
+
// contract, `attachTypedFail` adds `ctx.fail` so handlers can
|
|
392
|
+
// `throw ctx.fail('reason', ...)`; otherwise ctx is unchanged.
|
|
393
|
+
// Assigned by the measured callback below and read after it settles, on
|
|
394
|
+
// both the success and error paths.
|
|
395
|
+
let ctx;
|
|
407
396
|
// Execute handler with performance measurement.
|
|
408
397
|
// Wrap with Promise.resolve — handler may return sync or async.
|
|
409
|
-
const result = await measureToolExecution(() =>
|
|
410
|
-
|
|
398
|
+
const result = await measureToolExecution((spanContext) => {
|
|
399
|
+
ctx = attachTypedFail(createContext({
|
|
400
|
+
appContext: spanContext,
|
|
401
|
+
logger: services.logger,
|
|
402
|
+
storage: services.storage,
|
|
403
|
+
signal,
|
|
404
|
+
sessionId: handlerSessionId,
|
|
405
|
+
inputs: createContextInputs(mcpReq),
|
|
406
|
+
requestInput: createRequestInput(),
|
|
407
|
+
...(mcpReq?.log && { wireLog: mcpReq.log }),
|
|
408
|
+
notifyPromptListChanged: effectiveNotifiers.notifyPromptListChanged,
|
|
409
|
+
notifyResourceListChanged: effectiveNotifiers.notifyResourceListChanged,
|
|
410
|
+
notifyResourceUpdated: effectiveNotifiers.notifyResourceUpdated,
|
|
411
|
+
notifyToolListChanged: effectiveNotifiers.notifyToolListChanged,
|
|
412
|
+
}), def.errors);
|
|
413
|
+
return Promise.resolve(def.handler(validatedInput, ctx));
|
|
414
|
+
}, { ...appContext, toolName: def.name }, validatedInput, () => {
|
|
415
|
+
const store = ctx ? readEnrichmentStore(ctx) : undefined;
|
|
411
416
|
return store && Object.keys(store.values).length > 0
|
|
412
417
|
? { [ATTR_MCP_TOOL_ENRICHED]: true }
|
|
413
418
|
: {};
|
|
414
419
|
});
|
|
420
|
+
// Assigned by the measured callback above before the handler ran.
|
|
421
|
+
const handlerCtx = ctx;
|
|
415
422
|
const validatedResult = def.output.parse(result);
|
|
416
423
|
// Render content[] from the domain payload only (Resolution B). Isolate
|
|
417
424
|
// formatter errors from handler errors so they get classified correctly.
|
|
@@ -426,12 +433,12 @@ export function createToolHandler(def, services, notifiers) {
|
|
|
426
433
|
// ride content[] only — never structuredContent — so a handler can surface
|
|
427
434
|
// media for the model without the base64 duplicating into the typed output.
|
|
428
435
|
// Empty for tools that never call ctx.content, leaving content[] unchanged.
|
|
429
|
-
const collected = readContentStore(
|
|
436
|
+
const collected = readContentStore(handlerCtx)?.blocks;
|
|
430
437
|
if (collected && collected.length > 0) {
|
|
431
438
|
domainContent = [...collected, ...domainContent];
|
|
432
439
|
}
|
|
433
440
|
// Merge enrichment into structuredContent and append the content[] trailer.
|
|
434
|
-
return buildToolSuccessResult(def,
|
|
441
|
+
return buildToolSuccessResult(def, handlerCtx, validatedResult, domainContent);
|
|
435
442
|
}
|
|
436
443
|
catch (error) {
|
|
437
444
|
// `ctx.requestInput(...)` is protocol control flow, not a failure: return
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolHandlerFactory.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/toolHandlerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,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UAAU;aACpB,CAAC,CAAC;YACH,OAAO,+BAA+B,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bounded in-memory `EventStore` for stateful HTTP session
|
|
3
|
+
* resumability.
|
|
4
|
+
*
|
|
5
|
+
* Stateful HTTP survives a dropped connection but not the in-flight stream: the
|
|
6
|
+
* session is still there on reconnect, and everything the server emitted while
|
|
7
|
+
* the socket was down is gone. The SDK's transport closes that gap when it is
|
|
8
|
+
* given an `EventStore` — it stamps each SSE frame with an event ID, and a
|
|
9
|
+
* client reconnecting with `Last-Event-ID` gets the missed frames replayed
|
|
10
|
+
* before the live stream resumes.
|
|
11
|
+
*
|
|
12
|
+
* The store is framework-owned rather than a dependency's memory store because
|
|
13
|
+
* the bounds are the feature. Retention is capped two ways — a total event count
|
|
14
|
+
* and a per-event TTL — and one store belongs to one session, so eviction
|
|
15
|
+
* releases its buffer with it. Without both, a long-lived session on a busy
|
|
16
|
+
* server retains every frame it ever sent.
|
|
17
|
+
*
|
|
18
|
+
* **Legacy arm only.** Protocol revision 2026-07-28 is per-request and has no
|
|
19
|
+
* session to resume, so nothing here applies to it (#215).
|
|
20
|
+
*
|
|
21
|
+
* @module src/mcp-server/transports/http/eventStore
|
|
22
|
+
*/
|
|
23
|
+
import type { EventStore } from '@modelcontextprotocol/server';
|
|
24
|
+
/** Retention bounds. Both apply; whichever binds first evicts. */
|
|
25
|
+
export interface BoundedEventStoreOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Maximum events retained across every stream in the session. The oldest are
|
|
28
|
+
* dropped first, which is also the safe direction: a client far enough behind
|
|
29
|
+
* that its resume point was evicted starts a fresh stream instead.
|
|
30
|
+
*/
|
|
31
|
+
maxEvents?: number;
|
|
32
|
+
/** Injectable clock. Present for tests; production uses `Date.now`. */
|
|
33
|
+
now?: () => number;
|
|
34
|
+
/** How long an event stays replayable, in milliseconds. */
|
|
35
|
+
ttlMs?: number;
|
|
36
|
+
}
|
|
37
|
+
/** A session-scoped event store, plus the handles the transport layer needs. */
|
|
38
|
+
export interface BoundedEventStore extends EventStore {
|
|
39
|
+
/**
|
|
40
|
+
* Drops every retained event, releasing the buffer at an explicit DELETE
|
|
41
|
+
* rather than leaving it to the collector. A session that ends any other way
|
|
42
|
+
* (stale eviction, shutdown) discards the store with the transport that
|
|
43
|
+
* holds it, so this is promptness, not the only release path.
|
|
44
|
+
*/
|
|
45
|
+
clear(): void;
|
|
46
|
+
/** Events currently retained. */
|
|
47
|
+
readonly size: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a bounded in-memory event store for one session.
|
|
51
|
+
*
|
|
52
|
+
* Event IDs are `<streamId>_<sequence>` with a monotonic per-store counter, so
|
|
53
|
+
* insertion order is replay order and an ID identifies its own stream without a
|
|
54
|
+
* second index.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createBoundedEventStore(options?: BoundedEventStoreOptions): BoundedEventStore;
|
|
57
|
+
//# sourceMappingURL=eventStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventStore.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/eventStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,8BAA8B,CAAC;AAE/E,kEAAkE;AAClE,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,gFAAgF;AAChF,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACnD;;;;;OAKG;IACH,KAAK,IAAI,IAAI,CAAC;IACd,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAiCD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,wBAA6B,GAAG,iBAAiB,CAiEjG"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bounded in-memory `EventStore` for stateful HTTP session
|
|
3
|
+
* resumability.
|
|
4
|
+
*
|
|
5
|
+
* Stateful HTTP survives a dropped connection but not the in-flight stream: the
|
|
6
|
+
* session is still there on reconnect, and everything the server emitted while
|
|
7
|
+
* the socket was down is gone. The SDK's transport closes that gap when it is
|
|
8
|
+
* given an `EventStore` — it stamps each SSE frame with an event ID, and a
|
|
9
|
+
* client reconnecting with `Last-Event-ID` gets the missed frames replayed
|
|
10
|
+
* before the live stream resumes.
|
|
11
|
+
*
|
|
12
|
+
* The store is framework-owned rather than a dependency's memory store because
|
|
13
|
+
* the bounds are the feature. Retention is capped two ways — a total event count
|
|
14
|
+
* and a per-event TTL — and one store belongs to one session, so eviction
|
|
15
|
+
* releases its buffer with it. Without both, a long-lived session on a busy
|
|
16
|
+
* server retains every frame it ever sent.
|
|
17
|
+
*
|
|
18
|
+
* **Legacy arm only.** Protocol revision 2026-07-28 is per-request and has no
|
|
19
|
+
* session to resume, so nothing here applies to it (#215).
|
|
20
|
+
*
|
|
21
|
+
* @module src/mcp-server/transports/http/eventStore
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Retained events, capped at 512 by default.
|
|
25
|
+
*
|
|
26
|
+
* Sized for the gap a reconnect actually has to cover — a dropped socket, not a
|
|
27
|
+
* disconnected weekend — rather than for a full session transcript. Each entry
|
|
28
|
+
* holds one JSON-RPC message, so the memory cost scales with payload size;
|
|
29
|
+
* lower it on a server whose tools return large results.
|
|
30
|
+
*/
|
|
31
|
+
const DEFAULT_MAX_EVENTS = 512;
|
|
32
|
+
/** How long a retained event stays replayable. Five minutes by default. */
|
|
33
|
+
const DEFAULT_TTL_MS = 300_000;
|
|
34
|
+
/**
|
|
35
|
+
* The stream an event ID belongs to, read back off the ID itself.
|
|
36
|
+
*
|
|
37
|
+
* Only the sequence suffix has a fixed shape — a stream ID may itself contain
|
|
38
|
+
* `_`, as the SDK's standalone GET stream (`_GET_stream`) does — so the split
|
|
39
|
+
* is at the last separator, not the first.
|
|
40
|
+
*/
|
|
41
|
+
const streamIdOf = (eventId) => {
|
|
42
|
+
const separator = eventId.lastIndexOf('_');
|
|
43
|
+
return separator === -1 ? '' : eventId.slice(0, separator);
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Creates a bounded in-memory event store for one session.
|
|
47
|
+
*
|
|
48
|
+
* Event IDs are `<streamId>_<sequence>` with a monotonic per-store counter, so
|
|
49
|
+
* insertion order is replay order and an ID identifies its own stream without a
|
|
50
|
+
* second index.
|
|
51
|
+
*/
|
|
52
|
+
export function createBoundedEventStore(options = {}) {
|
|
53
|
+
const maxEvents = options.maxEvents ?? DEFAULT_MAX_EVENTS;
|
|
54
|
+
const ttlMs = options.ttlMs ?? DEFAULT_TTL_MS;
|
|
55
|
+
const now = options.now ?? Date.now;
|
|
56
|
+
// Insertion-ordered, which is what makes both the replay walk and the
|
|
57
|
+
// oldest-first eviction a plain iteration.
|
|
58
|
+
const events = new Map();
|
|
59
|
+
let sequence = 0;
|
|
60
|
+
const evict = () => {
|
|
61
|
+
const cutoff = now() - ttlMs;
|
|
62
|
+
for (const [eventId, event] of events) {
|
|
63
|
+
if (event.storedAt > cutoff)
|
|
64
|
+
break; // insertion-ordered: the rest are newer
|
|
65
|
+
events.delete(eventId);
|
|
66
|
+
}
|
|
67
|
+
while (events.size > maxEvents) {
|
|
68
|
+
const oldest = events.keys().next();
|
|
69
|
+
if (oldest.done)
|
|
70
|
+
break;
|
|
71
|
+
events.delete(oldest.value);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
storeEvent(streamId, message) {
|
|
76
|
+
const eventId = `${streamId}_${++sequence}`;
|
|
77
|
+
events.set(eventId, { message, storedAt: now(), streamId });
|
|
78
|
+
evict();
|
|
79
|
+
return Promise.resolve(eventId);
|
|
80
|
+
},
|
|
81
|
+
getStreamIdForEventId(eventId) {
|
|
82
|
+
return Promise.resolve(events.get(eventId)?.streamId);
|
|
83
|
+
},
|
|
84
|
+
async replayEventsAfter(lastEventId, { send }) {
|
|
85
|
+
const anchor = events.get(lastEventId);
|
|
86
|
+
// An unknown anchor means the client's resume point aged out or was
|
|
87
|
+
// evicted. Replaying from the start would deliver messages it already
|
|
88
|
+
// has, so send nothing and let the live stream carry on from here. An
|
|
89
|
+
// SDK-driven reconnect never gets this far — `getStreamIdForEventId`
|
|
90
|
+
// answers first, and an unknown ID is rejected there.
|
|
91
|
+
if (!anchor)
|
|
92
|
+
return streamIdOf(lastEventId);
|
|
93
|
+
const { streamId } = anchor;
|
|
94
|
+
let past = false;
|
|
95
|
+
for (const [eventId, event] of events) {
|
|
96
|
+
if (!past) {
|
|
97
|
+
past = eventId === lastEventId;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (event.streamId !== streamId)
|
|
101
|
+
continue;
|
|
102
|
+
await send(eventId, event.message);
|
|
103
|
+
}
|
|
104
|
+
return streamId;
|
|
105
|
+
},
|
|
106
|
+
clear() {
|
|
107
|
+
events.clear();
|
|
108
|
+
},
|
|
109
|
+
get size() {
|
|
110
|
+
return events.size;
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=eventStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventStore.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/eventStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AA+BH;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,2EAA2E;AAC3E,MAAM,cAAc,GAAG,OAAO,CAA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,IAAI,IAAI;YACN,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @module src/mcp-server/transports/http/httpServer
|
|
7
7
|
*/
|
|
8
8
|
import { type ServerType } from '@hono/node-server';
|
|
9
|
+
import type { ServerEventBus } from '@modelcontextprotocol/server';
|
|
9
10
|
import type { ServerManifest } from '../../../core/serverManifest.js';
|
|
10
11
|
import type { FrameworkServerFactory } from '../../../mcp-server/types.js';
|
|
11
12
|
import { type RequestContext } from '../../../utils/internal/requestContext.js';
|
|
@@ -18,5 +19,5 @@ export interface HttpTransportHandle {
|
|
|
18
19
|
server: ServerType;
|
|
19
20
|
stop: (parentContext: RequestContext) => Promise<void>;
|
|
20
21
|
}
|
|
21
|
-
export declare function startHttpTransport(serverFactory: FrameworkServerFactory, parentContext: RequestContext, manifest: ServerManifest): Promise<HttpTransportHandle>;
|
|
22
|
+
export declare function startHttpTransport(serverFactory: FrameworkServerFactory, parentContext: RequestContext, manifest: ServerManifest, bus?: ServerEventBus): Promise<HttpTransportHandle>;
|
|
22
23
|
//# sourceMappingURL=httpServer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpServer.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/httpServer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,KAAK,UAAU,EAAS,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"httpServer.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/httpServer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,KAAK,UAAU,EAAS,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,KAAK,cAAc,EAAa,MAAM,oCAAoC,CAAC;AAGpF;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,CAAC,aAAa,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AA2ED,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,sBAAsB,EACrC,aAAa,EAAE,cAAc,EAC7B,QAAQ,EAAE,cAAc,EACxB,GAAG,CAAC,EAAE,cAAc,GACnB,OAAO,CAAC,mBAAmB,CAAC,CAoB9B"}
|
|
@@ -61,10 +61,10 @@ function startHttpServerWithRetry(app, initialPort, host, maxRetries, parentCont
|
|
|
61
61
|
tryBind(initialPort, 1);
|
|
62
62
|
return promise;
|
|
63
63
|
}
|
|
64
|
-
export async function startHttpTransport(serverFactory, parentContext, manifest) {
|
|
64
|
+
export async function startHttpTransport(serverFactory, parentContext, manifest, bus) {
|
|
65
65
|
const transportContext = withExtra(parentContext, { component: 'HttpTransportStart' });
|
|
66
66
|
logger.info('Starting HTTP transport.', transportContext);
|
|
67
|
-
const { app, close } = await createHttpApp(serverFactory, transportContext, manifest);
|
|
67
|
+
const { app, close } = await createHttpApp(serverFactory, transportContext, manifest, bus);
|
|
68
68
|
const server = await startHttpServerWithRetry(app, config.mcpHttpPort, config.mcpHttpHost, config.mcpHttpMaxPortRetries, transportContext);
|
|
69
69
|
logger.info('HTTP transport started successfully.', transportContext);
|
|
70
70
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpServer.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/httpServer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAmB,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"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B,CAAC,mBAAmB,EAAE,CAAC;QAChD,CAAC,EAAE,gBAAgB,CAAC,CAAC;QACrB,UAAU,CAAC,KAAK,EAAE,CAAC;QAEnB,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,YAAY,CAAC,UAAU,CAAC,CAAC;YACzB,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;gBAClE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,gBAAgB,CAAC,CAAC;YAClE,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* @see {@link https://modelcontextprotocol.io/specification/2026-07-28/basic/transports | MCP Transports}
|
|
22
22
|
* @module src/mcp-server/transports/http/httpTransport
|
|
23
23
|
*/
|
|
24
|
-
import { type McpHttpHandler } from '@modelcontextprotocol/server';
|
|
24
|
+
import { type McpHttpHandler, type ServerEventBus } from '@modelcontextprotocol/server';
|
|
25
25
|
import { Hono } from 'hono';
|
|
26
26
|
import type { ServerManifest } from '../../../core/serverManifest.js';
|
|
27
27
|
import type { HonoNodeBindings } from '../../../mcp-server/transports/http/httpTypes.js';
|
|
28
28
|
import { SessionStore } from '../../../mcp-server/transports/http/sessionStore.js';
|
|
29
|
-
import type
|
|
29
|
+
import { type FrameworkServerFactory } from '../../../mcp-server/types.js';
|
|
30
30
|
import { type RequestContext } from '../../../utils/internal/requestContext.js';
|
|
31
31
|
/**
|
|
32
32
|
* Creates a Hono HTTP application for the MCP server.
|
|
@@ -41,9 +41,14 @@ import { type RequestContext } from '../../../utils/internal/requestContext.js';
|
|
|
41
41
|
* @template TBindings - The Hono binding type (must extend object, defaults to HonoNodeBindings for Node.js)
|
|
42
42
|
* @param mcpServer - The MCP server instance
|
|
43
43
|
* @param parentContext - Parent request context for logging
|
|
44
|
+
* @param bus - Change-event bus the modern leg's `subscriptions/listen` streams
|
|
45
|
+
* subscribe to. Pass the one the app publishes on (`ComposedApp.bus`), or a
|
|
46
|
+
* background emission reaches a different bus than the streams listen to and
|
|
47
|
+
* is silently dropped (#193). Omitted, the handler creates its own — fine for
|
|
48
|
+
* a test harness that never emits out of request.
|
|
44
49
|
* @returns Configured Hono application with the specified binding type
|
|
45
50
|
*/
|
|
46
|
-
export declare function createHttpApp<TBindings extends object = HonoNodeBindings>(serverFactory: FrameworkServerFactory, parentContext: RequestContext, manifest: ServerManifest): Promise<{
|
|
51
|
+
export declare function createHttpApp<TBindings extends object = HonoNodeBindings>(serverFactory: FrameworkServerFactory, parentContext: RequestContext, manifest: ServerManifest, bus?: ServerEventBus): Promise<{
|
|
47
52
|
app: Hono<{
|
|
48
53
|
Bindings: TBindings;
|
|
49
54
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpTransport.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/httpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAIL,KAAK,cAAc,EAEpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"httpTransport.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/httpTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,cAAc,EAEpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B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