knative / knative/func

MCP: consume `func --json` output and forward structured errors via CallToolResult.StructuredContent

Open
#3,770 2 comments 0 reactions 1 assignee View on GitHub

@Ankitsinghsisodya is already working on this.

Since May 17, 2026.

Dominant language
Go
Stars
365
Forks
223
Avg merge
2d 3h
Merged PRs (30d)
25

Description

Summary

Once func supports a --json flag (#3769), the MCP server should invoke func with --json everywhere and forward the structured payload to MCP clients via CallToolResult.StructuredContent — replacing all output parsing / error scraping currently done (or attempted) on the MCP side.

Depends on

  • #3769 — --json output mode on every func subcommand (prerequisite). This issue is implementable only after that lands.

Motivation

The MCP server currently treats func as a text-emitting black box: it captures stdout/stderr and either presents the blob to the agent verbatim or tries to classify it heuristically. Both shapes are dead ends:

  • Verbatim text gives agents no machine-readable handle to dispatch on.
  • Heuristic classification (see #3753) requires substring matching against output the producer can change at any time. Brittle, incomplete, and only deferred the problem.

Once func --json exists, the right MCP wrapper is roughly:

result, err := executor.Run("func", "build", "--json", ...)
// parse result.Stdout as the envelope from #3769
// on success: stick payload in StructuredContent
// on error: stick error object in StructuredContent, set IsError=true

Required changes

  • Invoke func with --json in every MCP tool handler (build, deploy, delete, create, list, describe, invoke, all config_*, healthcheck, etc.). Currently inconsistent — only some handlers attempt any structure at all.
  • Populate CallToolResult.StructuredContent with the parsed JSON, not TextContent. MCP already has a machine-readable channel; use it.
  • Surface the full error taxonomy to agents: READONLY_ERROR, TIMEOUT_ERROR, and any other categories func emits — don't drop them on the floor.
  • Forward the retryable / transient boolean from the structured error. This is the actual dispatch signal agents need ("try again" vs "give up").
  • Keep TextContent populated with a short human-readable summary for fallback / log display, but the canonical channel is StructuredContent.
  • Remove the in-MCP categorization heuristics entirely — func is the source of truth.

Related

  • #3750 — original ask that motivated this. Should be closed-as-superseded once both this issue and #3769 are scoped.
  • #3753 — first attempt, rejected because the categorization belonged in func rather than MCP.

Non-goals

  • Defining the error taxonomy itself — that's #3769's job.
  • Backwards compatibility with the current text-blob shape (the MCP surface is young; we'd rather get the shape right than freeze the current one).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.