apcore-mcp 0.9.0 → 0.10.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.
Files changed (41) hide show
  1. package/README.md +23 -0
  2. package/dist/adapters/annotations.d.ts.map +1 -1
  3. package/dist/adapters/annotations.js +21 -14
  4. package/dist/adapters/annotations.js.map +1 -1
  5. package/dist/apcore-mcp.d.ts +150 -0
  6. package/dist/apcore-mcp.d.ts.map +1 -0
  7. package/dist/apcore-mcp.js +217 -0
  8. package/dist/apcore-mcp.js.map +1 -0
  9. package/dist/auth/hooks.d.ts +30 -0
  10. package/dist/auth/hooks.d.ts.map +1 -0
  11. package/dist/auth/hooks.js +31 -0
  12. package/dist/auth/hooks.js.map +1 -0
  13. package/dist/index.d.ts +21 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +27 -14
  16. package/dist/index.js.map +1 -1
  17. package/dist/server/router.d.ts +16 -1
  18. package/dist/server/router.d.ts.map +1 -1
  19. package/dist/server/router.js +26 -3
  20. package/dist/server/router.js.map +1 -1
  21. package/dist/server/transport.d.ts +10 -9
  22. package/dist/server/transport.d.ts.map +1 -1
  23. package/dist/server/transport.js +33 -42
  24. package/dist/server/transport.js.map +1 -1
  25. package/dist/types.d.ts +7 -0
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/types.js +1 -0
  28. package/dist/types.js.map +1 -1
  29. package/package.json +4 -3
  30. package/dist/explorer/handler.d.ts +0 -64
  31. package/dist/explorer/handler.d.ts.map +0 -1
  32. package/dist/explorer/handler.js +0 -187
  33. package/dist/explorer/handler.js.map +0 -1
  34. package/dist/explorer/html.d.ts +0 -9
  35. package/dist/explorer/html.d.ts.map +0 -1
  36. package/dist/explorer/html.js +0 -401
  37. package/dist/explorer/html.js.map +0 -1
  38. package/dist/explorer/index.d.ts +0 -6
  39. package/dist/explorer/index.d.ts.map +0 -1
  40. package/dist/explorer/index.js +0 -5
  41. package/dist/explorer/index.js.map +0 -1
package/README.md CHANGED
@@ -186,6 +186,29 @@ function serve(
186
186
  ): Promise<void>;
187
187
  ```
188
188
 
189
+ ### `asyncServe(registryOrExecutor, options?)`
190
+
191
+ Embed the MCP server into a larger Node.js HTTP application. Returns an HTTP request handler and a close function for lifecycle management.
192
+
193
+ ```typescript
194
+ import { asyncServe } from "apcore-mcp";
195
+
196
+ const { handler, close } = await asyncServe(executor, {
197
+ name: "apcore-mcp",
198
+ explorer: true,
199
+ allowExecute: true,
200
+ });
201
+
202
+ // Mount in a custom HTTP server
203
+ const server = http.createServer(handler);
204
+ server.listen(8000);
205
+
206
+ // Clean up when done
207
+ await close();
208
+ ```
209
+
210
+ Accepts the same options as `serve()` except `transport`, `host`, `port`, `onStartup`, and `onShutdown`.
211
+
189
212
  ### Tool Explorer
190
213
 
191
214
  When `explorer: true` is passed to `serve()`, a browser-based Tool Explorer UI is mounted on HTTP transports. It provides an interactive page for browsing tool schemas and testing tool execution.
@@ -1 +1 @@
1
- {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/adapters/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEzE,qBAAa,gBAAgB;IAC3B;;;;;;;;;OASG;IACH,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,kBAAkB;IAoB3E;;;;;;OAMG;IACH,mBAAmB,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,MAAM;IAwDlE;;;;OAIG;IACH,mBAAmB,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO;CAOpE"}
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/adapters/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAczE,qBAAa,gBAAgB;IAC3B;;;;;;;;;OASG;IACH,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,kBAAkB;IAoB3E;;;;;;OAMG;IACH,mBAAmB,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,MAAM;IAmDlE;;;;OAIG;IACH,mBAAmB,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO;CAOpE"}
@@ -5,6 +5,17 @@
5
5
  * hint-based annotation system. Also provides description suffix generation
6
6
  * and approval requirement checking.
7
7
  */
8
+ /** Default annotation values matching apcore's ModuleAnnotations defaults. */
9
+ const DEFAULT_ANNOTATIONS = {
10
+ readonly: false,
11
+ destructive: false,
12
+ idempotent: false,
13
+ requiresApproval: false,
14
+ openWorld: true,
15
+ streaming: false,
16
+ cacheable: false,
17
+ paginated: false,
18
+ };
8
19
  export class AnnotationMapper {
9
20
  /**
10
21
  * Convert apcore module annotations to MCP annotations dict.
@@ -45,14 +56,6 @@ export class AnnotationMapper {
45
56
  if (annotations === null) {
46
57
  return "";
47
58
  }
48
- const DEFAULTS = {
49
- readonly: false,
50
- destructive: false,
51
- idempotent: false,
52
- requires_approval: false,
53
- open_world: true,
54
- streaming: false,
55
- };
56
59
  const warnings = [];
57
60
  if (annotations.destructive) {
58
61
  warnings.push("WARNING: DESTRUCTIVE - This operation may irreversibly modify or " +
@@ -62,18 +65,22 @@ export class AnnotationMapper {
62
65
  warnings.push("REQUIRES APPROVAL: Human confirmation is required before execution.");
63
66
  }
64
67
  const parts = [];
65
- if (annotations.readonly !== DEFAULTS.readonly)
68
+ if (annotations.readonly !== DEFAULT_ANNOTATIONS.readonly)
66
69
  parts.push(`readonly=${annotations.readonly}`);
67
- if (annotations.destructive !== DEFAULTS.destructive)
70
+ if (annotations.destructive !== DEFAULT_ANNOTATIONS.destructive)
68
71
  parts.push(`destructive=${annotations.destructive}`);
69
- if (annotations.idempotent !== DEFAULTS.idempotent)
72
+ if (annotations.idempotent !== DEFAULT_ANNOTATIONS.idempotent)
70
73
  parts.push(`idempotent=${annotations.idempotent}`);
71
- if (annotations.requiresApproval !== DEFAULTS.requires_approval)
74
+ if (annotations.requiresApproval !== DEFAULT_ANNOTATIONS.requiresApproval)
72
75
  parts.push(`requires_approval=${annotations.requiresApproval}`);
73
- if (annotations.openWorld !== DEFAULTS.open_world)
76
+ if (annotations.openWorld !== DEFAULT_ANNOTATIONS.openWorld)
74
77
  parts.push(`open_world=${annotations.openWorld}`);
75
- if (annotations.streaming !== DEFAULTS.streaming)
78
+ if (annotations.streaming !== DEFAULT_ANNOTATIONS.streaming)
76
79
  parts.push(`streaming=${annotations.streaming}`);
80
+ if ((annotations.cacheable ?? false) !== DEFAULT_ANNOTATIONS.cacheable)
81
+ parts.push(`cacheable=${annotations.cacheable}`);
82
+ if ((annotations.paginated ?? false) !== DEFAULT_ANNOTATIONS.paginated)
83
+ parts.push(`paginated=${annotations.paginated}`);
77
84
  if (warnings.length === 0 && parts.length === 0) {
78
85
  return "";
79
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"annotations.js","sourceRoot":"","sources":["../../src/adapters/annotations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,OAAO,gBAAgB;IAC3B;;;;;;;;;OASG;IACH,gBAAgB,CAAC,WAAqC;QACpD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO;gBACL,YAAY,EAAE,KAAK;gBACnB,eAAe,EAAE,KAAK;gBACtB,cAAc,EAAE,KAAK;gBACrB,aAAa,EAAE,IAAI;gBACnB,KAAK,EAAE,IAAI;aACZ,CAAC;QACJ,CAAC;QAED,OAAO;YACL,YAAY,EAAE,WAAW,CAAC,QAAQ;YAClC,eAAe,EAAE,WAAW,CAAC,WAAW;YACxC,cAAc,EAAE,WAAW,CAAC,UAAU;YACtC,aAAa,EAAE,WAAW,CAAC,SAAS;YACpC,KAAK,EAAE,IAAI;SACZ,CAAC;IACJ,CAAC;IAED;;;;;;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AM,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,WAAqC;QACvD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,WAAW,CAAC,gBAAgB,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * APCoreMCP: Unified entry point for apcore-mcp.
3
+ *
4
+ * Wraps Registry discovery, MCP server creation, and OpenAI tool export
5
+ * into a single object with a simple API.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // Minimal — just point to extensions
10
+ * const mcp = new APCoreMCP("./extensions");
11
+ * await mcp.serve();
12
+ *
13
+ * // With options
14
+ * const mcp = new APCoreMCP("./extensions", { name: "my-server", tags: ["public"] });
15
+ * await mcp.serve({ transport: "streamable-http", port: 9000, explorer: true });
16
+ *
17
+ * // Export OpenAI tools
18
+ * const tools = mcp.toOpenaiTools();
19
+ *
20
+ * // Embed into existing HTTP server
21
+ * const app = await mcp.asyncServe({ explorer: true });
22
+ * // app.handler is a Node.js request handler; call app.close() on shutdown
23
+ *
24
+ * // Use existing Registry or Executor
25
+ * const mcp = new APCoreMCP(registry);
26
+ * ```
27
+ */
28
+ import type { RegistryOrExecutor, Registry, Executor, OpenAIToolDef } from "./types.js";
29
+ import type { Authenticator } from "./auth/types.js";
30
+ import type { MetricsExporter } from "./server/transport.js";
31
+ import type { AsyncServeApp, ToOpenaiToolsOptions } from "./index.js";
32
+ /** Options for the APCoreMCP constructor. */
33
+ export interface APCoreMCPOptions {
34
+ /** MCP server name. Default: "apcore-mcp" */
35
+ name?: string;
36
+ /** MCP server version. Default: package version */
37
+ version?: string;
38
+ /** Filter modules by tags. */
39
+ tags?: string[] | null;
40
+ /** Filter modules by prefix. */
41
+ prefix?: string | null;
42
+ /** Minimum log level. */
43
+ logLevel?: "DEBUG" | "INFO" | "WARNING" | "ERROR" | "CRITICAL";
44
+ /** Enable input validation against schemas. Default: false */
45
+ validateInputs?: boolean;
46
+ /** Optional MetricsCollector for Prometheus /metrics endpoint. */
47
+ metricsCollector?: MetricsExporter;
48
+ /** Optional authenticator for request authentication (HTTP transports only). */
49
+ authenticator?: Authenticator;
50
+ /** If true (default), unauthenticated requests are rejected with 401. */
51
+ requireAuth?: boolean;
52
+ /** Custom paths exempt from authentication. */
53
+ exemptPaths?: string[];
54
+ /** Optional approval handler passed to the Executor. */
55
+ approvalHandler?: unknown;
56
+ /**
57
+ * Optional function that formats execution results into text for LLM consumption.
58
+ * When undefined, results are serialised with `JSON.stringify(result)`.
59
+ */
60
+ outputFormatter?: (result: Record<string, unknown>) => string;
61
+ }
62
+ /** Options for APCoreMCP.serve() (transport + lifecycle subset). */
63
+ export interface APCoreMCPServeOptions {
64
+ /** Transport type. Default: "stdio" */
65
+ transport?: "stdio" | "streamable-http" | "sse";
66
+ /** Host address for HTTP-based transports. Default: "127.0.0.1" */
67
+ host?: string;
68
+ /** Port number for HTTP-based transports. Default: 8000 */
69
+ port?: number;
70
+ /** Callback invoked before the server starts. */
71
+ onStartup?: () => void | Promise<void>;
72
+ /** Callback invoked after the server stops. */
73
+ onShutdown?: () => void | Promise<void>;
74
+ /** Enable the browser-based Tool Explorer UI (HTTP only). Default: false */
75
+ explorer?: boolean;
76
+ /** URL prefix for the explorer. Default: "/explorer" */
77
+ explorerPrefix?: string;
78
+ /** Allow tool execution from the explorer UI. Default: false */
79
+ allowExecute?: boolean;
80
+ /** Title for the explorer UI page. */
81
+ explorerTitle?: string;
82
+ /** Project name shown in the explorer UI footer. */
83
+ explorerProjectName?: string;
84
+ /** Project URL shown in the explorer UI footer. */
85
+ explorerProjectUrl?: string;
86
+ }
87
+ /** Options for APCoreMCP.asyncServe() (embed subset). */
88
+ export interface APCoreMCPAsyncServeOptions {
89
+ /** Enable the browser-based Tool Explorer UI. Default: false */
90
+ explorer?: boolean;
91
+ /** URL prefix for the explorer. Default: "/explorer" */
92
+ explorerPrefix?: string;
93
+ /** Allow tool execution from the explorer UI. Default: false */
94
+ allowExecute?: boolean;
95
+ /** MCP endpoint path. Default: "/mcp" */
96
+ endpoint?: string;
97
+ }
98
+ export declare class APCoreMCP {
99
+ private _backend;
100
+ private readonly _options;
101
+ private _registry;
102
+ private _executor;
103
+ private readonly _extensionsDir;
104
+ /**
105
+ * Create an APCoreMCP instance.
106
+ *
107
+ * @param extensionsDirOrBackend - Path to an apcore extensions directory,
108
+ * or an existing Registry or Executor instance.
109
+ * @param options - Configuration options.
110
+ */
111
+ constructor(extensionsDirOrBackend: string | RegistryOrExecutor, options?: APCoreMCPOptions);
112
+ /** The underlying apcore Registry. */
113
+ get registry(): Registry;
114
+ /** The underlying apcore Executor (resolved lazily). */
115
+ get executor(): Executor | undefined;
116
+ /** List all discovered module IDs that will be exposed as tools. */
117
+ get tools(): string[];
118
+ /**
119
+ * Build the full ServeOptions by merging constructor options with per-call overrides.
120
+ */
121
+ private _buildServeOptions;
122
+ /**
123
+ * Resolve the backend (handles extensions dir lazy init).
124
+ */
125
+ private _resolveBackend;
126
+ /**
127
+ * Launch the MCP server (blocks until shutdown).
128
+ *
129
+ * @param options - Transport and lifecycle options.
130
+ */
131
+ serve(options?: APCoreMCPServeOptions): Promise<void>;
132
+ /**
133
+ * Build an embeddable MCP HTTP request handler.
134
+ *
135
+ * Unlike `serve()`, this does NOT create its own HTTP server. Returns a
136
+ * Node.js HTTP request handler and a close function.
137
+ *
138
+ * @param options - Embed options.
139
+ * @returns Object with `handler` and `close()`.
140
+ */
141
+ asyncServe(options?: APCoreMCPAsyncServeOptions): Promise<AsyncServeApp>;
142
+ /**
143
+ * Export modules as OpenAI-compatible tool definitions.
144
+ *
145
+ * @param options - Conversion options (embedAnnotations, strict).
146
+ * @returns List of OpenAI tool definition dicts.
147
+ */
148
+ toOpenaiTools(options?: ToOpenaiToolsOptions): OpenAIToolDef[];
149
+ }
150
+ //# sourceMappingURL=apcore-mcp.d.ts.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GAAE,gBAAqB;IAiChC,sCAAsC;IACtC,IAAI,QAAQ,IAAI,QAAQ,CAYvB;IAED,wDAAwD;IACxD,IAAI,QAAQ,IAAI,QAAQ,GAAG,SAAS,CAEnC;IAED,oEAAoE;IACpE,IAAI,KAAK,IAAI,MAAM,EAAE,CAUpB;IAED;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA4B1B;;OAEG;YACW,eAAe;IA6B7B;;;;OAIG;IACG,KAAK,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/D;;;;;;;;OAQG;IACG,UAAU,CAAC,OAAO,GAAE,0BAA+B,GAAG,OAAO,CAAC,aAAa,CAAC;IAyBlF;;;;;OAKG;IACH,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,EAAE;CAQnE"}
@@ -0,0 +1,217 @@
1
+ /**
2
+ * APCoreMCP: Unified entry point for apcore-mcp.
3
+ *
4
+ * Wraps Registry discovery, MCP server creation, and OpenAI tool export
5
+ * into a single object with a simple API.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // Minimal — just point to extensions
10
+ * const mcp = new APCoreMCP("./extensions");
11
+ * await mcp.serve();
12
+ *
13
+ * // With options
14
+ * const mcp = new APCoreMCP("./extensions", { name: "my-server", tags: ["public"] });
15
+ * await mcp.serve({ transport: "streamable-http", port: 9000, explorer: true });
16
+ *
17
+ * // Export OpenAI tools
18
+ * const tools = mcp.toOpenaiTools();
19
+ *
20
+ * // Embed into existing HTTP server
21
+ * const app = await mcp.asyncServe({ explorer: true });
22
+ * // app.handler is a Node.js request handler; call app.close() on shutdown
23
+ *
24
+ * // Use existing Registry or Executor
25
+ * const mcp = new APCoreMCP(registry);
26
+ * ```
27
+ */
28
+ import { serve, asyncServe, toOpenaiTools, resolveRegistry, } from "./index.js";
29
+ export class APCoreMCP {
30
+ _backend;
31
+ _options;
32
+ _registry;
33
+ _executor;
34
+ _extensionsDir;
35
+ /**
36
+ * Create an APCoreMCP instance.
37
+ *
38
+ * @param extensionsDirOrBackend - Path to an apcore extensions directory,
39
+ * or an existing Registry or Executor instance.
40
+ * @param options - Configuration options.
41
+ */
42
+ constructor(extensionsDirOrBackend, options = {}) {
43
+ // Validate upfront
44
+ const name = options.name ?? "apcore-mcp";
45
+ if (!name || name.length === 0) {
46
+ throw new Error("name must not be empty");
47
+ }
48
+ if (name.length > 255) {
49
+ throw new Error("name must not exceed 255 characters");
50
+ }
51
+ if (options.tags) {
52
+ for (const tag of options.tags) {
53
+ if (!tag || tag.length === 0) {
54
+ throw new Error("tags must not contain empty strings");
55
+ }
56
+ }
57
+ }
58
+ if (options.prefix !== undefined && options.prefix !== null && options.prefix.length === 0) {
59
+ throw new Error("prefix must not be empty if provided");
60
+ }
61
+ this._options = { name, ...options };
62
+ if (typeof extensionsDirOrBackend === "string") {
63
+ // Defer discovery to first use — will be resolved lazily
64
+ this._backend = null;
65
+ this._extensionsDir = extensionsDirOrBackend;
66
+ }
67
+ else {
68
+ this._backend = extensionsDirOrBackend;
69
+ this._extensionsDir = undefined;
70
+ }
71
+ }
72
+ /** The underlying apcore Registry. */
73
+ get registry() {
74
+ if (!this._registry) {
75
+ if (this._backend !== null) {
76
+ this._registry = resolveRegistry(this._backend);
77
+ }
78
+ else {
79
+ throw new Error("Registry not yet resolved. Call serve() or asyncServe() first, " +
80
+ "or pass a Registry/Executor to the constructor.");
81
+ }
82
+ }
83
+ return this._registry;
84
+ }
85
+ /** The underlying apcore Executor (resolved lazily). */
86
+ get executor() {
87
+ return this._executor;
88
+ }
89
+ /** List all discovered module IDs that will be exposed as tools. */
90
+ get tools() {
91
+ const reg = this.registry;
92
+ const result = reg.list({
93
+ tags: this._options.tags ?? undefined,
94
+ prefix: this._options.prefix ?? undefined,
95
+ });
96
+ // registry.list() may return ModuleDescriptor[] or string[] depending on apcore-js version
97
+ if (result.length === 0)
98
+ return [];
99
+ if (typeof result[0] === "string")
100
+ return result;
101
+ return result.map((d) => d.moduleId);
102
+ }
103
+ /**
104
+ * Build the full ServeOptions by merging constructor options with per-call overrides.
105
+ */
106
+ _buildServeOptions(overrides = {}) {
107
+ return {
108
+ transport: overrides.transport,
109
+ host: overrides.host,
110
+ port: overrides.port,
111
+ name: this._options.name,
112
+ version: this._options.version,
113
+ validateInputs: this._options.validateInputs,
114
+ tags: this._options.tags,
115
+ prefix: this._options.prefix,
116
+ logLevel: this._options.logLevel,
117
+ onStartup: overrides.onStartup,
118
+ onShutdown: overrides.onShutdown,
119
+ metricsCollector: this._options.metricsCollector,
120
+ explorer: overrides.explorer,
121
+ explorerPrefix: overrides.explorerPrefix,
122
+ allowExecute: overrides.allowExecute,
123
+ explorerTitle: overrides.explorerTitle,
124
+ explorerProjectName: overrides.explorerProjectName,
125
+ explorerProjectUrl: overrides.explorerProjectUrl,
126
+ authenticator: this._options.authenticator,
127
+ requireAuth: this._options.requireAuth,
128
+ exemptPaths: this._options.exemptPaths,
129
+ approvalHandler: this._options.approvalHandler,
130
+ outputFormatter: this._options.outputFormatter,
131
+ };
132
+ }
133
+ /**
134
+ * Resolve the backend (handles extensions dir lazy init).
135
+ */
136
+ async _resolveBackend() {
137
+ if (this._backend !== null)
138
+ return this._backend;
139
+ if (!this._extensionsDir) {
140
+ throw new Error("No backend configured");
141
+ }
142
+ try {
143
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
144
+ const apcore = await import("apcore-js");
145
+ const RegistryClass = apcore.Registry ?? apcore.default?.Registry;
146
+ if (!RegistryClass) {
147
+ throw new Error("Cannot find Registry class in apcore-js");
148
+ }
149
+ const registry = new RegistryClass({ extensionsDir: this._extensionsDir });
150
+ if (typeof registry.discover === "function") {
151
+ await registry.discover();
152
+ }
153
+ this._registry = registry;
154
+ this._backend = registry;
155
+ return registry;
156
+ }
157
+ catch (err) {
158
+ throw new Error(`Failed to create Registry from extensions dir "${this._extensionsDir}". ` +
159
+ `Ensure apcore-js is installed. Original error: ${err}`);
160
+ }
161
+ }
162
+ /**
163
+ * Launch the MCP server (blocks until shutdown).
164
+ *
165
+ * @param options - Transport and lifecycle options.
166
+ */
167
+ async serve(options = {}) {
168
+ const backend = await this._resolveBackend();
169
+ await serve(backend, this._buildServeOptions(options));
170
+ }
171
+ /**
172
+ * Build an embeddable MCP HTTP request handler.
173
+ *
174
+ * Unlike `serve()`, this does NOT create its own HTTP server. Returns a
175
+ * Node.js HTTP request handler and a close function.
176
+ *
177
+ * @param options - Embed options.
178
+ * @returns Object with `handler` and `close()`.
179
+ */
180
+ async asyncServe(options = {}) {
181
+ const backend = await this._resolveBackend();
182
+ const asyncOpts = {
183
+ name: this._options.name,
184
+ version: this._options.version,
185
+ validateInputs: this._options.validateInputs,
186
+ tags: this._options.tags,
187
+ prefix: this._options.prefix,
188
+ logLevel: this._options.logLevel,
189
+ metricsCollector: this._options.metricsCollector,
190
+ explorer: options.explorer,
191
+ explorerPrefix: options.explorerPrefix,
192
+ allowExecute: options.allowExecute,
193
+ authenticator: this._options.authenticator,
194
+ requireAuth: this._options.requireAuth,
195
+ exemptPaths: this._options.exemptPaths,
196
+ approvalHandler: this._options.approvalHandler,
197
+ endpoint: options.endpoint,
198
+ outputFormatter: this._options.outputFormatter,
199
+ };
200
+ return asyncServe(backend, asyncOpts);
201
+ }
202
+ /**
203
+ * Export modules as OpenAI-compatible tool definitions.
204
+ *
205
+ * @param options - Conversion options (embedAnnotations, strict).
206
+ * @returns List of OpenAI tool definition dicts.
207
+ */
208
+ toOpenaiTools(options = {}) {
209
+ const reg = this.registry;
210
+ return toOpenaiTools(reg, {
211
+ ...options,
212
+ tags: this._options.tags ?? undefined,
213
+ prefix: this._options.prefix ?? undefined,
214
+ });
215
+ }
216
+ }
217
+ //# sourceMappingURL=apcore-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apcore-mcp.js","sourceRoot":"","sources":["../src/apcore-mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAUH,OAAO,EACL,KAAK,EACL,UAAU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I,CAAC,QAAQ,CAAC,OAAO;YAC9B,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,cAAc;YAC5C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;YACxB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM;YAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;YAChC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,gBAAgB;YAChD,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa;YAC1C,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW;YACtC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW;YACtC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,eAAe;YAC9C,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,eAAe;SAC/C,CAAC;QAEF,OAAO,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,UAAgC,EAAE;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC1B,OAAO,aAAa,CAAC,GAAG,EAAE;YACxB,GAAG,OAAO;YACV,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,SAAS;YACrC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,SAAS;SAC1C,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Auth hook builder for mcp-embedded-ui explorer integration.
3
+ *
4
+ * Mirrors the Python `_build_auth_hook` pattern from apcore-mcp-python.
5
+ * Bridges the Authenticator interface to mcp-embedded-ui's AuthHook,
6
+ * propagating identity through AsyncLocalStorage for the call chain.
7
+ */
8
+ import type { Authenticator } from "./types.js";
9
+ /**
10
+ * Minimal incoming request shape accepted by the auth hook.
11
+ * Compatible with mcp-embedded-ui's IncomingRequest.
12
+ */
13
+ interface IncomingRequest {
14
+ headers: Record<string, string | string[] | undefined>;
15
+ }
16
+ /**
17
+ * Build an auth hook for mcp-embedded-ui that bridges to an Authenticator.
18
+ *
19
+ * The hook:
20
+ * 1. Extracts headers from the incoming request
21
+ * 2. Delegates to `authenticator.authenticate()` for token validation
22
+ * 3. Throws on auth failure (mcp-embedded-ui catches this and returns 401)
23
+ * 4. Wraps `next()` in `identityStorage.run()` so `getCurrentIdentity()` works
24
+ *
25
+ * @param authenticator - An Authenticator instance (e.g. JWTAuthenticator)
26
+ * @returns An auth hook function compatible with mcp-embedded-ui's AuthHook type
27
+ */
28
+ export declare function buildExplorerAuthHook(authenticator: Authenticator): (req: IncomingRequest, next: () => Promise<Response>) => Promise<Response>;
29
+ export {};
30
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/auth/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD;;;GAGG;AACH,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;CACxD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,aAAa,GAC3B,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,CAS5E"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Auth hook builder for mcp-embedded-ui explorer integration.
3
+ *
4
+ * Mirrors the Python `_build_auth_hook` pattern from apcore-mcp-python.
5
+ * Bridges the Authenticator interface to mcp-embedded-ui's AuthHook,
6
+ * propagating identity through AsyncLocalStorage for the call chain.
7
+ */
8
+ import { identityStorage } from "./storage.js";
9
+ /**
10
+ * Build an auth hook for mcp-embedded-ui that bridges to an Authenticator.
11
+ *
12
+ * The hook:
13
+ * 1. Extracts headers from the incoming request
14
+ * 2. Delegates to `authenticator.authenticate()` for token validation
15
+ * 3. Throws on auth failure (mcp-embedded-ui catches this and returns 401)
16
+ * 4. Wraps `next()` in `identityStorage.run()` so `getCurrentIdentity()` works
17
+ *
18
+ * @param authenticator - An Authenticator instance (e.g. JWTAuthenticator)
19
+ * @returns An auth hook function compatible with mcp-embedded-ui's AuthHook type
20
+ */
21
+ export function buildExplorerAuthHook(authenticator) {
22
+ return async (req, next) => {
23
+ const shimReq = { headers: req.headers };
24
+ const identity = await authenticator.authenticate(shimReq);
25
+ if (!identity) {
26
+ throw new Error("Unauthorized");
27
+ }
28
+ return identityStorage.run(identity, next);
29
+ };
30
+ }
31
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/auth/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAU/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CACnC,aAA4B;IAE5B,OAAO,KAAK,EAAE,GAAoB,EAAE,IAA6B,EAAE,EAAE;QACnE,MAAM,OAAO,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAgC,CAAC;QACvE,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -22,14 +22,15 @@ export { JWTAuthenticator } from "./auth/jwt.js";
22
22
  export type { ClaimMapping, JWTAuthenticatorOptions } from "./auth/jwt.js";
23
23
  export type { Authenticator, Identity } from "./auth/types.js";
24
24
  export { identityStorage, getCurrentIdentity } from "./auth/storage.js";
25
+ export { buildExplorerAuthHook } from "./auth/hooks.js";
26
+ export { APCoreMCP } from "./apcore-mcp.js";
27
+ export type { APCoreMCPOptions, APCoreMCPServeOptions, APCoreMCPAsyncServeOptions } from "./apcore-mcp.js";
25
28
  export { MCPServerFactory } from "./server/factory.js";
26
29
  export { ExecutionRouter } from "./server/router.js";
27
30
  export type { CallResult, HandleCallExtra, ExecutionRouterOptions } from "./server/router.js";
28
31
  export { RegistryListener } from "./server/listener.js";
29
32
  export { TransportManager } from "./server/transport.js";
30
33
  export type { MetricsExporter } from "./server/transport.js";
31
- export { ExplorerHandler } from "./explorer/index.js";
32
- export type { ExplorerHandlerOptions } from "./explorer/index.js";
33
34
  export { AnnotationMapper } from "./adapters/annotations.js";
34
35
  export { SchemaConverter } from "./adapters/schema.js";
35
36
  export { ErrorMapper } from "./adapters/errors.js";
@@ -92,6 +93,12 @@ export interface ServeOptions {
92
93
  explorerPrefix?: string;
93
94
  /** Allow tool execution from the explorer UI. Default: false */
94
95
  allowExecute?: boolean;
96
+ /** Title for the explorer UI page. Default: "MCP Tool Explorer" */
97
+ explorerTitle?: string;
98
+ /** Project name shown in the explorer UI footer. */
99
+ explorerProjectName?: string;
100
+ /** Project URL shown in the explorer UI footer. */
101
+ explorerProjectUrl?: string;
95
102
  /** Optional authenticator for request authentication (HTTP transports only). */
96
103
  authenticator?: Authenticator;
97
104
  /**
@@ -104,6 +111,12 @@ export interface ServeOptions {
104
111
  exemptPaths?: string[];
105
112
  /** Optional approval handler passed to the Executor (e.g. ElicitationApprovalHandler). */
106
113
  approvalHandler?: unknown;
114
+ /**
115
+ * Optional function that formats execution results into text for LLM consumption.
116
+ * When undefined, results are serialised with `JSON.stringify(result)`.
117
+ * Only applied to plain-object results; non-object results always use JSON.stringify.
118
+ */
119
+ outputFormatter?: (result: Record<string, unknown>) => string;
107
120
  }
108
121
  /**
109
122
  * Launch an MCP Server that exposes all apcore modules as tools.
@@ -148,6 +161,12 @@ export interface AsyncServeOptions {
148
161
  approvalHandler?: unknown;
149
162
  /** MCP endpoint path. Default: "/mcp" */
150
163
  endpoint?: string;
164
+ /**
165
+ * Optional function that formats execution results into text for LLM consumption.
166
+ * When undefined, results are serialised with `JSON.stringify(result)`.
167
+ * Only applied to plain-object results; non-object results always use JSON.stringify.
168
+ */
169
+ outputFormatter?: (result: Record<string, unknown>) => string;
151
170
  }
152
171
  /** Return type of asyncServe(). */
153
172
  export interface AsyncServeApp {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EACV,kBAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIrD,eAAO,MAAM,OAAO,EAAE,MAAoB,CAAC;AAG3C,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxF,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG5E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