Oath MCP always using root level even though my rul is .../xmcp/mcp #4328

Open
opened 2026-02-16 17:43:27 -05:00 by yindo · 0 comments
Owner

Originally created by @adiberk on GitHub (Jan 6, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

My mcp url is /xmcp/mcp. This works fine for claude code and cursor.
However I think opencode is tyring to authenticate with mcp using root urls only. What do I need to change to fix?

AI informs me opencode may not be using the authroization information?

Here is my authorization resource endpoint:

curl -s http://localhost:8000/.well-known/oauth-protected-resource/xmcp/mcp
{"resource":"http://localhost:8000/xmcp/mcp","authorization_servers":["http://localhost:8000/xmcp"],"scopes_supported":["openid"],"bearer_methods_supported":["header"]}%  

here is authorization servers

curl -i http://localhost:8000/.well-known/oauth-authorization-server/xmcp
HTTP/1.1 200 OK
date: Tue, 06 Jan 2026 22:35:04 GMT
server: uvicorn
cache-control: public, max-age=3600
content-length: 633
content-type: application/json

{"issuer":"http://localhost:8000/xmcp","authorization_endpoint":"http://localhost:8000/xmcp/authorize","token_endpoint":"http://localhost:8000/xmcp/token","registration_endpoint":"http://localhost:8000/xmcp/register","scopes_supported":["openid"],"response_types_supported":["code"],"grant_types_supported":["authorization_code","refresh_token"],"token_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"revocation_endpoint":"http://localhost:8000/xmcp/revoke","revocation_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"code_challenge_methods_supported":["S256"]}%   

Here is my configuration

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "levmcp": {
      "type": "remote",
      "url": "http://localhost:8000/xmcp/mcp"
    },
  }
}

Here are requests being made by opencode

INFO [01/06/26 22:43:57] 172.66.0.243:42116 - "POST /xmcp/mcp HTTP/1.1" 401
[01/06/26 22:43:57] INFO     Auth error returned: invalid_token middleware.py:92
                             (status=401)                                       
INFO [01/06/26 22:43:57] 172.66.0.243:42116 - "GET 
/.well-known/oauth-protected-resource/xmcp/mcp HTTP/1.1" 200
INFO [01/06/26 22:43:57] 172.66.0.243:42116 - "GET 
/.well-known/oauth-authorization-server/xmcp/mcp HTTP/1.1" 404
INFO [01/06/26 22:43:57] 172.66.0.243:33885 - "GET 
/.well-known/oauth-authorization-server HTTP/1.1" 404
INFO [01/06/26 22:43:57] 172.66.0.243:42116 - "POST /register HTTP/1.1" 404

Plugins

mcp

OpenCode version

latest

Steps to reproduce

Use fastmcp app
Set mcp to mcp.http_app("/mcp", stateless_http=True)
Then mount to existing app at "/xmcp"

This will give you the configuration you need. It works for claude code just fine

Screenshot and/or share link

No response

Operating System

Mac OS

Terminal

warp

Originally created by @adiberk on GitHub (Jan 6, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description My mcp url is /xmcp/mcp. This works fine for claude code and cursor. However I think opencode is tyring to authenticate with mcp using root urls only. What do I need to change to fix? AI informs me opencode may not be using the authroization information? Here is my authorization resource endpoint: ``` curl -s http://localhost:8000/.well-known/oauth-protected-resource/xmcp/mcp {"resource":"http://localhost:8000/xmcp/mcp","authorization_servers":["http://localhost:8000/xmcp"],"scopes_supported":["openid"],"bearer_methods_supported":["header"]}% ``` here is authorization servers ``` curl -i http://localhost:8000/.well-known/oauth-authorization-server/xmcp HTTP/1.1 200 OK date: Tue, 06 Jan 2026 22:35:04 GMT server: uvicorn cache-control: public, max-age=3600 content-length: 633 content-type: application/json {"issuer":"http://localhost:8000/xmcp","authorization_endpoint":"http://localhost:8000/xmcp/authorize","token_endpoint":"http://localhost:8000/xmcp/token","registration_endpoint":"http://localhost:8000/xmcp/register","scopes_supported":["openid"],"response_types_supported":["code"],"grant_types_supported":["authorization_code","refresh_token"],"token_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"revocation_endpoint":"http://localhost:8000/xmcp/revoke","revocation_endpoint_auth_methods_supported":["client_secret_post","client_secret_basic"],"code_challenge_methods_supported":["S256"]}% ``` Here is my configuration ``` { "$schema": "https://opencode.ai/config.json", "mcp": { "levmcp": { "type": "remote", "url": "http://localhost:8000/xmcp/mcp" }, } } ``` Here are requests being made by opencode ``` INFO [01/06/26 22:43:57] 172.66.0.243:42116 - "POST /xmcp/mcp HTTP/1.1" 401 [01/06/26 22:43:57] INFO Auth error returned: invalid_token middleware.py:92 (status=401) INFO [01/06/26 22:43:57] 172.66.0.243:42116 - "GET /.well-known/oauth-protected-resource/xmcp/mcp HTTP/1.1" 200 INFO [01/06/26 22:43:57] 172.66.0.243:42116 - "GET /.well-known/oauth-authorization-server/xmcp/mcp HTTP/1.1" 404 INFO [01/06/26 22:43:57] 172.66.0.243:33885 - "GET /.well-known/oauth-authorization-server HTTP/1.1" 404 INFO [01/06/26 22:43:57] 172.66.0.243:42116 - "POST /register HTTP/1.1" 404 ``` ### Plugins mcp ### OpenCode version latest ### Steps to reproduce Use fastmcp app Set mcp to mcp.http_app("/mcp", stateless_http=True) Then mount to existing app at "/xmcp" This will give you the configuration you need. It works for claude code just fine ### Screenshot and/or share link _No response_ ### Operating System Mac OS ### Terminal warp
yindo added the bug label 2026-02-16 17:43:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4328