Skip to content

Say why a request was refused (401/403) instead of the generic message #398

Open

Description

@apeatling

When a request is refused, MCP Adapter returns core's generic rest_forbidden message: "Sorry, you are not allowed to do that." Missing credentials, a wrong password and an unknown user all get the same 401 and message, so owners and agents can't tell what's wrong. Core's own endpoints at least say "You are not currently logged in." in the same case.

The cause is that HttpTransport::check_permission() (includes/Transport/HttpTransport.php) returns false, so core writes the message.

Suggested change: return a WP_Error with a specific code and message, keeping the same status codes:

  • Not signed in (401): for example, "This request isn't signed in as a WordPress user. Check the username and Application Password, or the sign-in plugin you use." Link the site-owner guide.
  • Signed in without access (403): name the capability the user lacks.

Sites that use an OAuth or JWT plugin also reach this check, so the message shouldn't assume Application Passwords. The adapter shouldn't add a WWW-Authenticate header: it has no OAuth metadata to point to, and clients like claude.ai start an OAuth sign-in when they see one.

Part of #394.

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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions