MCPcopy
hub / github.com/googleapis/mcp-toolbox / GetCompatibleSource

Function GetCompatibleSource

internal/tools/tools.go:170–181  ·  view source on GitHub ↗
(resourceMgr SourceProvider, sourceName, toolName, toolType string)

Source from the content-addressed store, hash-verified

168}
169
170func GetCompatibleSource[T any](resourceMgr SourceProvider, sourceName, toolName, toolType string) (T, error) {
171 var zero T
172 s, ok := resourceMgr.GetSource(sourceName)
173 if !ok {
174 return zero, fmt.Errorf("unable to retrieve source %q for tool %q", sourceName, toolName)
175 }
176 source, ok := s.(T)
177 if !ok {
178 return zero, fmt.Errorf("invalid source for %q tool: source %q is not a compatible type", toolType, sourceName)
179 }
180 return source, nil
181}
182
183// GetCompatibleSourceFromMap looks up a source by name from a sources map and
184// asserts it to the requested type. It mirrors GetCompatibleSource for callers

Callers

nothing calls this directly

Calls 1

GetSourceMethod · 0.65

Tested by

no test coverage detected