Help us shape the future of Go! Take the 2026 Go Developer Survey

mcpagents

package
v0.55.8 Latest Latest
Warning

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

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

Documentation

Overview

Package mcpagents holds the per-agent StackKits MCP credentials and the per-call owner approvals of one installation. The server stores only a SHA-256 digest of each credential, so the file can be read without disclosing a usable token, and every request re-reads it so a revocation or approval takes effect immediately and from a separate owner CLI process.

Index

Constants

View Source
const (

	// ApprovalTTL bounds how long a pending or granted approval stays usable.
	ApprovalTTL = 15 * time.Minute
	// MaxPendingPerAgent caps unanswered requests so an agent cannot flood the owner.
	MaxPendingPerAgent = 20
)
View Source
const StateFile = ".stackkit/mcp/agents.json"

StateFile is the workspace-relative location of the store.

Variables

This section is empty.

Functions

func CallDigest

func CallDigest(operation string, parts ...string) string

CallDigest binds an approval to the exact operation, workspace and arguments, so a granted approval cannot be reused for a different call.

Types

type Agent

type Agent struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	CreatedAt time.Time  `json:"createdAt"`
	RotatedAt *time.Time `json:"rotatedAt,omitempty"`
	RevokedAt *time.Time `json:"revokedAt,omitempty"`
}

Agent is the public record of one credential; it never carries the token.

func (Agent) Active

func (a Agent) Active() bool

Active reports whether the credential can still authenticate.

type Approval

type Approval struct {
	ID        string        `json:"id"`
	AgentID   string        `json:"agentId"`
	Operation string        `json:"operation"`
	Digest    string        `json:"digest"`
	Summary   string        `json:"summary,omitempty"`
	State     ApprovalState `json:"state"`
	CreatedAt time.Time     `json:"createdAt"`
	ExpiresAt time.Time     `json:"expiresAt"`
}

Approval binds one owner decision to one exact call of one agent.

type ApprovalState

type ApprovalState string

ApprovalState is the owner's answer to one requested mutation.

const (
	ApprovalPending  ApprovalState = "pending"
	ApprovalApproved ApprovalState = "approved"
	ApprovalDenied   ApprovalState = "denied"
	ApprovalUsed     ApprovalState = "used"
)

type Store

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

Store is the on-disk credential and approval state of one workspace.

func Open

func Open(workspace string) *Store

Open returns the store of a workspace; the file is created on first write.

func (*Store) Approvals

func (s *Store) Approvals() ([]Approval, error)

Approvals lists unexpired approvals, newest first.

func (*Store) Authenticate

func (s *Store) Authenticate(token string) (Agent, bool)

Authenticate resolves a presented token to its active agent. Every stored digest is compared in constant time, so timing reveals neither which credential matched nor how many exist.

func (*Store) Consume

func (s *Store) Consume(agentID, operation, callDigest string) (bool, error)

Consume spends a granted approval for exactly this agent, operation and call digest. An approval authorizes one call and is never reusable.

func (*Store) Decide

func (s *Store) Decide(id string, approve bool) (Approval, error)

Decide records the owner's answer to a pending request.

func (*Store) HasActive

func (s *Store) HasActive() bool

HasActive reports whether any credential can still authenticate.

func (*Store) List

func (s *Store) List() ([]Agent, error)

List returns every credential, newest first, without token material.

func (*Store) Mint

func (s *Store) Mint(name string) (Agent, string, error)

Mint creates an agent credential. The token is returned exactly once.

func (*Store) Pending added in v0.54.8

func (s *Store) Pending(id string) (Approval, Agent, error)

Pending returns one unexpired pending request with the agent that made it, so an owner surface can show what exactly it is asked to approve.

func (*Store) Request

func (s *Store) Request(agentID, operation, callDigest, summary string) (Approval, error)

Request records a pending approval for one exact call, or returns the existing pending one, so a retried call does not multiply requests.

func (*Store) Revoke

func (s *Store) Revoke(id string) error

Revoke ends a credential and discards its unused approvals.

func (*Store) Rotate

func (s *Store) Rotate(id string) (Agent, string, error)

Rotate replaces an active credential's token; the old token stops working at once.

Jump to

Keyboard shortcuts

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