Skip to content

perf(mcp): cache Ability_Registry::get_exposed_abilities() per request #217

Description

@pluginslab

From the v0.12.0 MCP endpoint security review (PR #216, finding [Low #3]).

`Ability_Registry::resolve_tool_name()` calls `get_exposed_abilities()` on every `tools/call`, which re-walks `wp_get_abilities()` and re-reads settings. An authenticated client could spam bogus tool names and force repeated full-registry walks.

Fix: memoize `get_exposed_abilities()` for the lifetime of one `JsonRpc_Server::handle()` invocation. Either via an instance-level cache on `Ability_Registry` (cleared at the start of each `handle()` call) or by passing the resolved map down from `JsonRpc_Server`.

Acceptance:

  • A single MCP request that triggers `tools/list` followed by `tools/call` walks the abilities registry once.
  • No behavior change for the consumer.

Not security-critical — defense-in-depth + perf hardening.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestphpPHP backend work

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions