@lostgradient/mcp 0.2.5 → 0.3.0
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/LICENSE +1 -1
- package/README.md +15 -173
- package/dist/http.d.ts +35 -0
- package/dist/http.js +251 -0
- package/dist/internal/cryptography/encryption.d.ts +108 -0
- package/dist/internal/cryptography/encryption.js +241 -0
- package/dist/internal/cryptography/hash.d.ts +72 -0
- package/dist/internal/cryptography/hash.js +233 -0
- package/dist/internal/cryptography/index.d.ts +4 -0
- package/dist/internal/cryptography/index.js +2 -0
- package/dist/oauth/canonicalize-ip-address.d.ts +0 -6
- package/dist/oauth/canonicalize-ip-address.js +113 -0
- package/dist/oauth/client-metadata-documents.d.ts +2 -22
- package/dist/oauth/client-metadata-documents.js +205 -19
- package/dist/oauth/index.d.ts +9 -213
- package/dist/oauth/index.js +6 -69
- package/dist/oauth/issuer.d.ts +103 -0
- package/dist/oauth/issuer.js +564 -0
- package/dist/oauth/postgres.d.ts +12 -0
- package/dist/oauth/postgres.js +76 -0
- package/dist/oauth/safe-public-https-fetch.d.ts +3 -5
- package/dist/oauth/safe-public-https-fetch.js +114 -0
- package/dist/oauth/security-utilities.d.ts +0 -3
- package/dist/oauth/security-utilities.js +93 -0
- package/dist/oauth-store.d.ts +108 -0
- package/dist/oauth-store.js +321 -0
- package/package.json +50 -124
- package/dist/chunk-3ek3knfm.js +0 -73
- package/dist/chunk-3rr24vhh.js +0 -28
- package/dist/chunk-6ekjtvcq.js +0 -273
- package/dist/chunk-88nhf6xt.js +0 -449
- package/dist/chunk-en76akaq.js +0 -1107
- package/dist/chunk-k6fm3cmk.js +0 -132
- package/dist/chunk-qxwd8est.js +0 -916
- package/dist/chunk-rxnyn7tf.js +0 -19
- package/dist/chunk-taxyscge.js +0 -67
- package/dist/chunk-wsnfttyg.js +0 -4
- package/dist/chunk-xcf742mf.js +0 -14
- package/dist/conformance-fixture-registration.d.ts +0 -30
- package/dist/conformance-server.d.ts +0 -1
- package/dist/conformance.d.ts +0 -43
- package/dist/env.d.ts +0 -59
- package/dist/env.js +0 -9
- package/dist/environment-schema.d.ts +0 -29
- package/dist/environment-schema.js +0 -6
- package/dist/golden-prompts.d.ts +0 -42
- package/dist/handler-context.d.ts +0 -16
- package/dist/http/authenticate.d.ts +0 -35
- package/dist/http/authorization-header.d.ts +0 -5
- package/dist/http/grant-revocation-channel.d.ts +0 -24
- package/dist/http/handler.d.ts +0 -32
- package/dist/http/index.d.ts +0 -27
- package/dist/http/index.js +0 -870
- package/dist/http/listen-inspection.d.ts +0 -11
- package/dist/http/request-context.d.ts +0 -17
- package/dist/http/responses.d.ts +0 -13
- package/dist/http/serving-layer.d.ts +0 -25
- package/dist/http/user-handler-cache.d.ts +0 -37
- package/dist/http/user-server-event-bus.d.ts +0 -35
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -616
- package/dist/localhost-request-validation.d.ts +0 -2
- package/dist/logger.d.ts +0 -59
- package/dist/logger.js +0 -18
- package/dist/long-running-operation-support.d.ts +0 -34
- package/dist/metrics.d.ts +0 -64
- package/dist/metrics.js +0 -6
- package/dist/oauth/authorize-endpoint.d.ts +0 -5
- package/dist/oauth/client-authentication.d.ts +0 -10
- package/dist/oauth/discovery-metadata.d.ts +0 -19
- package/dist/oauth/endpoint-rate-limits.d.ts +0 -10
- package/dist/oauth/endpoint-responses.d.ts +0 -10
- package/dist/oauth/network-identity.d.ts +0 -32
- package/dist/oauth/pkce-validation.d.ts +0 -2
- package/dist/oauth/postgres/client-store.d.ts +0 -12
- package/dist/oauth/postgres/code-store.d.ts +0 -14
- package/dist/oauth/postgres/database.d.ts +0 -59
- package/dist/oauth/postgres/index.d.ts +0 -11
- package/dist/oauth/postgres/index.js +0 -616
- package/dist/oauth/postgres/schema.d.ts +0 -1476
- package/dist/oauth/postgres/token-store.d.ts +0 -16
- package/dist/oauth/postgres/transaction-store.d.ts +0 -14
- package/dist/oauth/redirect-uri-matching.d.ts +0 -2
- package/dist/oauth/registration-endpoint.d.ts +0 -2
- package/dist/oauth/request-body.d.ts +0 -14
- package/dist/oauth/revocation-endpoint.d.ts +0 -2
- package/dist/oauth/scope-utilities.d.ts +0 -15
- package/dist/oauth/stores.d.ts +0 -225
- package/dist/oauth/stores.js +0 -0
- package/dist/oauth/testing/contract-fixtures.d.ts +0 -134
- package/dist/oauth/testing/index.d.ts +0 -56
- package/dist/oauth/testing/index.js +0 -330
- package/dist/oauth/token-endpoint.d.ts +0 -2
- package/dist/oauth-scope-configuration.d.ts +0 -3
- package/dist/prompts/index.d.ts +0 -5
- package/dist/prompts/summarize.d.ts +0 -4
- package/dist/rate-limit/in-memory-sliding-window-store.d.ts +0 -3
- package/dist/rate-limit/index.d.ts +0 -23
- package/dist/rate-limit/index.js +0 -29
- package/dist/rate-limit/mcp-concurrency-limiter.d.ts +0 -26
- package/dist/rate-limit/rate-limit-response.d.ts +0 -1
- package/dist/rate-limit/redis-sliding-window-store.d.ts +0 -2
- package/dist/rate-limit/request-rate-limiter.d.ts +0 -10
- package/dist/rate-limit/sliding-window-rate-limiter.d.ts +0 -16
- package/dist/resources/index.d.ts +0 -4
- package/dist/resources/user-profile.d.ts +0 -1
- package/dist/scope-vocabulary.d.ts +0 -127
- package/dist/scopes.d.ts +0 -49
- package/dist/server.d.ts +0 -113
- package/dist/supported-scopes.d.ts +0 -25
- package/dist/sveltekit-mount-state.d.ts +0 -4
- package/dist/sveltekit-mount.d.ts +0 -43
- package/dist/sveltekit-mount.js +0 -344
- package/dist/template-registry.d.ts +0 -16
- package/dist/tool-response.d.ts +0 -100
- package/dist/tools/get-user-profile.d.ts +0 -8
- package/dist/tools/index.d.ts +0 -16
- package/dist/tools/list-audit-events.d.ts +0 -11
- package/dist/type-assertions.d.ts +0 -1
- package/dist/types/primitives.d.ts +0 -130
- package/dist/ui-extension-support.d.ts +0 -20
- package/dist/version.d.ts +0 -23
- package/dist/version.js +0 -6
package/dist/server.d.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/server';
|
|
2
|
-
import type { McpUserProfile } from './types/primitives.js';
|
|
3
|
-
import type { McpRegistry } from './scope-vocabulary.js';
|
|
4
|
-
/**
|
|
5
|
-
* Round-seventeen review (P2): `resources/read` rejects an under-scoped
|
|
6
|
-
* request via `assertRequiredScope` before the handler ever runs, but the
|
|
7
|
-
* `2026-07-28` `subscriptions/listen` stream (the push-notification path a
|
|
8
|
-
* modern client uses to receive `notifications/resources/updated` for
|
|
9
|
-
* `resourceSubscriptions: [uri, ...]`) never consulted scopes at all — a
|
|
10
|
-
* client holding only `prompts:read` could still subscribe to
|
|
11
|
-
* `user://profile` (which requires `profile:read`) and would receive a
|
|
12
|
-
* `resource_updated` event the moment that resource actually changed,
|
|
13
|
-
* despite never having been granted `profile:read`. That is a real
|
|
14
|
-
* authorization bypass: it leaks the *fact* that a scoped resource changed
|
|
15
|
-
* to a caller who was never allowed to read its contents.
|
|
16
|
-
*
|
|
17
|
-
* Root cause of why this could not simply reuse `assertRequiredScope`
|
|
18
|
-
* in-place: the installed `@modelcontextprotocol/server@2.0.0` SDK serves
|
|
19
|
-
* `subscriptions/listen` entirely outside the registered-handler dispatch
|
|
20
|
-
* this factory wires up. Confirmed by reading the SDK's own bundled
|
|
21
|
-
* `createMcpHandler` (`dist/index.mjs`): on a `subscriptions/listen`
|
|
22
|
-
* request it builds a FRESH server via the factory, reads only
|
|
23
|
-
* `server.getCapabilities()` off it, immediately calls `product.close()`,
|
|
24
|
-
* and hands the request to its own internal `listenRouter.serve(...)` —
|
|
25
|
-
* the constructed `McpServer` instance (and therefore anything registered
|
|
26
|
-
* on it, including `assertRequiredScope`'s call sites) never sees the
|
|
27
|
-
* request at all, and the factory itself is never even passed the
|
|
28
|
-
* requested `resourceSubscriptions` URIs to filter against. There is
|
|
29
|
-
* consequently no request-handler hook inside `createMcpServer` capable of
|
|
30
|
-
* enforcing this — the enforcement point has to live at the HTTP boundary
|
|
31
|
-
* that owns the raw request body, before it is ever handed to
|
|
32
|
-
* `McpHttpHandler.fetch()`.
|
|
33
|
-
*
|
|
34
|
-
* **A consumer wiring its own handler MUST call this before dispatch.** It is
|
|
35
|
-
* not invoked from `createMcpServer`, and it cannot be: `subscriptions/listen`
|
|
36
|
-
* is decided at the HTTP boundary, before the request reaches this
|
|
37
|
-
* `McpServer` at all. So wrapping `createMcpServer()` directly in the SDK's
|
|
38
|
-
* `createMcpHandler` — the obvious minimal wiring, and the shape this
|
|
39
|
-
* package's own tests use — leaves every scoped resource observable by an
|
|
40
|
-
* under-scoped client, because nothing checks. `applications/web`'s
|
|
41
|
-
* `mcp-handler.ts` is the worked example of doing it correctly.
|
|
42
|
-
*
|
|
43
|
-
* That this is a documented obligation rather than an enforced one is a real
|
|
44
|
-
* gap, tracked upstream: a consumer that never reads this comment gets no
|
|
45
|
-
* error, just a silent authorization bypass on subscription delivery.
|
|
46
|
-
*
|
|
47
|
-
* This function is the reusable piece `createMcpServer` CAN own: the same
|
|
48
|
-
* scope-lookup `assertRequiredScope` performs (grantedScopes vs. a
|
|
49
|
-
* resource definition's `requiredScope`), applied per requested URI against
|
|
50
|
-
* the registry's resources, the single source of truth for which scope each resource
|
|
51
|
-
* needs. `applications/web/src/lib/mcp-handler.ts` already peeks the
|
|
52
|
-
* request body to detect a `subscriptions/listen` call before dispatch
|
|
53
|
-
* (see `isSubscriptionsListenRequest`, added for an unrelated shutdown-
|
|
54
|
-
* tracking reason) — that is the natural call site for this function: read
|
|
55
|
-
* `params.notifications.resourceSubscriptions` off the same already-parsed
|
|
56
|
-
* body, call this with the caller's verified `scopes`, and refuse the
|
|
57
|
-
* WHOLE request (a single JSON-RPC error, not a per-URI partial ack) when
|
|
58
|
-
* it returns `false`.
|
|
59
|
-
*
|
|
60
|
-
* Design decision — reject the whole request, not a filtered subset:
|
|
61
|
-
* silently attaching only the permitted URIs while acking the rest would
|
|
62
|
-
* (a) never inform the client which of its requested subscriptions it
|
|
63
|
-
* actually got, and (b) let a caller distinguish "URI exists but I lack
|
|
64
|
-
* scope" from "URI doesn't exist" by comparing which URIs it lists in an
|
|
65
|
-
* absence-of-updates versus an outright rejection — a probe channel. A
|
|
66
|
-
* single all-or-nothing rejection, mirroring how `resources/read` already
|
|
67
|
-
* collapses "expired token" and "wrong audience" into one wire response
|
|
68
|
-
* (see `mcp-routes.ts`'s `OBS-001` comment), discloses nothing about which
|
|
69
|
-
* specific URI(s) failed or why. Fails closed: an unrecognized URI is
|
|
70
|
-
* treated identically to a recognized-but-under-scoped one (both deny),
|
|
71
|
-
* so denial never confirms or denies a resource's existence either.
|
|
72
|
-
*/
|
|
73
|
-
export declare function areResourceSubscriptionsAuthorized(uris: readonly string[], scopes: readonly string[], registry: McpRegistry): boolean;
|
|
74
|
-
export declare function createMcpServer(context: {
|
|
75
|
-
userId: string;
|
|
76
|
-
user: McpUserProfile;
|
|
77
|
-
/**
|
|
78
|
-
* OBS-001: the HTTP-boundary request identifier, threaded through to
|
|
79
|
-
* every tool/resource/prompt handler via `McpContext.requestId` so one
|
|
80
|
-
* connector action can be traced end to end through logs. Undefined for
|
|
81
|
-
* callers that build a server outside a real HTTP request (the
|
|
82
|
-
* standalone conformance server, tests).
|
|
83
|
-
*/
|
|
84
|
-
requestId?: string;
|
|
85
|
-
enableUiExtension: boolean;
|
|
86
|
-
enableConformanceMode?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* PROTO-002: which protocol era this particular `McpServer` instance
|
|
89
|
-
* will serve. Drives whether `resources.subscribe` is advertised (only
|
|
90
|
-
* ever true on `'modern'` — see `buildServerCapabilities`) — legacy
|
|
91
|
-
* serving has no delivery path for a subscription push. Defaults to
|
|
92
|
-
* `'legacy'` so existing callers (tests, the standalone conformance
|
|
93
|
-
* server) that do not pass it keep today's unadvertised behavior.
|
|
94
|
-
*/
|
|
95
|
-
era?: 'legacy' | 'modern';
|
|
96
|
-
/**
|
|
97
|
-
* PROTO-002 / S-11: publishes a `notifications/resources/updated` event
|
|
98
|
-
* scoped to only this context's `userId` (see
|
|
99
|
-
* `src/http/user-server-event-bus.ts`). Undefined when no
|
|
100
|
-
* event bus is wired for this request (e.g. the standalone conformance
|
|
101
|
-
* server) — `resources/subscribe` still acks, it just never delivers.
|
|
102
|
-
*/
|
|
103
|
-
publishResourceUpdate?: (uri: string) => Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* AUTHZ-001: the OAuth scopes the caller's access token actually carries
|
|
106
|
-
* (`McpRequestAuthExtra.scopes`, verified against the database by the
|
|
107
|
-
* HTTP boundary before this factory is ever called). Enforced here,
|
|
108
|
-
* once, before any tool/resource/prompt handler runs — "missing scopes
|
|
109
|
-
* fail before application data is read," per the roadmap's own wording
|
|
110
|
-
* for this item.
|
|
111
|
-
*/
|
|
112
|
-
scopes: readonly string[];
|
|
113
|
-
}, registry: McpRegistry): McpServer;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { McpRegistry } from './scope-vocabulary.js';
|
|
2
|
-
/**
|
|
3
|
-
* AUTHZ-001: the scopes an OAuth client can actually request and see
|
|
4
|
-
* advertised, derived mechanically from the *production* registries
|
|
5
|
-
* (`tools`/`resources`/`prompts` — never `conformanceOnlyTools`, which is
|
|
6
|
-
* only ever registered when `enableConformanceMode` is on and is never
|
|
7
|
-
* reachable through a real deployment's OAuth flow). Computing this from the
|
|
8
|
-
* registry itself, rather than hand-maintaining a parallel list, is what
|
|
9
|
-
* makes "authorization server and protected-resource metadata publish the
|
|
10
|
-
* same supported scopes" mechanically true everywhere this is called from,
|
|
11
|
-
* and what keeps a conformance-only fixture's scope out of production
|
|
12
|
-
* metadata without a second place that has to remember to exclude it.
|
|
13
|
-
*
|
|
14
|
-
* The registry is an argument rather than a module import so that a
|
|
15
|
-
* consumer's advertised `scopes_supported` describes the server it is
|
|
16
|
-
* actually running. Reading module-level barrels here would have made this
|
|
17
|
-
* answer this package's question no matter whose primitives were being
|
|
18
|
-
* served, which is precisely the bug that made the package unusable as a
|
|
19
|
-
* library.
|
|
20
|
-
*
|
|
21
|
-
* Sorted for a stable, deterministic `scope` string wherever this is joined
|
|
22
|
-
* with a space (metadata `scopes_supported`, the `/mcp` 401 challenge's
|
|
23
|
-
* `scope` attribute).
|
|
24
|
-
*/
|
|
25
|
-
export declare function getSupportedScopes(registry: McpRegistry): string[];
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export type SvelteKitMountState = 'available' | 'constructing' | 'live' | 'disposed';
|
|
2
|
-
export declare function getSvelteKitMountState(): SvelteKitMountState;
|
|
3
|
-
export declare function setSvelteKitMountState(state: SvelteKitMountState): void;
|
|
4
|
-
export declare function resetSvelteKitMountStateForTesting(): void;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { McpRegistry } from './scope-vocabulary.js';
|
|
2
|
-
import { type OAuthDiscoveryConfiguration, type OAuthHostSeams, type OAuthIdentity, type OAuthRequestContext } from './oauth/index.js';
|
|
3
|
-
export type SvelteKitLikeRequestEvent = {
|
|
4
|
-
request: Request;
|
|
5
|
-
url: URL;
|
|
6
|
-
locals: Record<PropertyKey, unknown>;
|
|
7
|
-
getClientAddress(): string;
|
|
8
|
-
};
|
|
9
|
-
export type SvelteKitMcpHandleInput = {
|
|
10
|
-
event: SvelteKitLikeRequestEvent;
|
|
11
|
-
resolve(event: SvelteKitLikeRequestEvent): Response | Promise<Response>;
|
|
12
|
-
};
|
|
13
|
-
export type SvelteKitMcpMount = {
|
|
14
|
-
handle(input: SvelteKitMcpHandleInput): Promise<Response>;
|
|
15
|
-
dispose(): Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
export type SvelteKitMcpRuntime = {
|
|
18
|
-
start(): Promise<void>;
|
|
19
|
-
shutdown(): Promise<void>;
|
|
20
|
-
publishGrantRevocation(subjectId: string): Promise<void>;
|
|
21
|
-
handle(context: OAuthRequestContext): Promise<Response>;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Records that the host identity handle ran for this request. A null identity
|
|
25
|
-
* is distinct from a handle that was skipped or sequenced after the MCP mount.
|
|
26
|
-
*/
|
|
27
|
-
export declare function primeSvelteKitMcpIdentity(event: SvelteKitLikeRequestEvent, identity: OAuthIdentity | null): void;
|
|
28
|
-
/**
|
|
29
|
-
* Creates one process-wide MCP/OAuth lifecycle for a SvelteKit-compatible
|
|
30
|
-
* handle chain without importing SvelteKit. The host retains ownership of its
|
|
31
|
-
* listener, signals, request draining, and process termination.
|
|
32
|
-
*/
|
|
33
|
-
export declare function createSvelteKitMcpMount<Scope extends string>(input: {
|
|
34
|
-
oauthSeams: OAuthHostSeams<Scope>;
|
|
35
|
-
discoveryConfiguration: OAuthDiscoveryConfiguration;
|
|
36
|
-
registry: McpRegistry<Scope>;
|
|
37
|
-
identityHandleName: string;
|
|
38
|
-
/** Must be true only for a process that persists across requests. */
|
|
39
|
-
longLivedProcess: boolean;
|
|
40
|
-
/** Supplies the host's existing request correlation identifier. */
|
|
41
|
-
getRequestId?(event: SvelteKitLikeRequestEvent): string;
|
|
42
|
-
mcp: SvelteKitMcpRuntime;
|
|
43
|
-
}): Promise<SvelteKitMcpMount>;
|
package/dist/sveltekit-mount.js
DELETED
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
handleOauthAuthorizationMetadataGet,
|
|
3
|
-
handleOauthAuthorizeApprove,
|
|
4
|
-
handleOauthAuthorizeDeny,
|
|
5
|
-
handleOauthAuthorizeGet,
|
|
6
|
-
handleOauthProtectedResourceMcpMetadataGet,
|
|
7
|
-
handleOauthProtectedResourceMetadataGet,
|
|
8
|
-
handleOauthRegisterPost,
|
|
9
|
-
handleOauthRevokePost,
|
|
10
|
-
handleOauthTokenPost,
|
|
11
|
-
oauthCorsHeaders
|
|
12
|
-
} from "./chunk-en76akaq.js";
|
|
13
|
-
import {
|
|
14
|
-
isValidCidr
|
|
15
|
-
} from "./chunk-88nhf6xt.js";
|
|
16
|
-
import"./chunk-3ek3knfm.js";
|
|
17
|
-
import {
|
|
18
|
-
getSupportedScopes
|
|
19
|
-
} from "./chunk-rxnyn7tf.js";
|
|
20
|
-
import"./chunk-k6fm3cmk.js";
|
|
21
|
-
import"./chunk-3rr24vhh.js";
|
|
22
|
-
import"./chunk-xcf742mf.js";
|
|
23
|
-
|
|
24
|
-
// src/sveltekit-mount-state.ts
|
|
25
|
-
var mountState = "available";
|
|
26
|
-
function getSvelteKitMountState() {
|
|
27
|
-
return mountState;
|
|
28
|
-
}
|
|
29
|
-
function setSvelteKitMountState(state) {
|
|
30
|
-
mountState = state;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// src/sveltekit-mount.ts
|
|
34
|
-
var primedIdentities = new WeakMap;
|
|
35
|
-
var missingRateLimitStoresDiagnostic = "OAuth rate limits are configured without rate-limit stores; OAuth endpoint rate limiting and failed-authentication lockout are disabled.";
|
|
36
|
-
var requiredOauthSeamFunctions = [
|
|
37
|
-
"fetchClientIdMetadataDocument",
|
|
38
|
-
"resolveIdentityBinding",
|
|
39
|
-
"resolveUserProfile",
|
|
40
|
-
"handleUnauthenticatedAuthorization",
|
|
41
|
-
"renderConsent",
|
|
42
|
-
"hashCredential"
|
|
43
|
-
];
|
|
44
|
-
function assertOauthSeamObject(value, path) {
|
|
45
|
-
if (!value || typeof value !== "object") {
|
|
46
|
-
throw new Error(`The SvelteKit MCP mount requires the OAuth host seam "${path}".`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function assertOauthSeamFunctions(value, path, names) {
|
|
50
|
-
for (const name of names) {
|
|
51
|
-
if (typeof value[name] !== "function") {
|
|
52
|
-
throw new Error(`The SvelteKit MCP mount requires the OAuth host seam "${path}.${name}".`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function assertOauthSeamNumber(value, path, minimumExclusive) {
|
|
57
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value <= minimumExclusive) {
|
|
58
|
-
throw new Error(`The SvelteKit MCP mount requires the OAuth host seam "${path}".`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function assertOauthStore(stores, name, requiredFunctions) {
|
|
62
|
-
assertOauthSeamObject(stores[name], `stores.${name}`);
|
|
63
|
-
assertOauthSeamFunctions(stores[name], `stores.${name}`, requiredFunctions);
|
|
64
|
-
}
|
|
65
|
-
function warnMissingRateLimitStores() {
|
|
66
|
-
process.stderr.write(`${JSON.stringify({
|
|
67
|
-
level: "warn",
|
|
68
|
-
operation: "sveltekit_mcp_mount",
|
|
69
|
-
protection: "oauth_rate_limits",
|
|
70
|
-
message: missingRateLimitStoresDiagnostic
|
|
71
|
-
})}
|
|
72
|
-
`);
|
|
73
|
-
}
|
|
74
|
-
function assertRequiredOauthSeams(seams) {
|
|
75
|
-
for (const name of requiredOauthSeamFunctions) {
|
|
76
|
-
if (typeof seams[name] !== "function") {
|
|
77
|
-
throw new Error(`The SvelteKit MCP mount requires the OAuth host seam "${name}".`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (seams.recordEvent !== undefined && typeof seams.recordEvent !== "function") {
|
|
81
|
-
throw new Error('The SvelteKit MCP mount requires the OAuth host seam "recordEvent".');
|
|
82
|
-
}
|
|
83
|
-
if (seams.crossInstanceMessaging !== undefined) {
|
|
84
|
-
assertOauthSeamObject(seams.crossInstanceMessaging, "crossInstanceMessaging");
|
|
85
|
-
assertOauthSeamFunctions(seams.crossInstanceMessaging, "crossInstanceMessaging", [
|
|
86
|
-
"publish",
|
|
87
|
-
"subscribe"
|
|
88
|
-
]);
|
|
89
|
-
}
|
|
90
|
-
assertOauthSeamObject(seams.stores, "stores");
|
|
91
|
-
assertOauthStore(seams.stores, "transactions", [
|
|
92
|
-
"create",
|
|
93
|
-
"consume",
|
|
94
|
-
"unconsume",
|
|
95
|
-
"deleteByBinding",
|
|
96
|
-
"deleteAllForUser",
|
|
97
|
-
"purgeExpired"
|
|
98
|
-
]);
|
|
99
|
-
assertOauthStore(seams.stores, "codes", [
|
|
100
|
-
"issue",
|
|
101
|
-
"findByHash",
|
|
102
|
-
"consume",
|
|
103
|
-
"unconsume",
|
|
104
|
-
"deleteAllForUser",
|
|
105
|
-
"purgeExpired"
|
|
106
|
-
]);
|
|
107
|
-
assertOauthStore(seams.stores, "tokens", [
|
|
108
|
-
"issueAuthorizationGrant",
|
|
109
|
-
"findByHash",
|
|
110
|
-
"rotateRefreshToken",
|
|
111
|
-
"revokeAccessToken",
|
|
112
|
-
"revokeRefreshToken",
|
|
113
|
-
"revokeFamily",
|
|
114
|
-
"deleteAllForUser",
|
|
115
|
-
"purgeExpired"
|
|
116
|
-
]);
|
|
117
|
-
assertOauthStore(seams.stores, "clients", ["register", "upsert", "findById", "update"]);
|
|
118
|
-
assertOauthSeamFunctions(seams.stores, "stores", ["deleteAllForUser"]);
|
|
119
|
-
assertOauthSeamObject(seams.scopes, "scopes");
|
|
120
|
-
assertOauthSeamObject(seams.scopes.vocabulary, "scopes.vocabulary");
|
|
121
|
-
assertOauthSeamFunctions(seams.scopes.vocabulary, "scopes.vocabulary", [
|
|
122
|
-
"isScope",
|
|
123
|
-
"defineTool",
|
|
124
|
-
"defineResource",
|
|
125
|
-
"definePrompt",
|
|
126
|
-
"defineRegistry"
|
|
127
|
-
]);
|
|
128
|
-
if (!Array.isArray(seams.scopes.vocabulary.scopes)) {
|
|
129
|
-
throw new Error('The SvelteKit MCP mount requires the OAuth host seam "scopes.vocabulary.scopes".');
|
|
130
|
-
}
|
|
131
|
-
assertOauthSeamObject(seams.scopes.vocabulary.descriptions, "scopes.vocabulary.descriptions");
|
|
132
|
-
if (!Array.isArray(seams.scopes.supportedScopes)) {
|
|
133
|
-
throw new Error('The SvelteKit MCP mount requires the OAuth host seam "scopes.supportedScopes".');
|
|
134
|
-
}
|
|
135
|
-
for (const [index, scope] of seams.scopes.supportedScopes.entries()) {
|
|
136
|
-
if (typeof scope !== "string" || !seams.scopes.vocabulary.isScope(scope)) {
|
|
137
|
-
throw new Error(`The SvelteKit MCP mount requires the OAuth host seam "scopes.supportedScopes[${index}]".`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
assertOauthSeamObject(seams.configuration, "configuration");
|
|
141
|
-
const configuration = seams.configuration;
|
|
142
|
-
if (typeof configuration.issuer !== "string" || configuration.issuer.trim().length === 0) {
|
|
143
|
-
throw new Error('The SvelteKit MCP mount requires the OAuth host seam "configuration.issuer".');
|
|
144
|
-
}
|
|
145
|
-
for (const name of ["baseUrl", "resource"]) {
|
|
146
|
-
if (!(configuration[name] instanceof URL)) {
|
|
147
|
-
throw new Error(`The SvelteKit MCP mount requires the OAuth host seam "configuration.${name}".`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
for (const name of [
|
|
151
|
-
"accessTokenTtlSeconds",
|
|
152
|
-
"refreshTokenTtlSeconds",
|
|
153
|
-
"clientSecretTtlSeconds"
|
|
154
|
-
]) {
|
|
155
|
-
assertOauthSeamNumber(configuration[name], `configuration.${name}`, 0);
|
|
156
|
-
}
|
|
157
|
-
assertOauthSeamFunctions(configuration, "configuration", ["isTrustedOrigin"]);
|
|
158
|
-
assertOauthSeamObject(configuration.trustedProxy, "configuration.trustedProxy");
|
|
159
|
-
if (!Array.isArray(configuration.trustedProxy.trustedProxyCidrs)) {
|
|
160
|
-
throw new Error('The SvelteKit MCP mount requires the OAuth host seam "configuration.trustedProxy.trustedProxyCidrs".');
|
|
161
|
-
}
|
|
162
|
-
for (const [index, cidr] of configuration.trustedProxy.trustedProxyCidrs.entries()) {
|
|
163
|
-
if (typeof cidr !== "string" || !isValidCidr(cidr)) {
|
|
164
|
-
throw new Error(`The SvelteKit MCP mount requires the OAuth host seam "configuration.trustedProxy.trustedProxyCidrs[${index}]".`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (configuration.trustedProxy.trustedProxyHeader !== undefined && !["x-forwarded-for", "forwarded", "cf-connecting-ip", "fly-client-ip"].includes(configuration.trustedProxy.trustedProxyHeader)) {
|
|
168
|
-
throw new Error('The SvelteKit MCP mount requires the OAuth host seam "configuration.trustedProxy.trustedProxyHeader".');
|
|
169
|
-
}
|
|
170
|
-
assertOauthSeamNumber(configuration.trustedProxy.trustedProxyHopCount, "configuration.trustedProxy.trustedProxyHopCount", -1);
|
|
171
|
-
if (!Number.isInteger(configuration.trustedProxy.trustedProxyHopCount)) {
|
|
172
|
-
throw new Error('The SvelteKit MCP mount requires the OAuth host seam "configuration.trustedProxy.trustedProxyHopCount".');
|
|
173
|
-
}
|
|
174
|
-
assertOauthSeamObject(configuration.rateLimits, "configuration.rateLimits");
|
|
175
|
-
assertOauthSeamNumber(configuration.rateLimits.maximumConcurrent, "configuration.rateLimits.maximumConcurrent", 0);
|
|
176
|
-
assertOauthSeamObject(configuration.rateLimits.categories, "configuration.rateLimits.categories");
|
|
177
|
-
for (const category of [
|
|
178
|
-
"oauth_authorize",
|
|
179
|
-
"oauth_register",
|
|
180
|
-
"oauth_token_network",
|
|
181
|
-
"oauth_token_client",
|
|
182
|
-
"oauth_revoke",
|
|
183
|
-
"mcp_network",
|
|
184
|
-
"mcp_user",
|
|
185
|
-
"failed_authentication"
|
|
186
|
-
]) {
|
|
187
|
-
const path = `configuration.rateLimits.categories.${category}`;
|
|
188
|
-
assertOauthSeamObject(configuration.rateLimits.categories[category], path);
|
|
189
|
-
assertOauthSeamNumber(configuration.rateLimits.categories[category].maximumRequests, `${path}.maximumRequests`, 0);
|
|
190
|
-
assertOauthSeamNumber(configuration.rateLimits.categories[category].windowSeconds, `${path}.windowSeconds`, 0);
|
|
191
|
-
}
|
|
192
|
-
assertOauthSeamObject(configuration.mcpUiExtension, "configuration.mcpUiExtension");
|
|
193
|
-
if (typeof configuration.mcpUiExtension.enabled !== "boolean") {
|
|
194
|
-
throw new Error('The SvelteKit MCP mount requires the OAuth host seam "configuration.mcpUiExtension.enabled".');
|
|
195
|
-
}
|
|
196
|
-
if (configuration.rateLimitStores === undefined) {
|
|
197
|
-
warnMissingRateLimitStores();
|
|
198
|
-
} else {
|
|
199
|
-
assertOauthSeamObject(configuration.rateLimitStores, "configuration.rateLimitStores");
|
|
200
|
-
assertOauthSeamObject(configuration.rateLimitStores.slidingWindow, "configuration.rateLimitStores.slidingWindow");
|
|
201
|
-
assertOauthSeamFunctions(configuration.rateLimitStores.slidingWindow, "configuration.rateLimitStores.slidingWindow", ["consume", "peek"]);
|
|
202
|
-
if (configuration.rateLimitStores.concurrencySlots !== undefined) {
|
|
203
|
-
assertOauthSeamObject(configuration.rateLimitStores.concurrencySlots, "configuration.rateLimitStores.concurrencySlots");
|
|
204
|
-
assertOauthSeamFunctions(configuration.rateLimitStores.concurrencySlots, "configuration.rateLimitStores.concurrencySlots", ["acquire", "renew", "release"]);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
function assertMountConfigurationAgreement(input) {
|
|
209
|
-
const expectedScopes = getSupportedScopes(input.registry);
|
|
210
|
-
const configuredScopes = [...input.oauthSeams.scopes.supportedScopes].sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
211
|
-
if (expectedScopes.length !== configuredScopes.length || expectedScopes.some((scope, index) => scope !== configuredScopes[index])) {
|
|
212
|
-
throw new Error('The SvelteKit MCP mount requires "scopes.supportedScopes" to match the mounted registry.');
|
|
213
|
-
}
|
|
214
|
-
const oauthConfiguration = input.oauthSeams.configuration;
|
|
215
|
-
const discoveryConfiguration = input.discoveryConfiguration;
|
|
216
|
-
if (oauthConfiguration.baseUrl.href !== `${oauthConfiguration.baseUrl.origin}/`) {
|
|
217
|
-
throw new Error('The SvelteKit MCP mount requires "configuration.baseUrl" to be an origin-only URL.');
|
|
218
|
-
}
|
|
219
|
-
if (discoveryConfiguration.issuer !== oauthConfiguration.issuer) {
|
|
220
|
-
throw new Error('The SvelteKit MCP mount requires "discoveryConfiguration.issuer" to match the OAuth host seams.');
|
|
221
|
-
}
|
|
222
|
-
if (discoveryConfiguration.baseUrl.href !== oauthConfiguration.baseUrl.href) {
|
|
223
|
-
throw new Error('The SvelteKit MCP mount requires "discoveryConfiguration.baseUrl" to match the OAuth host seams.');
|
|
224
|
-
}
|
|
225
|
-
if (discoveryConfiguration.resource.href !== oauthConfiguration.resource.href) {
|
|
226
|
-
throw new Error('The SvelteKit MCP mount requires "discoveryConfiguration.resource" to match the OAuth host seams.');
|
|
227
|
-
}
|
|
228
|
-
if (discoveryConfiguration.mcpUiExtension.enabled !== oauthConfiguration.mcpUiExtension.enabled) {
|
|
229
|
-
throw new Error('The SvelteKit MCP mount requires "discoveryConfiguration.mcpUiExtension" to match the OAuth host seams.');
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
function primeSvelteKitMcpIdentity(event, identity) {
|
|
233
|
-
primedIdentities.set(event, identity);
|
|
234
|
-
}
|
|
235
|
-
function createStatelessSeams(seams, runtime) {
|
|
236
|
-
return {
|
|
237
|
-
scopes: seams.scopes,
|
|
238
|
-
configuration: seams.configuration,
|
|
239
|
-
crossInstanceMessaging: seams.crossInstanceMessaging,
|
|
240
|
-
recordEvent: seams.recordEvent,
|
|
241
|
-
stores: {
|
|
242
|
-
clients: seams.stores.clients,
|
|
243
|
-
codes: seams.stores.codes,
|
|
244
|
-
tokens: seams.stores.tokens
|
|
245
|
-
},
|
|
246
|
-
hashCredential: seams.hashCredential,
|
|
247
|
-
publishGrantRevocation: (subjectId) => runtime.publishGrantRevocation(subjectId)
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
function preflightResponse() {
|
|
251
|
-
return new Response(null, { status: 204, headers: oauthCorsHeaders });
|
|
252
|
-
}
|
|
253
|
-
async function createSvelteKitMcpMount(input) {
|
|
254
|
-
const mountState2 = getSvelteKitMountState();
|
|
255
|
-
if (mountState2 === "constructing" || mountState2 === "live") {
|
|
256
|
-
throw new Error("The SvelteKit MCP mount has already been constructed in this process.");
|
|
257
|
-
}
|
|
258
|
-
if (mountState2 === "disposed") {
|
|
259
|
-
throw new Error("The SvelteKit MCP mount cannot be constructed again after disposal or failure.");
|
|
260
|
-
}
|
|
261
|
-
setSvelteKitMountState("constructing");
|
|
262
|
-
try {
|
|
263
|
-
assertRequiredOauthSeams(input.oauthSeams);
|
|
264
|
-
assertMountConfigurationAgreement(input);
|
|
265
|
-
if (!input.longLivedProcess) {
|
|
266
|
-
throw new Error("The MCP mount requires a long-lived process; request-scoped edge and serverless runtimes cannot preserve subscription state.");
|
|
267
|
-
}
|
|
268
|
-
await input.mcp.start();
|
|
269
|
-
} catch (error) {
|
|
270
|
-
setSvelteKitMountState("disposed");
|
|
271
|
-
try {
|
|
272
|
-
await input.mcp.shutdown();
|
|
273
|
-
} catch (shutdownError) {
|
|
274
|
-
throw new AggregateError([error, shutdownError], "The SvelteKit MCP mount failed to start and its cleanup also failed.", { cause: shutdownError });
|
|
275
|
-
}
|
|
276
|
-
throw error;
|
|
277
|
-
}
|
|
278
|
-
setSvelteKitMountState("live");
|
|
279
|
-
const getStatelessSeams = () => createStatelessSeams(input.oauthSeams, input.mcp);
|
|
280
|
-
let disposed = false;
|
|
281
|
-
return {
|
|
282
|
-
async handle({ event, resolve }) {
|
|
283
|
-
if (disposed || getSvelteKitMountState() !== "live") {
|
|
284
|
-
throw new Error("The SvelteKit MCP mount is disposed.");
|
|
285
|
-
}
|
|
286
|
-
if (!primedIdentities.has(event)) {
|
|
287
|
-
throw new Error(`The SvelteKit MCP mount requires the prior ${input.identityHandleName} handle to prime identity for every request. Ensure it appears earlier in sequence() and does not skip conditional requests.`);
|
|
288
|
-
}
|
|
289
|
-
const context = {
|
|
290
|
-
request: event.request,
|
|
291
|
-
requestUrl: event.url,
|
|
292
|
-
requestId: input.getRequestId?.(event) ?? crypto.randomUUID(),
|
|
293
|
-
socketAddress: event.getClientAddress(),
|
|
294
|
-
identity: primedIdentities.get(event) ?? null
|
|
295
|
-
};
|
|
296
|
-
const method = event.request.method;
|
|
297
|
-
const path = event.url.pathname;
|
|
298
|
-
if (method === "OPTIONS" && (path.startsWith("/.well-known/") || path.startsWith("/oauth/"))) {
|
|
299
|
-
return preflightResponse();
|
|
300
|
-
}
|
|
301
|
-
if (method === "GET" && path === "/.well-known/oauth-authorization-server") {
|
|
302
|
-
return handleOauthAuthorizationMetadataGet(context, input.discoveryConfiguration, input.registry);
|
|
303
|
-
}
|
|
304
|
-
if (method === "GET" && path === "/.well-known/oauth-protected-resource") {
|
|
305
|
-
return handleOauthProtectedResourceMetadataGet(context, input.discoveryConfiguration, input.registry);
|
|
306
|
-
}
|
|
307
|
-
if (method === "GET" && path === "/.well-known/oauth-protected-resource/mcp") {
|
|
308
|
-
return handleOauthProtectedResourceMcpMetadataGet(context, input.discoveryConfiguration, input.registry);
|
|
309
|
-
}
|
|
310
|
-
if (method === "GET" && path === "/oauth/authorize") {
|
|
311
|
-
return handleOauthAuthorizeGet(context, input.oauthSeams);
|
|
312
|
-
}
|
|
313
|
-
if (method === "POST" && path === "/oauth/authorize/approve") {
|
|
314
|
-
return handleOauthAuthorizeApprove(context, input.oauthSeams);
|
|
315
|
-
}
|
|
316
|
-
if (method === "POST" && path === "/oauth/authorize/deny") {
|
|
317
|
-
return handleOauthAuthorizeDeny(context, input.oauthSeams);
|
|
318
|
-
}
|
|
319
|
-
if (method === "POST" && path === "/oauth/register") {
|
|
320
|
-
return handleOauthRegisterPost(context, getStatelessSeams());
|
|
321
|
-
}
|
|
322
|
-
if (method === "POST" && path === "/oauth/token") {
|
|
323
|
-
return handleOauthTokenPost(context, getStatelessSeams());
|
|
324
|
-
}
|
|
325
|
-
if (method === "POST" && path === "/oauth/revoke") {
|
|
326
|
-
return handleOauthRevokePost(context, getStatelessSeams());
|
|
327
|
-
}
|
|
328
|
-
if (path === "/mcp")
|
|
329
|
-
return input.mcp.handle(context);
|
|
330
|
-
return resolve(event);
|
|
331
|
-
},
|
|
332
|
-
async dispose() {
|
|
333
|
-
if (disposed)
|
|
334
|
-
return;
|
|
335
|
-
disposed = true;
|
|
336
|
-
setSvelteKitMountState("disposed");
|
|
337
|
-
await input.mcp.shutdown();
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
export {
|
|
342
|
-
createSvelteKitMcpMount,
|
|
343
|
-
primeSvelteKitMcpIdentity
|
|
344
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { McpRegistry } from './scope-vocabulary.js';
|
|
2
|
-
import type { McpScope } from './scopes.js';
|
|
3
|
-
/**
|
|
4
|
-
* This repository's own registry, assembled from the barrels above.
|
|
5
|
-
*
|
|
6
|
-
* It exists because `createMcpServer` and `getSupportedScopes` now take a
|
|
7
|
-
* registry rather than reaching for module-level constants, and this
|
|
8
|
-
* repository is itself one of their consumers. A second consumer builds its
|
|
9
|
-
* own `McpRegistry` and passes that instead — which is the whole point of
|
|
10
|
-
* the change, and the reason the registry is a required argument rather
|
|
11
|
-
* than one defaulting to this value. A default here would mean a consumer
|
|
12
|
-
* that forgot to pass its own silently served `get_user_profile` in
|
|
13
|
-
* production, and this package already holds the position that a wrong
|
|
14
|
-
* default is worse than a missing one.
|
|
15
|
-
*/
|
|
16
|
-
export declare const templateRegistry: McpRegistry<McpScope>;
|
package/dist/tool-response.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SEC-004: the cap is measured in UTF-8 bytes, which is what actually goes on
|
|
3
|
-
* the wire — not `String.length`, which counts UTF-16 code units.
|
|
4
|
-
*
|
|
5
|
-
* The two diverge by up to 3x for non-ASCII output: 250,000 CJK characters
|
|
6
|
-
* satisfy a 256K *character* check and encode to roughly 750KB, nearly three
|
|
7
|
-
* times the advertised limit, on a bound whose entire purpose is stopping
|
|
8
|
-
* oversized payloads reaching a client.
|
|
9
|
-
*
|
|
10
|
-
* That defect survived its own tests because they pad with ASCII, where
|
|
11
|
-
* characters and bytes coincide — the cap read as enforced while the
|
|
12
|
-
* guarantee was absent for exactly the inputs that would breach it.
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Counts UTF-8 bytes without materializing the encoded payload.
|
|
16
|
-
*
|
|
17
|
-
* `TextEncoder.encode()` would be the obvious way to measure this, and it is
|
|
18
|
-
* the wrong one here: it allocates a second buffer holding the entire encoded
|
|
19
|
-
* result, up to three times the string's UTF-16 length, *before* the cap can
|
|
20
|
-
* reject anything. That puts the largest allocation on exactly the oversized
|
|
21
|
-
* multi-byte responses this bound exists to refuse — a guard that can exhaust
|
|
22
|
-
* memory on the input it was added to stop.
|
|
23
|
-
*
|
|
24
|
-
* Iterating instead keeps the extra memory at one integer. `for...of` walks
|
|
25
|
-
* code points rather than code units, so a surrogate pair is seen once as a
|
|
26
|
-
* single value above `0xFFFF` and correctly counted as four bytes; a lone
|
|
27
|
-
* surrogate is yielded on its own and lands in the three-byte branch, which
|
|
28
|
-
* matches how `TextEncoder` encodes it (as U+FFFD, also three bytes).
|
|
29
|
-
*
|
|
30
|
-
* It counts the whole string rather than stopping at the cap, deliberately:
|
|
31
|
-
* the error reports the real byte length, and that number is the only thing
|
|
32
|
-
* telling whoever hit the limit how far over they were. Counting is bounded
|
|
33
|
-
* work on a string that already exists in memory; allocating a copy of it was
|
|
34
|
-
* the actual problem.
|
|
35
|
-
*/
|
|
36
|
-
declare function utf8ByteLength(text: string): number;
|
|
37
|
-
/** Exported for the test that pins this against `TextEncoder`. */
|
|
38
|
-
export declare const __utf8ByteLengthForTests: typeof utf8ByteLength;
|
|
39
|
-
export declare function createToolTextResponse(text: string): {
|
|
40
|
-
content: [{
|
|
41
|
-
type: "text";
|
|
42
|
-
text: string;
|
|
43
|
-
}];
|
|
44
|
-
} | {
|
|
45
|
-
isError: boolean;
|
|
46
|
-
content: [{
|
|
47
|
-
type: "text";
|
|
48
|
-
text: string;
|
|
49
|
-
}];
|
|
50
|
-
};
|
|
51
|
-
export declare function createToolJsonResponse(data: unknown): {
|
|
52
|
-
content: [{
|
|
53
|
-
type: "text";
|
|
54
|
-
text: string;
|
|
55
|
-
}];
|
|
56
|
-
} | {
|
|
57
|
-
content: {
|
|
58
|
-
type: "text";
|
|
59
|
-
text: string;
|
|
60
|
-
}[];
|
|
61
|
-
isError: true;
|
|
62
|
-
} | {
|
|
63
|
-
isError: boolean;
|
|
64
|
-
content: [{
|
|
65
|
-
type: "text";
|
|
66
|
-
text: string;
|
|
67
|
-
}];
|
|
68
|
-
};
|
|
69
|
-
export declare function createToolErrorResponse(message: string): {
|
|
70
|
-
isError: boolean;
|
|
71
|
-
content: [{
|
|
72
|
-
type: "text";
|
|
73
|
-
text: string;
|
|
74
|
-
}];
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* META-001: the response shape for a tool that declares an `outputSchema`.
|
|
78
|
-
* `structuredContent` carries the data a client validates against that
|
|
79
|
-
* schema; `summary` is the separate, intentional human-readable text the
|
|
80
|
-
* roadmap asks for ("text content only for an intentional human-readable
|
|
81
|
-
* summary") rather than a second copy of the same JSON as text.
|
|
82
|
-
*
|
|
83
|
-
* Both the summary and the structured payload go through the same
|
|
84
|
-
* SEC-004 size bound as every other tool response.
|
|
85
|
-
*/
|
|
86
|
-
export declare function createToolStructuredResponse<T>(data: T, summary: string): {
|
|
87
|
-
content: {
|
|
88
|
-
type: "text";
|
|
89
|
-
text: string;
|
|
90
|
-
}[];
|
|
91
|
-
isError: boolean;
|
|
92
|
-
} | {
|
|
93
|
-
structuredContent: T;
|
|
94
|
-
content: [{
|
|
95
|
-
type: "text";
|
|
96
|
-
text: string;
|
|
97
|
-
}];
|
|
98
|
-
isError?: undefined;
|
|
99
|
-
};
|
|
100
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const getUserProfileTool: import("../index.js").McpToolDefinition<z.ZodObject<{}, z.core.$strip>, z.ZodObject<{
|
|
3
|
-
id: z.ZodString;
|
|
4
|
-
email: z.ZodString;
|
|
5
|
-
name: z.ZodString;
|
|
6
|
-
image: z.ZodNullable<z.ZodString>;
|
|
7
|
-
role: z.ZodString;
|
|
8
|
-
}, z.core.$strip>, "profile:read" | "audit:read" | "prompts:read">;
|