mcpresult

package
v0.4.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTextContent

func ExtractTextContent(result map[string]interface{}) string

ExtractTextContent returns the concatenated text from text content items in a raw MCP tool result map. Content items with a missing "type" are treated as text items for compatibility with older callers and tests.

func IsErrorResult added in v0.4.6

func IsErrorResult(result map[string]interface{}) bool

IsErrorResult reports whether a raw MCP tool result map is marked as an error result.

func NormalizeContentItems added in v0.3.26

func NormalizeContentItems(contentVal interface{}) ([]map[string]interface{}, bool)

NormalizeContentItems normalizes an MCP "content" field into a slice of item maps. It supports both []interface{} values produced by json.Unmarshal and []map[string]interface{} values produced by helper constructors.

Semantics: lenient — non-map items in []interface{} are silently skipped. This contrasts with the strict path in internal/mcp/tool_result.go (convertMapToCallToolResult) which returns an error for non-map content items. Use this function in contexts where partial results are acceptable (e.g. DIFC filtering, rate-limit detection); use the strict path when producing SDK-valid CallToolResult values where malformed items must surface as errors.

Both normalization paths handle the same wire format variations:

  • []interface{} — produced by json.Unmarshal on the raw backend response
  • []map[string]interface{} — produced by helper constructors (e.g. BuildMCPTextResponse)

When adding new content type variants, update both paths consistently.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL