[Feature]: opt-in setting to refuse ?apikey= credentials on MCP endpoints
Problem / motivation
Every MCP endpoint (/mcp, /mcp/all, /mcp/call, /mcp/code, /mcp/p/...) and the REST API accept the credential as a URL query parameter, ?apikey=<admin key or mcp_agt_ token>, on top of Authorization: Bearer and X-API-Key (httpapi.ExtractToken, mcpAuthMiddleware). That is useful for clients that can only be configured with a URL and for the Web UI's SSE stream, but a credential in a URL is copied into places header credentials never reach: reverse-proxy and load-balancer access logs, browser history, Referer headers, shell history and screenshots. MCPProxy's own logs scrub it (oauth.LogSafeRequestPath, the SEC-01 note in httpapi), but whatever sits in front of it does not.
For a deployment where every agent is a programmatic MCP client that can send a header (and the proxy sits behind Caddy/nginx), there is no way to say "never accept a token in the URL". And there is a sharper edge: with require_mcp_auth: false, a request with an unrecognised credential is served as the anonymous administrator, so a front proxy or a client that mangles the header form cannot rely on a typo being refused.
Proposed solution
An opt-in config key, mcp_reject_query_apikey (default false, so nothing changes by default). When true, every /mcp* endpoint answers a request that has an apikey query parameter with 401 and an explanatory body ("send it as Authorization: Bearer /events are deliberately untouched, since the UI (api.ts) builds ?apikey= URLs for SSE and export downloads; the key covers only the agent-facing endpoints. Live (no restart), documented in agent-tokens.md and config-file.md, plus swagger/TS regeneration and a CHANGELOG entry.
I have this implemented with tests and will open a PR that closes this issue.
Alternatives considered
- Reject the query form on the REST API as well. That breaks the Web UI's SSE and export links until they move to cookies or a short-lived ticket, which is a bigger change; the MCP-only switch is the part that matters for agent tokens.
- Strip the parameter in the reverse proxy. Works for Caddy/nginx users, but it is an easy rule to forget, and does nothing when MCPProxy is reached directly.
- Make the default
true. It would break clients that can only configure a URL (the connect wizard can emit such URLs), so I left the default alone.
Which edition?
Both (personal and server).
- [x] I searched existing issues and discussions for a similar request (#1180 is the related
/api/v1/infofix; nothing on this)