MCPcopy Index your code
hub / github.com/docker/docker-agent / samplingRoleToChat

Function samplingRoleToChat

pkg/runtime/sampling.go:144–157  ·  view source on GitHub ↗
(r mcp.Role)

Source from the content-addressed store, hash-verified

142}
143
144func samplingRoleToChat(r mcp.Role) (chat.MessageRole, error) {
145 switch string(r) {
146 case "user":
147 return chat.MessageRoleUser, nil
148 case "assistant":
149 return chat.MessageRoleAssistant, nil
150 case "":
151 // Some servers omit the role for the lone user turn; default to user
152 // rather than refuse the request, matching most other MCP hosts.
153 return chat.MessageRoleUser, nil
154 default:
155 return "", fmt.Errorf("unsupported sampling role %q", r)
156 }
157}
158
159// samplingContentToChat maps a single MCP content block to the host's
160// chat representation. Text blocks return a Content string; image blocks

Callers 1

samplingMessagesToChatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected