@ganintegrity/mcp 1.1.0 → 1.1.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 CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  A small library for mounting a [Model Context Protocol](https://modelcontextprotocol.io) server onto an Express app inside a Gan Integrity service. It owns the MCP plumbing — Streamable-HTTP transport wiring, per-request scoping, tool-result envelopes — and **inverts the dependencies** that vary per service: auth, logging, postgan construction, and the application's own error types are all injected by the caller.
4
4
 
5
- If you've worked on a `src/mcp/scaffold/` folder before, this is the library extraction of that pattern.
6
-
7
5
  ---
8
6
 
9
7
  ## Why this library exists
@@ -378,7 +376,7 @@ declare global {
378
376
  }
379
377
  ```
380
378
 
381
- This ships in `dist/index.d.ts` — once you import anything from `@ganintegrity/mcp`, both fields are available on `Request` throughout your project. The library does **not** declare `req.user` or `req.postgan` — those remain your service's concern (typically in your existing `types/express.d.ts`).
379
+ This ships in `dist/express/index.d.ts` — once you import anything from `@ganintegrity/mcp/express`, both fields are available on `Request` throughout your project. The framework-neutral root entry (`@ganintegrity/mcp`) has no Express side-effects, so services that don't run Express won't see Express types in their globals. The library does **not** declare `req.user` or `req.postgan` — those remain your service's concern (typically in your existing `types/express.d.ts`).
382
380
 
383
381
  ### The `AuthUser` contract
384
382
 
@@ -477,25 +475,8 @@ You could call `materializeSdkServer(mcp).registerTool(...)` directly and skip a
477
475
 
478
476
  ---
479
477
 
480
- ## Development
481
-
482
- ```bash
483
- pnpm install # install deps
484
- pnpm build # tsc → dist/
485
- pnpm typecheck # tsc --noEmit
486
- pnpm test # vitest run
487
- pnpm lint # eslint src/**/*.ts
488
- pnpm format # prettier --write
489
- ```
490
-
491
- The repo uses:
492
-
493
- - **TypeScript 6** with NodeNext module resolution and `rewriteRelativeImportExtensions` (so source can import `./foo.ts` and emit `./foo.js`).
494
- - **ESLint 10 flat config** + `typescript-eslint`.
495
- - **Vitest 4** for tests.
496
- - **Semantic-release** for publishing.
497
- - **Commitlint** with conventional-commits.
498
-
499
- ### A note on `pnpm.peerDependencyRules`
478
+ ## Contributing
500
479
 
501
- `package.json` sets `pnpm.peerDependencyRules.allowedVersions` for several `@ganintegrity/*` packages and an `ignoreMissing` list for optional peers (`pg-native`, `tedious`, etc.). These suppress warnings caused by transitive packages declaring older peer ranges than the resolved versions. The suppression is intentional — the version skew is known and tolerated within the gan ecosystem. If a real peer mismatch appears in a future install, it'll stand out instead of being lost in noise.
480
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for the development loop, the
481
+ public-API contract (api-extractor + checked-in `.api.md` reports), how to
482
+ ship a breaking change, and commit conventions.
@@ -4,17 +4,24 @@ import type { Logger } from "pino";
4
4
  import type { AuthUser } from "./auth/auth.types.ts";
5
5
  import type { McpErrorMapper } from "./errors/errors.types.ts";
6
6
  /**
7
- * Internal per-request bundle. Exported only for advanced consumers who
8
- * write their own tool wrappers and need to read the active scope directly;
9
- * regular tool handlers receive `ToolContext` instead.
7
+ * Per-request bundle held inside the library's `AsyncLocalStorage`. Exported
8
+ * only for advanced consumers who write their own tool wrappers and need to
9
+ * read the active scope directly; regular tool handlers receive `ToolContext`
10
+ * instead.
11
+ *
12
+ * @public
10
13
  */
11
14
  export interface RequestStore {
15
+ /** Authenticated user resolved from the bearer token. */
12
16
  user: AuthUser;
17
+ /** Per-request Postgan instance, attached upstream by `setupPostgan`. */
13
18
  postgan: Postgan;
19
+ /** `X-Session-Id` header value, if the client supplied one. */
14
20
  sessionId?: string;
21
+ /** Logger childed with `component: "mcp"` plus per-request scope. */
15
22
  logger: Logger;
16
23
  /**
17
- * Translate thrown errors into MCP envelopes. Set by `createMcpServer`
24
+ * Translate thrown errors into MCP envelopes. Set by `defineMcpServer`
18
25
  * from its `errorMapper` option; tool wrappers use it before falling
19
26
  * through to the redacted `INTERNAL_ERROR` envelope.
20
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"als.d.ts","sourceRoot":"","sources":["../../src/core/als.ts"],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 -1 +1 @@
1
- {"version":3,"file":"als.js","sourceRoot":"","sources":["../../src/core/als.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAyBrD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,iBAAiB,EAAgB,CAAC"}
1
+ {"version":3,"file":"als.js","sourceRoot":"","sources":["../../src/core/als.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAgCrD,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,iBAAiB,EAAgB,CAAC"}
@@ -5,13 +5,19 @@ import type { Logger } from "pino";
5
5
  * richer service-specific user type. Inside tool handlers, `ctx.user` is
6
6
  * typed as `AuthUser`; cast to your service's richer type when you need
7
7
  * extra fields.
8
+ *
9
+ * @public
8
10
  */
9
11
  export interface AuthUser {
12
+ /** Stable identifier for the authenticated user. */
10
13
  id: string;
14
+ /** Tenant key — the user's company subdomain, used for downstream scoping. */
11
15
  companySubdomainName: string;
12
16
  }
13
17
  /**
14
18
  * Configuration for `mcpAuth`.
19
+ *
20
+ * @public
15
21
  */
16
22
  export interface McpAuthOptions {
17
23
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"auth.types.d.ts","sourceRoot":"","sources":["../../../src/core/auth/auth.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;OAOG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClD,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;CAChB"}
1
+ {"version":3,"file":"auth.types.d.ts","sourceRoot":"","sources":["../../../src/core/auth/auth.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,oDAAoD;IACpD,EAAE,EAAE,MAAM,CAAC;IACX,8EAA8E;IAC9E,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;OAOG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClD,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -4,8 +4,8 @@ import type { AuthUser, McpAuthOptions } from "./auth.types.ts";
4
4
  * `ctx.headers` satisfy this shape — Node lowercases the keys at the HTTP
5
5
  * layer, so `"authorization"` and `"x-session-id"` reads work for either.
6
6
  */
7
- export type HeaderBag = Record<string, string | string[] | undefined>;
8
- export type AuthResult = {
7
+ type HeaderBag = Record<string, string | string[] | undefined>;
8
+ type AuthResult = {
9
9
  ok: true;
10
10
  user: AuthUser;
11
11
  token: string;
@@ -30,4 +30,5 @@ export type AuthResult = {
30
30
  * on `options.logger` before the result is returned.
31
31
  */
32
32
  export declare function resolveAuth(headers: HeaderBag, options: McpAuthOptions): Promise<AuthResult>;
33
+ export {};
33
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIhE;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAEtE,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAiBhD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,UAAU,CAAC,CA0BrB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIhE;;;;GAIG;AACH,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAE/D,KAAK,UAAU,GACX;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAiBhD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,UAAU,CAAC,CA0BrB"}
@@ -3,6 +3,8 @@ import type { McpErrorMapper } from "./errors/errors.types.ts";
3
3
  import type { ToolRegister, ToolRegistration } from "./tool/tool.types.ts";
4
4
  /**
5
5
  * Options for {@link defineMcpServer}.
6
+ *
7
+ * @public
6
8
  */
7
9
  export interface DefineMcpServerOptions {
8
10
  /** MCP server name advertised to clients during initialisation. */
@@ -30,11 +32,21 @@ export interface DefineMcpServerOptions {
30
32
  * The serialisable shape adapters consume. Holds the captured tool
31
33
  * registrations alongside the metadata needed to materialise an SDK server
32
34
  * per request. Treat as opaque outside of adapters and tests.
35
+ *
36
+ * @public
33
37
  */
34
38
  export interface McpDefinition {
39
+ /** MCP server name, forwarded to the SDK server on each request. */
35
40
  readonly name: string;
41
+ /** MCP server version, forwarded to the SDK server on each request. */
36
42
  readonly version: string;
43
+ /**
44
+ * Captured tool registrations. Adapters pass these through to
45
+ * `materializeSdkServer`, which replays them onto a fresh SDK server
46
+ * per request. Typical consumers don't touch this; adapter authors do.
47
+ */
37
48
  readonly registrations: readonly ToolRegistration[];
49
+ /** Error mapper carried from the `DefineMcpServerOptions`. */
38
50
  readonly errorMapper?: McpErrorMapper;
39
51
  }
40
52
  /**
@@ -47,6 +59,8 @@ export interface McpDefinition {
47
59
  * handler bakes in ALS-reading, transaction lifecycle, and error mapping
48
60
  * so per-request adapters can replay the registrations onto a fresh
49
61
  * `McpServer` without any extra wiring.
62
+ *
63
+ * @public
50
64
  */
51
65
  export declare function defineMcpServer(options: DefineMcpServerOptions): McpDefinition;
52
66
  /**
@@ -59,6 +73,8 @@ export declare function defineMcpServer(options: DefineMcpServerOptions): McpDef
59
73
  *
60
74
  * Exposed for tests and advanced consumers writing custom adapters.
61
75
  * Typical consumers don't call this directly.
76
+ *
77
+ * @public
62
78
  */
63
79
  export declare function materializeSdkServer(mcp: McpDefinition): McpServer;
64
80
  //# sourceMappingURL=define.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/core/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG3E;;GAEG;AACH,MAAM,WAAW,sBAA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CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,CAAC,EAAE,cAAc,CAAC;CACvC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,sBAAsB,GAC9B,aAAa,CAcf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,SAAS,CAiBlE"}
@@ -10,6 +10,8 @@ import { wrapToolHandler } from "./tool/index.js";
10
10
  * handler bakes in ALS-reading, transaction lifecycle, and error mapping
11
11
  * so per-request adapters can replay the registrations onto a fresh
12
12
  * `McpServer` without any extra wiring.
13
+ *
14
+ * @public
13
15
  */
14
16
  export function defineMcpServer(options) {
15
17
  const registrations = [];
@@ -36,6 +38,8 @@ export function defineMcpServer(options) {
36
38
  *
37
39
  * Exposed for tests and advanced consumers writing custom adapters.
38
40
  * Typical consumers don't call this directly.
41
+ *
42
+ * @public
39
43
  */
40
44
  export function materializeSdkServer(mcp) {
41
45
  const server = new McpServer({ name: mcp.name, version: mcp.version });
@@ -1 +1 @@
1
- {"version":3,"file":"define.js","sourceRoot":"","sources":["../../src/core/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAwClD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,OAA+B;IAE/B,MAAM,aAAa,GAAuB,EAAE,CAAC;IAC7C,MAAM,QAAQ,GAAiB;QAC7B,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;YACb,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;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;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,aAAa;QACb,WAAW,EAAE,OAAO,CAAC,WAAW;KACjC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAkB;IACrD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IASvE,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CACvC,MAAM,CACsB,CAAC;IAC/B,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;QACpC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -8,7 +8,7 @@ import { type McpDefinition } from "./define.ts";
8
8
  * adapter pulls these out of its native request shape (Express `req.user` /
9
9
  * `req.postgan` / `req.mcpSessionId`; Koa `ctx.state.*`).
10
10
  */
11
- export interface DispatchScope {
11
+ interface DispatchScope {
12
12
  user: AuthUser;
13
13
  postgan: Postgan;
14
14
  sessionId?: string;
@@ -31,4 +31,5 @@ export interface DispatchScope {
31
31
  * Never throws.
32
32
  */
33
33
  export declare function dispatchMcpRequest(mcp: McpDefinition, logger: Logger, scope: DispatchScope, invokeTransport: (transport: StreamableHTTPServerTransport) => Promise<void>, onTransportError: () => void): Promise<void>;
34
+ export {};
34
35
  //# sourceMappingURL=dispatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/core/dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACr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A6B,KAAK,OAAO,CAAC,IAAI,CAAC,EAC5E,gBAAgB,EAAE,MAAM,IAAI,GAC3B,OAAO,CAAC,IAAI,CAAC,CAmCf"}
@@ -1,4 +1,11 @@
1
1
  import type { Logger } from "pino";
2
+ /**
3
+ * Drives logging behaviour when a tool throws: `"warn"` logs at info level
4
+ * and treats the error as expected (e.g. validation rejection); `"error"`
5
+ * logs at error level with the original cause attached.
6
+ *
7
+ * @public
8
+ */
2
9
  export type McpToolErrorSeverity = "warn" | "error";
3
10
  /**
4
11
  * Shape returned by an {@link McpErrorMapper} to describe how a thrown error
@@ -7,6 +14,8 @@ export type McpToolErrorSeverity = "warn" | "error";
7
14
  * The library does not define an error *class* — consumers throw whatever
8
15
  * type their service already uses, and the mapper translates it into this
9
16
  * shape at the tool boundary.
17
+ *
18
+ * @public
10
19
  */
11
20
  export interface McpToolError {
12
21
  /** Stable machine-readable code surfaced to the agent. */
@@ -24,11 +33,23 @@ export interface McpToolError {
24
33
  * Translate a thrown error into an {@link McpToolError} envelope, or
25
34
  * return `null` to fall through to the generic `INTERNAL_ERROR` envelope
26
35
  * with a redacted message.
36
+ *
37
+ * @public
27
38
  */
28
39
  export type McpErrorMapper = (err: unknown) => McpToolError | null;
40
+ /**
41
+ * Context the tool wrapper passes to `toCallToolError` when building the
42
+ * MCP error envelope. Consumers writing their own tool wrappers populate
43
+ * this from their request scope.
44
+ *
45
+ * @public
46
+ */
29
47
  export interface ToolErrorMeta {
48
+ /** Tool name — included in error logs. */
30
49
  tool: string;
50
+ /** Forwarded `X-Session-Id` value if present — included in error logs. */
31
51
  sessionId?: string;
52
+ /** Logger to write the error/info entry against. */
32
53
  logger: Logger;
33
54
  }
34
55
  //# sourceMappingURL=errors.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.types.d.ts","sourceRoot":"","sources":["../../../src/core/errors/errors.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEn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AEnE;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -3,6 +3,8 @@ import type { McpToolError, ToolErrorMeta } from "./errors.types.ts";
3
3
  /**
4
4
  * The only code the library itself emits — surfaced in the redacted
5
5
  * envelope when a thrown error has no mapping. Consumer codes are theirs.
6
+ *
7
+ * @public
6
8
  */
7
9
  export declare const INTERNAL_ERROR = "INTERNAL_ERROR";
8
10
  /**
@@ -22,6 +24,8 @@ export declare const INTERNAL_ERROR = "INTERNAL_ERROR";
22
24
  * error message is **not** surfaced.
23
25
  *
24
26
  * Never throws (assumes `meta.logger` does not throw).
27
+ *
28
+ * @public
25
29
  */
26
30
  export declare function toCallToolError(mapped: McpToolError | null, originalErr: unknown, meta: ToolErrorMeta): CallToolResult;
27
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAErE;;;GAGG;AACH,eAAO,MAAM,cAAc,mBAAmB,CAAC;AA+D/C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,WAAW,EAAE,OAAO,EACpB,IAAI,EAAE,aAAa,GAClB,cAAc,CAMhB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,cAAc,mBAAmB,CAAC;AA+D/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,YAAY,GAAG,IAAI,EAC3B,WAAW,EAAE,OAAO,EACpB,IAAI,EAAE,aAAa,GAClB,cAAc,CAMhB"}
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * The only code the library itself emits — surfaced in the redacted
3
3
  * envelope when a thrown error has no mapping. Consumer codes are theirs.
4
+ *
5
+ * @public
4
6
  */
5
7
  export const INTERNAL_ERROR = "INTERNAL_ERROR";
6
8
  function logMappedError(mapped, meta) {
@@ -67,6 +69,8 @@ function unknownErrorEnvelope(err, meta) {
67
69
  * error message is **not** surfaced.
68
70
  *
69
71
  * Never throws (assumes `meta.logger` does not throw).
72
+ *
73
+ * @public
70
74
  */
71
75
  export function toCallToolError(mapped, originalErr, meta) {
72
76
  if (mapped) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/errors/index.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C,SAAS,cAAc,CAAC,MAAoB,EAAE,IAAmB;IAC/D,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,KAAK,CACf;YACE,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,EACD,iBAAiB,CAClB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,MAAM,CAAC,IAAI,CACd;YACE,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;YAC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OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvD;KACF,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,GAAY,EACZ,IAAmB;IAEnB,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,IAAI,CAAC,MAAM,CAAC,KAAK,CACf;QACE,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;QAC3C,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,EACD,0BAA0B,CAC3B,CAAC;IACF,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iDAAiD,EAAE;SAC1E;QACD,iBAAiB,EAAE;YACjB,IAAI,EAAE,cAAc;YACpB,OAAO;SACR;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,eAAe,CAC7B,MAA2B,EAC3B,WAAoB,EACpB,IAAmB;IAEnB,IAAI,MAAM,EAAE,CAAC;QACX,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7B,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC"}
@@ -4,6 +4,8 @@ import type { z } from "zod";
4
4
  import type { AuthUser } from "../auth/auth.types.ts";
5
5
  /**
6
6
  * What every tool handler receives as its second argument.
7
+ *
8
+ * @public
7
9
  */
8
10
  export interface ToolContext {
9
11
  /** Authenticated user. Cast to your service's richer type for extra fields. */
@@ -28,6 +30,8 @@ export interface ToolContext {
28
30
  *
29
31
  * Pick honestly: `readOnlyHint: true` on a tool that mutates is worse than
30
32
  * leaving the hint unset.
33
+ *
34
+ * @public
31
35
  */
32
36
  export interface ToolAnnotations {
33
37
  /** Human-readable display title (defaults to `name` if omitted). */
@@ -45,9 +49,11 @@ export interface ToolAnnotations {
45
49
  * Specification passed to `tool()`. Defines the tool's name, description,
46
50
  * input schema, optional annotations, and the handler that executes it.
47
51
  *
48
- * @template Schema Zod object schema describing the tool's input.
49
- * @template Output Plain object the handler returns. Surfaced as both a JSON
52
+ * @typeParam Schema - Zod object schema describing the tool's input.
53
+ * @typeParam Output - Plain object the handler returns. Surfaced as both a JSON
50
54
  * `text` content block and as `structuredContent`.
55
+ *
56
+ * @public
51
57
  */
52
58
  export interface ToolSpec<Schema extends z.ZodObject, Output> {
53
59
  /** Stable identifier the agent uses to invoke the tool. */
@@ -70,24 +76,33 @@ export interface ToolSpec<Schema extends z.ZodObject, Output> {
70
76
  handler: (args: z.infer<Schema>, ctx: ToolContext) => Promise<Output>;
71
77
  }
72
78
  /**
73
- * Internal data shape produced by `wrapToolHandler` and held on
74
- * `McpDefinition.registrations`. Loose types here the SDK's
75
- * `registerTool` is generically overloaded so `Parameters<>` resolves
76
- * unhelpfully; `materializeSdkServer` casts at the boundary.
79
+ * Captured tool registration held on `McpDefinition.registrations` and
80
+ * replayed onto a fresh SDK server by {@link materializeSdkServer}.
77
81
  *
78
- * Consumers never construct or inspect `ToolRegistration` directly.
82
+ * Loose types here the SDK's `registerTool` is generically overloaded so
83
+ * `Parameters<>` resolves unhelpfully; `materializeSdkServer` casts at the
84
+ * boundary. Typical consumers don't touch this; surfaced for adapter
85
+ * authors who walk `McpDefinition.registrations` directly.
86
+ *
87
+ * @public
79
88
  */
80
89
  export interface ToolRegistration {
90
+ /** The tool's stable identifier, forwarded to `registerTool` as the first argument. */
81
91
  name: string;
92
+ /** SDK-shaped registration config (description, input schema, annotations). */
82
93
  config: object;
94
+ /** Pre-wrapped handler — already wired with ALS, transactions, and error mapping. */
83
95
  handler: (...args: unknown[]) => Promise<unknown>;
84
96
  }
85
97
  /**
86
98
  * What `defineMcpServer({ tools })` hands to its callback. The single
87
99
  * `tool(spec)` method captures each registration into the underlying
88
100
  * {@link McpDefinition}.
101
+ *
102
+ * @public
89
103
  */
90
104
  export interface ToolRegister {
105
+ /** Capture a tool registration. Call once per tool inside the `tools` callback. */
91
106
  tool<Schema extends z.ZodObject, Output extends Record<string, unknown>>(spec: ToolSpec<Schema, Output>): void;
92
107
  }
93
108
  //# sourceMappingURL=tool.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.types.d.ts","sourceRoot":"","sources":["../../../src/core/tool/tool.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,IAAI,EAAE,QAAQ,CAAC;IACf,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,WAAW,EAAE,kBAAkB,CAAC;IAChC,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mDAAmD;IACnD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yEAAyE;IACzE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oFAAoF;IACpF,aAAa,CAAC,EAAE,O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;AACH,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,IAAI,CAAC,MAAM,SAAS,CAAC,CAAC,SAAS,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrE,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,IAAI,CAAC;CACT"}
@@ -7,7 +7,7 @@ import type { McpAuthOptions } from "../core/auth/auth.types.ts";
7
7
  * `401` and does not call `next`.
8
8
  *
9
9
  * On success it sets:
10
- * - `req.user` — the resolved {@link AuthUser}
10
+ * - `req.user` — the resolved `AuthUser` (re-export from `@ganintegrity/mcp`)
11
11
  * - `req.headers.company` — `user.companySubdomainName` (for downstream
12
12
  * middleware that keys off the company header)
13
13
  * - `req.auth` — SDK-shaped `AuthInfo`, surfaced to MCP tool handlers as
@@ -20,9 +20,11 @@ import type { McpAuthOptions } from "../core/auth/auth.types.ts";
20
20
  * **Never throws.** All failures (missing token, `tokenToUser` rejection)
21
21
  * are turned into `401` responses; the middleware does not call `next(err)`.
22
22
  *
23
- * Mounted automatically by `createMcpServer`'s `mount()`. Exported in case
24
- * you want to compose it differently (e.g. mount under a different router,
25
- * or stack additional middleware).
23
+ * Mounted automatically by {@link createMcpRouter}. Exported in case you
24
+ * want to compose it differently (e.g. mount under a different router, or
25
+ * stack additional middleware).
26
+ *
27
+ * @public
26
28
  */
27
29
  export declare function mcpAuth(options: McpAuthOptions): RequestHandler;
28
30
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/express/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAG/E,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI3E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAwB/D"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/express/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAG/E,OAAO,KAAK,EAAY,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI3E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAwB/D"}
@@ -6,7 +6,7 @@ import { resolveAuth } from "../core/auth/index.js";
6
6
  * `401` and does not call `next`.
7
7
  *
8
8
  * On success it sets:
9
- * - `req.user` — the resolved {@link AuthUser}
9
+ * - `req.user` — the resolved `AuthUser` (re-export from `@ganintegrity/mcp`)
10
10
  * - `req.headers.company` — `user.companySubdomainName` (for downstream
11
11
  * middleware that keys off the company header)
12
12
  * - `req.auth` — SDK-shaped `AuthInfo`, surfaced to MCP tool handlers as
@@ -19,9 +19,11 @@ import { resolveAuth } from "../core/auth/index.js";
19
19
  * **Never throws.** All failures (missing token, `tokenToUser` rejection)
20
20
  * are turned into `401` responses; the middleware does not call `next(err)`.
21
21
  *
22
- * Mounted automatically by `createMcpServer`'s `mount()`. Exported in case
23
- * you want to compose it differently (e.g. mount under a different router,
24
- * or stack additional middleware).
22
+ * Mounted automatically by {@link createMcpRouter}. Exported in case you
23
+ * want to compose it differently (e.g. mount under a different router, or
24
+ * stack additional middleware).
25
+ *
26
+ * @public
25
27
  */
26
28
  export function mcpAuth(options) {
27
29
  return async (req, res, next) => {
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/express/auth.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKpD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,OAAO,CAAC,OAAuB;IAC7C,OAAO,KAAK,EACV,GAAY,EACZ,GAAa,EACb,IAAkB,EACH,E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M,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1D,OAAO;QACT,CAAC;QACA,GAAmB,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxC,GAAG,CAAC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;QACvD,GAAG,CAAC,IAAI,GAAG;YACT,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE;YACxB,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE;SAC7B,CAAC;QACF,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACrB,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC;QACtC,CAAC;QACD,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
@@ -7,6 +7,8 @@ import type { AuthUser } from "../core/auth/auth.types.ts";
7
7
  * framework-neutral bits (name, version, tools, errorMapper) live on the
8
8
  * `McpDefinition` argument; this options bag holds only what's specific
9
9
  * to mounting against an Express stack.
10
+ *
11
+ * @public
10
12
  */
11
13
  export interface CreateMcpRouterOptions {
12
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"express.types.d.ts","sourceRoot":"","sources":["../../src/express/express.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClD;;;;OAIG;IACH,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG;IACzC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
1
+ {"version":3,"file":"express.types.d.ts","sourceRoot":"","sources":["../../src/express/express.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClD;;;;OAIG;IACH,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG;IACzC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Express adapter for `@ganintegrity/mcp`. Mounts an `McpDefinition` (built
3
+ * with `defineMcpServer`) as an Express router and provides the bearer-token
4
+ * auth middleware that resolves users for incoming requests.
5
+ *
6
+ * @packageDocumentation
7
+ */
1
8
  import { type Router } from "express";
2
9
  import type { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types.js";
3
10
  import { mcpAuth } from "./auth.ts";
@@ -14,7 +21,7 @@ declare global {
14
21
  export { mcpAuth };
15
22
  export type { CreateMcpRouterOptions } from "./express.types.ts";
16
23
  /**
17
- * Build an Express router that serves an {@link McpDefinition}. Mount the
24
+ * Build an Express router that serves an `McpDefinition` (from `@ganintegrity/mcp`). Mount the
18
25
  * returned router on whatever path you like
19
26
  * (`app.use("/mcp", createMcpRouter(mcp, opts))`).
20
27
  *
@@ -27,6 +34,8 @@ export type { CreateMcpRouterOptions } from "./express.types.ts";
27
34
  * `ToolContext` without Express objects leaking in.
28
35
  *
29
36
  * Synchronous and never throws.
37
+ *
38
+ * @public
30
39
  */
31
40
  export declare function createMcpRouter(mcp: McpDefinition, options: CreateMcpRouterOptions): Router;
32
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/express/index.ts"],"names":[],"mappings":"AAAA,OAAgB,EAA+B,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAG/E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,CAAC,MAAM,CAAC;IAIb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,IAAI,CAAC,EAAE,QAAQ,CAAC;SACjB;KACF;CACF;AAED,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AA+BjE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,sBAAsB,GAC9B,MAAM,CAQR"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/express/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAgB,EAA+B,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAG/E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,CAAC,MAAM,CAAC;IAIb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,IAAI,CAAC,EAAE,QAAQ,CAAC;SACjB;KACF;CACF;AAED,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AA+BjE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,sBAAsB,GAC9B,MAAM,CAQR"}
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Express adapter for `@ganintegrity/mcp`. Mounts an `McpDefinition` (built
3
+ * with `defineMcpServer`) as an Express router and provides the bearer-token
4
+ * auth middleware that resolves users for incoming requests.
5
+ *
6
+ * @packageDocumentation
7
+ */
1
8
  import express, {} from "express";
2
9
  import { mcpAuth } from "./auth.js";
3
10
  import { dispatchMcpRequest } from "../core/dispatch.js";
@@ -24,7 +31,7 @@ function handleMcpRequest(mcp, logger) {
24
31
  };
25
32
  }
26
33
  /**
27
- * Build an Express router that serves an {@link McpDefinition}. Mount the
34
+ * Build an Express router that serves an `McpDefinition` (from `@ganintegrity/mcp`). Mount the
28
35
  * returned router on whatever path you like
29
36
  * (`app.use("/mcp", createMcpRouter(mcp, opts))`).
30
37
  *
@@ -37,6 +44,8 @@ function handleMcpRequest(mcp, logger) {
37
44
  * `ToolContext` without Express objects leaking in.
38
45
  *
39
46
  * Synchronous and never throws.
47
+ *
48
+ * @public
40
49
  */
41
50
  export function createMcpRouter(mcp, options) {
42
51
  const mcpLogger = options.logger.child({ component: "mcp" });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/express/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAA4C,MAAM,SAAS,CAAC;AAI5E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAmBzD,OAAO,EAAE,OAAO,EAAE,CAAC;AAGnB;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,GAAkB,EAAE,MAAc;IAC1D,OAAO,KAAK,EAAE,GAAY,EAAE,GAAa,EAAiB,EAAE;QAC1D,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,GAAyB,CAAC;QACpD,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACtB,gEAAgE;YAChE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;YACnD,OAAO;QACT,CAAC;QAED,MAAM,kBAAkB,CACtB,GAAG,EACH,MAAM,EACN,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE,EAC9C,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,EAC1D,GAAG,EAAE;YACH,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,8BAA8B,EAAE,CAAC,CAAC;YAClE,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAA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
3
- * the types every adapter shares live here. Bootstrap files importing the
4
- * adapter factory should reach for a per-framework subpath
5
- * (`@ganintegrity/mcp/express`); tool files import from this root.
2
+ * Framework-neutral entry for `@ganintegrity/mcp`. Tool definitions, error
3
+ * envelope plumbing, and the types every adapter shares live here. Bootstrap
4
+ * files importing the adapter factory should reach for a per-framework
5
+ * subpath (`@ganintegrity/mcp/express`); tool files import from this root.
6
+ *
7
+ * @packageDocumentation
6
8
  */
7
9
  export { defineMcpServer, materializeSdkServer } from "./core/define.ts";
8
10
  export type { DefineMcpServerOptions, McpDefinition } from "./core/define.ts";
9
- export type { ToolSpec, ToolAnnotations, ToolContext, ToolRegister, } from "./core/tool/tool.types.ts";
11
+ export type { ToolSpec, ToolAnnotations, ToolContext, ToolRegister, ToolRegistration, } from "./core/tool/tool.types.ts";
12
+ /**
13
+ * MCP SDK server class — re-exported as a type for convenience so consumers
14
+ * can annotate adapter callbacks without importing the SDK directly.
15
+ *
16
+ * @public
17
+ */
10
18
  export type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
11
19
  export type { AuthUser, McpAuthOptions } from "./core/auth/auth.types.ts";
12
20
  export { INTERNAL_ERROR, toCallToolError } from "./core/errors/index.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9E,YAAY,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,YAAY,GACb,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzE,YAAY,EACV,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,aAAa,GACd,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9E,YAAY,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,YAAY,EACZ,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC;;;;;GAKG;AACH,YAAY,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzE,YAAY,EACV,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,aAAa,GACd,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  /**
2
- * Framework-neutral entry. Tool definitions, error envelope plumbing, and
3
- * the types every adapter shares live here. Bootstrap files importing the
4
- * adapter factory should reach for a per-framework subpath
5
- * (`@ganintegrity/mcp/express`); tool files import from this root.
2
+ * Framework-neutral entry for `@ganintegrity/mcp`. Tool definitions, error
3
+ * envelope plumbing, and the types every adapter shares live here. Bootstrap
4
+ * files importing the adapter factory should reach for a per-framework
5
+ * subpath (`@ganintegrity/mcp/express`); tool files import from this root.
6
+ *
7
+ * @packageDocumentation
6
8
  */
7
9
  export { defineMcpServer, materializeSdkServer } from "./core/define.js";
8
10
  export { INTERNAL_ERROR, toCallToolError } from "./core/errors/index.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAczE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAqBzE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ganintegrity/mcp",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Provides tooling to scaffold an MCP server",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,6 +26,8 @@
26
26
  "test:coverage": "vitest run --coverage",
27
27
  "lint": "eslint 'src/**/*.ts'",
28
28
  "typecheck": "tsc --noEmit && tsc -p tsconfig.test.json",
29
+ "api:check": "api-extractor run --config etc/api-extractor.root.json && api-extractor run --config etc/api-extractor.express.json",
30
+ "api:update": "api-extractor run --local --config etc/api-extractor.root.json && api-extractor run --local --config etc/api-extractor.express.json",
29
31
  "format": "pnpx prettier . -w",
30
32
  "format:check": "pnpx prettier . -c",
31
33
  "typecheck:watch": "tsc --noEmit --watch"
@@ -51,6 +53,7 @@
51
53
  "@commitlint/cli": "^20.5.3",
52
54
  "@commitlint/config-conventional": "^20.5.3",
53
55
  "@eslint/js": "^10.0.1",
56
+ "@microsoft/api-extractor": "^7.58.7",
54
57
  "@semantic-release/changelog": "^6.0.3",
55
58
  "@semantic-release/gitlab": "^13.3.2",
56
59
  "@types/express": "^5.0.6",