← 输入框|github.com|刷新
Skip to content

Paginate registry references before mapping - #653

Merged
chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
andreybolonin:perf/registry-paginate-before-map
Nov 2, 2026
Merged

chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
andreybolonin:perf/registry-paginate-before-map

Conversation

@andreybolonin

Copy link
Copy Markdown
Contributor

Paginated registry reads currently map every registered reference to its schema object before selecting a page. Select the page first for tools, resources, resource templates, and prompts, then map only its entries. Unlimited reads retain their associative keys; paginated reads retain their list order and cursor validation.

A unit test covers all four lists across three pages. A local PHP 8.5 microbenchmark of the affected mapping/slicing path (10,000 entries, page size 50, 1,000 iterations) took 354 → 1.2 ms and reduced peak additional memory from 983 → 4 KB. This is an operation benchmark, not end-to-end request latency.

Validation: make ci (Composer update, PHP CS Fixer, PHPStan, PHPUnit).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change to paginate registry entries before mapping them.

No open issues 🎉

What changed in this PR

This PR reduces mapping work in paginated registry reads by selecting references for the requested page before converting them to schema objects.

Changes:

  • Applies pagination before mapping tools, resources, resource templates, and prompts.
  • Preserves associative keys for unlimited reads and list order and cursor validation for paginated reads.
  • Adds a unit test covering all four lists across three pages.
File Description
tests/​Unit/​Capability/​RegistryTest.php Tests page ordering and cursor progression across all four registry lists.
src/​Capability/​Registry.php Maps only selected page entries while retaining unlimited-read behavior.

Review effort: Balanced

@chr-hertel
chr-hertel merged commit 5c0e213 into modelcontextprotocol:main Nov 2, 2026
28 checks passed
@chr-hertel chr-hertel added the Server Issues & PRs related to the Server component label Nov 2, 2026
chr-hertel added a commit to BrocksiNet/php-sdk that referenced this pull request Nov 4, 2026
…et/php-sdk into pr-618-end-a-listen-stream-that-can

* 'fix/listen-empty-filter' of https://github.com/BrocksiNet/php-sdk: (25 commits)
  [Server] Pass an explicit null to a nullable tool parameter with a default (modelcontextprotocol#642)
  [Capability] Check tool names against the spec's 128-character limit and character set (modelcontextprotocol#639)
  [Tests] Stop php -S servers together with their forked workers (modelcontextprotocol#658)
  chore(deps): bump astral-sh/setup-uv from 10.3.2 to 10.3.3 (modelcontextprotocol#659)
  [Server] Accept plain http on `*.localhost` and `127.0.0.0/8` hosts in OAuth URLs (modelcontextprotocol#620)
  [Capability] Map PHPDoc pseudo-types to the JSON Schema type of their base type (modelcontextprotocol#643)
  Raise minimum versions of `phpdocumentor/reflection-docblock` and `psr/container` (modelcontextprotocol#657)
  [Server] Use compact JSON in result formatters (modelcontextprotocol#647)
  [Server] Filter list completions in one pass (modelcontextprotocol#649)
  [Server] Fix result lists being sent as JSON objects (modelcontextprotocol#656)
  Avoid repeated array merges in prompt formatting (modelcontextprotocol#650)
  [Docs] Add AGENTS.md (modelcontextprotocol#634)
  Avoid repeated array merges in resource formatting (modelcontextprotocol#651)
  [Server] Fix `"0"` prefix offering all completions (modelcontextprotocol#655)
  Filter enum completions in one pass (modelcontextprotocol#652)
  Paginate registry references before mapping (modelcontextprotocol#653)
  Extract JWT scopes in one pass (modelcontextprotocol#654)
  [Server] Fix `Session::save()` wiping a session that the store failed to read (modelcontextprotocol#637)
  [Server] Answer a DELETE of an unknown or ended session with 404 (modelcontextprotocol#638)
  [Server] Add `Psr6SessionStore` and `Psr6NotificationBus` (modelcontextprotocol#635)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants