/** * Per-credential OdooClient pool for the HTTP transport. * * Each unique (url, db, user, password) combination gets its own * OdooClient + McpCache. Entries are evicted after IDLE_TIMEOUT_MS of * inactivity. * * McpOdooServer and StreamableHTTPServerTransport are intentionally NOT * pooled here — the MCP SDK's stateless transport (sessionIdGenerator: * undefined) sets _hasHandledRequest=true on first use and throws on the * second. A fresh pair must be created per HTTP request in the handler. */ import { OdooClient } from '@marcfargas/odoo-client'; import type { AuditWriter } from './audit'; import { McpCache } from './cache'; import type { PolicyRule } from './policy'; /** Connection parameters extracted from X-Odoo-* headers. */ export interface OdooConnectionConfig { url: string; db: string; user: string; password: string; } /** What the HTTP handler receives from acquire() for this credential set. */ export interface AcquiredSession { client: OdooClient; cache: McpCache; } export interface ClientPoolOptions { version: string; getPolicy: () => PolicyRule[]; audit: AuditWriter; /** Evict entries idle longer than this (default: 30 min). */ idleTimeoutMs?: number; /** How often to run the eviction sweep (default: 5 min). */ evictIntervalMs?: number; /** * Maximum number of live pool entries (default: 50). * Requests that would exceed this cap receive 429. */ maxSize?: number; } /** Exposed subset of options needed by the HTTP handler to build per-request servers. */ export interface PoolServerOptions { version: string; getPolicy: () => PolicyRule[]; audit: AuditWriter; } /** Thrown by OdooClientPool.acquire() when the pool is at capacity. */ export declare class McpPoolFullError extends Error { constructor(limit: number); } export declare class OdooClientPool { private readonly options; private readonly entries; private readonly idleTimeoutMs; private readonly maxSize; private readonly evictTimer; constructor(options: ClientPoolOptions); /** * Options the HTTP handler needs to construct a per-request McpOdooServer. * Exposed here so the handler doesn't need a separate config object. */ get serverOptions(): PoolServerOptions; /** * Acquire an authenticated session for the given credentials. * Creates a new entry (including Odoo authentication) if one doesn't exist. * Throws OdooAuthError if credentials are invalid — caller maps this to 401. */ acquire(config: OdooConnectionConfig): Promise; private createEntry; private evictIdle; private closeEntry; /** Return current number of live entries (useful for tests / metrics). */ get size(): number; /** Drain the pool: stop eviction timer, close all entries. */ close(): Promise; } //# sourceMappingURL=client-pool.d.ts.map