configmcp

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package configmcp provides an in-process MCP server that exposes denkeeper's own configuration as tools callable by the agent. This allows an agent to create skills, list skills, add schedules, and list schedules without relying on text-directive extraction from LLM responses.

The server runs in-process using mcp.NewInMemoryTransports so no subprocess is spawned, approval manager references are shared directly, and latency is negligible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CostSummaryData added in v0.1.0

type CostSummaryData struct {
	GlobalCost    float64            `json:"global_cost"`
	MaxPerSession float64            `json:"max_per_session"`
	SessionCosts  map[string]float64 `json:"session_costs"`
}

CostSummaryData holds the data returned by the get_cost_summary tool.

type Deps

type Deps struct {
	// AgentName is used as the agent label in approval requests.
	AgentName string

	// AgentSkillsDir is the directory where new skill files are written.
	// If empty, skill_create is disabled.
	AgentSkillsDir string

	// GetSkills returns the agent's current in-memory skill list.
	GetSkills func() []skill.Skill

	// AppendSkill adds a skill to the agent's in-memory skill list.
	AppendSkill func(skill.Skill)

	// Sched is the shared scheduler instance. If nil, schedule_add is disabled.
	Sched *scheduler.Scheduler

	// HandleMessage is invoked by scheduled jobs to dispatch a message to the
	// agent. Typically the engine's HandleMessage method. If nil, schedule_add
	// is disabled.
	HandleMessage func(ctx context.Context, msg adapter.IncomingMessage) error

	// Approvals is the shared approval manager. If nil, supervised mutations are
	// executed immediately (same behaviour as autonomous tier).
	Approvals *approval.Manager

	// PermissionTier returns the current effective tier for the agent
	// ("autonomous", "supervised", or "restricted").
	PermissionTier func() string

	// LifecycleMgr is the shared tool/plugin lifecycle manager. If nil,
	// tool_add/tool_remove/plugin_add/plugin_remove are disabled.
	LifecycleMgr *tool.LifecycleManager

	// KVStore is the per-agent key-value store. If nil, kv_* tools are disabled.
	KVStore kv.Store

	// CostSummary returns a snapshot of cost tracking data. If nil,
	// get_cost_summary is disabled.
	CostSummary func() CostSummaryData

	// SetFallbacks replaces the LLM router's fallback rule list. If nil,
	// set_fallback is disabled.
	SetFallbacks func(rules []FallbackRuleInput)

	Logger *slog.Logger
}

Deps holds the runtime dependencies injected into the Config MCP server. All fields are required unless noted.

type FallbackRuleInput added in v0.1.0

type FallbackRuleInput struct {
	Trigger    string  `json:"trigger"`
	Action     string  `json:"action"`
	Provider   string  `json:"provider,omitempty"`
	Model      string  `json:"model,omitempty"`
	Threshold  float64 `json:"threshold,omitempty"`
	MaxRetries int     `json:"max_retries,omitempty"`
	Backoff    string  `json:"backoff,omitempty"`
}

FallbackRuleInput describes a single fallback rule as provided by the agent.

type Server

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

Server is the in-process Config MCP server for a single agent. Construct with New, then call Connect to obtain a *mcp.ClientSession that can be registered into a tool.Manager.

func New

func New(deps Deps) *Server

New constructs and wires the Config MCP server. Tools are registered immediately; the server does not begin serving until Connect is called.

func (*Server) Connect

func (s *Server) Connect(ctx context.Context) (*mcp.ClientSession, error)

Connect starts the in-process server goroutine and returns a *mcp.ClientSession ready to be passed to tool.Manager.RegisterSession. The server runs until ctx is cancelled.

Jump to

Keyboard shortcuts

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