Skip to content

MCP with oauth doesn't work #5444

Closed
Closed

Description

@klaudworks

Description

Configured MCP like this inside my project:

"mcp": {
  "jira": {
    "type": "remote",
    "url": "https://mcp.atlassian.com/v1/sse"
  }
},

opencode mcp auth jira shows:

opencode mcp auth jira

┌  MCP OAuth Authentication
│
▲  No OAuth-enabled MCP servers configured
│
●  Add OAuth config to a remote MCP server in opencode.json:
│
●
│    "mcp": {
│      "my-server": {
│        "type": "remote",
│        "url": "https://example.com/mcp",
│        "oauth": {
│          "scope": "tools:read"
│        }
│      }
│    }
│
└  Done
Image

I thought it may also help to try to invoke the tools and then the Oauth process will start but the agent doesn't know the tools.

OpenCode version

1.0.150

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

macOS 26.1

Terminal

iTerm 2

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 12, 2025
  2. github-actions commented on Dec 12, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 12, 2025
  4. self-assigned this
    on Dec 12, 2025
  5. added a commit that references this issue on Dec 14, 2025
    805af91
  6. jmhill commented on Dec 19, 2025

    @jmhill

    I got the same issue (opencode mcp auth atlassian failed with the same message about No Oauth-enabled MCP servers configured), but when I set up opencode.json to use the local proxy instead, I was able to use Atlassian MCP. Not a solution, but hopefully a workaround that could help.

    {
    	"$schema": "https://opencode.ai/config.json",
    	"mcp": {
    		"atlassian": {
    			"type": "local",
    			"command": ["npx", "-y", "mcp-remote", "https://mcp.atlassian.com/v1/sse"]
    		}
    	}
    }
    
  7. daraghscopey commented on Dec 19, 2025

    @daraghscopey

    I got a similar issue in trying to connect the linear remote mcp server.

    I had to add this "oauth": {} to the config, and then when I ran opencode mcp auth linear it properly kicked off the auth flow.

    {
        "$schema": "https://opencode.ai/config.json",
        "mcp": {
            "linear": {
                "type": "remote",
                "url": "https://mcp.linear.app/mcp",
                "enabled": true,
               "oauth": {}
            }
        }
    }
  8. klaudworks commented on Dec 19, 2025

    @klaudworks
    Author

    thank you. adding "oauth": {} actually fixed it.

  9. tedmahsun commented on Feb 1, 2026

    @tedmahsun

    For me what worked was changing the http://127.0.0.1 url (on the page that failed) to http://localhost. :/

  10. seannetlife commented on Feb 11, 2026

    @seannetlife

    fyi. sometimes i have to explicitly logout and log back in to reauthenticate

    opencode mcp logout atlassian
    opencode mcp auth atlassian
    
  11. snarkipus commented on Mar 8, 2026

    @snarkipus

    For me what worked was changing the http://127.0.0.1 url (on the page that failed) to http://localhost. :/

    This worked for me as well for linear ... I assumed it was a WSL'ism.

  12. sghng commented on Mar 11, 2026

    @sghng

    For me what worked was changing the http://127.0.0.1 url (on the page that failed) to http://localhost. :/

    This doesn't work for me. Here's what I did on Firefox:

    1. When the OAuth web page is stuck at "waiting for 127.0.0.1", open developer panel.
    2. Go to network, find the GET request, double click.
    3. It loads the request into URL bar. The URL looks something like http://127.0.0.1:19876/mcp/oauth/callback?code=xxx&state=xxx
    4. Changing 127.0.0.1 to localhost, and hit enter

    This didn't work.

  13. chendeshen commented on Mar 28, 2026

    @chendeshen

    solved my issue

  14. gurvancampion commented on Apr 23, 2026

    @gurvancampion

    For me what worked was changing the http://127.0.0.1 url (on the page that failed) to http://localhost. :/

    This worked for me as well for linear ... I assumed it was a WSL'ism.

    This worked for me in my WSL environment setup

  15. removed
    bugSomething isn't working
    on May 3, 2026
  16. windseason commented on May 29, 2026

    @windseason

    this doesn't work for me.

    Bug Report: Linear MCP Authentication Fails Despite Valid Credentials

    Environment

    Problem Summary

    The linear MCP server shows as "connected" in opencode mcp list, but all tool invocations fail with invalid_token — even immediately after successful OAuth authentication.

    Configuration Used

    {
      "mcp": {
        "linear": {
          "type": "remote",
          "url": "https://mcp.linear.app/mcp",
          "enabled": true,
          "oauth": {}
        }
      }
    }

    Steps to Reproduce

    1. Configure Linear MCP in ~/.config/opencode/opencode.json with "oauth": {}
    2. Run opencode mcp auth linear and complete OAuth flow successfully
    3. Restart OpenCode to pick up config changes
    4. Verify connection: opencode mcp list shows ✓ linear connected
    5. Attempt to invoke any Linear MCP tool (e.g., linear_get_issue)

    Expected Behavior

    MCP tool should execute successfully using the authenticated OAuth token.

    Actual Behavior

    Failed to connect to MCP server "linear".
    URL: https://mcp.linear.app/mcp
    Reason: Streamable HTTP error: Error POSTing to endpoint: 
    {"error":"invalid_token","error_description":"Missing or invalid access token"}
    

    Debug Output (opencode mcp debug linear)

    ●  Auth status: ✓ authenticated
    ●    Access token: 22dadc00-c1d4-4da0-b...
    ●    Expires: 2026-05-30T05:46:06.390Z 
    ●    Refresh token: present
    ●    Client ID: J9BKiZgklNri5DVI
    ◇  HTTP response: 401 Unauthorized
    ●  WWW-Authenticate: Bearer realm="OAuth", resource_metadata="https://mcp.linear.app/.well-known/oauth-protected-resource/mcp", error="invalid_token", error_description="Missing or invalid access token"
    ▲  Server returned 401 Unauthorized
    

    Key Observations

    • Token IS obtained: debug shows valid access token and refresh token present
    • Auth flow succeeds: opencode mcp auth linear confirms "already has valid credentials"
    • Connection check passes: mcp list shows ✓ linear connected
    • HTTP test fails: The debug HTTP probe gets 401 Unauthorized from Linear's server
    • Native tools work fine: linear_get_issue (non-MCP) successfully fetches issue ACENOTE-1443
    • Tool execution fails: Only the actual tool invocation hits the auth error

    Root Cause Analysis

    The OAuth token acquisition works correctly (token is present, not expired, refresh token available), but OpenCode's MCP client is not properly attaching the token to HTTP requests when invoking tools. The 401 Unauthorized + WWW-Authenticate: Bearer response from Linear's server indicates the Authorization header is either:

    1. Missing entirely from tool invocation requests
    2. Malformed (wrong prefix, encoding, or format)
    3. Not being sent through the Streamable HTTP transport layer
  17. rekram1-node commented on Jun 24, 2026

    @rekram1-node
    Contributor

    Closing because the original report is fixed: remote MCP OAuth is now enabled by default unless oauth: false, so an explicit oauth: {} block is no longer required. This thread has since accumulated unrelated callback, WSL, and Linear token symptoms. Please open a focused current-version issue for any remaining provider-specific failure; note that mcp debug intentionally performs an unauthenticated probe, so its 401 alone does not show that tool requests omit the OAuth token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions