@mcpfn/core 0.0.6 → 0.0.7

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/dist/index.d.cts CHANGED
@@ -16,20 +16,29 @@ type McpFnRequestExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
16
16
  type McpFnTaskRequestExtra = McpFnRequestExtra & {
17
17
  taskStore: RequestTaskStore;
18
18
  };
19
- /** Safe structural JSON Schema diagnostic. Argument values are never retained. */
19
+ /**
20
+ * Safe structural JSON Schema diagnostic. Argument values are never retained.
21
+ * Fields are bounded: at most 100 issues per result, and each string field is
22
+ * limited to 256 characters (see `truncated`).
23
+ */
20
24
  interface McpFnSchemaIssue {
21
25
  /** Backwards-compatible alias for instancePath; `/` represents the root. */
22
26
  path: string;
23
- /** RFC 6901 path to the rejected input location; `/` represents the root. */
27
+ /**
28
+ * RFC 6901 path to the rejected input location; `/` represents the root.
29
+ * A path longer than 256 characters is reported as `/` with `truncated: true`.
30
+ */
24
31
  instancePath: string;
25
- /** JSON Schema path reported by the validator. */
32
+ /** JSON Schema path reported by the validator; `#` when longer than 256 characters. */
26
33
  schemaPath: string;
27
34
  keyword: string;
28
35
  message: string;
29
- /** Exact unknown property name for additionalProperties failures. */
36
+ /** Unknown property name for additionalProperties failures, cut to 256 characters. */
30
37
  rejectedProperty?: string;
31
- /** Exact missing property name for required failures. */
38
+ /** Missing property name for required failures, cut to 256 characters. */
32
39
  missingProperty?: string;
40
+ /** Set when any field above was shortened or replaced by the bounds. */
41
+ truncated?: true;
33
42
  }
34
43
  type McpFnToolLifecycleStage = "input-validation" | "invalid-arguments-handler" | "handler" | "output-validation";
35
44
  interface McpFnToolLifecycleObserver {
@@ -198,6 +207,12 @@ declare function promptArguments<TContext>(definition: McpFnPromptDefinition<TCo
198
207
  }[] | undefined;
199
208
  declare class McpFnRegistry<TContext = undefined> {
200
209
  private readonly schemaCompiler;
210
+ private readonly registrations;
211
+ private readonly schemas;
212
+ /** Clone in successful registration order, preserving cross-definition references. */
213
+ clone(): McpFnRegistry<TContext>;
214
+ /** Registered schema resources for catalog projections, including hidden tools and prompts. */
215
+ schemaDefinitions(): object[];
201
216
  private readonly tools;
202
217
  private readonly resources;
203
218
  private readonly resourceTemplates;
@@ -374,6 +389,8 @@ declare function buildMcpFnEffectiveCatalog<TContext>(input: {
374
389
  canonicalTools: McpFnListedTool[];
375
390
  /** Complete registry inventory when canonicalTools has already been visibility-filtered. */
376
391
  knownTools?: McpFnListedTool[];
392
+ /** All registered resources, including schemas of hidden tools and prompts. */
393
+ schemaResources?: readonly object[];
377
394
  resolved: McpFnResolvedClientProfile<TContext>;
378
395
  }): Promise<{
379
396
  tools: McpFnListedTool[];
@@ -445,6 +462,8 @@ declare class McpFnServer<TContext = undefined> {
445
462
  private readonly pageSize;
446
463
  private readonly serverOptions;
447
464
  private readonly requestServers;
465
+ private readonly resourceSubscriptions;
466
+ private readonly pendingResourceSubscriptions;
448
467
  private connected;
449
468
  constructor(options: McpFnServerOptions<TContext>);
450
469
  private installHandlers;
@@ -463,11 +482,40 @@ declare class McpFnServer<TContext = undefined> {
463
482
  elicit(params: McpFnElicitationParams, options?: McpFnClientRequestOptions): Promise<McpFnElicitationResult>;
464
483
  elicitForRequest(extra: McpFnRequestExtra, params: McpFnElicitationParams, options?: McpFnClientRequestOptions): Promise<McpFnElicitationResult>;
465
484
  listRoots(options?: RequestOptions): Promise<McpFnRootsResult>;
485
+ private directClientRequestError;
466
486
  listRootsForRequest(extra: McpFnRequestExtra, options?: McpFnClientRequestOptions): Promise<McpFnRootsResult>;
487
+ private connectedRequestServers;
488
+ private connectedServers;
489
+ private broadcast;
490
+ /**
491
+ * Sends `notifications/message` to one client, never to every session.
492
+ *
493
+ * Without `sessionId`, only the transport connected with `connect()` or
494
+ * `serveStdio()` receives it. With `sessionId`, only the client whose
495
+ * transport has that session id receives it: the directly connected
496
+ * transport or one `createWebStandardHandler()` session. Tool handlers
497
+ * behind `createWebStandardHandler()` pass `extra.sessionId`; a stateless
498
+ * handler has no session to name and logs through `extra.sendNotification`.
499
+ * The recipient's `logging/setLevel` choice is honoured.
500
+ */
467
501
  sendLoggingMessage(params: LoggingMessageNotification["params"], sessionId?: string): Promise<void>;
502
+ /**
503
+ * Sends `notifications/resources/updated` for `params.uri`. The transport
504
+ * connected with `connect()` or `serveStdio()` receives it as before; a
505
+ * `createWebStandardHandler()` session receives it only while it holds a
506
+ * subscription to that exact URI from a successful `resources/subscribe`
507
+ * (until it unsubscribes or the session closes).
508
+ */
468
509
  sendResourceUpdated(params: ResourceUpdatedNotification["params"]): Promise<void>;
510
+ /**
511
+ * Sends `notifications/resources/list_changed` to every connected client:
512
+ * the direct transport and every `createWebStandardHandler()` session. The
513
+ * notification carries no data and every client shares the registry.
514
+ */
469
515
  sendResourceListChanged(): Promise<void>;
516
+ /** Sends `notifications/tools/list_changed` to every connected client, like `sendResourceListChanged()`. */
470
517
  sendToolListChanged(): Promise<void>;
518
+ /** Sends `notifications/prompts/list_changed` to every connected client, like `sendResourceListChanged()`. */
471
519
  sendPromptListChanged(): Promise<void>;
472
520
  close(): Promise<void>;
473
521
  }
@@ -564,7 +612,12 @@ declare function validateSchemaCollection(schemas: readonly object[], engine?: S
564
612
  declare function createSchemaCompiler(engine?: SchemaEngine): SchemaCompiler;
565
613
  /** Whether the current runtime validates schemas via Ajv (Node) or the edge fallback. */
566
614
  declare const schemaEngine: SchemaEngine;
567
- /** Convert normalized engine failures into a bounded public diagnostic shape. */
615
+ /**
616
+ * Convert normalized engine failures into a bounded public diagnostic shape:
617
+ * at most 100 issues; property names, keywords and messages are cut to 256
618
+ * characters; instance and schema paths longer than 256 characters are
619
+ * replaced by the root (`/`, `#`). Any such shortening sets `truncated: true`.
620
+ */
568
621
  declare function formatMcpFnSchemaIssues(errors: SchemaIssue[] | null | undefined): McpFnSchemaIssue[];
569
622
 
570
623
  export { type CompiledSchema, type CreateManifestOptions, MCP_APP_EXTENSION_ID, MCP_APP_MIME_TYPE, type McpAppCsp, type McpAppPermissions, type McpAppResourceMetadata, type McpAppResourceOptions, type McpAppToolMetadata, type McpFnCatalogChange, type McpFnChangeSeverity, type McpFnClientProfile, type McpFnClientProfileCallInput, type McpFnClientProfileCatalogInput, McpFnClientProfileError, type McpFnClientProfileEvidence, type McpFnClientProfileHookInput, type McpFnClientProfileLifecycleStage, type McpFnClientProfilesOptions, type McpFnClientRequestOptions, type McpFnContractChange, type McpFnDiffResult, type McpFnElicitationParams, type McpFnElicitationResult, McpFnError, type McpFnJsonSchema, type McpFnListedResource, type McpFnListedResourceTemplate, type McpFnListedTool, type McpFnManifest, type McpFnManifestPrompt, type McpFnManifestResource, type McpFnManifestResourceTemplate, type McpFnManifestTool, type McpFnObjectSchema, McpFnOutputValidationError, type McpFnPromptDefinition, McpFnRegistry, type McpFnReportedClient, type McpFnRequestExtra, type McpFnResolvedClientProfile, type McpFnResourceDefinition, type McpFnResourceTemplateDefinition, type McpFnRootsResult, type McpFnSamplingParams, type McpFnSamplingResult, type McpFnSchemaIssue, McpFnServer, McpFnServerDeclaration, type McpFnServerDeclarationOptions, type McpFnServerInfo, type McpFnServerOptions, type McpFnServerRuntimeOptions, type McpFnTaskHandler, type McpFnTaskRequestExtra, type McpFnToolDefinition, type McpFnToolLifecycleObserver, type McpFnToolLifecycleStage, type McpFnToolVisibilityInput, McpFnValidationError, type McpFnVerifiedClientIdentity, type McpFnWebStandardHandlerOptions, type SchemaCompiler, type SchemaEngine, type SchemaIssue, assertMcpAppContracts, assertPromptSchemaSupportsStringValues, buildMcpFnEffectiveCatalog, canonicalJson, canonicalize, compareCodeUnits, createManifest, createMcpAppResource, createMcpFnServer, createSchemaCompiler, defineMcpFnServer, diffManifests, enrichMcpFnClientProfileCall, errorResult, formatMcpFnSchemaIssues, jsonSafe, mcpAppToolMetadata, promptArguments, resolveMcpFnClientProfile, resolveMcpFnServerCapabilities, schemaEngine, schemaPromptArguments, sha256, structuredResult, textResult, validateManifest, validateMcpFnClientProfiles, validateSchemaCollection };
package/dist/index.d.ts CHANGED
@@ -16,20 +16,29 @@ type McpFnRequestExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
16
16
  type McpFnTaskRequestExtra = McpFnRequestExtra & {
17
17
  taskStore: RequestTaskStore;
18
18
  };
19
- /** Safe structural JSON Schema diagnostic. Argument values are never retained. */
19
+ /**
20
+ * Safe structural JSON Schema diagnostic. Argument values are never retained.
21
+ * Fields are bounded: at most 100 issues per result, and each string field is
22
+ * limited to 256 characters (see `truncated`).
23
+ */
20
24
  interface McpFnSchemaIssue {
21
25
  /** Backwards-compatible alias for instancePath; `/` represents the root. */
22
26
  path: string;
23
- /** RFC 6901 path to the rejected input location; `/` represents the root. */
27
+ /**
28
+ * RFC 6901 path to the rejected input location; `/` represents the root.
29
+ * A path longer than 256 characters is reported as `/` with `truncated: true`.
30
+ */
24
31
  instancePath: string;
25
- /** JSON Schema path reported by the validator. */
32
+ /** JSON Schema path reported by the validator; `#` when longer than 256 characters. */
26
33
  schemaPath: string;
27
34
  keyword: string;
28
35
  message: string;
29
- /** Exact unknown property name for additionalProperties failures. */
36
+ /** Unknown property name for additionalProperties failures, cut to 256 characters. */
30
37
  rejectedProperty?: string;
31
- /** Exact missing property name for required failures. */
38
+ /** Missing property name for required failures, cut to 256 characters. */
32
39
  missingProperty?: string;
40
+ /** Set when any field above was shortened or replaced by the bounds. */
41
+ truncated?: true;
33
42
  }
34
43
  type McpFnToolLifecycleStage = "input-validation" | "invalid-arguments-handler" | "handler" | "output-validation";
35
44
  interface McpFnToolLifecycleObserver {
@@ -198,6 +207,12 @@ declare function promptArguments<TContext>(definition: McpFnPromptDefinition<TCo
198
207
  }[] | undefined;
199
208
  declare class McpFnRegistry<TContext = undefined> {
200
209
  private readonly schemaCompiler;
210
+ private readonly registrations;
211
+ private readonly schemas;
212
+ /** Clone in successful registration order, preserving cross-definition references. */
213
+ clone(): McpFnRegistry<TContext>;
214
+ /** Registered schema resources for catalog projections, including hidden tools and prompts. */
215
+ schemaDefinitions(): object[];
201
216
  private readonly tools;
202
217
  private readonly resources;
203
218
  private readonly resourceTemplates;
@@ -374,6 +389,8 @@ declare function buildMcpFnEffectiveCatalog<TContext>(input: {
374
389
  canonicalTools: McpFnListedTool[];
375
390
  /** Complete registry inventory when canonicalTools has already been visibility-filtered. */
376
391
  knownTools?: McpFnListedTool[];
392
+ /** All registered resources, including schemas of hidden tools and prompts. */
393
+ schemaResources?: readonly object[];
377
394
  resolved: McpFnResolvedClientProfile<TContext>;
378
395
  }): Promise<{
379
396
  tools: McpFnListedTool[];
@@ -445,6 +462,8 @@ declare class McpFnServer<TContext = undefined> {
445
462
  private readonly pageSize;
446
463
  private readonly serverOptions;
447
464
  private readonly requestServers;
465
+ private readonly resourceSubscriptions;
466
+ private readonly pendingResourceSubscriptions;
448
467
  private connected;
449
468
  constructor(options: McpFnServerOptions<TContext>);
450
469
  private installHandlers;
@@ -463,11 +482,40 @@ declare class McpFnServer<TContext = undefined> {
463
482
  elicit(params: McpFnElicitationParams, options?: McpFnClientRequestOptions): Promise<McpFnElicitationResult>;
464
483
  elicitForRequest(extra: McpFnRequestExtra, params: McpFnElicitationParams, options?: McpFnClientRequestOptions): Promise<McpFnElicitationResult>;
465
484
  listRoots(options?: RequestOptions): Promise<McpFnRootsResult>;
485
+ private directClientRequestError;
466
486
  listRootsForRequest(extra: McpFnRequestExtra, options?: McpFnClientRequestOptions): Promise<McpFnRootsResult>;
487
+ private connectedRequestServers;
488
+ private connectedServers;
489
+ private broadcast;
490
+ /**
491
+ * Sends `notifications/message` to one client, never to every session.
492
+ *
493
+ * Without `sessionId`, only the transport connected with `connect()` or
494
+ * `serveStdio()` receives it. With `sessionId`, only the client whose
495
+ * transport has that session id receives it: the directly connected
496
+ * transport or one `createWebStandardHandler()` session. Tool handlers
497
+ * behind `createWebStandardHandler()` pass `extra.sessionId`; a stateless
498
+ * handler has no session to name and logs through `extra.sendNotification`.
499
+ * The recipient's `logging/setLevel` choice is honoured.
500
+ */
467
501
  sendLoggingMessage(params: LoggingMessageNotification["params"], sessionId?: string): Promise<void>;
502
+ /**
503
+ * Sends `notifications/resources/updated` for `params.uri`. The transport
504
+ * connected with `connect()` or `serveStdio()` receives it as before; a
505
+ * `createWebStandardHandler()` session receives it only while it holds a
506
+ * subscription to that exact URI from a successful `resources/subscribe`
507
+ * (until it unsubscribes or the session closes).
508
+ */
468
509
  sendResourceUpdated(params: ResourceUpdatedNotification["params"]): Promise<void>;
510
+ /**
511
+ * Sends `notifications/resources/list_changed` to every connected client:
512
+ * the direct transport and every `createWebStandardHandler()` session. The
513
+ * notification carries no data and every client shares the registry.
514
+ */
469
515
  sendResourceListChanged(): Promise<void>;
516
+ /** Sends `notifications/tools/list_changed` to every connected client, like `sendResourceListChanged()`. */
470
517
  sendToolListChanged(): Promise<void>;
518
+ /** Sends `notifications/prompts/list_changed` to every connected client, like `sendResourceListChanged()`. */
471
519
  sendPromptListChanged(): Promise<void>;
472
520
  close(): Promise<void>;
473
521
  }
@@ -564,7 +612,12 @@ declare function validateSchemaCollection(schemas: readonly object[], engine?: S
564
612
  declare function createSchemaCompiler(engine?: SchemaEngine): SchemaCompiler;
565
613
  /** Whether the current runtime validates schemas via Ajv (Node) or the edge fallback. */
566
614
  declare const schemaEngine: SchemaEngine;
567
- /** Convert normalized engine failures into a bounded public diagnostic shape. */
615
+ /**
616
+ * Convert normalized engine failures into a bounded public diagnostic shape:
617
+ * at most 100 issues; property names, keywords and messages are cut to 256
618
+ * characters; instance and schema paths longer than 256 characters are
619
+ * replaced by the root (`/`, `#`). Any such shortening sets `truncated: true`.
620
+ */
568
621
  declare function formatMcpFnSchemaIssues(errors: SchemaIssue[] | null | undefined): McpFnSchemaIssue[];
569
622
 
570
623
  export { type CompiledSchema, type CreateManifestOptions, MCP_APP_EXTENSION_ID, MCP_APP_MIME_TYPE, type McpAppCsp, type McpAppPermissions, type McpAppResourceMetadata, type McpAppResourceOptions, type McpAppToolMetadata, type McpFnCatalogChange, type McpFnChangeSeverity, type McpFnClientProfile, type McpFnClientProfileCallInput, type McpFnClientProfileCatalogInput, McpFnClientProfileError, type McpFnClientProfileEvidence, type McpFnClientProfileHookInput, type McpFnClientProfileLifecycleStage, type McpFnClientProfilesOptions, type McpFnClientRequestOptions, type McpFnContractChange, type McpFnDiffResult, type McpFnElicitationParams, type McpFnElicitationResult, McpFnError, type McpFnJsonSchema, type McpFnListedResource, type McpFnListedResourceTemplate, type McpFnListedTool, type McpFnManifest, type McpFnManifestPrompt, type McpFnManifestResource, type McpFnManifestResourceTemplate, type McpFnManifestTool, type McpFnObjectSchema, McpFnOutputValidationError, type McpFnPromptDefinition, McpFnRegistry, type McpFnReportedClient, type McpFnRequestExtra, type McpFnResolvedClientProfile, type McpFnResourceDefinition, type McpFnResourceTemplateDefinition, type McpFnRootsResult, type McpFnSamplingParams, type McpFnSamplingResult, type McpFnSchemaIssue, McpFnServer, McpFnServerDeclaration, type McpFnServerDeclarationOptions, type McpFnServerInfo, type McpFnServerOptions, type McpFnServerRuntimeOptions, type McpFnTaskHandler, type McpFnTaskRequestExtra, type McpFnToolDefinition, type McpFnToolLifecycleObserver, type McpFnToolLifecycleStage, type McpFnToolVisibilityInput, McpFnValidationError, type McpFnVerifiedClientIdentity, type McpFnWebStandardHandlerOptions, type SchemaCompiler, type SchemaEngine, type SchemaIssue, assertMcpAppContracts, assertPromptSchemaSupportsStringValues, buildMcpFnEffectiveCatalog, canonicalJson, canonicalize, compareCodeUnits, createManifest, createMcpAppResource, createMcpFnServer, createSchemaCompiler, defineMcpFnServer, diffManifests, enrichMcpFnClientProfileCall, errorResult, formatMcpFnSchemaIssues, jsonSafe, mcpAppToolMetadata, promptArguments, resolveMcpFnClientProfile, resolveMcpFnServerCapabilities, schemaEngine, schemaPromptArguments, sha256, structuredResult, textResult, validateManifest, validateMcpFnClientProfiles, validateSchemaCollection };