Skip to content

[Tests] Pin that protected resource metadata advertises no scope of its own - #440

Merged
chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:pr/prm-scope-regression
Aug 18, 2026
Merged

[Tests] Pin that protected resource metadata advertises no scope of its own#440
chr-hertel merged 1 commit into
modelcontextprotocol:mainfrom
chr-hertel:pr/prm-scope-regression

Conversation

@chr-hertel

Copy link
Copy Markdown
Member

SEP-2207 (#364) says a resource server must not advertise offline_access as a required scope.

There is nothing to fix: ProtectedResourceMetadata::$scopesSupported is entirely operator-supplied, and nothing in src/ writes offline_access anywhere. But there was also nothing stopping a future default from quietly starting to advertise one, so this pins the behaviour with a regression test.

Test only — no production code changes.

…ts own

SEP-2207 says a resource server must not advertise `offline_access` as a
required scope. Nothing in src/ writes it - `scopesSupported` is entirely
operator-supplied - so there was nothing to fix, but also nothing stopping a
future default from quietly starting to advertise one.

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.

Pull request overview

Adds regression coverage to ensure the server-side Protected Resource Metadata (RFC 9728) emitted by the PHP SDK does not start advertising offline_access as a required/supported scope (per SEP-2207 / issue #364). This is a test-only PR intended to prevent future defaults from quietly introducing offline_access into scopes_supported.

Changes:

  • Added a unit test asserting scopes_supported reflects only operator-supplied scopes and does not include offline_access.
  • Added a unit test asserting that omitting scopes results in no scopes_supported member being serialized.
Suppressed comments (1)

tests/Unit/Server/Transport/Http/OAuth/ProtectedResourceMetadataTest.php:92

  • This comment says “advertising one”, which is ambiguous (it’s referring to the offline_access scope). Rewording makes the intent clearer.
        // SEP-2207: `offline_access` is a refresh-token scope, not something a
        // resource requires. Nothing in the SDK injects it — this pins that, so
        // a future default cannot quietly start advertising one.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

new ProtectedResourceMetadata([]);
}

#[TestDox('the SDK advertises exactly the scopes it was given, and never adds offline_access')]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not changing this — the test's input has no whitespace/empties/duplicates, so normalize() is a no-op here; the TestDox describes this test's specific SEP-2207 guard, not a general preservation guarantee.

Comment on lines +99 to +102
$data = $metadata->jsonSerialize();

$this->assertSame(['mcp:read', 'mcp:write'], $data['scopes_supported']);
$this->assertNotContains('offline_access', $data['scopes_supported']);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not adding assertArrayHasKey here — line 101 already dereferences the same key and would fail first with a clear message if it were missing; jsonSerialize() also guarantees the key is set whenever scopesSupported is non-null.

@chr-hertel
chr-hertel merged commit 5e3e69a into modelcontextprotocol:main Aug 18, 2026
23 checks passed
@chr-hertel
chr-hertel deleted the pr/prm-scope-regression branch August 18, 2026 18:21
@chr-hertel chr-hertel added this to the 0.8.0 milestone Aug 18, 2026
@chr-hertel chr-hertel added the 2026-07-28 All issues and PRs related to the spec release 2026-07-28 label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2026-07-28 All issues and PRs related to the spec release 2026-07-28

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants