Documentation
¶
Overview ¶
Package mcptools builds the MCP tool server every levelrail-mcp transport (stdio, network, and the in-process transport an embedded caller like internal/ai uses) shares: one *mcp.Server with every tool registered against the same apiclient.Client. Pulled out of cmd/levelrail-mcp (which cannot be imported, being package main) so a non-CLI caller can build the identical tool server without spawning a subprocess.
Index ¶
- Constants
- func AgentCoreTools() []string
- func Groups() []string
- func NewServer(client *apiclient.Client) *mcp.Server
- func ParseToolProfile(s string) (string, error)
- func ParseToolsets(s string) ([]string, error)
- func PlannableTools() []string
- type AppEnvView
- type Class
- type EnvChangeResult
- type Meta
- type Mode
- type Options
- type PlanChange
- type PlanResult
- type Summary
Constants ¶
const ( // MetaSensitiveKey is the tool _meta key set on sensitive tools. MetaSensitiveKey = "levelrail/sensitive" // MetaUntrustedKey is the tool _meta key set on tools whose result carries untrusted text. MetaUntrustedKey = "levelrail/untrusted-output" )
const ( // ModeReadOnly registers read tools only. ModeReadOnly Mode = "read-only" // ModeStandard registers read and mutating tools, not destructive ones. ModeStandard Mode = "standard" // ModeFull registers every tool. ModeFull Mode = "full" // EnvMode names the env var that selects the Mode. EnvMode = "APP_MCP_MODE" // EnvToolsets names the env var that selects the toolsets. EnvToolsets = "APP_MCP_TOOLSETS" // EnvAllowWrite names the env var that exposes the confirm-gated write tools. EnvAllowWrite = "APP_MCP_ALLOW_WRITE" // EnvOutputSchemas names the env var that keeps outputSchema in tools/list // for levelrail-mcp, which omits it by default. EnvOutputSchemas = "APP_MCP_OUTPUT_SCHEMAS" // EnvToolProfile names the env var that selects the tool profile. EnvToolProfile = "APP_MCP_TOOL_PROFILE" // ProfileAgentCore is a small allowlist of the tools an agent needs to // ship and debug an app. ProfileAgentCore = "agent-core" )
const ( EnvWaitWindow = "APP_MCP_WAIT_WINDOW_SECONDS" EnvWaitInterval = "APP_MCP_WAIT_POLL_SECONDS" )
Env vars bounding one wait_for_deploy call, in seconds.
const EnvResourceMaxBytes = "APP_MCP_RESOURCE_MAX_BYTES"
EnvResourceMaxBytes names the env var capping a docs resource's size.
Variables ¶
This section is empty.
Functions ¶
func AgentCoreTools ¶
func AgentCoreTools() []string
AgentCoreTools returns the sorted agent-core allowlist.
func NewServer ¶
NewServer builds the MCP server and registers every tool against client. Callers can connect to it directly over an in-memory transport (mcp.NewInMemoryTransports), without spawning a real process or touching stdio.
func ParseToolProfile ¶
ParseToolProfile validates a tool profile name; empty means no profile.
func ParseToolsets ¶
ParseToolsets parses a comma separated toolset list; empty means all.
func PlannableTools ¶
func PlannableTools() []string
PlannableTools returns the sorted names of mutating tools plan_change can plan.
Types ¶
type AppEnvView ¶
type AppEnvView struct {
Name string `json:"name"`
Env map[string]string `json:"env"`
SensitiveKeys []string `json:"sensitive_keys"`
SecretKeys []string `json:"secret_keys"`
}
AppEnvView is an app's visible plain env vars, plus the names, never values, of its secrets and of its sensitive plain vars.
type Class ¶
type Class int
Class is a tool's blast radius, the single source for its MCP annotations, the server modes, and the assistant's confirmation gate.
type EnvChangeResult ¶
type EnvChangeResult struct {
Name string `json:"name"`
Key string `json:"key"`
Secret bool `json:"secret"`
RedeployNeeded bool `json:"redeploy_needed"`
Hint string `json:"hint"`
}
EnvChangeResult reports which key changed, never any value.
type Meta ¶
Meta is one tool's classification.
func (Meta) Sensitive ¶
Sensitive reports whether the tool touches credentials, secrets or command output.
func (Meta) Untrusted ¶
Untrusted reports whether the tool's result carries attacker-influenced text.
func (Meta) WriteGated ¶
WriteGated reports whether the tool is hidden unless the server runs with AllowWrite.
type Mode ¶
type Mode string
Mode bounds which tool classes a server registers. The API token's own abilities still apply on top: a mode only shrinks what the model sees.
type Options ¶
type Options struct {
Mode Mode
Toolsets []string
// Profile, when set, replaces the mode's class filter with an allowlist.
// Read-only mode still hides every non-read tool.
Profile string
// AllowWrite exposes the confirm-gated write tools. Off by default.
AllowWrite bool
// OmitOutputSchemas drops outputSchema from tools/list. Results still
// carry structured content; only the schema advertisement is left out.
OmitOutputSchemas bool
}
Options selects the tools a server exposes.
type PlanChange ¶
type PlanChange struct {
Field string `json:"field"`
Before string `json:"before"`
After string `json:"after"`
}
PlanChange is one field a planned call would change. Values for secrets and env are never included, only whether they are set.
type PlanResult ¶
type PlanResult struct {
Tool string `json:"tool"`
DryRun bool `json:"dry_run"`
Executed bool `json:"executed"`
Plannable bool `json:"plannable"`
Summary string `json:"summary"`
Changes []PlanChange `json:"changes,omitempty"`
// Blocked is true when a freeze window or a required approval would stop
// the call from taking effect now.
Blocked bool `json:"blocked"`
Blockers []string `json:"blockers,omitempty"`
Note string `json:"note,omitempty"`
// Detail carries a richer plan when one already exists (a resource plan,
// a promotion preview).
Detail map[string]any `json:"detail,omitempty"`
}
PlanResult is what plan_change returns: what a mutating tool call would do, computed from reads only. Executed is always false.
Source Files
¶
- ai_control.go
- classes.go
- modes.go
- profile_compact.go
- prompts.go
- prompts_defs.go
- resources.go
- server.go
- tools_alert_noise.go
- tools_alerts.go
- tools_app_config.go
- tools_app_import.go
- tools_app_schedule.go
- tools_app_timeline.go
- tools_apps.go
- tools_apps_bulk.go
- tools_attention.go
- tools_audit.go
- tools_backup_targets.go
- tools_backups.go
- tools_build_cache.go
- tools_certificates.go
- tools_cloudflare.go
- tools_control_plane_backups.go
- tools_control_plane_dr.go
- tools_database_access.go
- tools_databases.go
- tools_deploy_approvals.go
- tools_deploy_cancel.go
- tools_deploy_compare.go
- tools_deploy_freeze.go
- tools_deployments.go
- tools_diagnose.go
- tools_domains.go
- tools_env.go
- tools_env_get.go
- tools_environments.go
- tools_expansion_read.go
- tools_expansion_write.go
- tools_failed_deploys.go
- tools_flags.go
- tools_global_environments.go
- tools_iac.go
- tools_iam.go
- tools_import.go
- tools_loadbalancer.go
- tools_log_archive.go
- tools_log_drains.go
- tools_log_signatures.go
- tools_metrics.go
- tools_migration_hub.go
- tools_models.go
- tools_models_fit.go
- tools_models_serving.go
- tools_nodes.go
- tools_notifications.go
- tools_orgs.go
- tools_pipelines.go
- tools_pipelines_overview.go
- tools_plan.go
- tools_plan_bulk.go
- tools_previews.go
- tools_promote.go
- tools_query_logs.go
- tools_registry.go
- tools_releases.go
- tools_requests.go
- tools_resource_advice.go
- tools_resource_recommendation.go
- tools_roles.go
- tools_scheduled_tasks.go
- tools_settings.go
- tools_system.go
- tools_templates.go
- tools_usage_report.go
- tools_volume_backups.go
- tools_wait_deploy.go
- tools_webhooks.go
- untrusted_output.go