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 ¶
- func ApplySkillCreate(agentSkillsDir string, appendSkill func(skill.Skill), logger interface{ ... }, ...) error
- func ApplySkillUpdate(agentSkillsDir string, updateSkill func(string, skill.Skill) bool, ...) error
- func BuildScheduleJob(cfg scheduler.Config, ...) scheduler.JobFunc
- func BuildSchedulePayload(name, schedule, skillName, channel, sessionMode, sessionTier string, ...) (string, error)
- func BuildSkillPayload(name, description, version string, triggers []string, body string) string
- func MergeScheduleUpdate(existing scheduler.Entry, input ScheduleUpdateInput) (scheduler.Config, string)
- type CostSummaryData
- type Deps
- type FallbackRuleInput
- type ScheduleUpdateInput
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplySkillCreate ¶ added in v0.9.0
func ApplySkillCreate(agentSkillsDir string, appendSkill func(skill.Skill), logger interface { Info(string, ...any) }, payload string) error
ApplySkillCreate writes the skill file to disk and appends it to the in-memory skill list.
func ApplySkillUpdate ¶ added in v0.9.0
func ApplySkillUpdate(agentSkillsDir string, updateSkill func(string, skill.Skill) bool, logger interface { Info(string, ...any) }, name string, payload string) error
ApplySkillUpdate writes the updated skill file to disk and replaces it in the in-memory skill list.
func BuildScheduleJob ¶ added in v0.9.0
func BuildScheduleJob(cfg scheduler.Config, handleMsg func(context.Context, adapter.IncomingMessage) error, logger *slog.Logger) scheduler.JobFunc
BuildScheduleJob returns a JobFunc that dispatches a message when the schedule fires. Used by both schedule_add and schedule_update.
func BuildSchedulePayload ¶ added in v0.9.0
func BuildSchedulePayload(name, schedule, skillName, channel, sessionMode, sessionTier string, tags []string, enabled bool) (string, error)
BuildSchedulePayload marshals the schedule config to TOML for storage as approval payload.
func BuildSkillPayload ¶ added in v0.9.0
BuildSkillPayload constructs the canonical +++ frontmatter + body format.
func MergeScheduleUpdate ¶ added in v0.9.0
func MergeScheduleUpdate(existing scheduler.Entry, input ScheduleUpdateInput) (scheduler.Config, string)
MergeScheduleUpdate applies partial updates from input onto an existing entry and returns the merged scheduler.Config plus the channel parts. Returns an error string if validation fails.
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)
// GetSkill returns a single skill by name and true, or zero value and false.
// If nil, skill_get is disabled.
GetSkill func(string) (skill.Skill, bool)
// UpdateSkill replaces an existing skill by name. Returns false if not found.
// If nil, skill_update is disabled.
UpdateSkill func(string, skill.Skill) bool
// 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)
// BrowserProfiles is the shared browser profile service. If nil,
// browser_profile_* tools are disabled.
BrowserProfiles *browser.ProfileService
// GetPersonaSection returns (content, editable, agentMutable, ok) for a
// persona section. If nil, persona_get is disabled.
GetPersonaSection func(section string) (string, bool, bool, bool)
// SavePersonaSection writes content to a persona section. If nil,
// persona_update is disabled.
SavePersonaSection func(section, content string) error
// ConfigPath is the path to the TOML config file. When non-empty,
// schedule mutations are persisted to disk so they survive restarts.
ConfigPath string
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 ScheduleUpdateInput ¶ added in v0.9.0
type ScheduleUpdateInput struct {
Name string `json:"name"`
Schedule *string `json:"schedule"`
Skill *string `json:"skill"`
Channel *string `json:"channel"`
SessionMode *string `json:"session_mode"`
SessionTier *string `json:"session_tier"`
Tags []string `json:"tags"`
Enabled *bool `json:"enabled"`
}
ScheduleUpdateInput holds the parsed arguments for schedule_update. ScheduleUpdateInput holds the parsed arguments for schedule_update. Exported so the REST API can reuse it.
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.