Skip to content

fix(deps): bump cogito to fix MCP image-content panic (#10101)#10105

Open
Dennisadira wants to merge 1 commit into
mudler:masterfrom
Dennisadira:fix/mcp-image-content-panic
Open

fix(deps): bump cogito to fix MCP image-content panic (#10101)#10105
Dennisadira wants to merge 1 commit into
mudler:masterfrom
Dennisadira:fix/mcp-image-content-panic

Conversation

@Dennisadira
Copy link
Copy Markdown
Contributor

Summary

Fixes #10101 — the API container crashes with a Go panic whenever an MCP tool returns non-text content (images, audio, resources):

panic: interface conversion: mcp.Content is *mcp.ImageContent, not *mcp.TextContent
github.com/mudler/cogito@v0.9.5.../mcp.go:52

The panic happens on an agent goroutine with no recover, which takes the whole process down.

Root cause: mcpTool.Execute in cogito unconditionally asserted every mcp.Content item to *mcp.TextContent. Any tool returning image/audio/resource content (e.g. the get_map_image tool in osmmcp, NASA MCP image tools) triggers the panic.

Fix: mudler/cogito#50 replaces the hard assertion with a type switch. Non-text blocks are summarised with descriptive markers ([image content (image/png), N bytes] etc.) so the model receives something useful instead of crashing.

This PR bumps github.com/mudler/cogito from v0.9.5-0.20260315222927-63abdec7189b to v0.9.5-0.20260531081147-2c13b6ac29cf (the tip of the fix/mcp-image-content-panic branch in cogito, which is the revision from mudler/cogito#50).

Test plan

  • go build github.com/mudler/cogito clean on the new pseudo-version
  • go mod tidy produces a clean go.sum
  • Manual: add an MCP server that returns image content (e.g. osmmcp) to an agent and confirm the agent returns a result instead of crashing

🤖 Generated with Claude Code

@mudler
Copy link
Copy Markdown
Owner

mudler commented May 31, 2026

@Dennisadira please rebase, lots of code which is not part of this PR shows up

@Dennisadira Dennisadira force-pushed the fix/mcp-image-content-panic branch from 9cf3bd1 to a65eb0b Compare June 3, 2026 03:52
@Dennisadira
Copy link
Copy Markdown
Contributor Author

Rebased onto current master — the branch now has a single commit touching only go.mod and go.sum.

Bumps github.com/mudler/cogito from
  v0.9.5-0.20260315222927-63abdec7189b
to
  v0.9.5-0.20260531081147-2c13b6ac29cf

The new revision contains mudler/cogito#50 which replaces the hard
*mcp.TextContent type assertion in mcpTool.Execute with a type switch.
Any MCP tool that returns image, audio, resource-link, or
embedded-resource content previously caused:

  panic: interface conversion: mcp.Content is *mcp.ImageContent, not *mcp.TextContent

bringing down the entire host process.  The new code summarises
non-text blocks with a descriptive marker so the model receives
something useful without crashing.

Closes mudler#10101

Assisted-by: Claude Sonnet 4.6 [claude-code]
Signed-off-by: Adira Denis Muhando <dennisadira@gmail.com>
@Dennisadira Dennisadira force-pushed the fix/mcp-image-content-panic branch from a65eb0b to 615d649 Compare June 3, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

api crashes when an mcp returns an image

2 participants