mcpserver

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package mcpserver serves Svarog's MCP endpoint as an OAuth protected resource.

Index

Constants

View Source
const (
	Path                 = "/mcp"
	ResourceMetadataPath = "/.well-known/oauth-protected-resource" + Path
)

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(options Options) http.Handler

NewHandler serves MCP over stateless Streamable HTTP, so any replica can answer any request. Every request needs an access token issued for Resource.

func NewResourceMetadataHandler

func NewResourceMetadataHandler(issuer, resource string) http.Handler

NewResourceMetadataHandler serves the RFC 9728 metadata that points MCP clients to the authorization server.

Types

type AccessTokens

type AccessTokens interface {
	VerifyAccessToken(ctx context.Context, token string) (oauth.AccessToken, error)
}
type ArchiveLinks interface {
	Sign(claims archivelink.Claims) string
}

type Archives

type Archives interface {
	List(ctx context.Context, scope archive.Scope, query archive.ListQuery) (archive.Page, error)
	Search(ctx context.Context, scope archive.Scope, query archive.SearchQuery) (archive.SearchResult, error)
	Get(ctx context.Context, scope archive.Scope, archiveID uuid.UUID) (archive.Archive, error)
}

type LogReader

type LogReader interface {
	Page(ctx context.Context, query logstore.PageQuery) (logstore.Page, error)
	Around(ctx context.Context, scope logstore.Scope, id int64, limit int, bounds *logstore.TimeRange) (logstore.Page, bool, error)
	Instances(ctx context.Context, scope logstore.Scope) ([]string, error)
}

type Options

type Options struct {
	// Issuer is the OAuth authorization server and the public base URL of
	// links; Resource is this endpoint's URL.
	Issuer       string
	Resource     string
	Tokens       AccessTokens
	Users        Users
	Projects     Projects
	Logs         LogReader
	Archives     Archives
	ArchiveLinks ArchiveLinks
}

type Projects

type Projects interface {
	All(ctx context.Context) ([]projects.Project, error)
	ByIDs(ctx context.Context, ids []string) ([]projects.Project, error)
	ClientsForProjects(ctx context.Context, projectIDs []uuid.UUID) ([]projects.ProjectClient, error)
	ClientBelongsToProject(ctx context.Context, projectID, clientID string) (bool, error)
}

type Users

type Users interface {
	GetUserByID(ctx context.Context, id string) (svarogauth.User, error)
	UserHasAccessToProject(ctx context.Context, userID, projectID string) (bool, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL