(r mcp.Role)
| 142 | } |
| 143 | |
| 144 | func 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 |
no outgoing calls
no test coverage detected