stacklok / stacklok/toolhive

Recover remote auth after vMCP session expires

Open
#6,556 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Summary

A thv run connection to a vMCP gateway authenticated with --remote-auth becomes unauthenticated after approximately one hour. The runner logs a 401 and marks the remote server unauthenticated. thv restart does not initiate or recover authentication; it immediately receives another 401. Removing the server and running it again is currently required to restore the connection.

The gateway URL has been intentionally redacted for privacy.

Reproduction

  1. Run a vMCP gateway using remote authentication:
    thv run <redacted-vmcp-gateway-url> --remote-auth --name stacklok-vmcp --remote-auth-scopes openid,profile,email,offline_access
    
  2. Keep the connection active for about one hour.
  3. Observe the server transition to unauthenticated after a 401 response.
  4. Run thv restart stacklok-vmcp.

Actual behavior

The client logs:

{"time":"2026-09-08T17:41:06-04:00","level":"WARN","msg":"received 401 Unauthorized response for remote server, marking as unauthenticated","server":"stacklok-vmcp"}

Restarting immediately encounters another 401 and does not recover the session.

Expected behavior

With the offline_access scope, ToolHive should refresh or otherwise re-establish remote authentication when the access token or session expires. A restart should recover an expired authentication session or provide an actionable re-authentication flow without requiring removal and recreation of the server.

Impact

Long-running vMCP gateway connections require manual removal and re-creation after token or session expiry.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the authentication flow used by thv run and thv restart for remote servers, focusing on the 401 transition described in the reproduction. Verify how the offline_access scope is handled when the session expires. Done means restart refreshes or re-establishes authentication, or presents an actionable re-authentication flow without removing and recreating the server.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.