/** * @fileoverview Capability profile loader + cache for BrAPI servers. Pulls * `/serverinfo`, `/calls`, and `/commoncropnames` on first use (or refresh), * normalizes the shape, and stores the result in tenant-scoped state. Tools * consult this before routing requests — if a required endpoint isn't in the * server's capability set, the service surfaces a clear `ValidationError` * instead of letting the call fail downstream. * * @module services/capability-registry/capability-registry */ import type { Context } from '@cyanheads/mcp-ts-core'; import type { ServerConfig } from '../../config/server-config.js'; import { type BrapiClient, type BrapiRequestOptions } from '../../services/brapi-client/index.js'; import type { CallDescriptor, CapabilityProfile, EndpointProbe } from './types.js'; export interface CapabilityLookupOptions extends Pick { /** Force a fresh fetch, bypassing the cached profile. */ forceRefresh?: boolean; } export declare class CapabilityRegistry { private readonly serverConfig; private readonly client; constructor(serverConfig: ServerConfig, client?: () => BrapiClient); /** * Load the capability profile for a base URL. Returns the cached profile * when present and not expired; otherwise fetches fresh and caches it. */ profile(baseUrl: string, ctx: Context, options?: CapabilityLookupOptions): Promise; /** * Throw a `ValidationError` if the requested endpoint (service + optional * HTTP method) is not in the server's capability set. Tools call this * before routing requests so missing-capability errors surface early with * a clear recovery hint. */ ensure(baseUrl: string, probe: EndpointProbe, ctx: Context, options?: CapabilityLookupOptions): Promise; /** Drop the cached profile for a base URL (e.g. on explicit reconnect). */ invalidate(baseUrl: string, ctx: Context): Promise; private fetchProfile; /** * `/calls` fallback — some servers don't embed calls in `/serverinfo` and * expect clients to hit the dedicated endpoint. Degrades to an empty list * if the server lacks this too; downstream `ensure()` will surface the * missing-capability error with a useful message. */ private fetchCallsFallback; private fetchCrops; private cacheKey; } export declare function initCapabilityRegistry(serverConfig: ServerConfig): void; export declare function getCapabilityRegistry(): CapabilityRegistry; export declare function resetCapabilityRegistry(): void; //# sourceMappingURL=capability-registry.d.ts.map