Enhancement: Support Remote Auth for Docker Containers
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.2k
- Forks
- 300
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 184
Description
Enhancement: Support Remote Auth (--remote-auth-*) for Docker Containers
Summary
Enable --remote-auth-* flags to work with containerized MCP servers, allowing ToolHive to acquire OAuth/OIDC tokens and inject them into requests to Docker containers, not just remote URLs.
Current Behavior
The --remote-auth-* flags currently only work when connecting to remote MCP servers via HTTP/HTTPS URLs. When running containerized MCP servers locally, remote authentication is disabled by design.
Current limitation in pkg/transport/http.go:314:
// Add OAuth token injection middleware for remote authentication if we have a token source
if t.remoteURL != "" && t.tokenSource != nil {
tokenMiddleware := t.createTokenInjectionMiddleware()
middlewares = append(middlewares, types.NamedMiddleware{
Name: "oauth-token-injection",
Function: tokenMiddleware,
})
}
The check t.remoteURL != "" prevents token injection for containers since remoteURL is only set for remote URLs, not container images.
Desired Behavior
Allow users to acquire OAuth/OIDC tokens via the --remote-auth-* flags and have ToolHive inject those tokens into HTTP requests to containerized MCP servers running with HTTP/SSE transport.
Example command:
thv run ghcr.io/example/github-mcp-server \
--transport sse \
--remote-auth-issuer https://github.com/login/oauth \
--remote-auth-client-id <client-id> \
--remote-auth-scopes "repo,user"
Expected flow:
- ToolHive initiates OAuth flow with GitHub
- User authenticates in browser
- ToolHive acquires access token
- Container starts with HTTP/SSE transport
- ToolHive injects
Authorization: Bearer <token>into all requests to the container - Container can use the token to make authenticated GitHub API calls
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pkg/transport/http.go:314 and trace how remoteURL and tokenSource control OAuth token injection for HTTP/SSE transports. Verify the container startup and transport path, then ensure the acquired Bearer token is injected into requests made to containerized MCP servers when the remote-auth flags are used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- authentication, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100