import type { StandardSchemaWithJSON } from "@modelcontextprotocol/server"; import type { Env } from "hono"; import type { OAuthMode, RequestContext } from "./context.js"; /** Native primitive setting and its presentation metadata. */ export interface SettingsField { /** * Primitive Standard Schema with JSON Schema conversion; read() returns effective values. * Validation must preserve supplied values; value-changing transforms are rejected at runtime. */ schema: Schema; /** Non-blank label displayed by the host. */ title: string; /** Optional explanatory text displayed by the host. */ description?: string; } /** Named primitive settings. */ export type SettingsFields = Record; /** Complete effective values inferred from the registered field schemas. */ export type SettingsValues = { -readonly [Key in keyof Fields]-?: Exclude, undefined>; }; /** A native settings section containing field controls and same-server actions. */ export interface SettingsLayoutGroup { /** Identifies a group; nested groups are unsupported. */ kind: "group"; /** Non-blank section heading. */ title: string; /** Ordered controls; omitted fields appear in the host's Other settings section. */ items: readonly ({ /** Identifies a field control. */ kind: "property"; /** Registered field key. */ property: Key; } | { /** Identifies an action button. */ kind: "tool"; /** Same-server tool accepting empty arguments. */ tool: string; /** Button label. */ title: string; /** Optional button description. */ description?: string; })[]; } /** Register native plugin settings; persistence and authorization remain application-owned. */ export interface SettingsRegistration { /** At least one field convertible to boolean, string, string enum, number, or integer JSON Schema. */ fields: Fields; /** Read tool name; defaults to settings.read. */ readTool?: string; /** Update tool name; defaults to settings.update. */ updateTool?: string; /** Optional grouped controls and action buttons. */ layout?: readonly SettingsLayoutGroup>[]; /** Authorize and return every effective value, including application defaults, without mutation. */ read: (ctx: RequestContext) => SettingsValues | Promise>; /** Authorize, preserve omitted fields, persist changes atomically, then return every effective value. */ update: (set: Partial>, ctx: RequestContext) => SettingsValues | Promise>; } /** Capture schemas/layout and derive validated settings tools without invoking handlers. @internal */ export declare function prepareSettings(options: Pick, "fields" | "layout" | "readTool" | "updateTool">): { capability: { readTool: string; updateTool: string; }; schema: { type: string; properties: Record; required: string[]; additionalProperties: boolean; }; layout: readonly SettingsLayoutGroup>[] | undefined; readDefinition: { name: string; inputSchema: StandardSchemaWithJSON; outputSchema: StandardSchemaWithJSON; }>; annotations: { readOnlyHint: true; }; }; updateDefinition: { name: string; inputSchema: StandardSchemaWithJSON; }>; outputSchema: StandardSchemaWithJSON; }>; }; };