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
- func CallDigest(operation string, parts ...string) string
- type Agent
- type Approval
- type ApprovalState
- type Store
- func (s *Store) Approvals() ([]Approval, error)
- func (s *Store) Authenticate(token string) (Agent, bool)
- func (s *Store) Consume(agentID, operation, callDigest string) (bool, error)
- func (s *Store) Decide(id string, approve bool) (Approval, error)
- func (s *Store) HasActive() bool
- func (s *Store) List() ([]Agent, error)
- func (s *Store) Mint(name string) (Agent, string, error)
- func (s *Store) Pending(id string) (Approval, Agent, error)
- func (s *Store) Request(agentID, operation, callDigest, summary string) (Approval, error)
- func (s *Store) Revoke(id string) error
- func (s *Store) Rotate(id string) (Agent, string, error)
Constants ¶
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 )
const StateFile = ".stackkit/mcp/agents.json"
StateFile is the workspace-relative location of the store.
Variables ¶
This section is empty.
Functions ¶
func CallDigest ¶
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.
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 (*Store) Authenticate ¶
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 ¶
Consume spends a granted approval for exactly this agent, operation and call digest. An approval authorizes one call and is never reusable.
func (*Store) Pending ¶ added in v0.54.8
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 ¶
Request records a pending approval for one exact call, or returns the existing pending one, so a retried call does not multiply requests.