@toolgrain/mcp 0.1.1 → 0.1.3
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 +19 -0
- package/README.md +9 -8
- package/dist/auth/audience.d.ts +9 -1
- package/dist/auth/audience.d.ts.map +1 -1
- package/dist/auth/audience.js +9 -1
- package/dist/auth/audience.js.map +1 -1
- package/dist/auth/context.d.ts +9 -1
- package/dist/auth/context.d.ts.map +1 -1
- package/dist/auth/context.js +9 -1
- package/dist/auth/context.js.map +1 -1
- package/dist/auth/errors.d.ts +19 -1
- package/dist/auth/errors.d.ts.map +1 -1
- package/dist/auth/errors.js +16 -1
- package/dist/auth/errors.js.map +1 -1
- package/dist/auth/types.d.ts +21 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/url.d.ts +9 -1
- package/dist/auth/url.d.ts.map +1 -1
- package/dist/auth/url.js +9 -1
- package/dist/auth/url.js.map +1 -1
- package/dist/context/definition.d.ts +28 -1
- package/dist/context/definition.d.ts.map +1 -1
- package/dist/context/definition.js +10 -1
- package/dist/context/definition.js.map +1 -1
- package/dist/diagnostics.d.ts +2 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js.map +1 -1
- package/dist/server.d.ts +59 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +9 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/context.d.ts +19 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +8 -1
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/definition.d.ts +49 -0
- package/dist/tools/definition.d.ts.map +1 -1
- package/dist/tools/definition.js +9 -0
- package/dist/tools/definition.js.map +1 -1
- package/dist/tools/name.d.ts +6 -1
- package/dist/tools/name.d.ts.map +1 -1
- package/dist/tools/name.js +5 -1
- package/dist/tools/name.js.map +1 -1
- package/dist/tools/registry.d.ts +4 -0
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/rich-result.d.ts +56 -2
- package/dist/tools/rich-result.d.ts.map +1 -1
- package/dist/tools/rich-result.js +7 -1
- package/dist/tools/rich-result.js.map +1 -1
- package/dist/tools/schema.d.ts +13 -1
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/schema.js +11 -1
- package/dist/tools/schema.js.map +1 -1
- package/dist/transport.d.ts +21 -0
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js.map +1 -1
- package/package.json +3 -3
- package/src/auth/audience.ts +9 -1
- package/src/auth/context.ts +9 -1
- package/src/auth/errors.ts +19 -1
- package/src/auth/types.ts +21 -0
- package/src/auth/url.ts +9 -1
- package/src/context/definition.ts +28 -1
- package/src/diagnostics.ts +2 -0
- package/src/server.ts +63 -3
- package/src/tools/context.ts +19 -1
- package/src/tools/definition.ts +52 -1
- package/src/tools/name.ts +6 -1
- package/src/tools/registry.ts +4 -0
- package/src/tools/rich-result.ts +68 -6
- package/src/tools/schema.ts +8 -0
- package/src/transport.ts +21 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @toolgrain/mcp
|
|
2
2
|
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @toolgrain/protocol@0.1.3
|
|
8
|
+
|
|
9
|
+
## 0.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- da94c47: Document the public API with JSDoc for exported types, members, options, and functions. Preserve field documentation in auth accessor return types and protocol constant hovers.
|
|
14
|
+
- f199707: Point package homepages and README documentation links to the live Toolgrain documentation site.
|
|
15
|
+
- d0c10ac: Use matching stable Toolgrain packages in installation instructions instead of
|
|
16
|
+
embedding outdated release pins.
|
|
17
|
+
- Updated dependencies [da94c47]
|
|
18
|
+
- Updated dependencies [f199707]
|
|
19
|
+
- Updated dependencies [d0c10ac]
|
|
20
|
+
- @toolgrain/protocol@0.1.2
|
|
21
|
+
|
|
3
22
|
## 0.1.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -13,16 +13,17 @@
|
|
|
13
13
|
Reusable tools, inferred Zod inputs and outputs, rich results, and request context
|
|
14
14
|
from one TypeScript authoring API.
|
|
15
15
|
|
|
16
|
-
[Documentation](https://
|
|
17
|
-
[Examples](https://
|
|
16
|
+
[Documentation](https://toolgrain.mintlify.site/tools/overview) ·
|
|
17
|
+
[Examples](https://toolgrain.mintlify.site/examples) ·
|
|
18
18
|
[npm](https://www.npmjs.com/package/@toolgrain/mcp)
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
22
|
-
Install
|
|
22
|
+
Install matching stable versions across Toolgrain libraries. These commands
|
|
23
|
+
resolve npm's `latest` tag.
|
|
23
24
|
|
|
24
25
|
```sh
|
|
25
|
-
npm install @toolgrain/mcp
|
|
26
|
+
npm install @toolgrain/mcp @toolgrain/node zod@^4.6.6
|
|
26
27
|
npm install --save-dev typescript @types/node
|
|
27
28
|
```
|
|
28
29
|
|
|
@@ -71,7 +72,7 @@ calls, which bypass server validation and result conversion. Unexpected server
|
|
|
71
72
|
execution failures return generic errors and reach the optional `onError`
|
|
72
73
|
callback. Request-cached dependencies use `createContext()` and inferred
|
|
73
74
|
accessors; see the
|
|
74
|
-
[context guide](https://
|
|
75
|
+
[context guide](https://toolgrain.mintlify.site/guides/context).
|
|
75
76
|
|
|
76
77
|
## Transports and compatibility
|
|
77
78
|
|
|
@@ -82,7 +83,7 @@ or mount a Web handler from
|
|
|
82
83
|
Both MCP `2026-07-28` and initialization-based `2025-06-18` are supported through
|
|
83
84
|
the same tool API. Current HTTP support uses independent POST requests and JSON
|
|
84
85
|
responses. See the
|
|
85
|
-
[client compatibility notes](https://
|
|
86
|
+
[client compatibility notes](https://toolgrain.mintlify.site/compatibility/protocol)
|
|
86
87
|
for tested clients and limitations.
|
|
87
88
|
|
|
88
89
|
## Requirements
|
|
@@ -90,8 +91,8 @@ for tested clients and limitations.
|
|
|
90
91
|
ESM only. Node.js `^24.20.0` or Bun `>=1.4.4 <2`; Zod `^4.6.6`; TypeScript 5.5.4
|
|
91
92
|
or later with `strict` enabled. Node stack traces can use the included source
|
|
92
93
|
maps with `node --enable-source-maps server.mjs`. See the
|
|
93
|
-
[support policy](https://
|
|
94
|
-
and [full API guide](https://
|
|
94
|
+
[support policy](https://toolgrain.mintlify.site/project/support-policy)
|
|
95
|
+
and [full API guide](https://toolgrain.mintlify.site/tools/overview).
|
|
95
96
|
|
|
96
97
|
## License
|
|
97
98
|
|
package/dist/auth/audience.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Require an already verified token's audience to contain the exact MCP resource URL.
|
|
3
|
+
* This checks only audience membership, not signatures, issuers, expiry, or revocation.
|
|
4
|
+
*
|
|
5
|
+
* @param audience - Verified `aud` claim: a string or array of strings.
|
|
6
|
+
* @param resource - Expected resource URL to match exactly.
|
|
7
|
+
* @throws `AuthError` with `invalid_token` for missing, malformed, or mismatched audiences.
|
|
8
|
+
* Missing and mismatched claims include public guidance without disclosing received claims.
|
|
9
|
+
*/
|
|
2
10
|
export declare function validateTokenAudience(audience: unknown, resource: string): void;
|
|
3
11
|
//# sourceMappingURL=audience.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../../src/auth/audience.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../../src/auth/audience.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,MAAM,GACf,IAAI,CAeN"}
|
package/dist/auth/audience.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { AuthError } from "./errors.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Require an already verified token's audience to contain the exact MCP resource URL.
|
|
4
|
+
* This checks only audience membership, not signatures, issuers, expiry, or revocation.
|
|
5
|
+
*
|
|
6
|
+
* @param audience - Verified `aud` claim: a string or array of strings.
|
|
7
|
+
* @param resource - Expected resource URL to match exactly.
|
|
8
|
+
* @throws `AuthError` with `invalid_token` for missing, malformed, or mismatched audiences.
|
|
9
|
+
* Missing and mismatched claims include public guidance without disclosing received claims.
|
|
10
|
+
*/
|
|
3
11
|
export function validateTokenAudience(audience, resource) {
|
|
4
12
|
if (audience === undefined)
|
|
5
13
|
throw new AuthError("invalid_token", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audience.js","sourceRoot":"","sources":["../../src/auth/audience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"audience.js","sourceRoot":"","sources":["../../src/auth/audience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAiB,EACjB,QAAgB;IAEhB,IAAI,QAAQ,KAAK,SAAS;QACxB,MAAM,IAAI,SAAS,CAAC,eAAe,EAAE;YACnC,WAAW,EAAE,0IAA0I,QAAQ,GAAG;SACnK,CAAC,CAAC;IACL,MAAM,SAAS,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACvE,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QACzB,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;QAEpD,MAAM,IAAI,SAAS,CAAC,eAAe,CAAC,CAAC;IACvC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC/B,MAAM,IAAI,SAAS,CAAC,eAAe,EAAE;YACnC,WAAW,EAAE,+DAA+D,QAAQ,2CAA2C;SAChI,CAAC,CAAC;AACP,CAAC"}
|
package/dist/auth/context.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { ToolContext } from "../tools/context.js";
|
|
2
2
|
import type { AuthIdentity, AuthReadonly } from "./types.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Create a synchronous accessor for a provider's already verified identity snapshot.
|
|
5
|
+
* Reading the identity performs no verification, network request, or lazy resolution.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam Identity - Plain identity data returned by the matching provider.
|
|
8
|
+
* @param type - The provider's identity symbol; use `Symbol.for()` across package copies.
|
|
9
|
+
* @returns An accessor accepting a tool context and returning its deeply frozen identity.
|
|
10
|
+
* The accessor throws if that context has no identity for this provider.
|
|
11
|
+
*/
|
|
4
12
|
export declare function createAuthAccessor<Identity extends object>(type: symbol): (ctx: ToolContext) => AuthReadonly<Identity>;
|
|
5
13
|
export declare function attachAuth(ctx: ToolContext, auth?: AuthIdentity): ToolContext;
|
|
6
14
|
/** Auth identities are plain data: copy them before exposing them to handlers. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/auth/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI7D
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/auth/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI7D;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,SACzD,WAAW,KAAG,YAAY,CAAC,QAAQ,CAAC,CAQlD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,WAAW,CAG7E;AAED,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAmBtD"}
|
package/dist/auth/context.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
const key = Symbol.for("@toolgrain/mcp/auth-context/v1");
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Create a synchronous accessor for a provider's already verified identity snapshot.
|
|
4
|
+
* Reading the identity performs no verification, network request, or lazy resolution.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam Identity - Plain identity data returned by the matching provider.
|
|
7
|
+
* @param type - The provider's identity symbol; use `Symbol.for()` across package copies.
|
|
8
|
+
* @returns An accessor accepting a tool context and returning its deeply frozen identity.
|
|
9
|
+
* The accessor throws if that context has no identity for this provider.
|
|
10
|
+
*/
|
|
3
11
|
export function createAuthAccessor(type) {
|
|
4
12
|
return (ctx) => {
|
|
5
13
|
const auth = Object.getOwnPropertyDescriptor(ctx, key)?.value;
|
package/dist/auth/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/auth/context.ts"],"names":[],"mappings":"AAGA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/auth/context.ts"],"names":[],"mappings":"AAGA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAA0B,IAAY;IACtE,OAAO,CAA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,CAAC,MAAM,CAAC,IAAI,CAAC;YAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;IACF,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IACxB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/auth/errors.d.ts
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
|
+
/** Public authorization failure categories mapped by HTTP adapters to 400, 401, 403, or 503. */
|
|
1
2
|
export type AuthErrorCode = "invalid_request" | "invalid_token" | "access_denied" | "temporarily_unavailable";
|
|
2
3
|
declare const brand: unique symbol;
|
|
3
4
|
/** Only an explicitly public description is exposed; provider causes stay private. */
|
|
4
5
|
export declare class AuthError extends Error {
|
|
6
|
+
/** Failure category; determines the default message and HTTP status. */
|
|
5
7
|
readonly code: AuthErrorCode;
|
|
6
8
|
readonly [brand] = true;
|
|
9
|
+
/** Explicitly client-visible guidance; omitted descriptions keep HTTP responses generic. */
|
|
7
10
|
readonly description?: string | undefined;
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Create an authorization failure with optional public guidance and a private cause.
|
|
13
|
+
*
|
|
14
|
+
* @param code - Authorization failure category used by HTTP adapters.
|
|
15
|
+
* @param options - Optional public description and private standard `Error` options.
|
|
16
|
+
*/
|
|
17
|
+
constructor(
|
|
18
|
+
/** Failure category; determines the default message and HTTP status. */
|
|
19
|
+
code: AuthErrorCode, options?: ErrorOptions & {
|
|
20
|
+
/** Public message included in HTTP error bodies and challenges; never include secrets. */
|
|
9
21
|
description?: string;
|
|
10
22
|
});
|
|
11
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Recognize branded authorization errors, including those from compatible package copies.
|
|
26
|
+
*
|
|
27
|
+
* @param value - Any thrown or returned value to inspect.
|
|
28
|
+
* @returns Whether the value is an `Error` with Toolgrain's authorization-error brand.
|
|
29
|
+
*/
|
|
12
30
|
export declare function isAuthError(value: unknown): value is AuthError;
|
|
13
31
|
export {};
|
|
14
32
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/auth/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,eAAe,GACf,eAAe,GACf,yBAAyB,CAAC;AAE9B,QAAA,MAAM,KAAK,eAA4C,CAAC;AAExD,sFAAsF;AACtF,qBAAa,SAAU,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/auth/errors.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,eAAe,GACf,eAAe,GACf,yBAAyB,CAAC;AAE9B,QAAA,MAAM,KAAK,eAA4C,CAAC;AAExD,sFAAsF;AACtF,qBAAa,SAAU,SAAQ,KAAK;IAYhC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,aAAa;IAZ9B,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ;IACxB,4FAA4F;IAC5F,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1C;;;;;OAKG;IACH;IACE,wEAAwE;IAC/D,IAAI,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,YAAY,GAAG;QACvB,0FAA0F;QAC1F,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,EAcF;CACF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D"}
|
package/dist/auth/errors.js
CHANGED
|
@@ -3,8 +3,17 @@ const brand = Symbol.for("@toolgrain/mcp/AuthError/v1");
|
|
|
3
3
|
export class AuthError extends Error {
|
|
4
4
|
code;
|
|
5
5
|
[brand] = true;
|
|
6
|
+
/** Explicitly client-visible guidance; omitted descriptions keep HTTP responses generic. */
|
|
6
7
|
description;
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Create an authorization failure with optional public guidance and a private cause.
|
|
10
|
+
*
|
|
11
|
+
* @param code - Authorization failure category used by HTTP adapters.
|
|
12
|
+
* @param options - Optional public description and private standard `Error` options.
|
|
13
|
+
*/
|
|
14
|
+
constructor(
|
|
15
|
+
/** Failure category; determines the default message and HTTP status. */
|
|
16
|
+
code, options) {
|
|
8
17
|
super(options?.description ??
|
|
9
18
|
{
|
|
10
19
|
invalid_request: "Invalid authorization request",
|
|
@@ -17,6 +26,12 @@ export class AuthError extends Error {
|
|
|
17
26
|
this.description = options?.description;
|
|
18
27
|
}
|
|
19
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Recognize branded authorization errors, including those from compatible package copies.
|
|
31
|
+
*
|
|
32
|
+
* @param value - Any thrown or returned value to inspect.
|
|
33
|
+
* @returns Whether the value is an `Error` with Toolgrain's authorization-error brand.
|
|
34
|
+
*/
|
|
20
35
|
export function isAuthError(value) {
|
|
21
36
|
return value instanceof Error && Reflect.get(value, brand) === true;
|
|
22
37
|
}
|
package/dist/auth/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/auth/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/auth/errors.ts"],"names":[],"mappings":"AAOA,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAExD,sFAAsF;AACtF,MAAM,OAAO,SAAU,SAAQ,KAAK;IAavB,IAAI;IAZN,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACxB,4FAA4F;IACnF,WAAW,CAAsB;IAE1C;;;;;OAKG;IACH;IACE,wEAAwE;IAC/D,IAAmB,EAC5B,OAGC;QAED,KAAK,CACH,OAAO,EAAE,WAAW;YAClB;gBACE,eAAe,EAAE,+BAA+B;gBAChD,aAAa,EAAE,sBAAsB;gBACrC,aAAa,EAAE,eAAe;gBAC9B,uBAAuB,EAAE,mCAAmC;aAC7D,CAAC,IAAI,CAAC,EACT,OAAO,CACR,CAAC;oBAfO,IAAI;QAgBb,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,CAAC;IAC1C,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;AACtE,CAAC"}
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -1,23 +1,44 @@
|
|
|
1
1
|
/** Implemented by integrations; the HTTP adapter supplies the resolved resource. */
|
|
2
2
|
export interface AuthProvider<Identity extends object = object> {
|
|
3
|
+
/** Stable provider identity used by `createAuthAccessor()`; use `Symbol.for()` across copies. */
|
|
3
4
|
readonly type: symbol;
|
|
5
|
+
/** Canonical public MCP resource URL; omission lets the HTTP adapter infer it per request. */
|
|
4
6
|
readonly resource?: string;
|
|
7
|
+
/** Nonempty list of trusted authorization-server URLs advertised in public metadata. */
|
|
5
8
|
readonly authorizationServers: readonly string[];
|
|
9
|
+
/**
|
|
10
|
+
* Verify token authenticity, validity, and resource audience before returning plain identity data.
|
|
11
|
+
* The server copies and deeply freezes the identity before exposing it to handlers.
|
|
12
|
+
*
|
|
13
|
+
* @param accessToken - Raw bearer token without its scheme prefix.
|
|
14
|
+
* @param options - Resolved resource and request cancellation signal.
|
|
15
|
+
* @returns Verified plain data; credentials and SDK methods should not be included.
|
|
16
|
+
* @throws `AuthError` for expected rejections; unexpected failures remain private diagnostics.
|
|
17
|
+
*/
|
|
6
18
|
verify(accessToken: string, options: AuthVerifyOptions): Promise<Identity>;
|
|
7
19
|
}
|
|
20
|
+
/** Resource and cancellation information supplied to an authorization provider. */
|
|
8
21
|
export interface AuthVerifyOptions {
|
|
22
|
+
/** Shared cancellation for verification, body reading, execution, and server shutdown. */
|
|
9
23
|
readonly signal: AbortSignal;
|
|
24
|
+
/** Expected token audience, after applying any provider resource override. */
|
|
10
25
|
readonly resource: string;
|
|
11
26
|
}
|
|
27
|
+
/** Public authorization configuration copied by `Server.getAuthMetadata()`. */
|
|
12
28
|
export interface AuthMetadata {
|
|
29
|
+
/** Canonical public resource URL, or absent when inferred from the current HTTP request. */
|
|
13
30
|
readonly resource?: string;
|
|
31
|
+
/** Trusted authorization-server URLs advertised by protected-resource metadata. */
|
|
14
32
|
readonly authorizationServers: readonly string[];
|
|
15
33
|
}
|
|
16
34
|
/** An opaque, single-use authorization for one server invocation. Always dispose it. */
|
|
17
35
|
export interface AuthScope {
|
|
36
|
+
/** Cancellation signal spanning verification and the authorized invocation. */
|
|
18
37
|
readonly signal: AbortSignal;
|
|
38
|
+
/** Release request bookkeeping and prevent future use; safe to call more than once. */
|
|
19
39
|
dispose(): void;
|
|
20
40
|
}
|
|
41
|
+
/** Recursively readonly view of the plain identity snapshot exposed by auth accessors. */
|
|
21
42
|
export type AuthReadonly<T> = T extends readonly (infer Item)[] ? readonly AuthReadonly<Item>[] : T extends object ? {
|
|
22
43
|
readonly [Key in keyof T]: AuthReadonly<T[Key]>;
|
|
23
44
|
} : T;
|
package/dist/auth/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,WAAW,YAAY,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAC;IACjD,MAAM,CAAC,WAAW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IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC5E;AAED,mFAAmF;AACnF,MAAM,WAAW,iBAAiB;IAChC,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,4FAA4F;IAC5F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAC;CAClD;AAED,wFAAwF;AACxF,MAAM,WAAW,SAAS;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,uFAAuF;IACvF,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,0FAA0F;AAC1F,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GAC3D,SAAS,YAAY,CAAC,IAAI,CAAC,EAAE,GAC7B,CAAC,SAAS,MAAM,GACd;IAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACnD,CAAC,CAAC;AAER,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB"}
|
package/dist/auth/url.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Validate an auth configuration URL, returning the original string unchanged.
|
|
3
|
+
* Requires HTTPS, except HTTP on `localhost`, `127.0.0.1`, or `[::1]` for development.
|
|
4
|
+
* Credentials, whitespace, control characters, queries, and fragments are rejected.
|
|
5
|
+
*
|
|
6
|
+
* @param value - Authorization-server, signing-key, or canonical resource URL.
|
|
7
|
+
* @returns The supplied URL after validation; no normalization is applied.
|
|
8
|
+
* @throws `TypeError` for an invalid or disallowed URL.
|
|
9
|
+
*/
|
|
2
10
|
export declare function authUrl(value: string): string;
|
|
3
11
|
//# sourceMappingURL=url.d.ts.map
|
package/dist/auth/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/auth/url.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/auth/url.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoB7C"}
|
package/dist/auth/url.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Validate an auth configuration URL, returning the original string unchanged.
|
|
3
|
+
* Requires HTTPS, except HTTP on `localhost`, `127.0.0.1`, or `[::1]` for development.
|
|
4
|
+
* Credentials, whitespace, control characters, queries, and fragments are rejected.
|
|
5
|
+
*
|
|
6
|
+
* @param value - Authorization-server, signing-key, or canonical resource URL.
|
|
7
|
+
* @returns The supplied URL after validation; no normalization is applied.
|
|
8
|
+
* @throws `TypeError` for an invalid or disallowed URL.
|
|
9
|
+
*/
|
|
2
10
|
export function authUrl(value) {
|
|
3
11
|
const url = new URL(value);
|
|
4
12
|
if (
|
package/dist/auth/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/auth/url.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/auth/url.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B;IACE,6HAA6H;IAC7H,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC;QACnC,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC;QAChC,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ;YACxB,CAAC,CACC,GAAG,CAAC,QAAQ,KAAK,OAAO;gBACxB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAC3D,CAAC;QACJ,GAAG,CAAC,QAAQ;QACZ,GAAG,CAAC,QAAQ;QACZ,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACnB,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QAEnB,MAAM,IAAI,SAAS,CACjB,6FAA6F,CAC9F,CAAC;IACJ,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -6,18 +6,45 @@ export interface ContextBinding {
|
|
|
6
6
|
}
|
|
7
7
|
/** Erase values for heterogeneous registrations without exposing unsafe overrides. */
|
|
8
8
|
export declare abstract class RegisteredContextProvider {
|
|
9
|
+
/** Nonempty diagnostic label; distinct providers may share a name without sharing identity. */
|
|
9
10
|
abstract readonly name: string;
|
|
10
11
|
abstract readonly use: (ctx: ToolContext) => Promise<unknown>;
|
|
11
12
|
"~toolgrain"(): "context@1";
|
|
12
13
|
}
|
|
13
14
|
/** An opaque, invariant value contract; use createContext() and provide() for bindings. */
|
|
14
15
|
export declare abstract class ContextProvider<Value> extends RegisteredContextProvider {
|
|
16
|
+
/**
|
|
17
|
+
* Read the context's lazy value, sharing one promise across concurrent readers.
|
|
18
|
+
* Always returns a promise, even for synchronous resolvers. Values remain unchanged
|
|
19
|
+
* and application-owned. Missing bindings, cycles, cancellation, and resolver failures reject.
|
|
20
|
+
*
|
|
21
|
+
* @param ctx - Context supplied by Toolgrain to a handler/resolver or made with `toolContext()`.
|
|
22
|
+
* @returns This context's cached value or failure for the provider identity.
|
|
23
|
+
*/
|
|
15
24
|
abstract readonly use: (ctx: ToolContext) => Promise<Value>;
|
|
25
|
+
/**
|
|
26
|
+
* Create an override with the same identity and inferred value contract.
|
|
27
|
+
* Register the override instead of the original; existing accessors find it automatically.
|
|
28
|
+
*
|
|
29
|
+
* @param resolve - Replacement factory, invoked only on first access in each context.
|
|
30
|
+
* @returns A frozen provider binding without changing this provider or other registrations.
|
|
31
|
+
*/
|
|
16
32
|
abstract readonly provide: (resolve: (ctx: ToolContext) => Value | PromiseLike<Value>) => ContextProvider<Value>;
|
|
17
33
|
}
|
|
18
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Define a lazy provider with an inferred value type, including asynchronous factories.
|
|
36
|
+
* Register it in a server or `toolContext()` before calling its `use` accessor.
|
|
37
|
+
* Identity belongs to the definition, not its name. Resources remain application-owned;
|
|
38
|
+
* Toolgrain does not copy, freeze, or automatically dispose the resolved value.
|
|
39
|
+
*
|
|
40
|
+
* @param options - Diagnostic name and factory for the value.
|
|
41
|
+
* @returns A frozen provider with a typed async accessor and override factory.
|
|
42
|
+
* @throws `TypeError` if the name is empty or the resolver is not a function.
|
|
43
|
+
*/
|
|
19
44
|
export declare function createContext<Value>(options: {
|
|
45
|
+
/** Nonempty diagnostic label, used in missing-provider and dependency-cycle errors. */
|
|
20
46
|
name: string;
|
|
47
|
+
/** Lazy factory; may await other registered providers and should pass `ctx.signal` to work. */
|
|
21
48
|
resolve: (ctx: ToolContext) => Value;
|
|
22
49
|
}): ContextProvider<Awaited<Value>>;
|
|
23
50
|
export declare function contextBinding(provider: unknown): ContextBinding;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/context/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMvD,MAAM,WAAW,cAAc;IAC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GAAG,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAG9D,YAAY,IAAI,WAAW,CAE1B;CACF;AAKD,2FAA2F;AAC3F,8BAAsB,eAAe,CAAC,KAAK,CAAE,SAAQ,yBAAyB;IAC5E;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAE5D;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,CACzB,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,KACtD,eAAe,CAAC,KAAK,CAAC,CAAC;CAC7B;AA6BD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE;IAC5C,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAC;IACb,+FAA+F;IAC/F,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,KAAK,CAAC;CACtC,GAAG,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAelC;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,cAAc,CAgBhE"}
|
|
@@ -30,7 +30,16 @@ class Provider extends ContextProvider {
|
|
|
30
30
|
return new Provider({ ...contextBinding(this), resolve }, this.use);
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Define a lazy provider with an inferred value type, including asynchronous factories.
|
|
35
|
+
* Register it in a server or `toolContext()` before calling its `use` accessor.
|
|
36
|
+
* Identity belongs to the definition, not its name. Resources remain application-owned;
|
|
37
|
+
* Toolgrain does not copy, freeze, or automatically dispose the resolved value.
|
|
38
|
+
*
|
|
39
|
+
* @param options - Diagnostic name and factory for the value.
|
|
40
|
+
* @returns A frozen provider with a typed async accessor and override factory.
|
|
41
|
+
* @throws `TypeError` if the name is empty or the resolver is not a function.
|
|
42
|
+
*/
|
|
34
43
|
export function createContext(options) {
|
|
35
44
|
if (!options ||
|
|
36
45
|
typeof options.name !== "string" ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/context/definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAC/D,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAQnE,sFAAsF;AACtF,MAAM,OAAgB,yBAAyB;
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/context/definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAC/D,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AAQnE,sFAAsF;AACtF,MAAM,OAAgB,yBAAyB;IAK7C,qEAAqE;IACrE,YAAY;QACV,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AACD,MAAM,CAAC,cAAc,CAAC,yBAAyB,CAAC,SAAS,EAAE,KAAK,EAAE;IAChE,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC;AAEH,2FAA2F;AAC3F,MAAM,OAAgB,eAAuB,SAAQ,yBAAyB;CAqB7E;AAED,MAAM,QAAgB,SAAQ,eAAsB;IACzC,IAAI,CAAS;IACb,GAAG,CAAuC;IAEnD,YACE,OAAuB,EACvB,GAAG,GAAG,CAAC,GAAgB,EAAE,EAAE,CACzB,WAAW,CAAQ,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC;QAEzD,KAA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AM,OAAO,GAAG,MAAM,CAAC,wBAAwB,CAAC,QAAQ,EAAE,UAAU,CAAC;QACnE,EAAE,KAAmC,CAAC;IACxC,IAAI,CAAC,OAAO;QACV,MAAM,IAAI,SAAS,CACjB,wDAAwD,CACzD,CAAC;IACJ,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ToolRequest } from "./tools/context.js";
|
|
2
2
|
/** Private diagnostics for an unexpected tool failure; no arguments or auth data are added. */
|
|
3
3
|
export interface ToolErrorDetails {
|
|
4
|
+
/** Exposed registration name of the tool whose execution failed. */
|
|
4
5
|
readonly toolName: string;
|
|
6
|
+
/** Frozen request metadata; arguments and authorization credentials are not added. */
|
|
5
7
|
readonly request: ToolRequest;
|
|
6
8
|
}
|
|
7
9
|
export type ErrorHandler = (error: unknown, details?: ToolErrorDetails) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,+FAA+F;AAC/F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAEhF,8FAA8F;AAC9F,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,GAAG,SAAS,EACjC,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,gBAAgB,GACzB,IAAI,CASN"}
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,+FAA+F;AAC/F,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAEhF,8FAA8F;AAC9F,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,GAAG,SAAS,EACjC,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,gBAAgB,GACzB,IAAI,CASN"}
|
package/dist/diagnostics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAYA,8FAA8F;AAC9F,MAAM,UAAU,WAAW,CACzB,OAAiC,EACjC,KAAc,EACd,OAA0B;IAE1B,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,IAAI,CAAC;QACH,MAAM,MAAM,GACV,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACnE,KAAK,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,wDAAwD;IAC1D,CAAC;AACH,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -4,32 +4,89 @@ import type { RegisteredContextProvider } from "./context/definition.js";
|
|
|
4
4
|
import { type ErrorHandler } from "./diagnostics.js";
|
|
5
5
|
import type { ToolMap } from "./tools/registry.js";
|
|
6
6
|
import { type RequestTransport, type Transport } from "./transport.js";
|
|
7
|
+
/** Tool registrations, identity, and shared configuration for an MCP server. */
|
|
7
8
|
export interface ServerOptions<Tools extends ToolMap = ToolMap> {
|
|
9
|
+
/** Server implementation name advertised to clients. */
|
|
8
10
|
name: string;
|
|
11
|
+
/** Application version advertised to clients; independent of the protocol revision. */
|
|
9
12
|
version: string;
|
|
13
|
+
/** Tools made with `tool()`; each registration key becomes its exposed tool name. */
|
|
10
14
|
tools: Tools;
|
|
15
|
+
/** Optional usage instructions advertised to clients during discovery or initialization. */
|
|
11
16
|
instructions?: string;
|
|
12
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Receives original unexpected failures for private diagnostics. Tool failures
|
|
19
|
+
* include frozen tool/request details; auth and transport failures pass only
|
|
20
|
+
* the error. Throws and rejected promises from this callback are ignored.
|
|
21
|
+
*/
|
|
13
22
|
onError?: ErrorHandler;
|
|
23
|
+
/** Eager endpoint authorization; requires a request transport rather than stdio. */
|
|
14
24
|
auth?: AuthProvider;
|
|
25
|
+
/** Lazy providers or typed overrides available to handlers; registration order is irrelevant. */
|
|
15
26
|
context?: readonly RegisteredContextProvider[];
|
|
16
27
|
}
|
|
28
|
+
/** Request-local settings for direct protocol dispatch through `Server.handle()`. */
|
|
17
29
|
export interface HandleOptions {
|
|
30
|
+
/** Cooperative cancellation signal; handlers must observe it, and late responses are suppressed. */
|
|
18
31
|
signal?: AbortSignal;
|
|
32
|
+
/**
|
|
33
|
+
* Protocol revision selected by the adapter. If omitted, dispatch is modern except
|
|
34
|
+
* for legacy initialization requests without explicit protocol-version metadata.
|
|
35
|
+
*/
|
|
19
36
|
protocolVersion?: SupportedProtocolVersion;
|
|
37
|
+
/** Single-use scope issued by this server's `authorize()`; dispose it in `finally`. */
|
|
20
38
|
auth?: AuthScope;
|
|
21
39
|
}
|
|
40
|
+
/** An MCP dispatcher with one optional transport attachment and terminal shutdown. */
|
|
22
41
|
export interface Server {
|
|
42
|
+
/**
|
|
43
|
+
* Dispatch a decoded JSON value, including tool validation and MCP result conversion.
|
|
44
|
+
* This independent request path does not retain initialization or session state.
|
|
45
|
+
*
|
|
46
|
+
* @param message - Untrusted, already JSON-decoded protocol message.
|
|
47
|
+
* @param options - Cancellation, protocol selection, and any required authorization scope.
|
|
48
|
+
* @returns A protocol response, or `undefined` for ignored or cancelled messages.
|
|
49
|
+
* @throws If the server is closed or its required authorization scope is invalid.
|
|
50
|
+
*/
|
|
23
51
|
handle(message: unknown, options?: HandleOptions): Promise<ProtocolResponse | undefined>;
|
|
52
|
+
/** Return copied wire descriptions using registration keys as tool names. */
|
|
24
53
|
getToolDefinitions(): ProtocolTool[];
|
|
54
|
+
/** Return copied public auth configuration, or `undefined` for an unprotected server. */
|
|
25
55
|
getAuthMetadata(): AuthMetadata | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Verify a bearer token before reading a request body or invoking tools.
|
|
58
|
+
* The identity is copied and deeply frozen before a server-bound scope is issued.
|
|
59
|
+
*
|
|
60
|
+
* @param accessToken - Raw bearer token, without the `Bearer ` prefix.
|
|
61
|
+
* @param options - Resource audience and cancellation settings for this request.
|
|
62
|
+
* @returns A single-use scope; the caller must dispose it in `finally`.
|
|
63
|
+
* @throws For rejected credentials, provider failures, cancellation, or a closed server.
|
|
64
|
+
*/
|
|
26
65
|
authorize(accessToken: string, options: {
|
|
66
|
+
/** Public MCP resource URL; a configured provider resource takes precedence. */
|
|
27
67
|
resource: string;
|
|
68
|
+
/** Cancels verification and remains active while the returned scope is in use. */
|
|
28
69
|
signal?: AbortSignal;
|
|
29
70
|
}): Promise<AuthScope>;
|
|
71
|
+
/**
|
|
72
|
+
* Attach and start one single-use transport, resolving when startup completes.
|
|
73
|
+
* Auth-configured servers require a request transport. A closed server cannot restart.
|
|
74
|
+
*
|
|
75
|
+
* @param transport - An unused transport, including one from a compatible package copy.
|
|
76
|
+
* @throws If attachment or startup fails, or the transport is already owned.
|
|
77
|
+
*/
|
|
30
78
|
listen(transport: Transport | RequestTransport): Promise<void>;
|
|
79
|
+
/** Abort active work and close the attached transport; repeated or nested calls are safe. */
|
|
31
80
|
close(): Promise<void>;
|
|
32
81
|
}
|
|
33
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Create a server from reusable tools, optional auth, and lazy context providers.
|
|
84
|
+
* Registration validates tool names, metadata, and exposable schemas immediately.
|
|
85
|
+
* Creating the server does not start a transport or resolve context providers.
|
|
86
|
+
*
|
|
87
|
+
* @param options - Server identity and application-owned tool/provider registrations.
|
|
88
|
+
* @returns An independent server ready for direct dispatch or `listen()`.
|
|
89
|
+
* @throws For invalid registrations, tool schemas, or authorization configuration.
|
|
90
|
+
*/
|
|
34
91
|
export declare function createServer<const Tools extends ToolMap>(options: ServerOptions<Tools>): Server;
|
|
35
92
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,IAAI,IAAI,YAAY,EACpB,wBAAwB,EACzB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAKlE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,aAAa,CAAC,KAAK,SAAS,OAAO,GAAG,OAAO;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,E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;;;;;;;OAQG;IACH,MAAM,CACJ,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IACzC,6EAA6E;IAC7E,kBAAkB,IAAI,YAAY,EAAE,CAAC;IACrC,yFAAyF;IACzF,eAAe,IAAI,YAAY,GAAG,SAAS,CAAC;IAC5C;;;;;;;;OAQG;IACH,SAAS,CACP,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;QACP,gFAAgF;QAChF,QAAQ,EAAE,MAAM,CAAC;QACjB,kFAAkF;QAClF,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,GACA,OAAO,CAAC,SAAS,CAAC,CAAC;IACtB;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,6FAA6F;IAC7F,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,KAAK,SAAS,OAAO,EACtD,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,GAC5B,MAAM,CAyGR"}
|
package/dist/server.js
CHANGED
|
@@ -8,7 +8,15 @@ import { executeRequest } from "./execute-request.js";
|
|
|
8
8
|
import { decode } from "./protocol/decode.js";
|
|
9
9
|
import { createToolAdapter } from "./tools/adapter.js";
|
|
10
10
|
import { isRequestTransport, } from "./transport.js";
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Create a server from reusable tools, optional auth, and lazy context providers.
|
|
13
|
+
* Registration validates tool names, metadata, and exposable schemas immediately.
|
|
14
|
+
* Creating the server does not start a transport or resolve context providers.
|
|
15
|
+
*
|
|
16
|
+
* @param options - Server identity and application-owned tool/provider registrations.
|
|
17
|
+
* @returns An independent server ready for direct dispatch or `listen()`.
|
|
18
|
+
* @throws For invalid registrations, tool schemas, or authorization configuration.
|
|
19
|
+
*/
|
|
12
20
|
export function createServer(options) {
|
|
13
21
|
const authorization = createAuthorization(options.auth);
|
|
14
22
|
const tools = createToolAdapter(options.tools, options.onError);
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAqB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EACL,kBAAkB,GAGnB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAqB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MA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