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

Method CurrentMCPPrompts

pkg/runtime/runtime.go:1108–1135  ·  view source on GitHub ↗

CurrentMCPPrompts returns the available MCP prompts from all active MCP toolsets for the current agent. It discovers prompts by calling ListPrompts on each MCP toolset and aggregates the results into a map keyed by prompt name.

(ctx context.Context)

Source from the content-addressed store, hash-verified

1106// for the current agent. It discovers prompts by calling ListPrompts on each MCP toolset
1107// and aggregates the results into a map keyed by prompt name.
1108func (r *LocalRuntime) CurrentMCPPrompts(ctx context.Context) map[string]mcptools.PromptInfo {
1109 prompts := make(map[string]mcptools.PromptInfo)
1110
1111 // Get the current agent to access its toolsets
1112 currentAgent := r.CurrentAgent()
1113 if currentAgent == nil {
1114 slog.WarnContext(ctx, "No current agent available for MCP prompt discovery")
1115 return prompts
1116 }
1117
1118 // Iterate through all toolsets of the current agent
1119 for _, toolset := range currentAgent.ToolSets() {
1120 if mcpToolset, ok := tools.As[*mcptools.Toolset](toolset); ok {
1121 slog.DebugContext(ctx, "Found MCP toolset", "toolset", mcpToolset)
1122 // Discover prompts from this MCP toolset
1123 mcpPrompts := r.discoverMCPPrompts(ctx, mcpToolset)
1124
1125 // Merge prompts into the result map
1126 // If there are name conflicts, the later toolset's prompt will override
1127 maps.Copy(prompts, mcpPrompts)
1128 } else {
1129 slog.DebugContext(ctx, "Toolset is not an MCP toolset", "type", fmt.Sprintf("%T", toolset))
1130 }
1131 }
1132
1133 slog.DebugContext(ctx, "Discovered MCP prompts", "agent", currentAgent.Name(), "prompt_count", len(prompts))
1134 return prompts
1135}
1136
1137// discoverMCPPrompts queries an MCP toolset for available prompts and converts them
1138// to PromptInfo structures. This method handles the MCP protocol communication

Callers

nothing calls this directly

Calls 4

CurrentAgentMethod · 0.95
discoverMCPPromptsMethod · 0.95
ToolSetsMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected