Access Token Invalid or Expired (MCP Server + CodeScene Cloud)
If you encounter an "access token is invalid or expired" error when using the MCP Server with CodeScene Cloud, this typically indicates a configuration, environment, or connectivity issue rather than a problem with the token itself.
For interactive use, OAuth is the recommended authentication method. If you are using OAuth, you do not need to manually create or manage an access token.
Step 1: Run Diagnostics
Start by running the MCP tool:
verify_installation
This provides detailed diagnostics and can help identify whether the problem is related to authentication, connectivity, or configuration.
If you are using OAuth
Step 2: Sign in again
If you are using OAuth and authentication is failing, start the CodeScene login flow again.
Ask your AI assistant:
Log me in to CodeScene
This will open your browser and allow you to authenticate with CodeScene Cloud.
Once authentication is complete, try using the MCP Server again.
Using multiple CodeScene Cloud accounts
If you belong to more than one CodeScene Cloud account, make sure the correct Account ID is configured before signing in.
Ask your AI assistant:
Set my CodeScene account ID to 123
Replace 123 with the Account ID for the CodeScene Cloud account you want to use.
You can find your Account ID under My Account in CodeScene Cloud.
Important: No configuration is required on the CodeScene server for OAuth. This is separate from CodeScene SSO configuration.
If you are using a Personal Access Token
PAT authentication is an alternative to OAuth and can be useful for CI/CD pipelines, headless environments, automated workflows, or situations where you prefer a static credential.
Step 2: Confirm your token
Ensure that:
Your Personal Access Token for CodeScene Cloud is valid and active.
The token has not expired or been revoked.
The token is configured correctly in your MCP client.
If you are unsure whether the token is still valid, create a new Personal Access Token and replace the existing one.
Important: If
CS_ACCESS_TOKENis configured, it takes precedence over an OAuth session.
Step 3: Check for Environmental Restrictions
If authentication still fails, the issue may be related to your environment rather than your credentials.
For example:
You may be working in a corporate or restricted network.
Outbound access to CodeScene Cloud might be blocked or filtered.
HTTPS traffic may be inspected or intercepted by your organization's security infrastructure.
Verify that your environment allows connections to CodeScene Cloud endpoints.
Step 4: Check for Custom Certificate Authority (CA) Issues
If your environment uses a custom certificate authority (CA), you may need to configure the MCP Server accordingly.
Set the REQUESTS_CA_BUNDLE environment variable to point to your CA bundle.
See the CodeScene MCP Server configuration documentation for more information.
Important: MCP versions 1.3, 1.3.1, and 1.3.2 have a known issue related to custom CA handling. This can cause valid authentication credentials to be incorrectly rejected.
Step 5: Upgrade the MCP Server
Make sure you are using the latest version of the CodeScene MCP Server.
Newer versions include:
Improved handling of custom certificate authorities.
More detailed and actionable diagnostic output from
verify_installation.The latest authentication improvements, including OAuth support.
Common Causes
When using OAuth
Your OAuth session needs to be refreshed.
The wrong CodeScene Cloud account is selected.
An Account ID is required because you belong to multiple CodeScene Cloud accounts.
Network or certificate restrictions are preventing communication with CodeScene Cloud.
You are using an outdated MCP Server version.
When using a Personal Access Token
The PAT is invalid, expired, or revoked.
The token is incorrectly configured.
Network restrictions are blocking CodeScene Cloud.
A custom CA is not configured correctly.
You are using an outdated MCP Server version.
Still having problems?
Run:
verify_installation and include its output when contacting the CodeScene MCP team via Github Issues.
This will help identify whether the problem is related to authentication, connectivity, or configuration.