discoverMCPPrompts queries an MCP toolset for available prompts and converts them to PromptInfo structures. This method handles the MCP protocol communication and gracefully handles any errors during prompt discovery.
(ctx context.Context, toolset *mcptools.Toolset)
| 1138 | // to PromptInfo structures. This method handles the MCP protocol communication |
| 1139 | // and gracefully handles any errors during prompt discovery. |
| 1140 | func (r *LocalRuntime) discoverMCPPrompts(ctx context.Context, toolset *mcptools.Toolset) map[string]mcptools.PromptInfo { |
| 1141 | mcpPrompts, err := toolset.ListPrompts(ctx) |
| 1142 | if err != nil { |
| 1143 | slog.WarnContext(ctx, "Failed to list MCP prompts from toolset", "error", err) |
| 1144 | return nil |
| 1145 | } |
| 1146 | |
| 1147 | prompts := make(map[string]mcptools.PromptInfo, len(mcpPrompts)) |
| 1148 | for _, mcpPrompt := range mcpPrompts { |
| 1149 | promptInfo := mcptools.PromptInfo{ |
| 1150 | Name: mcpPrompt.Name, |
| 1151 | Description: mcpPrompt.Description, |
| 1152 | Arguments: make([]mcptools.PromptArgument, 0, len(mcpPrompt.Arguments)), |
| 1153 | } |
| 1154 | |
| 1155 | for _, arg := range mcpPrompt.Arguments { |
| 1156 | promptInfo.Arguments = append(promptInfo.Arguments, mcptools.PromptArgument{ |
| 1157 | Name: arg.Name, |
| 1158 | Description: arg.Description, |
| 1159 | Required: arg.Required, |
| 1160 | }) |
| 1161 | } |
| 1162 | |
| 1163 | prompts[mcpPrompt.Name] = promptInfo |
| 1164 | slog.DebugContext(ctx, "Discovered MCP prompt", "name", mcpPrompt.Name, "args_count", len(promptInfo.Arguments)) |
| 1165 | } |
| 1166 | |
| 1167 | return prompts |
| 1168 | } |
| 1169 | |
| 1170 | // CurrentAgent returns the current agent |
| 1171 | func (r *LocalRuntime) CurrentAgent() *agent.Agent { |
no test coverage detected