Problem
Currently, MCP handlers return most CLI failures as raw strings:
fmt.Errorf("%w\n%s", err, string(out))
This works for humans, but it is difficult for agents to reliably reason about failures. Parsing CLI output is fragile and dependent on message formatting.
For example, an agent should be able to distinguish between:
- build failures
- registry authentication issues
- Kubernetes connectivity problems
- read-only mode violations
without relying on string matching.
Proposed Solution
Introduce structured error categories in MCP responses.
Proposed Model
type McpErrorResponse struct {
Category string `json:"category"`
Code int `json:"code"`
Message string `json:"message"`
}
Suggested Categories
VALIDATION_ERROR
BUILD_ERROR
REGISTRY_ERROR
CLUSTER_ERROR
READONLY_ERROR
TIMEOUT_ERROR
Why This Helps
Structured errors would allow agents to make better decisions programmatically.
Example:
if error.category == "REGISTRY_ERROR":
suggest("Run 'func config registry'")
instead of parsing raw CLI output.
Possible Implementation Area
The handlers can map known failure cases into stable categories while still preserving existing human-readable messages.
Strategic Alignment
This aligns well with the "agent-native toolchain" direction and would improve:
- autonomous workflows
- guided remediation
- IDE integrations
- conversational debugging
Problem
Currently, MCP handlers return most CLI failures as raw strings:
This works for humans, but it is difficult for agents to reliably reason about failures. Parsing CLI output is fragile and dependent on message formatting.
For example, an agent should be able to distinguish between:
without relying on string matching.
Proposed Solution
Introduce structured error categories in MCP responses.
Proposed Model
Suggested Categories
VALIDATION_ERRORBUILD_ERRORREGISTRY_ERRORCLUSTER_ERRORREADONLY_ERRORTIMEOUT_ERRORWhy This Helps
Structured errors would allow agents to make better decisions programmatically.
Example:
instead of parsing raw CLI output.
Possible Implementation Area
The handlers can map known failure cases into stable categories while still preserving existing human-readable messages.
Strategic Alignment
This aligns well with the "agent-native toolchain" direction and would improve: