Files
github--github-mcp-server/pkg/context/token.go
Adam Holt aa302209b0 Add Streamable HTTP mode (#1849)
Adds new `http` command supporting Streamable HTTP support, OAuth Metadata handler and Scope filtering.

Co-authored-by: kerobbi <kerobbi@github.com>
Co-authored-by: Matt Holloway <mattdholloway@github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-06 15:33:41 +01:00

33 lines
769 B
Go

package context
import (
"context"
"github.com/github/github-mcp-server/pkg/utils"
)
// tokenCtxKey is a context key for authentication token information
type tokenCtx string
var tokenCtxKey tokenCtx = "tokenctx"
type TokenInfo struct {
Token string
TokenType utils.TokenType
ScopesFetched bool
Scopes []string
}
// WithTokenInfo adds TokenInfo to the context
func WithTokenInfo(ctx context.Context, tokenInfo *TokenInfo) context.Context {
return context.WithValue(ctx, tokenCtxKey, tokenInfo)
}
// GetTokenInfo retrieves the authentication token from the context
func GetTokenInfo(ctx context.Context) (*TokenInfo, bool) {
if tokenInfo, ok := ctx.Value(tokenCtxKey).(*TokenInfo); ok {
return tokenInfo, true
}
return nil, false
}