k8sstore

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIGroup            = mcpv1alpha1.Group
	APIVersion          = mcpv1alpha1.Version
	AccessGrantResource = mcpv1alpha1.MCPAccessGrantResource
	MCPServerResource   = mcpv1alpha1.MCPServerResource
)

Variables

This section is empty.

Functions

func ToGrantSummary

func ToGrantSummary(grant MCPAccessGrant) access.GrantSummary

ToGrantSummary converts an MCPAccessGrant to a GrantSummary.

func ToSessionSummary

func ToSessionSummary(session MCPAgentSession) access.SessionSummary

ToSessionSummary converts an MCPAgentSession to a SessionSummary.

Types

type MCPAccessGrant

type MCPAccessGrant struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   access.MCPAccessGrantSpec   `json:"spec,omitempty"`
	Status access.MCPAccessGrantStatus `json:"status,omitempty"`
}

MCPAccessGrant grants a human or agent access to an MCPServer.

type MCPAccessGrantList

type MCPAccessGrantList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []MCPAccessGrant `json:"items"`
}

MCPAccessGrantList contains a list of MCPAccessGrant.

type MCPAgentSession

type MCPAgentSession struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   access.MCPAgentSessionSpec   `json:"spec,omitempty"`
	Status access.MCPAgentSessionStatus `json:"status,omitempty"`
}

MCPAgentSession is a platform session management envelope, not a Kubernetes resource.

type MCPAgentSessionList

type MCPAgentSessionList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []MCPAgentSession `json:"items"`
}

MCPAgentSessionList contains a list of MCPAgentSession.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages Kubernetes grants and delegates sessions to the platform backend.

func NewManager

func NewManager(dynamic dynamic.Interface, clientset kubernetes.Interface) *Manager

NewManager creates a new access resource manager.

func (*Manager) ApplyGrant

func (m *Manager) ApplyGrant(ctx context.Context, grant *MCPAccessGrant) (*MCPAccessGrant, error)

ApplyGrant creates or updates an MCPAccessGrant resource.

func (*Manager) ApplySession

func (m *Manager) ApplySession(ctx context.Context, session *MCPAgentSession) (*MCPAgentSession, error)

ApplySession uses the authoritative platform session backend.

func (*Manager) AssertMCPServerRef

func (m *Manager) AssertMCPServerRef(ctx context.Context, ref access.ServerReference) error

AssertMCPServerRef checks that a server exists and accepts new authorization. Use this before creating grants or sessions so the API can reject unknown targets early.

func (*Manager) CompleteSessionEnrollment

func (m *Manager) CompleteSessionEnrollment(ctx context.Context, name, namespace, uid string) error

CompleteSessionEnrollment conditionally completes enrollment in the platform store.

func (*Manager) DeleteGrant

func (m *Manager) DeleteGrant(ctx context.Context, name, namespace string) error

DeleteGrant removes an MCPAccessGrant.

func (*Manager) DeletePendingSession

func (m *Manager) DeletePendingSession(ctx context.Context, name, namespace, uid, humanID string) error

DeletePendingSession conditionally removes the caller's pending enrollment.

func (*Manager) DeleteSession

func (m *Manager) DeleteSession(ctx context.Context, name, namespace string) error

DeleteSession uses the authoritative platform session backend.

func (*Manager) DisableGrant

func (m *Manager) DisableGrant(ctx context.Context, name, namespace string) error

DisableGrant disables an MCPAccessGrant by setting spec.disabled to true.

func (*Manager) EnableGrant

func (m *Manager) EnableGrant(ctx context.Context, name, namespace string) error

EnableGrant enables an MCPAccessGrant by setting spec.disabled to false.

func (*Manager) GetActiveMCPServerRef

func (m *Manager) GetActiveMCPServerRef(ctx context.Context, ref access.ServerReference) (*mcpv1alpha1.MCPServer, error)

GetActiveMCPServerRef resolves an authorization target for issuance. Ordinary lookups retain retiring servers so management can still check ownership and clean up access after a failed retirement.

func (*Manager) GetGrant

func (m *Manager) GetGrant(ctx context.Context, name, namespace string) (*MCPAccessGrant, error)

GetGrant returns a specific MCPAccessGrant resource.

func (*Manager) GetMCPServerRef

func (m *Manager) GetMCPServerRef(ctx context.Context, ref access.ServerReference) (*mcpv1alpha1.MCPServer, error)

GetMCPServerRef returns the MCPServer referenced by ref.

func (*Manager) GetServerPolicy

func (m *Manager) GetServerPolicy(ctx context.Context, namespace, serverName string) (map[string]interface{}, error)

GetServerPolicy returns the rendered policy for a specific server if available.

func (*Manager) GetSession

func (m *Manager) GetSession(ctx context.Context, name, namespace string) (*MCPAgentSession, error)

GetSession uses the authoritative platform session backend.

func (*Manager) ListGrantSessions

func (m *Manager) ListGrantSessions(ctx context.Context, namespace, name string) (*MCPAgentSessionList, error)

func (*Manager) ListGrants

func (m *Manager) ListGrants(ctx context.Context, namespace string) (*MCPAccessGrantList, error)

ListGrants returns all MCPAccessGrant resources, optionally filtered by namespace.

func (*Manager) ListMCPServers

func (m *Manager) ListMCPServers(ctx context.Context, namespace string) (*mcpv1alpha1.MCPServerList, error)

ListMCPServers returns all MCPServer resources, optionally filtered by namespace.

func (*Manager) ListSessions

func (m *Manager) ListSessions(ctx context.Context, namespace string) (*MCPAgentSessionList, error)

ListSessions uses the authoritative platform session backend.

func (*Manager) RetireServerAccess

func (m *Manager) RetireServerAccess(ctx context.Context, namespace, name string) error

RetireServerAccess invalidates and removes all authorization referencing the exact server identity, including resources held in other namespaces. It does not remove agents or audit history. A failure is safe to retry: all records are invalidated before any record is removed, and missing records are tolerated.

func (*Manager) RevokeGrantSessions

func (m *Manager) RevokeGrantSessions(ctx context.Context, namespace, name string) (int64, error)

RevokeGrantSessions atomically revokes linked sessions in the platform store.

func (*Manager) RevokeSession

func (m *Manager) RevokeSession(ctx context.Context, name, namespace string) error

RevokeSession uses the authoritative platform session backend.

func (*Manager) SetGrantMode

func (m *Manager) SetGrantMode(ctx context.Context, name, namespace string, mode access.GrantMode) error

SetGrantMode updates only enforcement mode, preserving the grant restrictions.

func (*Manager) UnrevokeSession

func (m *Manager) UnrevokeSession(ctx context.Context, name, namespace string) error

UnrevokeSession uses the authoritative platform session backend.

func (*Manager) WithSessionBackend

func (m *Manager) WithSessionBackend(backend SessionBackend) *Manager

WithSessionBackend selects the authoritative session store at construction. A configured backend error never falls back to Kubernetes session state.

type SessionBackend

type SessionBackend interface {
	ListSessions(context.Context, string) (*MCPAgentSessionList, error)
	GetSession(context.Context, string, string) (*MCPAgentSession, error)
	ApplySession(context.Context, *MCPAgentSession) (*MCPAgentSession, error)
	RevokeSession(context.Context, string, string) error
	UnrevokeSession(context.Context, string, string) error
	DeleteSession(context.Context, string, string) error
}

SessionBackend owns runtime session persistence. Grants remain Kubernetes resources; platform-managed sessions use the platform API instead of CRDs.

Jump to

Keyboard shortcuts

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