mcpwn API
    Preparing search index...

    Class Correlator

    Tracks in-flight requests so responses (which carry no method on the wire) can be tagged with the method that produced them. Without this, rules and the UI cannot say "this is the tools/call result".

    MCP is bidirectional: the client issues requests (tools/call, tools/list, …) and the server issues requests back (sampling/createMessage, roots/list, elicitation/create) whose replies travel the other way. The two id-spaces are independent and collide (both start at 1), so the in-flight map is keyed by (request-direction, id).

    Entries are normally cleared the instant their response is correlated. But a dropped request, a crashed peer, or a server that simply never replies would otherwise leak an entry forever — unbounded growth over a long session. A TTL + size cap reap those orphans without ever disturbing a normally-timed round trip. The Map preserves insertion order, which (since each entry's ts is stamped at insertion) is also oldest-first order, so both evictors can scan/trim from the front.

    Index
    • Record an outgoing request's id->method mapping, keyed by the direction the request itself travelled. Reaps expired/overflowing orphans first so the map stays bounded in a long session.

      Parameters

      Returns void

    • Resolve the originating method for a response/error by its id. The request it answers flowed the opposite direction, so look there. An entry that has already passed its TTL is treated as absent (the response arrived too late to be trusted) and cleared.

      Parameters

      Returns string | undefined

    • Current number of tracked in-flight requests (for tests / introspection).

      Returns number