@20baht/elysia-openapi-mcp 0.0.0-stage → 0.1.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/CHANGELOG.md +142 -0
- package/README.md +628 -2
- package/dist/auth/access.d.ts +13 -0
- package/dist/auth/access.d.ts.map +1 -0
- package/dist/auth/authenticate.d.ts +24 -0
- package/dist/auth/authenticate.d.ts.map +1 -0
- package/dist/auth/bearer.d.ts +13 -0
- package/dist/auth/bearer.d.ts.map +1 -0
- package/dist/auth/prm.d.ts +4 -0
- package/dist/auth/prm.d.ts.map +1 -0
- package/dist/auth/resolve.d.ts +110 -0
- package/dist/auth/resolve.d.ts.map +1 -0
- package/dist/auth/resource.d.ts +10 -0
- package/dist/auth/resource.d.ts.map +1 -0
- package/dist/auth/verify.d.ts +62 -0
- package/dist/auth/verify.d.ts.map +1 -0
- package/dist/execute.d.ts +43 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1577 -0
- package/dist/index.js.map +24 -0
- package/dist/openapi/derive.d.ts +61 -0
- package/dist/openapi/derive.d.ts.map +1 -0
- package/dist/openapi/naming.d.ts +21 -0
- package/dist/openapi/naming.d.ts.map +1 -0
- package/dist/openapi/schema.d.ts +83 -0
- package/dist/openapi/schema.d.ts.map +1 -0
- package/dist/openapi/types.d.ts +79 -0
- package/dist/openapi/types.d.ts.map +1 -0
- package/dist/plugin.d.ts +143 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/transport.d.ts +32 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/warnings.d.ts +14 -0
- package/dist/warnings.d.ts.map +1 -0
- package/package.json +63 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/auth/authenticate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAkC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAuD,CAAC;AAEpG,MAAM,MAAM,WAAW,GACrB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE5F,sFAAsF;AACtF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,GAAG,GAAG,GAAG,EACjB,KAAK,EAAE,eAAe,GAAG,SAAS,EAClC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACnC,QAAQ,CAYV;AAcD,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGvE;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA0E7F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** RFC 6750 bearer extraction and `WWW-Authenticate` challenge building. */
|
|
2
|
+
export declare function extractBearer(header: string | null | undefined): string | null;
|
|
3
|
+
export type BearerErrorCode = 'invalid_request' | 'invalid_token' | 'insufficient_scope';
|
|
4
|
+
export interface ChallengeOptions {
|
|
5
|
+
/** Absolute URL of the Protected Resource Metadata document (RFC 9728 §5.1). */
|
|
6
|
+
resourceMetadataUrl: string;
|
|
7
|
+
error?: BearerErrorCode;
|
|
8
|
+
errorDescription?: string;
|
|
9
|
+
scope?: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
/** `Bearer realm="OAuth", resource_metadata="…"[, error="…"][, error_description="…"][, scope="…"]` */
|
|
12
|
+
export declare function bearerChallenge(o: ChallengeOptions): string;
|
|
13
|
+
//# sourceMappingURL=bearer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bearer.d.ts","sourceRoot":"","sources":["../../src/auth/bearer.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAI9E;AAED,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAEzF,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAID,uGAAuG;AACvG,wBAAgB,eAAe,CAAC,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAM3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prm.d.ts","sourceRoot":"","sources":["../../src/auth/prm.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYrF"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** Validate and normalise the `auth` option block. */
|
|
2
|
+
import type { ToolSpec } from '../openapi/derive.js';
|
|
3
|
+
import { type FetchLike, type TokenVerifier } from './verify.js';
|
|
4
|
+
export interface McpifyAuthOptions {
|
|
5
|
+
/** Canonical URI of this MCP server; the audience every token must carry (RFC 8707). */
|
|
6
|
+
resource: string;
|
|
7
|
+
/** Issuer identifiers of the authorization servers allowed to mint tokens for it. */
|
|
8
|
+
authorizationServers: string[];
|
|
9
|
+
/** Replace the default JWKS verifier (e.g. `verifyWithOAuthProvider(...)`). */
|
|
10
|
+
verify?: TokenVerifier;
|
|
11
|
+
/** Where the RFC 9728 document is served. Default: `/.well-known/oauth-protected-resource<resource path>`. */
|
|
12
|
+
prmPath?: string;
|
|
13
|
+
/** Scopes every MCP request must hold (403 `insufficient_scope` otherwise). */
|
|
14
|
+
scopes?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Let requests without an `Authorization` header connect, list tools, and
|
|
17
|
+
* call tools marked `detail.mcp: { public: true }`; any other call gets the
|
|
18
|
+
* 401 challenge that starts sign-in. A token that is present is always
|
|
19
|
+
* verified. Default false.
|
|
20
|
+
*/
|
|
21
|
+
allowAnonymous?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Expose only tools that declare `detail.mcp.scopes` or `detail.mcp.public`;
|
|
24
|
+
* the rest are left out of the tool set with a warning. Default false: any
|
|
25
|
+
* token valid for `resource` (and holding `scopes`) can call every tool that
|
|
26
|
+
* declares no scopes of its own.
|
|
27
|
+
*/
|
|
28
|
+
requireToolScopes?: boolean;
|
|
29
|
+
/** Advertised in the PRM document and the 401 challenge. */
|
|
30
|
+
scopesSupported?: string[];
|
|
31
|
+
resourceName?: string;
|
|
32
|
+
resourceDocumentation?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Seconds of slack when checking `exp`. Default: `jwks.clockTolerance`
|
|
35
|
+
* (30) with the built-in verifier, 0 with a custom `verify`.
|
|
36
|
+
*/
|
|
37
|
+
clockTolerance?: number;
|
|
38
|
+
/** Default verifier tuning; ignored when `verify` is set. */
|
|
39
|
+
jwks?: {
|
|
40
|
+
uri?: string | Record<string, string>;
|
|
41
|
+
algorithms?: string[];
|
|
42
|
+
clockTolerance?: number;
|
|
43
|
+
/** Required JOSE `typ` header. Default `at+jwt` (RFC 9068); `false` skips the check. */
|
|
44
|
+
typ?: string | false;
|
|
45
|
+
fetch?: FetchLike;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `verify` refusing with its own answer: a JSON-RPC error with this HTTP
|
|
50
|
+
* `status` (400-599), `code` (default -32001) and `message`, so a caller who
|
|
51
|
+
* is signed in but may not use the endpoint learns why.
|
|
52
|
+
*/
|
|
53
|
+
export interface RequestAuthRefusal {
|
|
54
|
+
status: number;
|
|
55
|
+
code?: number;
|
|
56
|
+
message: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `verify` admitting with limits. Only the tools that pass every given
|
|
60
|
+
* filter are listed by `tools/list` and callable by `tools/call`; any other
|
|
61
|
+
* is answered like an unknown tool. At least one field must be present.
|
|
62
|
+
*/
|
|
63
|
+
export interface RequestAuthAdmission {
|
|
64
|
+
/**
|
|
65
|
+
* Scopes the caller holds. A tool that declares `detail.mcp.scopes` is kept
|
|
66
|
+
* only when every one of them is here, as in OAuth mode; a tool without
|
|
67
|
+
* scopes is kept.
|
|
68
|
+
*/
|
|
69
|
+
scopes?: string[];
|
|
70
|
+
/** Keep only the tools for which this returns `true`. */
|
|
71
|
+
tools?: (tool: ToolSpec) => boolean;
|
|
72
|
+
/** `true` keeps only the tools marked `readOnlyHint` (GET routes). */
|
|
73
|
+
readOnly?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* `true` admits with every tool, an admission object admits with a filtered
|
|
77
|
+
* tool set, a refusal object answers with its own error; anything else
|
|
78
|
+
* (`false`, a throw, any other value) is a bare 401.
|
|
79
|
+
*/
|
|
80
|
+
export type RequestAuthResult = boolean | RequestAuthRefusal | RequestAuthAdmission;
|
|
81
|
+
/**
|
|
82
|
+
* Request mode, for apps that already guard their routes with an API key or a
|
|
83
|
+
* session cookie: `verify` sees every MCP request (including `tools/list`)
|
|
84
|
+
* and decides with a `RequestAuthResult`. No OAuth discovery is offered.
|
|
85
|
+
*/
|
|
86
|
+
export interface McpifyRequestAuthOptions {
|
|
87
|
+
verify: (request: Request) => RequestAuthResult | Promise<RequestAuthResult>;
|
|
88
|
+
resource?: never;
|
|
89
|
+
authorizationServers?: never;
|
|
90
|
+
}
|
|
91
|
+
/** OAuth when `resource` is set; request mode otherwise (and then OAuth-only keys are an error). */
|
|
92
|
+
export declare function isRequestAuth(auth: McpifyAuthOptions | McpifyRequestAuthOptions): auth is McpifyRequestAuthOptions;
|
|
93
|
+
export interface ResolvedAuth {
|
|
94
|
+
resource: string;
|
|
95
|
+
resourceUrl: URL;
|
|
96
|
+
authorizationServers: string[];
|
|
97
|
+
verify: TokenVerifier;
|
|
98
|
+
prmPath: string;
|
|
99
|
+
resourceMetadataUrl: string;
|
|
100
|
+
scopes: string[];
|
|
101
|
+
allowAnonymous: boolean;
|
|
102
|
+
requireToolScopes: boolean;
|
|
103
|
+
scopesSupported?: string[];
|
|
104
|
+
resourceName?: string;
|
|
105
|
+
resourceDocumentation?: string;
|
|
106
|
+
/** Seconds of slack applied to the `exp` check. */
|
|
107
|
+
clockTolerance: number;
|
|
108
|
+
}
|
|
109
|
+
export declare function resolveAuth(auth: McpifyAuthOptions): ResolvedAuth;
|
|
110
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/auth/resolve.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAsB,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,WAAW,iBAAiB;IAChC,wFAAwF;IACxF,QAAQ,EAAE,MAAM,CAAC;IACjB,qFAAqF;IACrF,oBAAoB,EAAE,MAA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B,CAAC;AAEpF;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC7E,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,oBAAoB,CAAC,EAAE,KAAK,CAAC;CAC9B;AAeD,oGAAoG;AACpG,wBAAgB,aAAa,CAC3B,IAAI,EAAE,iBAAiB,GAAG,wBAAwB,GACjD,IAAI,IAAI,wBAAwB,CAelC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC;IACjB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,YAAY,CA2CjE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 8707 resource identifier handling. Comparison normalises the things
|
|
3
|
+
* that legitimately differ between an `aud` claim and a configured resource:
|
|
4
|
+
* scheme/host case, a lone trailing slash, and the (forbidden) fragment.
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeResource(resource: string): string;
|
|
7
|
+
export declare function resourcesEqual(a: string, b: string): boolean;
|
|
8
|
+
/** RFC 8707 §2: absolute URI, no fragment. We additionally require http(s). */
|
|
9
|
+
export declare function validateResourceUri(resource: string, label?: string): URL;
|
|
10
|
+
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/auth/resource.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAK1D;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAa,GAAG,GAAG,CAY7E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface TokenClaims {
|
|
2
|
+
iss: string;
|
|
3
|
+
/** Absent → the plugin rejects the token (fail closed). */
|
|
4
|
+
aud?: string | string[];
|
|
5
|
+
sub: string;
|
|
6
|
+
scope?: string;
|
|
7
|
+
client_id?: string;
|
|
8
|
+
exp?: number;
|
|
9
|
+
[claim: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
/** Return the claims of a genuine token, or `null` when it is not. */
|
|
12
|
+
export type TokenVerifier = (token: string, context: {
|
|
13
|
+
request: Request;
|
|
14
|
+
}) => Promise<TokenClaims | null> | TokenClaims | null;
|
|
15
|
+
export type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
16
|
+
export interface JwksVerifierOptions {
|
|
17
|
+
/** Issuer identifiers of the trusted authorization servers. */
|
|
18
|
+
authorizationServers: readonly string[];
|
|
19
|
+
/**
|
|
20
|
+
* Skip discovery: a single JWKS URL (one authorization server) or a map of
|
|
21
|
+
* issuer → JWKS URL.
|
|
22
|
+
*/
|
|
23
|
+
jwksUri?: string | Record<string, string>;
|
|
24
|
+
/** Allowed JWS algorithms. Default: the asymmetric set jose can verify against a JWKS. */
|
|
25
|
+
algorithms?: string[];
|
|
26
|
+
/** Seconds of clock skew tolerated on `exp` / `nbf`. Default 30. */
|
|
27
|
+
clockTolerance?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Required JOSE `typ` header (compared case-insensitively, `application/`
|
|
30
|
+
* prefix optional). Default `at+jwt` (RFC 9068 §4), which stops an ID token
|
|
31
|
+
* or other JWT signed by the same keys from passing as an access token.
|
|
32
|
+
* `false` skips the check, for authorization servers that do not set it.
|
|
33
|
+
*/
|
|
34
|
+
typ?: string | false;
|
|
35
|
+
/** Used for metadata + JWKS requests (tests inject `app.handle`). */
|
|
36
|
+
fetch?: FetchLike;
|
|
37
|
+
}
|
|
38
|
+
/** RFC 8414 §3.1 then OIDC Discovery §4.1 candidate URLs for an issuer. */
|
|
39
|
+
export declare function metadataCandidates(issuer: string): string[];
|
|
40
|
+
/**
|
|
41
|
+
* JWT access-token verifier backed by each authorization server's JWKS.
|
|
42
|
+
* Signature, `iss`, `exp`/`nbf` are enforced here; `aud` and scopes are
|
|
43
|
+
* enforced by the plugin so custom verifiers get the same treatment.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createJwksVerifier(o: JwksVerifierOptions): TokenVerifier;
|
|
46
|
+
/** The subset of `@20baht/elysia-oauth-provider`'s `ctx.oauthProvider` / `core` we need. */
|
|
47
|
+
export interface OAuthProviderLike {
|
|
48
|
+
verifyAccessToken(token: string): Promise<{
|
|
49
|
+
userId: string;
|
|
50
|
+
clientId: string;
|
|
51
|
+
scopes: string[];
|
|
52
|
+
expiresAt: number;
|
|
53
|
+
audience?: string;
|
|
54
|
+
} | null>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Validate tokens (opaque or JWT) directly against a co-located
|
|
58
|
+
* `@20baht/elysia-oauth-provider` instance. Only reads; never mints. Tokens without an
|
|
59
|
+
* audience are reported without `aud`, so the plugin rejects them.
|
|
60
|
+
*/
|
|
61
|
+
export declare function verifyWithOAuthProvider(provider: OAuthProviderLike, issuer: string): TokenVerifier;
|
|
62
|
+
//# sourceMappingURL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M,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ3D;AA4BD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,mBAAmB,GAAG,aAAa,CAmDxE;AAED,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QACxC,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,IAAI,CAAC,CAAC;CACX;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,GACb,aAAa,CAmBf"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool execution: unflatten arguments, build a synthetic `Request`, run it
|
|
3
|
+
* through `app.handle()` (full Elysia lifecycle), and turn the `Response`
|
|
4
|
+
* into an MCP `CallToolResult`.
|
|
5
|
+
*/
|
|
6
|
+
import { type CallToolResult } from '@modelcontextprotocol/server';
|
|
7
|
+
import type { ToolSpec } from './openapi/derive.js';
|
|
8
|
+
export interface Handler {
|
|
9
|
+
handle(request: Request): Promise<Response>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* True for the request a `tools/call` runs through the app, so hooks and
|
|
13
|
+
* handlers can tell an agent's call from a direct HTTP request (to audit it,
|
|
14
|
+
* or to refuse what only people may do). Elysia hands that same object to
|
|
15
|
+
* every lifecycle hook as `request`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isToolCall(request: Request): boolean;
|
|
18
|
+
/** What `onToolCall` hears after each tool call that reached the app. */
|
|
19
|
+
export interface ToolCallEvent {
|
|
20
|
+
tool: ToolSpec;
|
|
21
|
+
/** The arguments as the client sent them. */
|
|
22
|
+
args: Record<string, unknown>;
|
|
23
|
+
/** The synthetic request the route ran on (`isToolCall(request)` is true; its body is spent). */
|
|
24
|
+
request: Request;
|
|
25
|
+
/** A copy of the route's response, free to read. */
|
|
26
|
+
response: Response;
|
|
27
|
+
/** Time spent in `app.handle()`, in milliseconds. */
|
|
28
|
+
durationMs: number;
|
|
29
|
+
}
|
|
30
|
+
export type OnToolCall = (event: ToolCallEvent) => void | Promise<void>;
|
|
31
|
+
/** Decide which incoming MCP request headers reach the synthetic request. */
|
|
32
|
+
export type HeaderPolicy = (incoming: Headers) => HeadersInit;
|
|
33
|
+
export declare const defaultHeaderPolicy: HeaderPolicy;
|
|
34
|
+
export declare function buildToolRequest(tool: ToolSpec, args: Record<string, unknown>, original: Request, headerPolicy?: HeaderPolicy): Request;
|
|
35
|
+
export declare function toCallToolResult(tool: ToolSpec, res: Response): Promise<CallToolResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Run one tool call through the app. `onToolCall` is awaited after the
|
|
38
|
+
* result is built; it gets a clone of the response, so reading it does not
|
|
39
|
+
* disturb the result. Errors it throws reach the caller (the plugin catches
|
|
40
|
+
* and reports them).
|
|
41
|
+
*/
|
|
42
|
+
export declare function callTool(app: Handler, tool: ToolSpec, args: Record<string, unknown>, original: Request, headerPolicy?: HeaderPolicy, onToolCall?: OnToolCall): Promise<CallToolResult>;
|
|
43
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7C;AASD;;;;;GAKG;AACH,wBAAgB,U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|
+
export type { McpifyAuthMode, McpifyBaseOptions, McpifyCorsOption, McpifyOptions, } from './plugin.js';
|
|
3
|
+
export type { McpifyAuthOptions, McpifyRequestAuthOptions, RequestAuthAdmission, RequestAuthRefusal, RequestAuthResult, ResolvedAuth, } from './auth/resolve.js';
|
|
4
|
+
export { MCPIFY_WARNING_KINDS } from './warnings.js';
|
|
5
|
+
export type { McpifyWarning, McpifyWarningKind } from './warnings.js';
|
|
6
|
+
export { resolveAuth } from './auth/resolve.js';
|
|
7
|
+
export { createJwksVerifier, verifyWithOAuthProvider, metadataCandidates } from './auth/verify.js';
|
|
8
|
+
export type { TokenClaims, TokenVerifier, JwksVerifierOptions, OAuthProviderLike, FetchLike, } from './auth/verify.js';
|
|
9
|
+
export { authenticate, audienceMatches } from './auth/authenticate.js';
|
|
10
|
+
export type { AuthOutcome } from './auth/authenticate.js';
|
|
11
|
+
export { bearerChallenge, extractBearer } from './auth/bearer.js';
|
|
12
|
+
export type { ChallengeOptions, BearerErrorCode } from './auth/bearer.js';
|
|
13
|
+
export { protectedResourceMetadata } from './auth/prm.js';
|
|
14
|
+
export { normalizeResource, resourcesEqual, validateResourceUri } from './auth/resource.js';
|
|
15
|
+
export { deriveTools, toMcpTool, toolNameFor, isExcluded, DEFAULT_EXCLUDED_PATHS, } from './openapi/derive.js';
|
|
16
|
+
export type { ToolSpec, DeriveOptions, DeriveResult } from './openapi/derive.js';
|
|
17
|
+
export { deriveToolName, elysiaDefaultOperationId, sanitizeToolName, templateParams, } from './openapi/naming.js';
|
|
18
|
+
export { dereference, flattenOperation, unflattenArgs, outputSchemaFor, simplifyNumeric, WRAPPED_RESULT_KEY, } from './openapi/schema.js';
|
|
19
|
+
export type { FlatSchema, PropertyOrigin, OutputSchema, UnflattenedArgs, } from './openapi/schema.js';
|
|
20
|
+
export type { McpRouteOptions, OpenAPIDocument, OpenAPIOperation, OpenAPIParameter, JsonSchema, } from './openapi/types.js';
|
|
21
|
+
export { buildToolRequest, toCallToolResult, callTool, defaultHeaderPolicy, isToolCall, } from './execute.js';
|
|
22
|
+
export type { HeaderPolicy, Handler, OnToolCall, ToolCallEvent } from './execute.js';
|
|
23
|
+
export { serveMcp } from './transport.js';
|
|
24
|
+
export type { ToolSet, ServeOptions } from './transport.js';
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACnG,YAAY,EACV,WAAW,EACX,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACvE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,iBAAi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