@lostgradient/mcp 0.1.0 → 0.2.1
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/README.md +68 -8
- package/dist/chunk-3ek3knfm.js +73 -0
- package/dist/{chunk-v14p4gng.js → chunk-3rr24vhh.js} +4 -1
- package/dist/chunk-6ekjtvcq.js +273 -0
- package/dist/chunk-7dpts3r9.js +909 -0
- package/dist/chunk-88nhf6xt.js +449 -0
- package/dist/{chunk-psnez3q2.js → chunk-k6fm3cmk.js} +23 -2
- package/dist/chunk-rxnyn7tf.js +19 -0
- package/dist/{chunk-mf3t0afg.js → chunk-wfty87ws.js} +1 -1
- package/dist/{chunk-wmkqd45r.js → chunk-xcf742mf.js} +1 -1
- package/dist/chunk-yf4nw40e.js +1102 -0
- package/dist/conformance.d.ts +43 -0
- package/dist/env.d.ts +1 -1
- package/dist/env.js +2 -2
- package/dist/environment-schema.d.ts +1 -1
- package/dist/environment-schema.js +1 -1
- package/dist/http/authenticate.d.ts +35 -0
- package/dist/http/authorization-header.d.ts +5 -0
- package/dist/http/grant-revocation-channel.d.ts +24 -0
- package/dist/http/handler.d.ts +32 -0
- package/dist/http/index.d.ts +27 -0
- package/dist/http/index.js +813 -0
- package/dist/http/request-context.d.ts +17 -0
- package/dist/http/responses.d.ts +11 -0
- package/dist/http/serving-layer.d.ts +18 -0
- package/dist/http/user-handler-cache.d.ts +37 -0
- package/dist/http/user-server-event-bus.d.ts +35 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +230 -940
- package/dist/logger.d.ts +20 -0
- package/dist/logger.js +9 -5
- package/dist/oauth/authorize-endpoint.d.ts +5 -0
- package/dist/oauth/canonicalize-ip-address.d.ts +20 -0
- package/dist/oauth/client-authentication.d.ts +10 -0
- package/dist/oauth/client-metadata-documents.d.ts +52 -0
- package/dist/oauth/client-metadata-documents.js +19 -0
- package/dist/oauth/discovery-metadata.d.ts +19 -0
- package/dist/oauth/endpoint-rate-limits.d.ts +10 -0
- package/dist/oauth/endpoint-responses.d.ts +10 -0
- package/dist/oauth/index.d.ts +214 -0
- package/dist/oauth/index.js +69 -0
- package/dist/oauth/network-identity.d.ts +32 -0
- package/dist/oauth/pkce-validation.d.ts +2 -0
- package/dist/oauth/postgres/client-store.d.ts +12 -0
- package/dist/oauth/postgres/code-store.d.ts +14 -0
- package/dist/oauth/postgres/database.d.ts +18 -0
- package/dist/oauth/postgres/index.d.ts +11 -0
- package/dist/oauth/postgres/index.js +584 -0
- package/dist/oauth/postgres/schema.d.ts +1455 -0
- package/dist/oauth/postgres/token-store.d.ts +16 -0
- package/dist/oauth/postgres/transaction-store.d.ts +14 -0
- package/dist/oauth/redirect-uri-matching.d.ts +2 -0
- package/dist/oauth/registration-endpoint.d.ts +2 -0
- package/dist/oauth/request-body.d.ts +14 -0
- package/dist/oauth/revocation-endpoint.d.ts +2 -0
- package/dist/oauth/safe-public-https-fetch.d.ts +28 -0
- package/dist/oauth/scope-utilities.d.ts +15 -0
- package/dist/oauth/security-utilities.d.ts +8 -0
- package/dist/oauth/stores.d.ts +225 -0
- package/dist/oauth/stores.js +0 -0
- package/dist/oauth/testing/contract-fixtures.d.ts +134 -0
- package/dist/oauth/testing/index.d.ts +56 -0
- package/dist/oauth/testing/index.js +330 -0
- package/dist/oauth/token-endpoint.d.ts +2 -0
- package/dist/oauth-scope-configuration.d.ts +3 -0
- package/dist/rate-limit/in-memory-sliding-window-store.d.ts +3 -0
- package/dist/rate-limit/index.d.ts +23 -0
- package/dist/rate-limit/index.js +29 -0
- package/dist/rate-limit/mcp-concurrency-limiter.d.ts +26 -0
- package/dist/rate-limit/rate-limit-response.d.ts +1 -0
- package/dist/rate-limit/redis-sliding-window-store.d.ts +2 -0
- package/dist/rate-limit/request-rate-limiter.d.ts +10 -0
- package/dist/rate-limit/sliding-window-rate-limiter.d.ts +16 -0
- package/dist/scopes.d.ts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/sveltekit-mount-state.d.ts +4 -0
- package/dist/sveltekit-mount.d.ts +43 -0
- package/dist/sveltekit-mount.js +332 -0
- package/dist/tool-response.d.ts +6 -0
- package/dist/types/primitives.d.ts +1 -1
- package/dist/ui-extension-support.d.ts +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +56 -4
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { McpRegistry, McpScopeVocabulary } from './scope-vocabulary.js';
|
|
2
|
+
import type { McpUserProfile } from './types/primitives.js';
|
|
3
|
+
export type McpConformanceEra = 'modern' | 'legacy';
|
|
4
|
+
export type McpConformanceResult = {
|
|
5
|
+
readonly era: McpConformanceEra;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly status: 'passed' | 'failed';
|
|
8
|
+
readonly error?: string;
|
|
9
|
+
};
|
|
10
|
+
export type McpConformanceIdentity = {
|
|
11
|
+
readonly userId: string;
|
|
12
|
+
readonly user: McpUserProfile;
|
|
13
|
+
};
|
|
14
|
+
export type ConsumerConformanceOptions<Scope extends string> = {
|
|
15
|
+
readonly registry: McpRegistry<Scope>;
|
|
16
|
+
readonly scopeVocabulary: McpScopeVocabulary<Scope>;
|
|
17
|
+
readonly enableConformanceMode?: boolean;
|
|
18
|
+
/** Stable application identity used for every stateless request. */
|
|
19
|
+
readonly identity?: McpConformanceIdentity;
|
|
20
|
+
};
|
|
21
|
+
export type RunMcpConformanceOptions<Scope extends string> = Omit<ConsumerConformanceOptions<Scope>, 'enableConformanceMode'> & {
|
|
22
|
+
readonly era: McpConformanceEra;
|
|
23
|
+
/** Valid arguments for the consumer tools the harness should invoke. */
|
|
24
|
+
readonly toolProbes?: Readonly<Record<string, Record<string, unknown>>>;
|
|
25
|
+
/** Registry resource URIs the harness should read. */
|
|
26
|
+
readonly resourceProbes?: readonly string[];
|
|
27
|
+
/** Valid arguments for the consumer prompts the harness should get. */
|
|
28
|
+
readonly promptProbes?: Readonly<Record<string, Record<string, string>>>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Creates the same stateless MCP boundary used by the standalone conformance
|
|
32
|
+
* server, but against a consumer-owned registry and scope vocabulary.
|
|
33
|
+
* Localhost DNS-rebinding validation is intentionally outside every mode
|
|
34
|
+
* branch so enabling or disabling conformance fixtures cannot disable it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createConsumerConformanceHandler<Scope extends string>(options: ConsumerConformanceOptions<Scope>): {
|
|
37
|
+
fetch(request: Request): Promise<Response>;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Exercises one protocol era and returns independently actionable results.
|
|
41
|
+
* A failed behavior never prevents later behaviors from running.
|
|
42
|
+
*/
|
|
43
|
+
export declare function runMcpConformance<Scope extends string>(options: RunMcpConformanceOptions<Scope>): Promise<readonly McpConformanceResult[]>;
|
package/dist/env.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
declare const mcpServerEnvironmentObject: z.ZodObject<{
|
|
3
|
-
MCP_SERVER_NAME: z.
|
|
3
|
+
MCP_SERVER_NAME: z.ZodString;
|
|
4
4
|
MCP_CONFORMANCE_MODE: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
5
5
|
true: "true";
|
|
6
6
|
false: "false";
|
package/dist/env.js
CHANGED
|
@@ -7,7 +7,7 @@ import { z } from 'zod';
|
|
|
7
7
|
* has no side effects: it never reads `process.env` and never throws.
|
|
8
8
|
*/
|
|
9
9
|
export declare const mcpServerEnvironmentSchema: {
|
|
10
|
-
MCP_SERVER_NAME: z.
|
|
10
|
+
MCP_SERVER_NAME: z.ZodString;
|
|
11
11
|
MCP_CONFORMANCE_MODE: z.ZodPipe<z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
12
12
|
true: "true";
|
|
13
13
|
false: "false";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AuthInfo } from '@modelcontextprotocol/server';
|
|
2
|
+
import type { OAuthRequestContext, ResolveUserProfile, TrustedProxyConfiguration } from '../oauth/index.js';
|
|
3
|
+
import type { AccessToken, TokenStore } from '../oauth/stores.js';
|
|
4
|
+
import type { RequestRateLimiter } from '../rate-limit/index.js';
|
|
5
|
+
export type McpAuthenticationOutcome = 'success' | 'expired_or_invalid_token' | 'invalid_resource';
|
|
6
|
+
export type McpAuthenticationConfiguration = {
|
|
7
|
+
resource: URL;
|
|
8
|
+
protocolVersion: string;
|
|
9
|
+
supportedScopes: readonly string[];
|
|
10
|
+
allowedOrigins: ReadonlySet<string>;
|
|
11
|
+
maximumBearerTokenLength: number;
|
|
12
|
+
maximumFailedAuthenticationAttempts: number;
|
|
13
|
+
dnsRebindingProtection: boolean;
|
|
14
|
+
trustedProxy: TrustedProxyConfiguration;
|
|
15
|
+
};
|
|
16
|
+
export type McpAuthenticationSeams = {
|
|
17
|
+
tokens: TokenStore;
|
|
18
|
+
resolveUserProfile: ResolveUserProfile;
|
|
19
|
+
findTokenAndUserProfileByHash?(tokenHash: string): Promise<{
|
|
20
|
+
token: AccessToken;
|
|
21
|
+
profile: NonNullable<Awaited<ReturnType<ResolveUserProfile>>>;
|
|
22
|
+
} | null>;
|
|
23
|
+
hashCredential(value: string): string;
|
|
24
|
+
rateLimiter: Pick<RequestRateLimiter, 'consume' | 'peek'>;
|
|
25
|
+
recordEvent(outcome: McpAuthenticationOutcome, requestId?: string): void;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Authenticates in this fixed order: rebinding, origin, preflight, lockout,
|
|
29
|
+
* bearer scheme, bearer bounds and lookup, then resource audience.
|
|
30
|
+
*/
|
|
31
|
+
export declare function authenticateMcpUser(input: {
|
|
32
|
+
context: OAuthRequestContext;
|
|
33
|
+
configuration: McpAuthenticationConfiguration;
|
|
34
|
+
seams: McpAuthenticationSeams;
|
|
35
|
+
}): Promise<Response | AuthInfo>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CrossInstanceMessaging } from '../oauth/index.js';
|
|
2
|
+
export type GrantRevocationRetryConfiguration = {
|
|
3
|
+
initialDelayMilliseconds: number;
|
|
4
|
+
maximumDelayMilliseconds: number;
|
|
5
|
+
};
|
|
6
|
+
/** Coordinates live-stream closure after a committed grant revocation. */
|
|
7
|
+
export declare class GrantRevocationChannel {
|
|
8
|
+
private readonly closeLocalUser;
|
|
9
|
+
private readonly messaging?;
|
|
10
|
+
private readonly onError;
|
|
11
|
+
private readonly retryConfiguration;
|
|
12
|
+
private unsubscribe;
|
|
13
|
+
private startup;
|
|
14
|
+
private closeRequested;
|
|
15
|
+
private finishRetryDelay;
|
|
16
|
+
private retryDelayMilliseconds;
|
|
17
|
+
constructor(closeLocalUser: (userId: string) => void | Promise<unknown>, messaging?: CrossInstanceMessaging | undefined, onError?: (error: unknown, userId?: string) => void, retryConfiguration?: GrantRevocationRetryConfiguration);
|
|
18
|
+
start(): Promise<void>;
|
|
19
|
+
publish(userId: string): Promise<void>;
|
|
20
|
+
close(): Promise<void>;
|
|
21
|
+
private subscribe;
|
|
22
|
+
private waitBeforeRetry;
|
|
23
|
+
private runLocalCloser;
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AuthInfo } from '@modelcontextprotocol/server';
|
|
2
|
+
import type { McpRegistry } from '../scope-vocabulary.js';
|
|
3
|
+
import type { CrossInstanceMessaging } from '../oauth/index.js';
|
|
4
|
+
export type McpHandlerConfiguration = {
|
|
5
|
+
protocolVersion: string;
|
|
6
|
+
maximumRequestBodyBytes: number;
|
|
7
|
+
maximumSubscriptionsPerUser: number;
|
|
8
|
+
userHandlerSweepIntervalMilliseconds: number;
|
|
9
|
+
userHandlerIdleMilliseconds: number;
|
|
10
|
+
enableUiExtension: boolean;
|
|
11
|
+
enableConformanceMode: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type McpHandlerSeams = {
|
|
14
|
+
messaging?: CrossInstanceMessaging;
|
|
15
|
+
markServerOnlyCloseableStream?(response: Response): Response;
|
|
16
|
+
reportDegradation(degradation: 'single_instance_messaging_fallback'): void;
|
|
17
|
+
recordEvent(outcome: 'transport_failure' | 'insufficient_scope'): void;
|
|
18
|
+
onError(error: unknown, operation: string, userId?: string): void;
|
|
19
|
+
};
|
|
20
|
+
export type McpServingHandler = {
|
|
21
|
+
start(): Promise<void>;
|
|
22
|
+
handle(request: Request, authInfo: AuthInfo): Promise<Response>;
|
|
23
|
+
publishUserResourceUpdate(userId: string, uri: string): void;
|
|
24
|
+
publishGrantRevocation(userId: string): Promise<void>;
|
|
25
|
+
closeUser(userId: string): Promise<boolean>;
|
|
26
|
+
shutdown(): Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
export declare function createMcpServingHandler<Scope extends string>(input: {
|
|
29
|
+
registry: McpRegistry<Scope>;
|
|
30
|
+
configuration: McpHandlerConfiguration;
|
|
31
|
+
seams: McpHandlerSeams;
|
|
32
|
+
}): McpServingHandler;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as authorizationHeaderModule from './authorization-header.js';
|
|
2
|
+
import * as grantRevocationModule from './grant-revocation-channel.js';
|
|
3
|
+
import * as handlerModule from './handler.js';
|
|
4
|
+
import * as requestContextModule from './request-context.js';
|
|
5
|
+
import * as responsesModule from './responses.js';
|
|
6
|
+
import * as servingLayerModule from './serving-layer.js';
|
|
7
|
+
import * as userHandlerCacheModule from './user-handler-cache.js';
|
|
8
|
+
import * as userServerEventBusModule from './user-server-event-bus.js';
|
|
9
|
+
export declare const parseAuthorizationHeader: typeof authorizationHeaderModule.parseAuthorizationHeader;
|
|
10
|
+
export declare const GrantRevocationChannel: typeof grantRevocationModule.GrantRevocationChannel;
|
|
11
|
+
export declare const createMcpServingHandler: typeof handlerModule.createMcpServingHandler;
|
|
12
|
+
export declare const buildMcpAuthInfo: typeof requestContextModule.buildMcpAuthInfo;
|
|
13
|
+
export declare const readMcpRequestAuthExtra: typeof requestContextModule.readMcpRequestAuthExtra;
|
|
14
|
+
export declare const createMcpCorsHeaders: typeof responsesModule.createMcpCorsHeaders;
|
|
15
|
+
export declare const createMcpProtocolErrorResponse: typeof responsesModule.createMcpProtocolErrorResponse;
|
|
16
|
+
export declare const isMcpOriginAllowed: typeof responsesModule.isMcpOriginAllowed;
|
|
17
|
+
export declare const createMcpHttpServingLayer: typeof servingLayerModule.createMcpHttpServingLayer;
|
|
18
|
+
export declare const McpUserHandlerCache: typeof userHandlerCacheModule.McpUserHandlerCache;
|
|
19
|
+
export declare const createUserServerEventBus: typeof userServerEventBusModule.createUserServerEventBus;
|
|
20
|
+
export declare const CrossInstanceUserServerEventBus: typeof userServerEventBusModule.CrossInstanceUserServerEventBus;
|
|
21
|
+
export type { McpAuthenticationConfiguration, McpAuthenticationOutcome, McpAuthenticationSeams, } from './authenticate.js';
|
|
22
|
+
export type { GrantRevocationRetryConfiguration } from './grant-revocation-channel.js';
|
|
23
|
+
export type { McpHandlerConfiguration, McpHandlerSeams, McpServingHandler } from './handler.js';
|
|
24
|
+
export type { McpRequestAuthExtra } from './request-context.js';
|
|
25
|
+
export type { McpHttpServingLayer } from './serving-layer.js';
|
|
26
|
+
export type { McpHandlerLifecycleError, McpUserHandlerEntry } from './user-handler-cache.js';
|
|
27
|
+
export type { McpMessagingError, UserServerEventBus } from './user-server-event-bus.js';
|