@every-app/sdk 0.3.0-rc.12 → 0.3.0-rc.14
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 +7 -8
- package/dist/cloudflare/worker.d.ts +18 -9
- package/dist/cloudflare/worker.d.ts.map +1 -1
- package/dist/cloudflare/worker.js +13 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/appSettings.d.ts +136 -81
- package/dist/internal/appSettings.d.ts.map +1 -1
- package/dist/internal/appSettings.js +263 -144
- package/dist/internal/capabilities.d.ts +12 -0
- package/dist/internal/capabilities.d.ts.map +1 -1
- package/dist/internal/gatewaySettings.d.ts +4 -14
- package/dist/internal/gatewaySettings.d.ts.map +1 -1
- package/dist/internal/gatewaySettings.js +5 -17
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +1 -0
- package/dist/internal/mcpOAuth.d.ts +210 -0
- package/dist/internal/mcpOAuth.d.ts.map +1 -0
- package/dist/internal/mcpOAuth.js +735 -0
- package/dist/internal/oauthBuiltIns.d.ts +1 -1
- package/dist/internal/oauthBuiltIns.js +1 -1
- package/dist/internal/oauthSpec.d.ts +1 -1
- package/dist/internal/oauthSpec.d.ts.map +1 -1
- package/dist/internal/oauthSpec.js +51 -1
- package/dist/internal/providerRegistry.d.ts +4 -3
- package/dist/internal/providerRegistry.d.ts.map +1 -1
- package/dist/internal/providerRegistry.js +11 -3
- package/dist/internal/remoteMcp.d.ts +158 -41
- package/dist/internal/remoteMcp.d.ts.map +1 -1
- package/dist/internal/remoteMcp.js +254 -114
- package/dist/manifest.d.ts +49 -13
- package/dist/manifest.d.ts.map +1 -1
- package/dist/server/tools.d.ts +5 -2
- package/dist/server/tools.d.ts.map +1 -1
- package/dist/server/tools.js +5 -2
- package/package.json +1 -1
|
@@ -29,20 +29,10 @@ export type SettableGatewaySetting = Exclude<CapabilitySecret, (typeof INSTALL_O
|
|
|
29
29
|
*/
|
|
30
30
|
export declare const SETTABLE_GATEWAY_SETTINGS: readonly SettableGatewaySetting[];
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* registry
|
|
36
|
-
* names (`everyapp secret set` reads no registry to decide), an app's own
|
|
37
|
-
* secret can never take one (the manifest validator refuses the family),
|
|
38
|
-
* and a remote server can never be given a fixed provider key.
|
|
39
|
-
*/
|
|
40
|
-
export declare const REMOTE_MCP_SECRET_PATTERN: RegExp;
|
|
41
|
-
/** Whether `name` is a remote MCP app's credential name (`TREG_MCP_TOKEN`). */
|
|
42
|
-
export declare function isRemoteMcpSecretName(name: string): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Whether `everyapp secret set <name>` changes the Gateway: one of the
|
|
45
|
-
* fixed settings, or a remote MCP app's credential name.
|
|
32
|
+
* Whether `everyapp secret set <name>` changes the Gateway because the
|
|
33
|
+
* catalog or the Gateway itself reads it. A registered provider row's
|
|
34
|
+
* settings (a remote MCP app's `<APPID>_MCP_TOKEN` among them) are the
|
|
35
|
+
* registry's (`providerRegistry().settingNames()`), checked at run time.
|
|
46
36
|
*/
|
|
47
37
|
export declare function isSettableGatewaySetting(name: string): boolean;
|
|
48
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gatewaySettings.d.ts","sourceRoot":"","sources":["../../src/internal/gatewaySettings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAM3B;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,mLASjC,CAAC;AAMX,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElE;AAmBD,mGAAmG;AACnG,eAAO,MAAM,oBAAoB,+kBA+BvB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAC9B,OAAO,CAAC,gBAAgB,EAAE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,OAAO,CAE7D;AAmBD,iDAAiD;AACjD,eAAO,MAAM,8BAA8B,sFAC0C,CAAC;AAEtF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM7D;AAED,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAQ5E"}
|
|
@@ -91,25 +91,13 @@ export const SETTABLE_GATEWAY_SETTINGS = [
|
|
|
91
91
|
];
|
|
92
92
|
const SETTABLE = new Set(SETTABLE_GATEWAY_SETTINGS);
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* registry
|
|
98
|
-
* names (`everyapp secret set` reads no registry to decide), an app's own
|
|
99
|
-
* secret can never take one (the manifest validator refuses the family),
|
|
100
|
-
* and a remote server can never be given a fixed provider key.
|
|
101
|
-
*/
|
|
102
|
-
export const REMOTE_MCP_SECRET_PATTERN = /^[A-Z][A-Z0-9_]*_MCP_TOKEN$/;
|
|
103
|
-
/** Whether `name` is a remote MCP app's credential name (`TREG_MCP_TOKEN`). */
|
|
104
|
-
export function isRemoteMcpSecretName(name) {
|
|
105
|
-
return REMOTE_MCP_SECRET_PATTERN.test(name);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Whether `everyapp secret set <name>` changes the Gateway: one of the
|
|
109
|
-
* fixed settings, or a remote MCP app's credential name.
|
|
94
|
+
* Whether `everyapp secret set <name>` changes the Gateway because the
|
|
95
|
+
* catalog or the Gateway itself reads it. A registered provider row's
|
|
96
|
+
* settings (a remote MCP app's `<APPID>_MCP_TOKEN` among them) are the
|
|
97
|
+
* registry's (`providerRegistry().settingNames()`), checked at run time.
|
|
110
98
|
*/
|
|
111
99
|
export function isSettableGatewaySetting(name) {
|
|
112
|
-
return SETTABLE.has(name)
|
|
100
|
+
return SETTABLE.has(name);
|
|
113
101
|
}
|
|
114
102
|
/**
|
|
115
103
|
* Settable Gateway settings whose value is a plain word, address, list
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./audit.js";
|
|
|
18
18
|
export * from "./providerSpec.js";
|
|
19
19
|
export * from "./providerRegistry.js";
|
|
20
20
|
export * from "./remoteMcp.js";
|
|
21
|
+
export * from "./mcpOAuth.js";
|
|
21
22
|
export * from "./signInProviders.js";
|
|
22
23
|
export * from "./devProviders.js";
|
|
23
24
|
export { ConfigurationError, IdentityError, assertOrganizationPin, getIdentityFromRequest, parsePublicKeys, resolveVerifyOptions, verifyIdentity, verifyIdentityJwt, verifyPublicMarkerJwt, verifySystemJwt, type IdentityResult, type RequestIdentityOptions, type VerifiedIdentity, type VerifyOptions, } from "./identity.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC"}
|
package/dist/internal/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./audit.js";
|
|
|
18
18
|
export * from "./providerSpec.js";
|
|
19
19
|
export * from "./providerRegistry.js";
|
|
20
20
|
export * from "./remoteMcp.js";
|
|
21
|
+
export * from "./mcpOAuth.js";
|
|
21
22
|
export * from "./signInProviders.js";
|
|
22
23
|
export * from "./devProviders.js";
|
|
23
24
|
export { ConfigurationError, IdentityError, assertOrganizationPin, getIdentityFromRequest, parsePublicKeys, resolveVerifyOptions, verifyIdentity, verifyIdentityJwt, verifyPublicMarkerJwt, verifySystemJwt, } from "./identity.js";
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth to remote MCP servers (docs/design/2026-11-mcp-apps-auth.md, the
|
|
3
|
+
* MCP authorization spec): discovering a server's authorization server,
|
|
4
|
+
* registering a client with it, and the provider specs `everyapp mcp add`
|
|
5
|
+
* and the Gateway's "Add an MCP server" write for an app's own credential
|
|
6
|
+
* (`<appId>-mcp`, ./remoteMcp.ts). Pure apart from the injected `fetch`:
|
|
7
|
+
* the CLI runs it from the operator's machine, the Gateway in-process.
|
|
8
|
+
*
|
|
9
|
+
* Every fetch here is bounded the same way: https only, a public host
|
|
10
|
+
* (`publicHostProblem`, and no IP literal), the default port, no redirects
|
|
11
|
+
* followed (`redirect: "manual"`; a 3xx is a failure), at most
|
|
12
|
+
* {@link MCP_OAUTH_MAX_BODY} bytes of answer and {@link MCP_OAUTH_TIMEOUT_MS}
|
|
13
|
+
* per request. Nothing fetched here ever carries a credential except the
|
|
14
|
+
* registration request, which carries none either (RFC 7591's open
|
|
15
|
+
* registration).
|
|
16
|
+
*
|
|
17
|
+
* A client: the one the server registers for this Gateway (RFC 7591 DCR),
|
|
18
|
+
* else, for a server that registers none but takes OAuth client ID
|
|
19
|
+
* metadata documents (CIMD, `client_id_metadata_document_supported`), the
|
|
20
|
+
* URL of the document the Gateway serves about itself as the client id: a
|
|
21
|
+
* public client (PKCE, no secret) whose one redirect URI is the Gateway's
|
|
22
|
+
* callback for that app.
|
|
23
|
+
*
|
|
24
|
+
* Discovery (RFC 9728, then RFC 8414 / OpenID discovery):
|
|
25
|
+
* 1. the protected resource metadata: `resourceMetadataUrl` (the 401's
|
|
26
|
+
* `resource_metadata`) when given, else
|
|
27
|
+
* `<origin>/.well-known/oauth-protected-resource<path>`, then
|
|
28
|
+
* `<origin>/.well-known/oauth-protected-resource`. Its `resource` must
|
|
29
|
+
* be the MCP URL or a path prefix of it on the same origin;
|
|
30
|
+
* `authorization_servers[0]` is the issuer.
|
|
31
|
+
* 2. the issuer's metadata: `/.well-known/oauth-authorization-server`
|
|
32
|
+
* path-inserted, then `/.well-known/openid-configuration` path-inserted
|
|
33
|
+
* and path-appended. `issuer` must be the one asked for; PKCE S256
|
|
34
|
+
* must be supported.
|
|
35
|
+
* 3. a server without resource metadata (the 2025-03-26 spec): the
|
|
36
|
+
* authorization server metadata at the MCP URL's origin.
|
|
37
|
+
*/
|
|
38
|
+
import type { OAuthClientInjection } from "./capabilities.js";
|
|
39
|
+
import { type RemoteMcpStaticKind } from "./remoteMcp.js";
|
|
40
|
+
/** The largest answer a discovery or registration fetch reads: 64 KiB. */
|
|
41
|
+
export declare const MCP_OAUTH_MAX_BODY: number;
|
|
42
|
+
/** How long one discovery or registration fetch may take. */
|
|
43
|
+
export declare const MCP_OAUTH_TIMEOUT_MS = 10000;
|
|
44
|
+
/** The fetch this module is given (the global one, or a test's). */
|
|
45
|
+
export type McpOAuthFetch = (input: string, init: RequestInit) => Promise<Response>;
|
|
46
|
+
/** What a `WWW-Authenticate: Bearer …` challenge says (RFC 6750, RFC 9728 section 5.1). */
|
|
47
|
+
export interface McpBearerChallenge {
|
|
48
|
+
/** `resource_metadata`: where the protected resource metadata is. */
|
|
49
|
+
resourceMetadata?: string;
|
|
50
|
+
/** `scope`: the scopes the server wants for the request, space-separated. */
|
|
51
|
+
scope?: string;
|
|
52
|
+
/** `error`: `invalid_token`, `insufficient_scope`, … */
|
|
53
|
+
error?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The Bearer challenge of a `WWW-Authenticate` header, or null when the
|
|
57
|
+
* header carries none. Reads several challenges in one header
|
|
58
|
+
* (`Basic realm="x", Bearer resource_metadata="…"`), quoted and bare
|
|
59
|
+
* values, and parameter names in any case.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseWwwAuthenticate(header: string | null | undefined): McpBearerChallenge | null;
|
|
62
|
+
/** What discovery found: everything the synthesized OAuth row needs. */
|
|
63
|
+
export interface McpOAuthDiscovery {
|
|
64
|
+
/** The protected resource (RFC 8707 `resource`): the metadata's `resource`, or the MCP URL for a server without metadata. */
|
|
65
|
+
resource: string;
|
|
66
|
+
/** The authorization server's issuer, as its metadata spells it (what `iss` must equal). */
|
|
67
|
+
issuer: string;
|
|
68
|
+
authorizationEndpoint: string;
|
|
69
|
+
tokenEndpoint: string;
|
|
70
|
+
registrationEndpoint?: string;
|
|
71
|
+
revocationEndpoint?: string;
|
|
72
|
+
/** The scopes to ask for: the challenge's `scope`, else the resource's `scopes_supported`, else none. */
|
|
73
|
+
scopes: string[];
|
|
74
|
+
/** The resource's `scopes_supported`, every one a token may carry. */
|
|
75
|
+
supportedScopes?: string[];
|
|
76
|
+
/** `token_endpoint_auth_methods_supported`, `["client_secret_basic"]` when the server says nothing (RFC 8414's default). */
|
|
77
|
+
tokenEndpointAuthMethods: string[];
|
|
78
|
+
/** Whether the server had protected resource metadata (false: the 2025-03-26 fallback). */
|
|
79
|
+
resourceMetadata: boolean;
|
|
80
|
+
/** Whether the authorization server takes a client metadata document's URL as a client id (CIMD). */
|
|
81
|
+
clientIdMetadataDocument?: boolean;
|
|
82
|
+
}
|
|
83
|
+
export type McpOAuthDiscoveryResult = {
|
|
84
|
+
ok: true;
|
|
85
|
+
discovery: McpOAuthDiscovery;
|
|
86
|
+
} | {
|
|
87
|
+
ok: false;
|
|
88
|
+
problem: string;
|
|
89
|
+
};
|
|
90
|
+
/** Why `url` can't be fetched by discovery, or null when it can. */
|
|
91
|
+
export declare function mcpOAuthUrlProblem(url: string, { query }?: {
|
|
92
|
+
query?: boolean;
|
|
93
|
+
}): string | null;
|
|
94
|
+
/**
|
|
95
|
+
* Find how `url`'s MCP server takes OAuth: its protected resource, its
|
|
96
|
+
* authorization server, the endpoints, the scopes to ask for and the
|
|
97
|
+
* client authentication it accepts. Refuses (with the reason) anything
|
|
98
|
+
* the Gateway would not run: no PKCE S256, a resource that isn't this
|
|
99
|
+
* server, metadata naming another issuer, an endpoint off https or on a
|
|
100
|
+
* private host, a redirect anywhere.
|
|
101
|
+
*/
|
|
102
|
+
export declare function discoverMcpOAuth(input: {
|
|
103
|
+
url: string;
|
|
104
|
+
fetch: McpOAuthFetch;
|
|
105
|
+
/** The 401's `resource_metadata` ({@link parseWwwAuthenticate}). */
|
|
106
|
+
resourceMetadataUrl?: string | null;
|
|
107
|
+
/** The 401's `scope`, asked for ahead of `scopes_supported`. */
|
|
108
|
+
scope?: string | null;
|
|
109
|
+
}): Promise<McpOAuthDiscoveryResult>;
|
|
110
|
+
export type McpClientRegistration = {
|
|
111
|
+
ok: true;
|
|
112
|
+
clientId: string;
|
|
113
|
+
clientSecret?: string;
|
|
114
|
+
/** Where the client goes on the token request: HTTP Basic, or the form body. */
|
|
115
|
+
inject: OAuthClientInjection;
|
|
116
|
+
/** The method the server registered (`client_secret_basic`, `client_secret_post`, `none`). */
|
|
117
|
+
authMethod: string;
|
|
118
|
+
} | {
|
|
119
|
+
ok: false;
|
|
120
|
+
problem: string;
|
|
121
|
+
/** The server offers no registration endpoint: a client must be pasted. */
|
|
122
|
+
unsupported?: boolean;
|
|
123
|
+
};
|
|
124
|
+
/** The token endpoint auth method to ask for: Basic when offered, else the form, else a public client. */
|
|
125
|
+
export declare function chooseTokenEndpointAuthMethod(supported: readonly string[]): "client_secret_basic" | "client_secret_post" | "none" | null;
|
|
126
|
+
/**
|
|
127
|
+
* Register a client with the server's authorization server (RFC 7591
|
|
128
|
+
* dynamic client registration): the Gateway's callback as the one
|
|
129
|
+
* redirect URI, the authorization-code and refresh grants, and the token
|
|
130
|
+
* endpoint auth method {@link chooseTokenEndpointAuthMethod} picks. Reads
|
|
131
|
+
* back what the server registered: its method decides `inject`.
|
|
132
|
+
*/
|
|
133
|
+
export declare function registerMcpClient(input: {
|
|
134
|
+
discovery: McpOAuthDiscovery;
|
|
135
|
+
redirectUri: string;
|
|
136
|
+
clientName: string;
|
|
137
|
+
fetch: McpOAuthFetch;
|
|
138
|
+
}): Promise<McpClientRegistration>;
|
|
139
|
+
/**
|
|
140
|
+
* The client metadata document the Gateway serves at `clientId` (CIMD):
|
|
141
|
+
* a public client (`token_endpoint_auth_method: none`, so PKCE is its
|
|
142
|
+
* proof) with the Gateway's callback for the app as its one redirect URI.
|
|
143
|
+
*/
|
|
144
|
+
export declare function mcpClientMetadataDocument(input: {
|
|
145
|
+
clientId: string;
|
|
146
|
+
redirectUri: string;
|
|
147
|
+
clientName: string;
|
|
148
|
+
clientUri: string;
|
|
149
|
+
}): Record<string, unknown>;
|
|
150
|
+
/**
|
|
151
|
+
* A client for the Gateway at the server: the one it registers (RFC 7591),
|
|
152
|
+
* else, when it registers none, the Gateway's client metadata document's
|
|
153
|
+
* URL (`documentUrl`, null for a Gateway not on https) where the server
|
|
154
|
+
* takes CIMD and public clients. `unsupported` when neither can be had: a
|
|
155
|
+
* client must be registered by hand and pasted.
|
|
156
|
+
*/
|
|
157
|
+
export declare function obtainMcpClient(input: {
|
|
158
|
+
discovery: McpOAuthDiscovery;
|
|
159
|
+
redirectUri: string;
|
|
160
|
+
clientName: string;
|
|
161
|
+
documentUrl: string | null;
|
|
162
|
+
fetch: McpOAuthFetch;
|
|
163
|
+
}): Promise<McpClientRegistration & {
|
|
164
|
+
via?: "dcr" | "cimd";
|
|
165
|
+
}>;
|
|
166
|
+
/** A built spec, checked by `parseProviderSpec`, or why it can't be. */
|
|
167
|
+
export type McpProviderSpecResult = {
|
|
168
|
+
ok: true;
|
|
169
|
+
id: string;
|
|
170
|
+
spec: Record<string, unknown>;
|
|
171
|
+
} | {
|
|
172
|
+
ok: false;
|
|
173
|
+
problem: string;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* The `oauth2-user` spec of an app's own OAuth row (`<appId>-mcp`): the
|
|
177
|
+
* MCP URL's host as its one API host (the token goes there and nowhere
|
|
178
|
+
* else), the discovered endpoints, the client in `<APPID>_MCP_CLIENT_ID`
|
|
179
|
+
* (and `_SECRET` for a confidential client), PKCE, the `resource` and
|
|
180
|
+
* `issuer`. The scopes the connect asks for are the app's (its manifest's
|
|
181
|
+
* entry, from discovery); the ones the server says it supports are
|
|
182
|
+
* tolerated on a token.
|
|
183
|
+
*/
|
|
184
|
+
export declare function mcpOAuthProviderSpec(input: {
|
|
185
|
+
appId: string;
|
|
186
|
+
name: string;
|
|
187
|
+
url: string;
|
|
188
|
+
discovery: McpOAuthDiscovery;
|
|
189
|
+
client: {
|
|
190
|
+
hasSecret: boolean;
|
|
191
|
+
inject: OAuthClientInjection;
|
|
192
|
+
};
|
|
193
|
+
}): McpProviderSpecResult;
|
|
194
|
+
/**
|
|
195
|
+
* The API-key spec of an app's own static credential (`<appId>-mcp`): the
|
|
196
|
+
* MCP URL's host as its one host, the value in `<APPID>_MCP_TOKEN`, placed
|
|
197
|
+
* as `kind` says: `Authorization: Bearer` (or `<prefix>` as the scheme),
|
|
198
|
+
* a header (`header`, `prefix`), a query parameter (`param`), or HTTP
|
|
199
|
+
* Basic with the value as `user:password`.
|
|
200
|
+
*/
|
|
201
|
+
export declare function mcpStaticProviderSpec(input: {
|
|
202
|
+
appId: string;
|
|
203
|
+
name: string;
|
|
204
|
+
url: string;
|
|
205
|
+
kind: RemoteMcpStaticKind;
|
|
206
|
+
header?: string | null;
|
|
207
|
+
prefix?: string | null;
|
|
208
|
+
param?: string | null;
|
|
209
|
+
}): McpProviderSpecResult;
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