diff --git a/internal/server/api.go b/internal/server/api.go index 22068e3015..5f701baa55 100644 --- a/internal/server/api.go +++ b/internal/server/api.go @@ -172,7 +172,7 @@ func toolInvokeHandler(s *Server, w http.ResponseWriter, r *http.Request) { accessToken := tools.AccessToken(r.Header.Get("Authorization")) // Check if this specific tool requires the standard authorization header - if tool.RequiresClientAuthorization() { + if tool.RequiresClientAuthorization(s.ResourceMgr) { if accessToken == "" { err = fmt.Errorf("tool requires client authorization but access token is missing from the request header") s.logger.DebugContext(ctx, err.Error()) @@ -239,7 +239,7 @@ func toolInvokeHandler(s *Server, w http.ResponseWriter, r *http.Request) { } s.logger.DebugContext(ctx, fmt.Sprintf("invocation params: %s", params)) - res, err := tool.Invoke(ctx, params, accessToken) + res, err := tool.Invoke(ctx, s.ResourceMgr, params, accessToken) // Determine what error to return to the users. if err != nil { @@ -255,7 +255,7 @@ func toolInvokeHandler(s *Server, w http.ResponseWriter, r *http.Request) { } if statusCode == http.StatusUnauthorized || statusCode == http.StatusForbidden { - if tool.RequiresClientAuthorization() { + if tool.RequiresClientAuthorization(s.ResourceMgr) { // Propagate the original 401/403 error. s.logger.DebugContext(ctx, fmt.Sprintf("error invoking tool. Client credentials lack authorization to the source: %v", err)) _ = render.Render(w, r, newErrResponse(err, statusCode)) diff --git a/internal/server/common_test.go b/internal/server/common_test.go index 2722da61fb..4735a560ff 100644 --- a/internal/server/common_test.go +++ b/internal/server/common_test.go @@ -26,6 +26,7 @@ import ( "github.com/go-chi/chi/v5" "github.com/googleapis/genai-toolbox/internal/log" "github.com/googleapis/genai-toolbox/internal/prompts" + "github.com/googleapis/genai-toolbox/internal/server/resources" "github.com/googleapis/genai-toolbox/internal/telemetry" "github.com/googleapis/genai-toolbox/internal/tools" "github.com/googleapis/genai-toolbox/internal/util/parameters" @@ -49,7 +50,7 @@ type MockTool struct { requiresClientAuthrorization bool } -func (t MockTool) Invoke(context.Context, parameters.ParamValues, tools.AccessToken) (any, error) { +func (t MockTool) Invoke(context.Context, tools.SourceProvider, parameters.ParamValues, tools.AccessToken) (any, error) { mock := []any{t.Name} return mock, nil } @@ -76,7 +77,7 @@ func (t MockTool) Authorized(verifiedAuthServices []string) bool { return !t.unauthorized } -func (t MockTool) RequiresClientAuthorization() bool { +func (t MockTool) RequiresClientAuthorization(tools.SourceProvider) bool { // defaulted to false return t.requiresClientAuthrorization } @@ -275,7 +276,7 @@ func setUpServer(t *testing.T, router string, tools map[string]tools.Tool, tools sseManager := newSseManager(ctx) - resourceManager := NewResourceManager(nil, nil, tools, toolsets, prompts, promptsets) + resourceManager := resources.NewResourceManager(nil, nil, tools, toolsets, prompts, promptsets) server := Server{ version: fakeVersionString, diff --git a/internal/server/mcp.go b/internal/server/mcp.go index e6a58e9b88..442369db5c 100644 --- a/internal/server/mcp.go +++ b/internal/server/mcp.go @@ -519,7 +519,7 @@ func processMcpMessage(ctx context.Context, body []byte, s *Server, protocolVers err = fmt.Errorf("promptset does not exist") return "", jsonrpc.NewError(baseMessage.Id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err } - res, err := mcp.ProcessMethod(ctx, protocolVersion, baseMessage.Id, baseMessage.Method, toolset, s.ResourceMgr.GetToolsMap(), promptset, s.ResourceMgr.GetPromptsMap(), s.ResourceMgr.GetAuthServiceMap(), body, header) + res, err := mcp.ProcessMethod(ctx, protocolVersion, baseMessage.Id, baseMessage.Method, toolset, promptset, s.ResourceMgr, body, header) return "", res, err } } diff --git a/internal/server/mcp/mcp.go b/internal/server/mcp/mcp.go index 8dac5147d1..74ff1bee59 100644 --- a/internal/server/mcp/mcp.go +++ b/internal/server/mcp/mcp.go @@ -21,13 +21,13 @@ import ( "net/http" "slices" - "github.com/googleapis/genai-toolbox/internal/auth" "github.com/googleapis/genai-toolbox/internal/prompts" "github.com/googleapis/genai-toolbox/internal/server/mcp/jsonrpc" mcputil "github.com/googleapis/genai-toolbox/internal/server/mcp/util" v20241105 "github.com/googleapis/genai-toolbox/internal/server/mcp/v20241105" v20250326 "github.com/googleapis/genai-toolbox/internal/server/mcp/v20250326" v20250618 "github.com/googleapis/genai-toolbox/internal/server/mcp/v20250618" + "github.com/googleapis/genai-toolbox/internal/server/resources" "github.com/googleapis/genai-toolbox/internal/tools" ) @@ -100,14 +100,14 @@ func NotificationHandler(ctx context.Context, body []byte) error { // ProcessMethod returns a response for the request. // This is the Operation phase of the lifecycle for MCP client-server connections. -func ProcessMethod(ctx context.Context, mcpVersion string, id jsonrpc.RequestId, method string, toolset tools.Toolset, tools map[string]tools.Tool, promptset prompts.Promptset, prompts map[string]prompts.Prompt, authServices map[string]auth.AuthService, body []byte, header http.Header) (any, error) { +func ProcessMethod(ctx context.Context, mcpVersion string, id jsonrpc.RequestId, method string, toolset tools.Toolset, promptset prompts.Promptset, resourceMgr *resources.ResourceManager, body []byte, header http.Header) (any, error) { switch mcpVersion { case v20250618.PROTOCOL_VERSION: - return v20250618.ProcessMethod(ctx, id, method, toolset, tools, promptset, prompts, authServices, body, header) + return v20250618.ProcessMethod(ctx, id, method, toolset, promptset, resourceMgr, body, header) case v20250326.PROTOCOL_VERSION: - return v20250326.ProcessMethod(ctx, id, method, toolset, tools, promptset, prompts, authServices, body, header) + return v20250326.ProcessMethod(ctx, id, method, toolset, promptset, resourceMgr, body, header) default: - return v20241105.ProcessMethod(ctx, id, method, toolset, tools, promptset, prompts, authServices, body, header) + return v20241105.ProcessMethod(ctx, id, method, toolset, promptset, resourceMgr, body, header) } } diff --git a/internal/server/mcp/v20241105/method.go b/internal/server/mcp/v20241105/method.go index 6934033460..6b2bf223e6 100644 --- a/internal/server/mcp/v20241105/method.go +++ b/internal/server/mcp/v20241105/method.go @@ -23,26 +23,26 @@ import ( "net/http" "strings" - "github.com/googleapis/genai-toolbox/internal/auth" "github.com/googleapis/genai-toolbox/internal/prompts" "github.com/googleapis/genai-toolbox/internal/server/mcp/jsonrpc" + "github.com/googleapis/genai-toolbox/internal/server/resources" "github.com/googleapis/genai-toolbox/internal/tools" "github.com/googleapis/genai-toolbox/internal/util" ) // ProcessMethod returns a response for the request. -func ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, toolset tools.Toolset, tools map[string]tools.Tool, promptset prompts.Promptset, prompts map[string]prompts.Prompt, authServices map[string]auth.AuthService, body []byte, header http.Header) (any, error) { +func ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, toolset tools.Toolset, promptset prompts.Promptset, resourceMgr *resources.ResourceManager, body []byte, header http.Header) (any, error) { switch method { case PING: return pingHandler(id) case TOOLS_LIST: return toolsListHandler(id, toolset, body) case TOOLS_CALL: - return toolsCallHandler(ctx, id, tools, authServices, body, header) + return toolsCallHandler(ctx, id, resourceMgr, body, header) case PROMPTS_LIST: return promptsListHandler(ctx, id, promptset, body) case PROMPTS_GET: - return promptsGetHandler(ctx, id, prompts, body) + return promptsGetHandler(ctx, id, resourceMgr, body) default: err := fmt.Errorf("invalid method %s", method) return jsonrpc.NewError(id, jsonrpc.METHOD_NOT_FOUND, err.Error(), nil), err @@ -83,7 +83,9 @@ func toolsListHandler(id jsonrpc.RequestId, toolset tools.Toolset, body []byte) } // toolsCallHandler generate a response for tools call. -func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[string]tools.Tool, authServices map[string]auth.AuthService, body []byte, header http.Header) (any, error) { +func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *resources.ResourceManager, body []byte, header http.Header) (any, error) { + authServices := resourceMgr.GetAuthServiceMap() + // retrieve logger from context logger, err := util.LoggerFromContext(ctx) if err != nil { @@ -99,7 +101,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st toolName := req.Params.Name toolArgument := req.Params.Arguments logger.DebugContext(ctx, fmt.Sprintf("tool name: %s", toolName)) - tool, ok := toolsMap[toolName] + tool, ok := resourceMgr.GetTool(toolName) if !ok { err = fmt.Errorf("invalid tool name: tool with name %q does not exist", toolName) return jsonrpc.NewError(id, jsonrpc.INVALID_PARAMS, err.Error(), nil), err @@ -109,7 +111,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st accessToken := tools.AccessToken(header.Get(tool.GetAuthTokenHeaderName())) // Check if this specific tool requires the standard authorization header - if tool.RequiresClientAuthorization() { + if tool.RequiresClientAuthorization(resourceMgr) { if accessToken == "" { return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, "missing access token in the 'Authorization' header", nil), util.ErrUnauthorized } @@ -172,7 +174,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st logger.DebugContext(ctx, fmt.Sprintf("invocation params: %s", params)) // run tool invocation and generate response. - results, err := tool.Invoke(ctx, params, accessToken) + results, err := tool.Invoke(ctx, resourceMgr, params, accessToken) if err != nil { errStr := err.Error() // Missing authService tokens. @@ -181,7 +183,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st } // Upstream auth error if strings.Contains(errStr, "Error 401") || strings.Contains(errStr, "Error 403") { - if tool.RequiresClientAuthorization() { + if tool.RequiresClientAuthorization(resourceMgr) { // Error with client credentials should pass down to the client return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err } @@ -252,7 +254,7 @@ func promptsListHandler(ctx context.Context, id jsonrpc.RequestId, promptset pro } // promptsGetHandler handles the "prompts/get" method. -func promptsGetHandler(ctx context.Context, id jsonrpc.RequestId, promptsMap map[string]prompts.Prompt, body []byte) (any, error) { +func promptsGetHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *resources.ResourceManager, body []byte) (any, error) { // retrieve logger from context logger, err := util.LoggerFromContext(ctx) if err != nil { @@ -268,7 +270,7 @@ func promptsGetHandler(ctx context.Context, id jsonrpc.RequestId, promptsMap map promptName := req.Params.Name logger.DebugContext(ctx, fmt.Sprintf("prompt name: %s", promptName)) - prompt, ok := promptsMap[promptName] + prompt, ok := resourceMgr.GetPrompt(promptName) if !ok { err := fmt.Errorf("prompt with name %q does not exist", promptName) return jsonrpc.NewError(id, jsonrpc.INVALID_PARAMS, err.Error(), nil), err diff --git a/internal/server/mcp/v20250326/method.go b/internal/server/mcp/v20250326/method.go index 4214a7cb39..c50b1b9636 100644 --- a/internal/server/mcp/v20250326/method.go +++ b/internal/server/mcp/v20250326/method.go @@ -23,26 +23,26 @@ import ( "net/http" "strings" - "github.com/googleapis/genai-toolbox/internal/auth" "github.com/googleapis/genai-toolbox/internal/prompts" "github.com/googleapis/genai-toolbox/internal/server/mcp/jsonrpc" + "github.com/googleapis/genai-toolbox/internal/server/resources" "github.com/googleapis/genai-toolbox/internal/tools" "github.com/googleapis/genai-toolbox/internal/util" ) // ProcessMethod returns a response for the request. -func ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, toolset tools.Toolset, tools map[string]tools.Tool, promptset prompts.Promptset, prompts map[string]prompts.Prompt, authServices map[string]auth.AuthService, body []byte, header http.Header) (any, error) { +func ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, toolset tools.Toolset, promptset prompts.Promptset, resourceMgr *resources.ResourceManager, body []byte, header http.Header) (any, error) { switch method { case PING: return pingHandler(id) case TOOLS_LIST: return toolsListHandler(id, toolset, body) case TOOLS_CALL: - return toolsCallHandler(ctx, id, tools, authServices, body, header) + return toolsCallHandler(ctx, id, resourceMgr, body, header) case PROMPTS_LIST: return promptsListHandler(ctx, id, promptset, body) case PROMPTS_GET: - return promptsGetHandler(ctx, id, prompts, body) + return promptsGetHandler(ctx, id, resourceMgr, body) default: err := fmt.Errorf("invalid method %s", method) return jsonrpc.NewError(id, jsonrpc.METHOD_NOT_FOUND, err.Error(), nil), err @@ -83,7 +83,9 @@ func toolsListHandler(id jsonrpc.RequestId, toolset tools.Toolset, body []byte) } // toolsCallHandler generate a response for tools call. -func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[string]tools.Tool, authServices map[string]auth.AuthService, body []byte, header http.Header) (any, error) { +func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *resources.ResourceManager, body []byte, header http.Header) (any, error) { + authServices := resourceMgr.GetAuthServiceMap() + // retrieve logger from context logger, err := util.LoggerFromContext(ctx) if err != nil { @@ -99,7 +101,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st toolName := req.Params.Name toolArgument := req.Params.Arguments logger.DebugContext(ctx, fmt.Sprintf("tool name: %s", toolName)) - tool, ok := toolsMap[toolName] + tool, ok := resourceMgr.GetTool(toolName) if !ok { err = fmt.Errorf("invalid tool name: tool with name %q does not exist", toolName) return jsonrpc.NewError(id, jsonrpc.INVALID_PARAMS, err.Error(), nil), err @@ -109,7 +111,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st accessToken := tools.AccessToken(header.Get(tool.GetAuthTokenHeaderName())) // Check if this specific tool requires the standard authorization header - if tool.RequiresClientAuthorization() { + if tool.RequiresClientAuthorization(resourceMgr) { if accessToken == "" { return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, "missing access token in the 'Authorization' header", nil), util.ErrUnauthorized } @@ -172,7 +174,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st logger.DebugContext(ctx, fmt.Sprintf("invocation params: %s", params)) // run tool invocation and generate response. - results, err := tool.Invoke(ctx, params, accessToken) + results, err := tool.Invoke(ctx, resourceMgr, params, accessToken) if err != nil { errStr := err.Error() // Missing authService tokens. @@ -181,7 +183,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st } // Upstream auth error if strings.Contains(errStr, "Error 401") || strings.Contains(errStr, "Error 403") { - if tool.RequiresClientAuthorization() { + if tool.RequiresClientAuthorization(resourceMgr) { // Error with client credentials should pass down to the client return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err } @@ -251,7 +253,7 @@ func promptsListHandler(ctx context.Context, id jsonrpc.RequestId, promptset pro } // promptsGetHandler handles the "prompts/get" method. -func promptsGetHandler(ctx context.Context, id jsonrpc.RequestId, promptsMap map[string]prompts.Prompt, body []byte) (any, error) { +func promptsGetHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *resources.ResourceManager, body []byte) (any, error) { // retrieve logger from context logger, err := util.LoggerFromContext(ctx) if err != nil { @@ -267,7 +269,7 @@ func promptsGetHandler(ctx context.Context, id jsonrpc.RequestId, promptsMap map promptName := req.Params.Name logger.DebugContext(ctx, fmt.Sprintf("prompt name: %s", promptName)) - prompt, ok := promptsMap[promptName] + prompt, ok := resourceMgr.GetPrompt(promptName) if !ok { err := fmt.Errorf("prompt with name %q does not exist", promptName) return jsonrpc.NewError(id, jsonrpc.INVALID_PARAMS, err.Error(), nil), err diff --git a/internal/server/mcp/v20250618/method.go b/internal/server/mcp/v20250618/method.go index 3ba18df908..183ada0188 100644 --- a/internal/server/mcp/v20250618/method.go +++ b/internal/server/mcp/v20250618/method.go @@ -23,26 +23,26 @@ import ( "net/http" "strings" - "github.com/googleapis/genai-toolbox/internal/auth" "github.com/googleapis/genai-toolbox/internal/prompts" "github.com/googleapis/genai-toolbox/internal/server/mcp/jsonrpc" + "github.com/googleapis/genai-toolbox/internal/server/resources" "github.com/googleapis/genai-toolbox/internal/tools" "github.com/googleapis/genai-toolbox/internal/util" ) // ProcessMethod returns a response for the request. -func ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, toolset tools.Toolset, tools map[string]tools.Tool, promptset prompts.Promptset, prompts map[string]prompts.Prompt, authServices map[string]auth.AuthService, body []byte, header http.Header) (any, error) { +func ProcessMethod(ctx context.Context, id jsonrpc.RequestId, method string, toolset tools.Toolset, promptset prompts.Promptset, resourceMgr *resources.ResourceManager, body []byte, header http.Header) (any, error) { switch method { case PING: return pingHandler(id) case TOOLS_LIST: return toolsListHandler(id, toolset, body) case TOOLS_CALL: - return toolsCallHandler(ctx, id, tools, authServices, body, header) + return toolsCallHandler(ctx, id, resourceMgr, body, header) case PROMPTS_LIST: return promptsListHandler(ctx, id, promptset, body) case PROMPTS_GET: - return promptsGetHandler(ctx, id, prompts, body) + return promptsGetHandler(ctx, id, resourceMgr, body) default: err := fmt.Errorf("invalid method %s", method) return jsonrpc.NewError(id, jsonrpc.METHOD_NOT_FOUND, err.Error(), nil), err @@ -76,7 +76,9 @@ func toolsListHandler(id jsonrpc.RequestId, toolset tools.Toolset, body []byte) } // toolsCallHandler generate a response for tools call. -func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[string]tools.Tool, authServices map[string]auth.AuthService, body []byte, header http.Header) (any, error) { +func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *resources.ResourceManager, body []byte, header http.Header) (any, error) { + authServices := resourceMgr.GetAuthServiceMap() + // retrieve logger from context logger, err := util.LoggerFromContext(ctx) if err != nil { @@ -92,7 +94,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st toolName := req.Params.Name toolArgument := req.Params.Arguments logger.DebugContext(ctx, fmt.Sprintf("tool name: %s", toolName)) - tool, ok := toolsMap[toolName] + tool, ok := resourceMgr.GetTool(toolName) if !ok { err = fmt.Errorf("invalid tool name: tool with name %q does not exist", toolName) return jsonrpc.NewError(id, jsonrpc.INVALID_PARAMS, err.Error(), nil), err @@ -102,7 +104,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st accessToken := tools.AccessToken(header.Get(tool.GetAuthTokenHeaderName())) // Check if this specific tool requires the standard authorization header - if tool.RequiresClientAuthorization() { + if tool.RequiresClientAuthorization(resourceMgr) { if accessToken == "" { return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, "missing access token in the 'Authorization' header", nil), util.ErrUnauthorized } @@ -165,7 +167,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st logger.DebugContext(ctx, fmt.Sprintf("invocation params: %s", params)) // run tool invocation and generate response. - results, err := tool.Invoke(ctx, params, accessToken) + results, err := tool.Invoke(ctx, resourceMgr, params, accessToken) if err != nil { errStr := err.Error() // Missing authService tokens. @@ -174,7 +176,7 @@ func toolsCallHandler(ctx context.Context, id jsonrpc.RequestId, toolsMap map[st } // Upstream auth error if strings.Contains(errStr, "Error 401") || strings.Contains(errStr, "Error 403") { - if tool.RequiresClientAuthorization() { + if tool.RequiresClientAuthorization(resourceMgr) { // Error with client credentials should pass down to the client return jsonrpc.NewError(id, jsonrpc.INVALID_REQUEST, err.Error(), nil), err } @@ -244,7 +246,7 @@ func promptsListHandler(ctx context.Context, id jsonrpc.RequestId, promptset pro } // promptsGetHandler handles the "prompts/get" method. -func promptsGetHandler(ctx context.Context, id jsonrpc.RequestId, promptsMap map[string]prompts.Prompt, body []byte) (any, error) { +func promptsGetHandler(ctx context.Context, id jsonrpc.RequestId, resourceMgr *resources.ResourceManager, body []byte) (any, error) { // retrieve logger from context logger, err := util.LoggerFromContext(ctx) if err != nil { @@ -260,8 +262,7 @@ func promptsGetHandler(ctx context.Context, id jsonrpc.RequestId, promptsMap map promptName := req.Params.Name logger.DebugContext(ctx, fmt.Sprintf("prompt name: %s", promptName)) - - prompt, ok := promptsMap[promptName] + prompt, ok := resourceMgr.GetPrompt(promptName) if !ok { err := fmt.Errorf("prompt with name %q does not exist", promptName) return jsonrpc.NewError(id, jsonrpc.INVALID_PARAMS, err.Error(), nil), err diff --git a/internal/server/mcp_test.go b/internal/server/mcp_test.go index 6f344b3caa..90b8676098 100644 --- a/internal/server/mcp_test.go +++ b/internal/server/mcp_test.go @@ -29,6 +29,7 @@ import ( "github.com/googleapis/genai-toolbox/internal/log" "github.com/googleapis/genai-toolbox/internal/server/mcp/jsonrpc" + "github.com/googleapis/genai-toolbox/internal/server/resources" "github.com/googleapis/genai-toolbox/internal/telemetry" ) @@ -1106,7 +1107,7 @@ func TestStdioSession(t *testing.T) { sseManager := newSseManager(ctx) - resourceManager := NewResourceManager(nil, nil, toolsMap, toolsets, promptsMap, promptsets) + resourceManager := resources.NewResourceManager(nil, nil, toolsMap, toolsets, promptsMap, promptsets) server := &Server{ version: fakeVersionString, diff --git a/internal/server/resources/resources.go b/internal/server/resources/resources.go new file mode 100644 index 0000000000..0cea0b7eaa --- /dev/null +++ b/internal/server/resources/resources.go @@ -0,0 +1,138 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package resources + +import ( + "sync" + + "github.com/googleapis/genai-toolbox/internal/auth" + "github.com/googleapis/genai-toolbox/internal/prompts" + "github.com/googleapis/genai-toolbox/internal/sources" + "github.com/googleapis/genai-toolbox/internal/tools" +) + +// ResourceManager contains available resources for the server. Should be initialized with NewResourceManager(). +type ResourceManager struct { + mu sync.RWMutex + sources map[string]sources.Source + authServices map[string]auth.AuthService + tools map[string]tools.Tool + toolsets map[string]tools.Toolset + prompts map[string]prompts.Prompt + promptsets map[string]prompts.Promptset +} + +func NewResourceManager( + sourcesMap map[string]sources.Source, + authServicesMap map[string]auth.AuthService, + toolsMap map[string]tools.Tool, toolsetsMap map[string]tools.Toolset, + promptsMap map[string]prompts.Prompt, promptsetsMap map[string]prompts.Promptset, + +) *ResourceManager { + resourceMgr := &ResourceManager{ + mu: sync.RWMutex{}, + sources: sourcesMap, + authServices: authServicesMap, + tools: toolsMap, + toolsets: toolsetsMap, + prompts: promptsMap, + promptsets: promptsetsMap, + } + + return resourceMgr +} + +func (r *ResourceManager) GetSource(sourceName string) (sources.Source, bool) { + r.mu.RLock() + defer r.mu.RUnlock() + source, ok := r.sources[sourceName] + return source, ok +} + +func (r *ResourceManager) GetAuthService(authServiceName string) (auth.AuthService, bool) { + r.mu.RLock() + defer r.mu.RUnlock() + authService, ok := r.authServices[authServiceName] + return authService, ok +} + +func (r *ResourceManager) GetTool(toolName string) (tools.Tool, bool) { + r.mu.RLock() + defer r.mu.RUnlock() + tool, ok := r.tools[toolName] + return tool, ok +} + +func (r *ResourceManager) GetToolset(toolsetName string) (tools.Toolset, bool) { + r.mu.RLock() + defer r.mu.RUnlock() + toolset, ok := r.toolsets[toolsetName] + return toolset, ok +} + +func (r *ResourceManager) GetPrompt(promptName string) (prompts.Prompt, bool) { + r.mu.RLock() + defer r.mu.RUnlock() + prompt, ok := r.prompts[promptName] + return prompt, ok +} + +func (r *ResourceManager) GetPromptset(promptsetName string) (prompts.Promptset, bool) { + r.mu.RLock() + defer r.mu.RUnlock() + promptset, ok := r.promptsets[promptsetName] + return promptset, ok +} + +func (r *ResourceManager) SetResources(sourcesMap map[string]sources.Source, authServicesMap map[string]auth.AuthService, toolsMap map[string]tools.Tool, toolsetsMap map[string]tools.Toolset, promptsMap map[string]prompts.Prompt, promptsetsMap map[string]prompts.Promptset) { + r.mu.Lock() + defer r.mu.Unlock() + r.sources = sourcesMap + r.authServices = authServicesMap + r.tools = toolsMap + r.toolsets = toolsetsMap + r.prompts = promptsMap + r.promptsets = promptsetsMap +} + +func (r *ResourceManager) GetAuthServiceMap() map[string]auth.AuthService { + r.mu.RLock() + defer r.mu.RUnlock() + copiedMap := make(map[string]auth.AuthService, len(r.authServices)) + for k, v := range r.authServices { + copiedMap[k] = v + } + return copiedMap +} + +func (r *ResourceManager) GetToolsMap() map[string]tools.Tool { + r.mu.RLock() + defer r.mu.RUnlock() + copiedMap := make(map[string]tools.Tool, len(r.tools)) + for k, v := range r.tools { + copiedMap[k] = v + } + return copiedMap +} + +func (r *ResourceManager) GetPromptsMap() map[string]prompts.Prompt { + r.mu.RLock() + defer r.mu.RUnlock() + copiedMap := make(map[string]prompts.Prompt, len(r.prompts)) + for k, v := range r.prompts { + copiedMap[k] = v + } + return copiedMap +} diff --git a/internal/server/resources/resources_test.go b/internal/server/resources/resources_test.go new file mode 100644 index 0000000000..b746abf3fc --- /dev/null +++ b/internal/server/resources/resources_test.go @@ -0,0 +1,103 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package resources_test + +import ( + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/googleapis/genai-toolbox/internal/auth" + "github.com/googleapis/genai-toolbox/internal/prompts" + "github.com/googleapis/genai-toolbox/internal/server/resources" + "github.com/googleapis/genai-toolbox/internal/sources" + "github.com/googleapis/genai-toolbox/internal/sources/alloydbpg" + "github.com/googleapis/genai-toolbox/internal/tools" +) + +func TestUpdateServer(t *testing.T) { + newSources := map[string]sources.Source{ + "example-source": &alloydbpg.Source{ + Config: alloydbpg.Config{ + Name: "example-alloydb-source", + Kind: "alloydb-postgres", + }, + }, + } + newAuth := map[string]auth.AuthService{"example-auth": nil} + newTools := map[string]tools.Tool{"example-tool": nil} + newToolsets := map[string]tools.Toolset{ + "example-toolset": { + ToolsetConfig: tools.ToolsetConfig{ + Name: "example-toolset", + }, + Tools: []*tools.Tool{}, + }, + } + newPrompts := map[string]prompts.Prompt{"example-prompt": nil} + newPromptsets := map[string]prompts.Promptset{ + "example-promptset": { + PromptsetConfig: prompts.PromptsetConfig{ + Name: "example-promptset", + }, + Prompts: []*prompts.Prompt{}, + }, + } + resMgr := resources.NewResourceManager(newSources, newAuth, newTools, newToolsets, newPrompts, newPromptsets) + + gotSource, _ := resMgr.GetSource("example-source") + if diff := cmp.Diff(gotSource, newSources["example-source"]); diff != "" { + t.Errorf("error updating server, sources (-want +got):\n%s", diff) + } + + gotAuthService, _ := resMgr.GetAuthService("example-auth") + if diff := cmp.Diff(gotAuthService, newAuth["example-auth"]); diff != "" { + t.Errorf("error updating server, authServices (-want +got):\n%s", diff) + } + + gotTool, _ := resMgr.GetTool("example-tool") + if diff := cmp.Diff(gotTool, newTools["example-tool"]); diff != "" { + t.Errorf("error updating server, tools (-want +got):\n%s", diff) + } + + gotToolset, _ := resMgr.GetToolset("example-toolset") + if diff := cmp.Diff(gotToolset, newToolsets["example-toolset"]); diff != "" { + t.Errorf("error updating server, toolset (-want +got):\n%s", diff) + } + + gotPrompt, _ := resMgr.GetPrompt("example-prompt") + if diff := cmp.Diff(gotPrompt, newPrompts["example-prompt"]); diff != "" { + t.Errorf("error updating server, prompts (-want +got):\n%s", diff) + } + + gotPromptset, _ := resMgr.GetPromptset("example-promptset") + if diff := cmp.Diff(gotPromptset, newPromptsets["example-promptset"]); diff != "" { + t.Errorf("error updating server, promptset (-want +got):\n%s", diff) + } + + updateSource := map[string]sources.Source{ + "example-source2": &alloydbpg.Source{ + Config: alloydbpg.Config{ + Name: "example-alloydb-source2", + Kind: "alloydb-postgres", + }, + }, + } + + resMgr.SetResources(updateSource, newAuth, newTools, newToolsets, newPrompts, newPromptsets) + gotSource, _ = resMgr.GetSource("example-source2") + if diff := cmp.Diff(gotSource, updateSource["example-source2"]); diff != "" { + t.Errorf("error updating server, sources (-want +got):\n%s", diff) + } +} diff --git a/internal/server/server.go b/internal/server/server.go index 7bbe218f28..4d2f600bd1 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -23,7 +23,6 @@ import ( "slices" "strconv" "strings" - "sync" "time" "github.com/go-chi/chi/v5" @@ -33,6 +32,7 @@ import ( "github.com/googleapis/genai-toolbox/internal/auth" "github.com/googleapis/genai-toolbox/internal/log" "github.com/googleapis/genai-toolbox/internal/prompts" + "github.com/googleapis/genai-toolbox/internal/server/resources" "github.com/googleapis/genai-toolbox/internal/sources" "github.com/googleapis/genai-toolbox/internal/telemetry" "github.com/googleapis/genai-toolbox/internal/tools" @@ -50,109 +50,7 @@ type Server struct { logger log.Logger instrumentation *telemetry.Instrumentation sseManager *sseManager - ResourceMgr *ResourceManager -} - -// ResourceManager contains available resources for the server. Should be initialized with NewResourceManager(). -type ResourceManager struct { - mu sync.RWMutex - sources map[string]sources.Source - authServices map[string]auth.AuthService - tools map[string]tools.Tool - toolsets map[string]tools.Toolset - prompts map[string]prompts.Prompt - promptsets map[string]prompts.Promptset -} - -func NewResourceManager( - sourcesMap map[string]sources.Source, - authServicesMap map[string]auth.AuthService, - toolsMap map[string]tools.Tool, toolsetsMap map[string]tools.Toolset, - promptsMap map[string]prompts.Prompt, promptsetsMap map[string]prompts.Promptset, - -) *ResourceManager { - resourceMgr := &ResourceManager{ - mu: sync.RWMutex{}, - sources: sourcesMap, - authServices: authServicesMap, - tools: toolsMap, - toolsets: toolsetsMap, - prompts: promptsMap, - promptsets: promptsetsMap, - } - - return resourceMgr -} - -func (r *ResourceManager) GetSource(sourceName string) (sources.Source, bool) { - r.mu.RLock() - defer r.mu.RUnlock() - source, ok := r.sources[sourceName] - return source, ok -} - -func (r *ResourceManager) GetAuthService(authServiceName string) (auth.AuthService, bool) { - r.mu.RLock() - defer r.mu.RUnlock() - authService, ok := r.authServices[authServiceName] - return authService, ok -} - -func (r *ResourceManager) GetTool(toolName string) (tools.Tool, bool) { - r.mu.RLock() - defer r.mu.RUnlock() - tool, ok := r.tools[toolName] - return tool, ok -} - -func (r *ResourceManager) GetToolset(toolsetName string) (tools.Toolset, bool) { - r.mu.RLock() - defer r.mu.RUnlock() - toolset, ok := r.toolsets[toolsetName] - return toolset, ok -} - -func (r *ResourceManager) GetPrompt(promptName string) (prompts.Prompt, bool) { - r.mu.RLock() - defer r.mu.RUnlock() - prompt, ok := r.prompts[promptName] - return prompt, ok -} - -func (r *ResourceManager) GetPromptset(promptsetName string) (prompts.Promptset, bool) { - r.mu.RLock() - defer r.mu.RUnlock() - promptset, ok := r.promptsets[promptsetName] - return promptset, ok -} - -func (r *ResourceManager) SetResources(sourcesMap map[string]sources.Source, authServicesMap map[string]auth.AuthService, toolsMap map[string]tools.Tool, toolsetsMap map[string]tools.Toolset, promptsMap map[string]prompts.Prompt, promptsetsMap map[string]prompts.Promptset) { - r.mu.Lock() - defer r.mu.Unlock() - r.sources = sourcesMap - r.authServices = authServicesMap - r.tools = toolsMap - r.toolsets = toolsetsMap - r.prompts = promptsMap - r.promptsets = promptsetsMap -} - -func (r *ResourceManager) GetAuthServiceMap() map[string]auth.AuthService { - r.mu.RLock() - defer r.mu.RUnlock() - return r.authServices -} - -func (r *ResourceManager) GetToolsMap() map[string]tools.Tool { - r.mu.RLock() - defer r.mu.RUnlock() - return r.tools -} - -func (r *ResourceManager) GetPromptsMap() map[string]prompts.Prompt { - r.mu.RLock() - defer r.mu.RUnlock() - return r.prompts + ResourceMgr *resources.ResourceManager } func InitializeConfigs(ctx context.Context, cfg ServerConfig) ( @@ -432,7 +330,7 @@ func NewServer(ctx context.Context, cfg ServerConfig) (*Server, error) { sseManager := newSseManager(ctx) - resourceManager := NewResourceManager(sourcesMap, authServicesMap, toolsMap, toolsetsMap, promptsMap, promptsetsMap) + resourceManager := resources.NewResourceManager(sourcesMap, authServicesMap, toolsMap, toolsetsMap, promptsMap, promptsetsMap) s := &Server{ version: cfg.Version, diff --git a/internal/tools/alloydb/alloydbcreatecluster/alloydbcreatecluster.go b/internal/tools/alloydb/alloydbcreatecluster/alloydbcreatecluster.go index 4b5a1f5efd..eeec42b655 100644 --- a/internal/tools/alloydb/alloydbcreatecluster/alloydbcreatecluster.go +++ b/internal/tools/alloydb/alloydbcreatecluster/alloydbcreatecluster.go @@ -119,7 +119,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) if !ok || project == "" { @@ -198,7 +198,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydb/alloydbcreateinstance/alloydbcreateinstance.go b/internal/tools/alloydb/alloydbcreateinstance/alloydbcreateinstance.go index b401278148..2c6344a2b1 100644 --- a/internal/tools/alloydb/alloydbcreateinstance/alloydbcreateinstance.go +++ b/internal/tools/alloydb/alloydbcreateinstance/alloydbcreateinstance.go @@ -120,7 +120,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) if !ok || project == "" { @@ -208,7 +208,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydb/alloydbcreateuser/alloydbcreateuser.go b/internal/tools/alloydb/alloydbcreateuser/alloydbcreateuser.go index 82a15e9943..873995e547 100644 --- a/internal/tools/alloydb/alloydbcreateuser/alloydbcreateuser.go +++ b/internal/tools/alloydb/alloydbcreateuser/alloydbcreateuser.go @@ -120,7 +120,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) if !ok || project == "" { @@ -208,7 +208,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydb/alloydbgetcluster/alloydbgetcluster.go b/internal/tools/alloydb/alloydbgetcluster/alloydbgetcluster.go index f4fa519f9c..30cf291bea 100644 --- a/internal/tools/alloydb/alloydbgetcluster/alloydbgetcluster.go +++ b/internal/tools/alloydb/alloydbgetcluster/alloydbgetcluster.go @@ -116,7 +116,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -167,7 +167,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydb/alloydbgetinstance/alloydbgetinstance.go b/internal/tools/alloydb/alloydbgetinstance/alloydbgetinstance.go index c62e798058..44dbb7d42d 100644 --- a/internal/tools/alloydb/alloydbgetinstance/alloydbgetinstance.go +++ b/internal/tools/alloydb/alloydbgetinstance/alloydbgetinstance.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -172,7 +172,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydb/alloydbgetuser/alloydbgetuser.go b/internal/tools/alloydb/alloydbgetuser/alloydbgetuser.go index ab057edb9e..7c33bd340c 100644 --- a/internal/tools/alloydb/alloydbgetuser/alloydbgetuser.go +++ b/internal/tools/alloydb/alloydbgetuser/alloydbgetuser.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -172,7 +172,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydb/alloydblistclusters/alloydblistclusters.go b/internal/tools/alloydb/alloydblistclusters/alloydblistclusters.go index 83f2d7bea9..eab2c4a7e8 100644 --- a/internal/tools/alloydb/alloydblistclusters/alloydblistclusters.go +++ b/internal/tools/alloydb/alloydblistclusters/alloydblistclusters.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -162,7 +162,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydb/alloydblistinstances/alloydblistinstances.go b/internal/tools/alloydb/alloydblistinstances/alloydblistinstances.go index ff73c28478..02e8d026a5 100644 --- a/internal/tools/alloydb/alloydblistinstances/alloydblistinstances.go +++ b/internal/tools/alloydb/alloydblistinstances/alloydblistinstances.go @@ -116,7 +116,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -167,7 +167,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydb/alloydblistusers/alloydblistusers.go b/internal/tools/alloydb/alloydblistusers/alloydblistusers.go index 3b4d09b2ff..c33a982382 100644 --- a/internal/tools/alloydb/alloydblistusers/alloydblistusers.go +++ b/internal/tools/alloydb/alloydblistusers/alloydblistusers.go @@ -116,7 +116,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -167,7 +167,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydb/alloydbwaitforoperation/alloydbwaitforoperation.go b/internal/tools/alloydb/alloydbwaitforoperation/alloydbwaitforoperation.go index 6ca877c540..dd909c42c3 100644 --- a/internal/tools/alloydb/alloydbwaitforoperation/alloydbwaitforoperation.go +++ b/internal/tools/alloydb/alloydbwaitforoperation/alloydbwaitforoperation.go @@ -214,7 +214,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -363,7 +363,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/alloydbainl/alloydbainl.go b/internal/tools/alloydbainl/alloydbainl.go index e7bc102c30..39564680ad 100644 --- a/internal/tools/alloydbainl/alloydbainl.go +++ b/internal/tools/alloydbainl/alloydbainl.go @@ -151,7 +151,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sliceParams := params.AsSlice() allParamValues := make([]any, len(sliceParams)+1) allParamValues[0] = fmt.Sprintf("%s", sliceParams[0]) // nl_question @@ -203,7 +203,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/bigquery/bigqueryanalyzecontribution/bigqueryanalyzecontribution.go b/internal/tools/bigquery/bigqueryanalyzecontribution/bigqueryanalyzecontribution.go index 25c9439986..6fe64b28e2 100644 --- a/internal/tools/bigquery/bigqueryanalyzecontribution/bigqueryanalyzecontribution.go +++ b/internal/tools/bigquery/bigqueryanalyzecontribution/bigqueryanalyzecontribution.go @@ -174,7 +174,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke runs the contribution analysis. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() inputData, ok := paramsMap["input_data"].(string) if !ok { @@ -385,7 +385,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/bigquery/bigqueryconversationalanalytics/bigqueryconversationalanalytics.go b/internal/tools/bigquery/bigqueryconversationalanalytics/bigqueryconversationalanalytics.go index a1c5119f08..945ac9fe5a 100644 --- a/internal/tools/bigquery/bigqueryconversationalanalytics/bigqueryconversationalanalytics.go +++ b/internal/tools/bigquery/bigqueryconversationalanalytics/bigqueryconversationalanalytics.go @@ -205,7 +205,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { var tokenStr string var err error @@ -303,7 +303,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/bigquery/bigqueryexecutesql/bigqueryexecutesql.go b/internal/tools/bigquery/bigqueryexecutesql/bigqueryexecutesql.go index c1bbeadaf8..fe5dcb5029 100644 --- a/internal/tools/bigquery/bigqueryexecutesql/bigqueryexecutesql.go +++ b/internal/tools/bigquery/bigqueryexecutesql/bigqueryexecutesql.go @@ -175,7 +175,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -374,7 +374,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/bigquery/bigqueryforecast/bigqueryforecast.go b/internal/tools/bigquery/bigqueryforecast/bigqueryforecast.go index 1e4262b995..583bc51df1 100644 --- a/internal/tools/bigquery/bigqueryforecast/bigqueryforecast.go +++ b/internal/tools/bigquery/bigqueryforecast/bigqueryforecast.go @@ -153,7 +153,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() historyData, ok := paramsMap["history_data"].(string) if !ok { @@ -349,7 +349,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/bigquery/bigquerygetdatasetinfo/bigquerygetdatasetinfo.go b/internal/tools/bigquery/bigquerygetdatasetinfo/bigquerygetdatasetinfo.go index e850df70f3..d570eaf327 100644 --- a/internal/tools/bigquery/bigquerygetdatasetinfo/bigquerygetdatasetinfo.go +++ b/internal/tools/bigquery/bigquerygetdatasetinfo/bigquerygetdatasetinfo.go @@ -136,7 +136,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() projectId, ok := mapParams[projectKey].(string) if !ok { @@ -193,7 +193,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/bigquery/bigquerygettableinfo/bigquerygettableinfo.go b/internal/tools/bigquery/bigquerygettableinfo/bigquerygettableinfo.go index d903a4b9bf..c6174e4199 100644 --- a/internal/tools/bigquery/bigquerygettableinfo/bigquerygettableinfo.go +++ b/internal/tools/bigquery/bigquerygettableinfo/bigquerygettableinfo.go @@ -140,7 +140,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() projectId, ok := mapParams[projectKey].(string) if !ok { @@ -203,7 +203,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/bigquery/bigquerylistdatasetids/bigquerylistdatasetids.go b/internal/tools/bigquery/bigquerylistdatasetids/bigquerylistdatasetids.go index 5b77282d4f..99484a3c20 100644 --- a/internal/tools/bigquery/bigquerylistdatasetids/bigquerylistdatasetids.go +++ b/internal/tools/bigquery/bigquerylistdatasetids/bigquerylistdatasetids.go @@ -135,7 +135,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { if len(t.AllowedDatasets) > 0 { return t.AllowedDatasets, nil } @@ -197,7 +197,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/bigquery/bigquerylisttableids/bigquerylisttableids.go b/internal/tools/bigquery/bigquerylisttableids/bigquerylisttableids.go index eed9ea10e9..d02a550304 100644 --- a/internal/tools/bigquery/bigquerylisttableids/bigquerylisttableids.go +++ b/internal/tools/bigquery/bigquerylisttableids/bigquerylisttableids.go @@ -139,7 +139,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() projectId, ok := mapParams[projectKey].(string) if !ok { @@ -208,7 +208,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/bigquery/bigquerysearchcatalog/bigquerysearchcatalog.go b/internal/tools/bigquery/bigquerysearchcatalog/bigquerysearchcatalog.go index baeda85773..0c53a7be6d 100644 --- a/internal/tools/bigquery/bigquerysearchcatalog/bigquerysearchcatalog.go +++ b/internal/tools/bigquery/bigquerysearchcatalog/bigquerysearchcatalog.go @@ -133,7 +133,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } @@ -206,7 +206,7 @@ func ExtractType(resourceString string) string { return typeMap[resourceString[lastIndex+1:]] } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() pageSize := int32(paramsMap["pageSize"].(int)) prompt, _ := paramsMap["prompt"].(string) diff --git a/internal/tools/bigquery/bigquerysql/bigquerysql.go b/internal/tools/bigquery/bigquerysql/bigquerysql.go index 2a4f78249e..ad4784cb63 100644 --- a/internal/tools/bigquery/bigquerysql/bigquerysql.go +++ b/internal/tools/bigquery/bigquerysql/bigquerysql.go @@ -135,7 +135,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { highLevelParams := make([]bigqueryapi.QueryParameter, 0, len(t.Parameters)) lowLevelParams := make([]*bigqueryrestapi.QueryParameter, 0, len(t.Parameters)) @@ -311,7 +311,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/bigtable/bigtable.go b/internal/tools/bigtable/bigtable.go index 52b6be1de0..3f63994815 100644 --- a/internal/tools/bigtable/bigtable.go +++ b/internal/tools/bigtable/bigtable.go @@ -155,7 +155,7 @@ func getMapParamsType(tparams parameters.Parameters, params parameters.ParamValu return btParamTypes, nil } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -224,7 +224,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/cassandra/cassandracql/cassandracql.go b/internal/tools/cassandra/cassandracql/cassandracql.go index bfcf4d883c..b650e3ba97 100644 --- a/internal/tools/cassandra/cassandracql/cassandracql.go +++ b/internal/tools/cassandra/cassandracql/cassandracql.go @@ -113,7 +113,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // RequiresClientAuthorization implements tools.Tool. -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } @@ -123,7 +123,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { } // Invoke implements tools.Tool. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { diff --git a/internal/tools/clickhouse/clickhouseexecutesql/clickhouseexecutesql.go b/internal/tools/clickhouse/clickhouseexecutesql/clickhouseexecutesql.go index d42c2c76d0..4e5e0448ee 100644 --- a/internal/tools/clickhouse/clickhouseexecutesql/clickhouseexecutesql.go +++ b/internal/tools/clickhouse/clickhouseexecutesql/clickhouseexecutesql.go @@ -102,7 +102,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, token tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, token tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -183,7 +183,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/clickhouse/clickhouselistdatabases/clickhouselistdatabases.go b/internal/tools/clickhouse/clickhouselistdatabases/clickhouselistdatabases.go index 15fe368e8b..9015e511cb 100644 --- a/internal/tools/clickhouse/clickhouselistdatabases/clickhouselistdatabases.go +++ b/internal/tools/clickhouse/clickhouselistdatabases/clickhouselistdatabases.go @@ -101,7 +101,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, token tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, token tools.AccessToken) (any, error) { // Query to list all databases query := "SHOW DATABASES" @@ -146,7 +146,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/clickhouse/clickhouselisttables/clickhouselisttables.go b/internal/tools/clickhouse/clickhouselisttables/clickhouselisttables.go index ca98bbea30..094fb28b02 100644 --- a/internal/tools/clickhouse/clickhouselisttables/clickhouselisttables.go +++ b/internal/tools/clickhouse/clickhouselisttables/clickhouselisttables.go @@ -105,7 +105,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, token tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, token tools.AccessToken) (any, error) { mapParams := params.AsMap() database, ok := mapParams[databaseKey].(string) if !ok { @@ -157,7 +157,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/clickhouse/clickhousesql/clickhousesql.go b/internal/tools/clickhouse/clickhousesql/clickhousesql.go index 969eadef66..6dade66701 100644 --- a/internal/tools/clickhouse/clickhousesql/clickhousesql.go +++ b/internal/tools/clickhouse/clickhousesql/clickhousesql.go @@ -102,7 +102,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, token tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, token tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -191,7 +191,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/cloudhealthcare/cloudhealthcarefhirfetchpage/cloudhealthcarefhirfetchpage.go b/internal/tools/cloudhealthcare/cloudhealthcarefhirfetchpage/cloudhealthcarefhirfetchpage.go index 21b0ee2c8e..5a4c22c471 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcarefhirfetchpage/cloudhealthcarefhirfetchpage.go +++ b/internal/tools/cloudhealthcare/cloudhealthcarefhirfetchpage/cloudhealthcarefhirfetchpage.go @@ -135,7 +135,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { url, ok := params.AsMap()[pageURLKey].(string) if !ok { return nil, fmt.Errorf("invalid or missing '%s' parameter; expected a string", pageURLKey) @@ -201,7 +201,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcarefhirpatienteverything/cloudhealthcarefhirpatienteverything.go b/internal/tools/cloudhealthcare/cloudhealthcarefhirpatienteverything/cloudhealthcarefhirpatienteverything.go index bedf91f3c1..11745be090 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcarefhirpatienteverything/cloudhealthcarefhirpatienteverything.go +++ b/internal/tools/cloudhealthcare/cloudhealthcarefhirpatienteverything/cloudhealthcarefhirpatienteverything.go @@ -141,7 +141,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -225,7 +225,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcarefhirpatientsearch/cloudhealthcarefhirpatientsearch.go b/internal/tools/cloudhealthcare/cloudhealthcarefhirpatientsearch/cloudhealthcarefhirpatientsearch.go index e4fd8f42d7..23acc98a4d 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcarefhirpatientsearch/cloudhealthcarefhirpatientsearch.go +++ b/internal/tools/cloudhealthcare/cloudhealthcarefhirpatientsearch/cloudhealthcarefhirpatientsearch.go @@ -175,7 +175,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -298,7 +298,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcaregetdataset/cloudhealthcaregetdataset.go b/internal/tools/cloudhealthcare/cloudhealthcaregetdataset/cloudhealthcaregetdataset.go index 79dd1ef727..4b07558300 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcaregetdataset/cloudhealthcaregetdataset.go +++ b/internal/tools/cloudhealthcare/cloudhealthcaregetdataset/cloudhealthcaregetdataset.go @@ -121,7 +121,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { svc := t.Service var err error @@ -161,7 +161,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcaregetdicomstore/cloudhealthcaregetdicomstore.go b/internal/tools/cloudhealthcare/cloudhealthcaregetdicomstore/cloudhealthcaregetdicomstore.go index 88ad99d3e3..ee81cf5fc3 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcaregetdicomstore/cloudhealthcaregetdicomstore.go +++ b/internal/tools/cloudhealthcare/cloudhealthcaregetdicomstore/cloudhealthcaregetdicomstore.go @@ -129,7 +129,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -172,7 +172,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcaregetdicomstoremetrics/cloudhealthcaregetdicomstoremetrics.go b/internal/tools/cloudhealthcare/cloudhealthcaregetdicomstoremetrics/cloudhealthcaregetdicomstoremetrics.go index e2d309445b..b6b9f5fbc9 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcaregetdicomstoremetrics/cloudhealthcaregetdicomstoremetrics.go +++ b/internal/tools/cloudhealthcare/cloudhealthcaregetdicomstoremetrics/cloudhealthcaregetdicomstoremetrics.go @@ -129,7 +129,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -172,7 +172,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcaregetfhirresource/cloudhealthcaregetfhirresource.go b/internal/tools/cloudhealthcare/cloudhealthcaregetfhirresource/cloudhealthcaregetfhirresource.go index c4dbe540dc..e8c00d78c1 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcaregetfhirresource/cloudhealthcaregetfhirresource.go +++ b/internal/tools/cloudhealthcare/cloudhealthcaregetfhirresource/cloudhealthcaregetfhirresource.go @@ -137,7 +137,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -204,7 +204,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcaregetfhirstore/cloudhealthcaregetfhirstore.go b/internal/tools/cloudhealthcare/cloudhealthcaregetfhirstore/cloudhealthcaregetfhirstore.go index f2a3928a4d..0a42c25190 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcaregetfhirstore/cloudhealthcaregetfhirstore.go +++ b/internal/tools/cloudhealthcare/cloudhealthcaregetfhirstore/cloudhealthcaregetfhirstore.go @@ -129,7 +129,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -172,7 +172,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcaregetfhirstoremetrics/cloudhealthcaregetfhirstoremetrics.go b/internal/tools/cloudhealthcare/cloudhealthcaregetfhirstoremetrics/cloudhealthcaregetfhirstoremetrics.go index 867cd6cd65..7c1f60363d 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcaregetfhirstoremetrics/cloudhealthcaregetfhirstoremetrics.go +++ b/internal/tools/cloudhealthcare/cloudhealthcaregetfhirstoremetrics/cloudhealthcaregetfhirstoremetrics.go @@ -129,7 +129,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -172,7 +172,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcarelistdicomstores/cloudhealthcarelistdicomstores.go b/internal/tools/cloudhealthcare/cloudhealthcarelistdicomstores/cloudhealthcarelistdicomstores.go index 1709cfc59f..8e25aa52f5 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcarelistdicomstores/cloudhealthcarelistdicomstores.go +++ b/internal/tools/cloudhealthcare/cloudhealthcarelistdicomstores/cloudhealthcarelistdicomstores.go @@ -126,7 +126,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { svc := t.Service var err error @@ -180,7 +180,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcarelistfhirstores/cloudhealthcarelistfhirstores.go b/internal/tools/cloudhealthcare/cloudhealthcarelistfhirstores/cloudhealthcarelistfhirstores.go index ef33387b53..287311b09a 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcarelistfhirstores/cloudhealthcarelistfhirstores.go +++ b/internal/tools/cloudhealthcare/cloudhealthcarelistfhirstores/cloudhealthcarelistfhirstores.go @@ -126,7 +126,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { svc := t.Service var err error @@ -180,7 +180,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcareretrieverendereddicominstance/cloudhealthcareretrieverendereddicominstance.go b/internal/tools/cloudhealthcare/cloudhealthcareretrieverendereddicominstance/cloudhealthcareretrieverendereddicominstance.go index 29eeb8234d..076b3cae58 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcareretrieverendereddicominstance/cloudhealthcareretrieverendereddicominstance.go +++ b/internal/tools/cloudhealthcare/cloudhealthcareretrieverendereddicominstance/cloudhealthcareretrieverendereddicominstance.go @@ -142,7 +142,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -214,7 +214,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcaresearchdicominstances/cloudhealthcaresearchdicominstances.go b/internal/tools/cloudhealthcare/cloudhealthcaresearchdicominstances/cloudhealthcaresearchdicominstances.go index 38b1d93413..50021bba41 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcaresearchdicominstances/cloudhealthcaresearchdicominstances.go +++ b/internal/tools/cloudhealthcare/cloudhealthcaresearchdicominstances/cloudhealthcaresearchdicominstances.go @@ -156,7 +156,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -244,7 +244,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcaresearchdicomseries/cloudhealthcaresearchdicomseries.go b/internal/tools/cloudhealthcare/cloudhealthcaresearchdicomseries/cloudhealthcaresearchdicomseries.go index 9425c9103e..00c51db961 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcaresearchdicomseries/cloudhealthcaresearchdicomseries.go +++ b/internal/tools/cloudhealthcare/cloudhealthcaresearchdicomseries/cloudhealthcaresearchdicomseries.go @@ -152,7 +152,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -227,7 +227,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudhealthcare/cloudhealthcaresearchdicomstudies/cloudhealthcaresearchdicomstudies.go b/internal/tools/cloudhealthcare/cloudhealthcaresearchdicomstudies/cloudhealthcaresearchdicomstudies.go index 6951dfccd5..d22c8832e4 100644 --- a/internal/tools/cloudhealthcare/cloudhealthcaresearchdicomstudies/cloudhealthcaresearchdicomstudies.go +++ b/internal/tools/cloudhealthcare/cloudhealthcaresearchdicomstudies/cloudhealthcaresearchdicomstudies.go @@ -148,7 +148,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { storeID, err := common.ValidateAndFetchStoreID(params, t.AllowedStores) if err != nil { return nil, err @@ -211,7 +211,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/cloudmonitoring/cloudmonitoring.go b/internal/tools/cloudmonitoring/cloudmonitoring.go index ccf70b4add..acfebeb8ca 100644 --- a/internal/tools/cloudmonitoring/cloudmonitoring.go +++ b/internal/tools/cloudmonitoring/cloudmonitoring.go @@ -108,7 +108,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() projectID, ok := paramsMap["projectId"].(string) if !ok { @@ -175,7 +175,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/cloudsql/cloudsqlcreatedatabase/cloudsqlcreatedatabase.go b/internal/tools/cloudsql/cloudsqlcreatedatabase/cloudsqlcreatedatabase.go index 08b19e013b..6f4a4b11a4 100644 --- a/internal/tools/cloudsql/cloudsqlcreatedatabase/cloudsqlcreatedatabase.go +++ b/internal/tools/cloudsql/cloudsqlcreatedatabase/cloudsqlcreatedatabase.go @@ -114,7 +114,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -169,7 +169,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/cloudsql/cloudsqlcreateusers/cloudsqlcreateusers.go b/internal/tools/cloudsql/cloudsqlcreateusers/cloudsqlcreateusers.go index ccc9b8cf58..71ac68c217 100644 --- a/internal/tools/cloudsql/cloudsqlcreateusers/cloudsqlcreateusers.go +++ b/internal/tools/cloudsql/cloudsqlcreateusers/cloudsqlcreateusers.go @@ -116,7 +116,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -182,7 +182,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/cloudsql/cloudsqlgetinstances/cloudsqlgetinstances.go b/internal/tools/cloudsql/cloudsqlgetinstances/cloudsqlgetinstances.go index 5fd2b41ef3..d1ecc621f0 100644 --- a/internal/tools/cloudsql/cloudsqlgetinstances/cloudsqlgetinstances.go +++ b/internal/tools/cloudsql/cloudsqlgetinstances/cloudsqlgetinstances.go @@ -113,7 +113,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() projectId, ok := paramsMap["projectId"].(string) @@ -158,7 +158,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/cloudsql/cloudsqllistdatabases/cloudsqllistdatabases.go b/internal/tools/cloudsql/cloudsqllistdatabases/cloudsqllistdatabases.go index 03e3763d01..32c9f01f01 100644 --- a/internal/tools/cloudsql/cloudsqllistdatabases/cloudsqllistdatabases.go +++ b/internal/tools/cloudsql/cloudsqllistdatabases/cloudsqllistdatabases.go @@ -112,7 +112,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -176,7 +176,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/cloudsql/cloudsqllistinstances/cloudsqllistinstances.go b/internal/tools/cloudsql/cloudsqllistinstances/cloudsqllistinstances.go index c06c79f961..51d5829c0b 100644 --- a/internal/tools/cloudsql/cloudsqllistinstances/cloudsqllistinstances.go +++ b/internal/tools/cloudsql/cloudsqllistinstances/cloudsqllistinstances.go @@ -111,7 +111,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -169,7 +169,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.source.UseClientAuthorization() } diff --git a/internal/tools/cloudsql/cloudsqlwaitforoperation/cloudsqlwaitforoperation.go b/internal/tools/cloudsql/cloudsqlwaitforoperation/cloudsqlwaitforoperation.go index cbb184fe45..f46dc9c724 100644 --- a/internal/tools/cloudsql/cloudsqlwaitforoperation/cloudsqlwaitforoperation.go +++ b/internal/tools/cloudsql/cloudsqlwaitforoperation/cloudsqlwaitforoperation.go @@ -209,7 +209,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -305,7 +305,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/cloudsqlmssql/cloudsqlmssqlcreateinstance/cloudsqlmssqlcreateinstance.go b/internal/tools/cloudsqlmssql/cloudsqlmssqlcreateinstance/cloudsqlmssqlcreateinstance.go index 89e75c34b4..caa5aac470 100644 --- a/internal/tools/cloudsqlmssql/cloudsqlmssqlcreateinstance/cloudsqlmssqlcreateinstance.go +++ b/internal/tools/cloudsqlmssql/cloudsqlmssqlcreateinstance/cloudsqlmssqlcreateinstance.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -200,7 +200,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/cloudsqlmysql/cloudsqlmysqlcreateinstance/cloudsqlmysqlcreateinstance.go b/internal/tools/cloudsqlmysql/cloudsqlmysqlcreateinstance/cloudsqlmysqlcreateinstance.go index e4fa0c7c5b..d9eedb69df 100644 --- a/internal/tools/cloudsqlmysql/cloudsqlmysqlcreateinstance/cloudsqlmysqlcreateinstance.go +++ b/internal/tools/cloudsqlmysql/cloudsqlmysqlcreateinstance/cloudsqlmysqlcreateinstance.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -200,7 +200,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/cloudsqlpg/cloudsqlpgcreateinstances/cloudsqlpgcreateinstances.go b/internal/tools/cloudsqlpg/cloudsqlpgcreateinstances/cloudsqlpgcreateinstances.go index 2f56d032e2..edbcecd652 100644 --- a/internal/tools/cloudsqlpg/cloudsqlpgcreateinstances/cloudsqlpgcreateinstances.go +++ b/internal/tools/cloudsqlpg/cloudsqlpgcreateinstances/cloudsqlpgcreateinstances.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -200,7 +200,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/cloudsqlpg/cloudsqlpgupgradeprecheck/cloudsqlpgupgradeprecheck.go b/internal/tools/cloudsqlpg/cloudsqlpgupgradeprecheck/cloudsqlpgupgradeprecheck.go index 1491cf86f5..5cde40216d 100644 --- a/internal/tools/cloudsqlpg/cloudsqlpgupgradeprecheck/cloudsqlpgupgradeprecheck.go +++ b/internal/tools/cloudsqlpg/cloudsqlpgupgradeprecheck/cloudsqlpgupgradeprecheck.go @@ -145,7 +145,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the tool's logic. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() project, ok := paramsMap["project"].(string) @@ -234,7 +234,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.Source.UseClientAuthorization() } diff --git a/internal/tools/couchbase/couchbase.go b/internal/tools/couchbase/couchbase.go index 402948ebb2..2149691c82 100644 --- a/internal/tools/couchbase/couchbase.go +++ b/internal/tools/couchbase/couchbase.go @@ -119,7 +119,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { namedParamsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, namedParamsMap) if err != nil { @@ -166,7 +166,7 @@ func (t Tool) Authorized(verifiedAuthSources []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthSources) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/dataform/dataformcompilelocal/dataformcompilelocal.go b/internal/tools/dataform/dataformcompilelocal/dataformcompilelocal.go index fbab4bed08..d7e88428e6 100644 --- a/internal/tools/dataform/dataformcompilelocal/dataformcompilelocal.go +++ b/internal/tools/dataform/dataformcompilelocal/dataformcompilelocal.go @@ -85,7 +85,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() projectDir, ok := paramsMap["project_dir"].(string) @@ -118,7 +118,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/dataplex/dataplexlookupentry/dataplexlookupentry.go b/internal/tools/dataplex/dataplexlookupentry/dataplexlookupentry.go index 4c8b8e09a6..cdf3f62c41 100644 --- a/internal/tools/dataplex/dataplexlookupentry/dataplexlookupentry.go +++ b/internal/tools/dataplex/dataplexlookupentry/dataplexlookupentry.go @@ -129,7 +129,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() viewMap := map[int]dataplexpb.EntryView{ 1: dataplexpb.EntryView_BASIC, @@ -179,7 +179,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/dataplex/dataplexsearchaspecttypes/dataplexsearchaspecttypes.go b/internal/tools/dataplex/dataplexsearchaspecttypes/dataplexsearchaspecttypes.go index f33215a12e..e450a15a55 100644 --- a/internal/tools/dataplex/dataplexsearchaspecttypes/dataplexsearchaspecttypes.go +++ b/internal/tools/dataplex/dataplexsearchaspecttypes/dataplexsearchaspecttypes.go @@ -116,7 +116,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { // Invoke the tool with the provided parameters paramsMap := params.AsMap() query, _ := paramsMap["query"].(string) @@ -192,7 +192,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/dataplex/dataplexsearchentries/dataplexsearchentries.go b/internal/tools/dataplex/dataplexsearchentries/dataplexsearchentries.go index c4c04e406e..114601bbb1 100644 --- a/internal/tools/dataplex/dataplexsearchentries/dataplexsearchentries.go +++ b/internal/tools/dataplex/dataplexsearchentries/dataplexsearchentries.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() query, _ := paramsMap["query"].(string) pageSize := int32(paramsMap["pageSize"].(int)) @@ -163,7 +163,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/dgraph/dgraph.go b/internal/tools/dgraph/dgraph.go index 4a9b5a4fd0..4615a177a2 100644 --- a/internal/tools/dgraph/dgraph.go +++ b/internal/tools/dgraph/dgraph.go @@ -109,7 +109,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMapWithDollarPrefix() resp, err := t.DgraphClient.ExecuteQuery(t.Statement, paramsMap, t.IsQuery, t.Timeout) @@ -148,7 +148,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/elasticsearch/elasticsearchesql/elasticsearchesql.go b/internal/tools/elasticsearch/elasticsearchesql/elasticsearchesql.go index 2b898da4e1..7b432bee63 100644 --- a/internal/tools/elasticsearch/elasticsearchesql/elasticsearchesql.go +++ b/internal/tools/elasticsearch/elasticsearchesql/elasticsearchesql.go @@ -119,7 +119,7 @@ type esqlResult struct { Values [][]any `json:"values"` } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { var cancel context.CancelFunc if t.Timeout > 0 { ctx, cancel = context.WithTimeout(ctx, time.Duration(t.Timeout)*time.Second) @@ -230,7 +230,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firebird/firebirdexecutesql/firebirdexecutesql.go b/internal/tools/firebird/firebirdexecutesql/firebirdexecutesql.go index 1e2531289f..97fd2296e7 100644 --- a/internal/tools/firebird/firebirdexecutesql/firebirdexecutesql.go +++ b/internal/tools/firebird/firebirdexecutesql/firebirdexecutesql.go @@ -106,7 +106,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -180,7 +180,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firebird/firebirdsql/firebirdsql.go b/internal/tools/firebird/firebirdsql/firebirdsql.go index 07604840cf..f249dca46f 100644 --- a/internal/tools/firebird/firebirdsql/firebirdsql.go +++ b/internal/tools/firebird/firebirdsql/firebirdsql.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() statement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -204,7 +204,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firestore/firestoreadddocuments/firestoreadddocuments.go b/internal/tools/firestore/firestoreadddocuments/firestoreadddocuments.go index f4f2efd589..18d2d9354a 100644 --- a/internal/tools/firestore/firestoreadddocuments/firestoreadddocuments.go +++ b/internal/tools/firestore/firestoreadddocuments/firestoreadddocuments.go @@ -147,7 +147,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() // Get collection path @@ -221,7 +221,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firestore/firestoredeletedocuments/firestoredeletedocuments.go b/internal/tools/firestore/firestoredeletedocuments/firestoredeletedocuments.go index 65ad5bbf96..b1d95a58e2 100644 --- a/internal/tools/firestore/firestoredeletedocuments/firestoredeletedocuments.go +++ b/internal/tools/firestore/firestoredeletedocuments/firestoredeletedocuments.go @@ -113,7 +113,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() documentPathsRaw, ok := mapParams[documentPathsKey].([]any) if !ok { @@ -198,7 +198,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firestore/firestoregetdocuments/firestoregetdocuments.go b/internal/tools/firestore/firestoregetdocuments/firestoregetdocuments.go index 6b59c13e18..0a9666d8d8 100644 --- a/internal/tools/firestore/firestoregetdocuments/firestoregetdocuments.go +++ b/internal/tools/firestore/firestoregetdocuments/firestoregetdocuments.go @@ -113,7 +113,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() documentPathsRaw, ok := mapParams[documentPathsKey].([]any) if !ok { @@ -190,7 +190,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firestore/firestoregetrules/firestoregetrules.go b/internal/tools/firestore/firestoregetrules/firestoregetrules.go index 0cb37b9801..eb958c445c 100644 --- a/internal/tools/firestore/firestoregetrules/firestoregetrules.go +++ b/internal/tools/firestore/firestoregetrules/firestoregetrules.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { // Get the latest release for Firestore releaseName := fmt.Sprintf("projects/%s/releases/cloud.firestore/%s", t.ProjectId, t.DatabaseId) release, err := t.RulesClient.Projects.Releases.Get(releaseName).Context(ctx).Do() @@ -158,7 +158,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firestore/firestorelistcollections/firestorelistcollections.go b/internal/tools/firestore/firestorelistcollections/firestorelistcollections.go index 92fe1c4bfd..382161099a 100644 --- a/internal/tools/firestore/firestorelistcollections/firestorelistcollections.go +++ b/internal/tools/firestore/firestorelistcollections/firestorelistcollections.go @@ -114,7 +114,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() var collectionRefs []*firestoreapi.CollectionRef @@ -177,7 +177,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firestore/firestorequery/firestorequery.go b/internal/tools/firestore/firestorequery/firestorequery.go index a7319cbf6b..8ae527452c 100644 --- a/internal/tools/firestore/firestorequery/firestorequery.go +++ b/internal/tools/firestore/firestorequery/firestorequery.go @@ -200,7 +200,7 @@ type QueryResponse struct { } // Invoke executes the Firestore query based on the provided parameters -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() // Process collection path with template substitution @@ -525,7 +525,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firestore/firestorequerycollection/firestorequerycollection.go b/internal/tools/firestore/firestorequerycollection/firestorequerycollection.go index a16e3c16eb..72c4d27086 100644 --- a/internal/tools/firestore/firestorequerycollection/firestorequerycollection.go +++ b/internal/tools/firestore/firestorequerycollection/firestorequerycollection.go @@ -265,7 +265,7 @@ type QueryResponse struct { } // Invoke executes the Firestore query based on the provided parameters -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { // Parse parameters queryParams, err := t.parseQueryParameters(params) if err != nil { @@ -531,7 +531,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firestore/firestoreupdatedocument/firestoreupdatedocument.go b/internal/tools/firestore/firestoreupdatedocument/firestoreupdatedocument.go index d26a7a7895..fa5576ce31 100644 --- a/internal/tools/firestore/firestoreupdatedocument/firestoreupdatedocument.go +++ b/internal/tools/firestore/firestoreupdatedocument/firestoreupdatedocument.go @@ -157,7 +157,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() // Get document path @@ -314,7 +314,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/firestore/firestorevalidaterules/firestorevalidaterules.go b/internal/tools/firestore/firestorevalidaterules/firestorevalidaterules.go index 21bf1df9e4..028677cc99 100644 --- a/internal/tools/firestore/firestorevalidaterules/firestorevalidaterules.go +++ b/internal/tools/firestore/firestorevalidaterules/firestorevalidaterules.go @@ -153,7 +153,7 @@ type ValidationResult struct { RawIssues []Issue `json:"rawIssues,omitempty"` } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() // Get source parameter @@ -287,7 +287,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/http/http.go b/internal/tools/http/http.go index e7b463e542..4013d25d75 100644 --- a/internal/tools/http/http.go +++ b/internal/tools/http/http.go @@ -228,7 +228,7 @@ func getHeaders(headerParams parameters.Parameters, defaultHeaders map[string]st return allHeaders, nil } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() // Calculate request body @@ -295,7 +295,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/looker/lookeradddashboardelement/lookeradddashboardelement.go b/internal/tools/looker/lookeradddashboardelement/lookeradddashboardelement.go index 0ad1961198..21c30d50f2 100644 --- a/internal/tools/looker/lookeradddashboardelement/lookeradddashboardelement.go +++ b/internal/tools/looker/lookeradddashboardelement/lookeradddashboardelement.go @@ -129,7 +129,7 @@ var ( visType string = "vis" ) -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -207,7 +207,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerconversationalanalytics/lookerconversationalanalytics.go b/internal/tools/looker/lookerconversationalanalytics/lookerconversationalanalytics.go index 35b90aed8b..2d9f178b85 100644 --- a/internal/tools/looker/lookerconversationalanalytics/lookerconversationalanalytics.go +++ b/internal/tools/looker/lookerconversationalanalytics/lookerconversationalanalytics.go @@ -222,7 +222,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { var tokenStr string var err error @@ -311,7 +311,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookercreateprojectfile/lookercreateprojectfile.go b/internal/tools/looker/lookercreateprojectfile/lookercreateprojectfile.go index 70c9f05ab6..a202c104be 100644 --- a/internal/tools/looker/lookercreateprojectfile/lookercreateprojectfile.go +++ b/internal/tools/looker/lookercreateprojectfile/lookercreateprojectfile.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sdk, err := lookercommon.GetLookerSDK(t.UseClientOAuth, t.ApiSettings, t.Client, accessToken) if err != nil { return nil, fmt.Errorf("error getting sdk: %w", err) @@ -168,7 +168,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerdeleteprojectfile/lookerdeleteprojectfile.go b/internal/tools/looker/lookerdeleteprojectfile/lookerdeleteprojectfile.go index 76b7a0f6e5..9611ba7759 100644 --- a/internal/tools/looker/lookerdeleteprojectfile/lookerdeleteprojectfile.go +++ b/internal/tools/looker/lookerdeleteprojectfile/lookerdeleteprojectfile.go @@ -114,7 +114,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sdk, err := lookercommon.GetLookerSDK(t.UseClientOAuth, t.ApiSettings, t.Client, accessToken) if err != nil { return nil, fmt.Errorf("error getting sdk: %w", err) @@ -158,7 +158,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerdevmode/lookerdevmode.go b/internal/tools/looker/lookerdevmode/lookerdevmode.go index dcf7735413..3f982cb729 100644 --- a/internal/tools/looker/lookerdevmode/lookerdevmode.go +++ b/internal/tools/looker/lookerdevmode/lookerdevmode.go @@ -116,7 +116,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -165,7 +165,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergenerateembedurl/lookergenerateembedurl.go b/internal/tools/looker/lookergenerateembedurl/lookergenerateembedurl.go index 20d92af198..372abde764 100644 --- a/internal/tools/looker/lookergenerateembedurl/lookergenerateembedurl.go +++ b/internal/tools/looker/lookergenerateembedurl/lookergenerateembedurl.go @@ -122,7 +122,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -177,7 +177,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetconnectiondatabases/lookergetconnectiondatabases.go b/internal/tools/looker/lookergetconnectiondatabases/lookergetconnectiondatabases.go index e73fcc6ec4..c8cfb5c2aa 100644 --- a/internal/tools/looker/lookergetconnectiondatabases/lookergetconnectiondatabases.go +++ b/internal/tools/looker/lookergetconnectiondatabases/lookergetconnectiondatabases.go @@ -113,7 +113,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() conn, ok := mapParams["conn"].(string) if !ok { @@ -149,7 +149,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetconnections/lookergetconnections.go b/internal/tools/looker/lookergetconnections/lookergetconnections.go index b4e307418b..629fdf6382 100644 --- a/internal/tools/looker/lookergetconnections/lookergetconnections.go +++ b/internal/tools/looker/lookergetconnections/lookergetconnections.go @@ -113,7 +113,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -168,7 +168,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetconnectionschemas/lookergetconnectionschemas.go b/internal/tools/looker/lookergetconnectionschemas/lookergetconnectionschemas.go index dc471bc9b0..34cf76569d 100644 --- a/internal/tools/looker/lookergetconnectionschemas/lookergetconnectionschemas.go +++ b/internal/tools/looker/lookergetconnectionschemas/lookergetconnectionschemas.go @@ -114,7 +114,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { mapParams := params.AsMap() conn, ok := mapParams["conn"].(string) if !ok { @@ -155,7 +155,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetconnectiontablecolumns/lookergetconnectiontablecolumns.go b/internal/tools/looker/lookergetconnectiontablecolumns/lookergetconnectiontablecolumns.go index 0d881919e6..5622669fdc 100644 --- a/internal/tools/looker/lookergetconnectiontablecolumns/lookergetconnectiontablecolumns.go +++ b/internal/tools/looker/lookergetconnectiontablecolumns/lookergetconnectiontablecolumns.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -192,7 +192,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetconnectiontables/lookergetconnectiontables.go b/internal/tools/looker/lookergetconnectiontables/lookergetconnectiontables.go index 853296c32d..8fd8bfc82c 100644 --- a/internal/tools/looker/lookergetconnectiontables/lookergetconnectiontables.go +++ b/internal/tools/looker/lookergetconnectiontables/lookergetconnectiontables.go @@ -116,7 +116,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -183,7 +183,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetdashboards/lookergetdashboards.go b/internal/tools/looker/lookergetdashboards/lookergetdashboards.go index 4438468adb..b69a152c56 100644 --- a/internal/tools/looker/lookergetdashboards/lookergetdashboards.go +++ b/internal/tools/looker/lookergetdashboards/lookergetdashboards.go @@ -122,7 +122,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -194,7 +194,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetdimensions/lookergetdimensions.go b/internal/tools/looker/lookergetdimensions/lookergetdimensions.go index 58f1f833b3..713b28185e 100644 --- a/internal/tools/looker/lookergetdimensions/lookergetdimensions.go +++ b/internal/tools/looker/lookergetdimensions/lookergetdimensions.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -169,7 +169,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetexplores/lookergetexplores.go b/internal/tools/looker/lookergetexplores/lookergetexplores.go index ebc10ba765..78b66de909 100644 --- a/internal/tools/looker/lookergetexplores/lookergetexplores.go +++ b/internal/tools/looker/lookergetexplores/lookergetexplores.go @@ -116,7 +116,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -179,7 +179,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetfilters/lookergetfilters.go b/internal/tools/looker/lookergetfilters/lookergetfilters.go index 8204f004ca..ef758e0a4b 100644 --- a/internal/tools/looker/lookergetfilters/lookergetfilters.go +++ b/internal/tools/looker/lookergetfilters/lookergetfilters.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -169,7 +169,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetlooks/lookergetlooks.go b/internal/tools/looker/lookergetlooks/lookergetlooks.go index 33b4135f09..e602f66cfc 100644 --- a/internal/tools/looker/lookergetlooks/lookergetlooks.go +++ b/internal/tools/looker/lookergetlooks/lookergetlooks.go @@ -122,7 +122,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -194,7 +194,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetmeasures/lookergetmeasures.go b/internal/tools/looker/lookergetmeasures/lookergetmeasures.go index de1bef032e..3fafe8aaf7 100644 --- a/internal/tools/looker/lookergetmeasures/lookergetmeasures.go +++ b/internal/tools/looker/lookergetmeasures/lookergetmeasures.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -169,7 +169,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetmodels/lookergetmodels.go b/internal/tools/looker/lookergetmodels/lookergetmodels.go index cfa027384d..fbd08bbdda 100644 --- a/internal/tools/looker/lookergetmodels/lookergetmodels.go +++ b/internal/tools/looker/lookergetmodels/lookergetmodels.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -171,7 +171,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetparameters/lookergetparameters.go b/internal/tools/looker/lookergetparameters/lookergetparameters.go index d84ec07726..56b20d5984 100644 --- a/internal/tools/looker/lookergetparameters/lookergetparameters.go +++ b/internal/tools/looker/lookergetparameters/lookergetparameters.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -169,7 +169,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetprojectfile/lookergetprojectfile.go b/internal/tools/looker/lookergetprojectfile/lookergetprojectfile.go index 6d91d09b14..1a2b9f43aa 100644 --- a/internal/tools/looker/lookergetprojectfile/lookergetprojectfile.go +++ b/internal/tools/looker/lookergetprojectfile/lookergetprojectfile.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -165,7 +165,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetprojectfiles/lookergetprojectfiles.go b/internal/tools/looker/lookergetprojectfiles/lookergetprojectfiles.go index 0705449536..fac6179a26 100644 --- a/internal/tools/looker/lookergetprojectfiles/lookergetprojectfiles.go +++ b/internal/tools/looker/lookergetprojectfiles/lookergetprojectfiles.go @@ -114,7 +114,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -182,7 +182,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookergetprojects/lookergetprojects.go b/internal/tools/looker/lookergetprojects/lookergetprojects.go index 2e4a2d23a3..177044ffd0 100644 --- a/internal/tools/looker/lookergetprojects/lookergetprojects.go +++ b/internal/tools/looker/lookergetprojects/lookergetprojects.go @@ -113,7 +113,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -159,7 +159,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerhealthanalyze/lookerhealthanalyze.go b/internal/tools/looker/lookerhealthanalyze/lookerhealthanalyze.go index a0aad8335f..7ff375a3de 100644 --- a/internal/tools/looker/lookerhealthanalyze/lookerhealthanalyze.go +++ b/internal/tools/looker/lookerhealthanalyze/lookerhealthanalyze.go @@ -128,7 +128,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -207,7 +207,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerhealthpulse/lookerhealthpulse.go b/internal/tools/looker/lookerhealthpulse/lookerhealthpulse.go index e0dd560e79..0831828ebd 100644 --- a/internal/tools/looker/lookerhealthpulse/lookerhealthpulse.go +++ b/internal/tools/looker/lookerhealthpulse/lookerhealthpulse.go @@ -119,7 +119,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -171,7 +171,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerhealthvacuum/lookerhealthvacuum.go b/internal/tools/looker/lookerhealthvacuum/lookerhealthvacuum.go index 39bf4cfb21..8d3075a22f 100644 --- a/internal/tools/looker/lookerhealthvacuum/lookerhealthvacuum.go +++ b/internal/tools/looker/lookerhealthvacuum/lookerhealthvacuum.go @@ -128,7 +128,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sdk, err := lookercommon.GetLookerSDK(t.UseClientOAuth, t.ApiSettings, t.Client, accessToken) if err != nil { return nil, fmt.Errorf("error getting sdk: %w", err) @@ -185,7 +185,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookermakedashboard/lookermakedashboard.go b/internal/tools/looker/lookermakedashboard/lookermakedashboard.go index 961461add9..818dbd419c 100644 --- a/internal/tools/looker/lookermakedashboard/lookermakedashboard.go +++ b/internal/tools/looker/lookermakedashboard/lookermakedashboard.go @@ -120,7 +120,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -207,7 +207,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookermakelook/lookermakelook.go b/internal/tools/looker/lookermakelook/lookermakelook.go index c4180ea4f0..99942948c3 100644 --- a/internal/tools/looker/lookermakelook/lookermakelook.go +++ b/internal/tools/looker/lookermakelook/lookermakelook.go @@ -126,7 +126,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -224,7 +224,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerquery/lookerquery.go b/internal/tools/looker/lookerquery/lookerquery.go index 7d0a4c5209..0ce58268b7 100644 --- a/internal/tools/looker/lookerquery/lookerquery.go +++ b/internal/tools/looker/lookerquery/lookerquery.go @@ -114,7 +114,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -161,7 +161,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerquerysql/lookerquerysql.go b/internal/tools/looker/lookerquerysql/lookerquerysql.go index f3c3c0e07c..9fe925fe34 100644 --- a/internal/tools/looker/lookerquerysql/lookerquerysql.go +++ b/internal/tools/looker/lookerquerysql/lookerquerysql.go @@ -113,7 +113,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -151,7 +151,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerqueryurl/lookerqueryurl.go b/internal/tools/looker/lookerqueryurl/lookerqueryurl.go index 61ae4904a1..6f2d7b014e 100644 --- a/internal/tools/looker/lookerqueryurl/lookerqueryurl.go +++ b/internal/tools/looker/lookerqueryurl/lookerqueryurl.go @@ -120,7 +120,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -180,7 +180,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerrundashboard/lookerrundashboard.go b/internal/tools/looker/lookerrundashboard/lookerrundashboard.go index c7ac9831b6..381b75bb80 100644 --- a/internal/tools/looker/lookerrundashboard/lookerrundashboard.go +++ b/internal/tools/looker/lookerrundashboard/lookerrundashboard.go @@ -119,7 +119,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -177,7 +177,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerrunlook/lookerrunlook.go b/internal/tools/looker/lookerrunlook/lookerrunlook.go index c8cdf1ecc9..89eb6c550a 100644 --- a/internal/tools/looker/lookerrunlook/lookerrunlook.go +++ b/internal/tools/looker/lookerrunlook/lookerrunlook.go @@ -120,7 +120,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { logger, err := util.LoggerFromContext(ctx) if err != nil { return nil, fmt.Errorf("unable to get logger from ctx: %s", err) @@ -186,7 +186,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/looker/lookerupdateprojectfile/lookerupdateprojectfile.go b/internal/tools/looker/lookerupdateprojectfile/lookerupdateprojectfile.go index 957e96667c..2a4e454eb6 100644 --- a/internal/tools/looker/lookerupdateprojectfile/lookerupdateprojectfile.go +++ b/internal/tools/looker/lookerupdateprojectfile/lookerupdateprojectfile.go @@ -115,7 +115,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sdk, err := lookercommon.GetLookerSDK(t.UseClientOAuth, t.ApiSettings, t.Client, accessToken) if err != nil { return nil, fmt.Errorf("error getting sdk: %w", err) @@ -168,7 +168,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return t.UseClientOAuth } diff --git a/internal/tools/mindsdb/mindsdbexecutesql/mindsdbexecutesql.go b/internal/tools/mindsdb/mindsdbexecutesql/mindsdbexecutesql.go index b7dbcb7823..2158ca33f8 100644 --- a/internal/tools/mindsdb/mindsdbexecutesql/mindsdbexecutesql.go +++ b/internal/tools/mindsdb/mindsdbexecutesql/mindsdbexecutesql.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -193,7 +193,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mindsdb/mindsdbsql/mindsdbsql.go b/internal/tools/mindsdb/mindsdbsql/mindsdbsql.go index 58adaf433d..5c07d00235 100644 --- a/internal/tools/mindsdb/mindsdbsql/mindsdbsql.go +++ b/internal/tools/mindsdb/mindsdbsql/mindsdbsql.go @@ -119,7 +119,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -203,7 +203,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mongodb/mongodbaggregate/mongodbaggregate.go b/internal/tools/mongodb/mongodbaggregate/mongodbaggregate.go index c5ade9d127..5f5d3d0018 100644 --- a/internal/tools/mongodb/mongodbaggregate/mongodbaggregate.go +++ b/internal/tools/mongodb/mongodbaggregate/mongodbaggregate.go @@ -114,7 +114,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() pipelineString, err := parameters.PopulateTemplateWithJSON("MongoDBAggregatePipeline", t.PipelinePayload, paramsMap) @@ -185,7 +185,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mongodb/mongodbdeletemany/mongodbdeletemany.go b/internal/tools/mongodb/mongodbdeletemany/mongodbdeletemany.go index e089b35ee0..80c852fed6 100644 --- a/internal/tools/mongodb/mongodbdeletemany/mongodbdeletemany.go +++ b/internal/tools/mongodb/mongodbdeletemany/mongodbdeletemany.go @@ -119,7 +119,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() filterString, err := parameters.PopulateTemplateWithJSON("MongoDBDeleteManyFilter", t.FilterPayload, paramsMap) @@ -164,7 +164,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mongodb/mongodbdeleteone/mongodbdeleteone.go b/internal/tools/mongodb/mongodbdeleteone/mongodbdeleteone.go index 7ac903ff2f..0dd3cef756 100644 --- a/internal/tools/mongodb/mongodbdeleteone/mongodbdeleteone.go +++ b/internal/tools/mongodb/mongodbdeleteone/mongodbdeleteone.go @@ -118,7 +118,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() filterString, err := parameters.PopulateTemplateWithJSON("MongoDBDeleteOneFilter", t.FilterPayload, paramsMap) @@ -159,7 +159,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mongodb/mongodbfind/mongodbfind.go b/internal/tools/mongodb/mongodbfind/mongodbfind.go index 4aeebf1652..fb67d7fb1f 100644 --- a/internal/tools/mongodb/mongodbfind/mongodbfind.go +++ b/internal/tools/mongodb/mongodbfind/mongodbfind.go @@ -168,7 +168,7 @@ func getOptions(ctx context.Context, sortParameters parameters.Parameters, proje return opts, nil } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() filterString, err := parameters.PopulateTemplateWithJSON("MongoDBFindFilterString", t.FilterPayload, paramsMap) @@ -230,7 +230,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mongodb/mongodbfindone/mongodbfindone.go b/internal/tools/mongodb/mongodbfindone/mongodbfindone.go index bba70fe976..35260a4a14 100644 --- a/internal/tools/mongodb/mongodbfindone/mongodbfindone.go +++ b/internal/tools/mongodb/mongodbfindone/mongodbfindone.go @@ -151,7 +151,7 @@ func getOptions(sortParameters parameters.Parameters, projectPayload string, par return opts, nil } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() filterString, err := parameters.PopulateTemplateWithJSON("MongoDBFindOneFilterString", t.FilterPayload, paramsMap) @@ -210,7 +210,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mongodb/mongodbinsertmany/mongodbinsertmany.go b/internal/tools/mongodb/mongodbinsertmany/mongodbinsertmany.go index bf4c4512bd..f3cef20125 100644 --- a/internal/tools/mongodb/mongodbinsertmany/mongodbinsertmany.go +++ b/internal/tools/mongodb/mongodbinsertmany/mongodbinsertmany.go @@ -112,7 +112,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { if len(params) == 0 { return nil, errors.New("no input found") } @@ -154,7 +154,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mongodb/mongodbinsertone/mongodbinsertone.go b/internal/tools/mongodb/mongodbinsertone/mongodbinsertone.go index 8939921995..aa89b712ad 100644 --- a/internal/tools/mongodb/mongodbinsertone/mongodbinsertone.go +++ b/internal/tools/mongodb/mongodbinsertone/mongodbinsertone.go @@ -113,7 +113,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { if len(params) == 0 { return nil, errors.New("no input found") } @@ -153,7 +153,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mongodb/mongodbupdatemany/mongodbupdatemany.go b/internal/tools/mongodb/mongodbupdatemany/mongodbupdatemany.go index 31c91368ca..ebca8736e3 100644 --- a/internal/tools/mongodb/mongodbupdatemany/mongodbupdatemany.go +++ b/internal/tools/mongodb/mongodbupdatemany/mongodbupdatemany.go @@ -121,7 +121,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() filterString, err := parameters.PopulateTemplateWithJSON("MongoDBUpdateManyFilter", t.FilterPayload, paramsMap) @@ -170,7 +170,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mongodb/mongodbupdateone/mongodbupdateone.go b/internal/tools/mongodb/mongodbupdateone/mongodbupdateone.go index 4615c71be6..a2d2c909aa 100644 --- a/internal/tools/mongodb/mongodbupdateone/mongodbupdateone.go +++ b/internal/tools/mongodb/mongodbupdateone/mongodbupdateone.go @@ -122,7 +122,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() filterString, err := parameters.PopulateTemplateWithJSON("MongoDBUpdateOneFilter", t.FilterPayload, paramsMap) @@ -171,7 +171,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mssql/mssqlexecutesql/mssqlexecutesql.go b/internal/tools/mssql/mssqlexecutesql/mssqlexecutesql.go index bd9bd65049..e2bbbb4cc2 100644 --- a/internal/tools/mssql/mssqlexecutesql/mssqlexecutesql.go +++ b/internal/tools/mssql/mssqlexecutesql/mssqlexecutesql.go @@ -111,7 +111,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -183,7 +183,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mssql/mssqllisttables/mssqllisttables.go b/internal/tools/mssql/mssqllisttables/mssqllisttables.go index c838ea4fe9..4bb186db43 100644 --- a/internal/tools/mssql/mssqllisttables/mssqllisttables.go +++ b/internal/tools/mssql/mssqllisttables/mssqllisttables.go @@ -360,7 +360,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() outputFormat, _ := paramsMap["output_format"].(string) @@ -428,7 +428,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mssql/mssqlsql/mssqlsql.go b/internal/tools/mssql/mssqlsql/mssqlsql.go index 1aff17e8f4..7b18fabbcc 100644 --- a/internal/tools/mssql/mssqlsql/mssqlsql.go +++ b/internal/tools/mssql/mssqlsql/mssqlsql.go @@ -115,7 +115,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -198,7 +198,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mysql/mysqlexecutesql/mysqlexecutesql.go b/internal/tools/mysql/mysqlexecutesql/mysqlexecutesql.go index 6d0ec4a72a..0a780b621e 100644 --- a/internal/tools/mysql/mysqlexecutesql/mysqlexecutesql.go +++ b/internal/tools/mysql/mysqlexecutesql/mysqlexecutesql.go @@ -114,7 +114,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -197,7 +197,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mysql/mysqllistactivequeries/mysqllistactivequeries.go b/internal/tools/mysql/mysqllistactivequeries/mysqllistactivequeries.go index 2a7373f231..0768a305b8 100644 --- a/internal/tools/mysql/mysqllistactivequeries/mysqllistactivequeries.go +++ b/internal/tools/mysql/mysqllistactivequeries/mysqllistactivequeries.go @@ -186,7 +186,7 @@ type Tool struct { statement string } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() duration, ok := paramsMap["min_duration_secs"].(int) @@ -273,7 +273,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mysql/mysqllisttablefragmentation/mysqllisttablefragmentation.go b/internal/tools/mysql/mysqllisttablefragmentation/mysqllisttablefragmentation.go index e058669777..d0346a1a68 100644 --- a/internal/tools/mysql/mysqllisttablefragmentation/mysqllisttablefragmentation.go +++ b/internal/tools/mysql/mysqllisttablefragmentation/mysqllisttablefragmentation.go @@ -135,7 +135,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() table_schema, ok := paramsMap["table_schema"].(string) @@ -230,7 +230,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mysql/mysqllisttables/mysqllisttables.go b/internal/tools/mysql/mysqllisttables/mysqllisttables.go index b2ffc60714..e2b21aedaf 100644 --- a/internal/tools/mysql/mysqllisttables/mysqllisttables.go +++ b/internal/tools/mysql/mysqllisttables/mysqllisttables.go @@ -265,7 +265,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() tableNames, ok := paramsMap["table_names"].(string) @@ -345,7 +345,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mysql/mysqllisttablesmissinguniqueindexes/mysqllisttablesmissinguniqueindexes.go b/internal/tools/mysql/mysqllisttablesmissinguniqueindexes/mysqllisttablesmissinguniqueindexes.go index 4878f20028..4931b66a5d 100644 --- a/internal/tools/mysql/mysqllisttablesmissinguniqueindexes/mysqllisttablesmissinguniqueindexes.go +++ b/internal/tools/mysql/mysqllisttablesmissinguniqueindexes/mysqllisttablesmissinguniqueindexes.go @@ -134,7 +134,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() table_schema, ok := paramsMap["table_schema"].(string) @@ -221,7 +221,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/mysql/mysqlsql/mysqlsql.go b/internal/tools/mysql/mysqlsql/mysqlsql.go index a84239c738..4b3aed5a59 100644 --- a/internal/tools/mysql/mysqlsql/mysqlsql.go +++ b/internal/tools/mysql/mysqlsql/mysqlsql.go @@ -117,7 +117,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -198,7 +198,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/neo4j/neo4jcypher/neo4jcypher.go b/internal/tools/neo4j/neo4jcypher/neo4jcypher.go index a38f7b86ce..294ac5e90c 100644 --- a/internal/tools/neo4j/neo4jcypher/neo4jcypher.go +++ b/internal/tools/neo4j/neo4jcypher/neo4jcypher.go @@ -109,7 +109,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() config := neo4j.ExecuteQueryWithDatabase(t.Database) @@ -149,7 +149,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/neo4j/neo4jexecutecypher/neo4jexecutecypher.go b/internal/tools/neo4j/neo4jexecutecypher/neo4jexecutecypher.go index 7d809a9135..1f7fb8837e 100644 --- a/internal/tools/neo4j/neo4jexecutecypher/neo4jexecutecypher.go +++ b/internal/tools/neo4j/neo4jexecutecypher/neo4jexecutecypher.go @@ -121,7 +121,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() cypherStr, ok := paramsMap["cypher"].(string) if !ok { @@ -208,7 +208,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/neo4j/neo4jschema/neo4jschema.go b/internal/tools/neo4j/neo4jschema/neo4jschema.go index b813ba5bcf..6bef46a5e0 100644 --- a/internal/tools/neo4j/neo4jschema/neo4jschema.go +++ b/internal/tools/neo4j/neo4jschema/neo4jschema.go @@ -135,7 +135,7 @@ type Tool struct { // Invoke executes the tool's main logic: fetching the Neo4j schema. // It first checks the cache for a valid schema before extracting it from the database. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { // Check if a valid schema is already in the cache. if cachedSchema, ok := t.cache.Get("schema"); ok { if schema, ok := cachedSchema.(*types.SchemaInfo); ok { @@ -176,7 +176,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/oceanbase/oceanbaseexecutesql/oceanbaseexecutesql.go b/internal/tools/oceanbase/oceanbaseexecutesql/oceanbaseexecutesql.go index c493240ecf..3dea5ec1ca 100644 --- a/internal/tools/oceanbase/oceanbaseexecutesql/oceanbaseexecutesql.go +++ b/internal/tools/oceanbase/oceanbaseexecutesql/oceanbaseexecutesql.go @@ -109,7 +109,7 @@ type Tool struct { } // Invoke executes the SQL statement provided in the parameters. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sliceParams := params.AsSlice() sqlStr, ok := sliceParams[0].(string) if !ok { @@ -189,7 +189,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/oceanbase/oceanbasesql/oceanbasesql.go b/internal/tools/oceanbase/oceanbasesql/oceanbasesql.go index 00793824e2..c411f80c51 100644 --- a/internal/tools/oceanbase/oceanbasesql/oceanbasesql.go +++ b/internal/tools/oceanbase/oceanbasesql/oceanbasesql.go @@ -114,7 +114,7 @@ type Tool struct { } // Invoke executes the SQL statement with the provided parameters. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -200,7 +200,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/oracle/oracleexecutesql/oracleexecutesql.go b/internal/tools/oracle/oracleexecutesql/oracleexecutesql.go index 2a40112c76..23d3a9b3de 100644 --- a/internal/tools/oracle/oracleexecutesql/oracleexecutesql.go +++ b/internal/tools/oracle/oracleexecutesql/oracleexecutesql.go @@ -98,7 +98,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sqlParam, ok := paramsMap["sql"].(string) if !ok { @@ -230,7 +230,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/oracle/oraclesql/oraclesql.go b/internal/tools/oracle/oraclesql/oraclesql.go index d41f62c742..ff0cc07402 100644 --- a/internal/tools/oracle/oraclesql/oraclesql.go +++ b/internal/tools/oracle/oraclesql/oraclesql.go @@ -102,7 +102,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -230,7 +230,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgresdatabaseoverview/postgresdatabaseoverview.go b/internal/tools/postgres/postgresdatabaseoverview/postgresdatabaseoverview.go index b3472b3178..ff87062329 100644 --- a/internal/tools/postgres/postgresdatabaseoverview/postgresdatabaseoverview.go +++ b/internal/tools/postgres/postgresdatabaseoverview/postgresdatabaseoverview.go @@ -133,7 +133,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sliceParams := params.AsSlice() results, err := t.pool.Query(ctx, databaseOverviewStatement, sliceParams...) @@ -181,7 +181,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgresexecutesql/postgresexecutesql.go b/internal/tools/postgres/postgresexecutesql/postgresexecutesql.go index 92fe4ea7aa..56a204d4a2 100644 --- a/internal/tools/postgres/postgresexecutesql/postgresexecutesql.go +++ b/internal/tools/postgres/postgresexecutesql/postgresexecutesql.go @@ -113,7 +113,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -170,7 +170,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgresgetcolumncardinality/postgresgetcolumncardinality.go b/internal/tools/postgres/postgresgetcolumncardinality/postgresgetcolumncardinality.go index c0448fc17b..150d61f86b 100644 --- a/internal/tools/postgres/postgresgetcolumncardinality/postgresgetcolumncardinality.go +++ b/internal/tools/postgres/postgresgetcolumncardinality/postgresgetcolumncardinality.go @@ -149,7 +149,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newParams, err := parameters.GetParams(t.allParams, paramsMap) @@ -202,7 +202,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.authRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslistactivequeries/postgreslistactivequeries.go b/internal/tools/postgres/postgreslistactivequeries/postgreslistactivequeries.go index a4a104189a..9531041b9e 100644 --- a/internal/tools/postgres/postgreslistactivequeries/postgreslistactivequeries.go +++ b/internal/tools/postgres/postgreslistactivequeries/postgreslistactivequeries.go @@ -140,7 +140,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newParams, err := parameters.GetParams(t.allParams, paramsMap) @@ -194,7 +194,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslistavailableextensions/postgreslistavailableextensions.go b/internal/tools/postgres/postgreslistavailableextensions/postgreslistavailableextensions.go index 23309e7374..e74d1709a2 100644 --- a/internal/tools/postgres/postgreslistavailableextensions/postgreslistavailableextensions.go +++ b/internal/tools/postgres/postgreslistavailableextensions/postgreslistavailableextensions.go @@ -120,7 +120,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { results, err := t.Pool.Query(ctx, listAvailableExtensionsQuery) if err != nil { return nil, fmt.Errorf("unable to execute query: %w", err) @@ -165,7 +165,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslistindexes/postgreslistindexes.go b/internal/tools/postgres/postgreslistindexes/postgreslistindexes.go index aba26fd339..09339f3b76 100644 --- a/internal/tools/postgres/postgreslistindexes/postgreslistindexes.go +++ b/internal/tools/postgres/postgreslistindexes/postgreslistindexes.go @@ -168,7 +168,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sliceParams := params.AsSlice() results, err := t.pool.Query(ctx, listIndexesStatement, sliceParams...) @@ -216,7 +216,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslistinstalledextensions/postgreslistinstalledextensions.go b/internal/tools/postgres/postgreslistinstalledextensions/postgreslistinstalledextensions.go index 2a30799569..2ea41d9204 100644 --- a/internal/tools/postgres/postgreslistinstalledextensions/postgreslistinstalledextensions.go +++ b/internal/tools/postgres/postgreslistinstalledextensions/postgreslistinstalledextensions.go @@ -131,7 +131,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { results, err := t.Pool.Query(ctx, listAvailableExtensionsQuery) if err != nil { return nil, fmt.Errorf("unable to execute query: %w", err) @@ -176,7 +176,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslistlocks/postgreslistlocks.go b/internal/tools/postgres/postgreslistlocks/postgreslistlocks.go index dc3c26f3a6..68f6d566fe 100644 --- a/internal/tools/postgres/postgreslistlocks/postgreslistlocks.go +++ b/internal/tools/postgres/postgreslistlocks/postgreslistlocks.go @@ -147,7 +147,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newParams, err := parameters.GetParams(t.allParams, paramsMap) @@ -196,7 +196,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.authRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslistquerystats/postgreslistquerystats.go b/internal/tools/postgres/postgreslistquerystats/postgreslistquerystats.go index e7652b0f67..1544eccefb 100644 --- a/internal/tools/postgres/postgreslistquerystats/postgreslistquerystats.go +++ b/internal/tools/postgres/postgreslistquerystats/postgreslistquerystats.go @@ -149,7 +149,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newParams, err := parameters.GetParams(t.allParams, paramsMap) @@ -202,7 +202,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.authRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslistschemas/postgreslistschemas.go b/internal/tools/postgres/postgreslistschemas/postgreslistschemas.go index 5058a0122e..4bd134fea5 100644 --- a/internal/tools/postgres/postgreslistschemas/postgreslistschemas.go +++ b/internal/tools/postgres/postgreslistschemas/postgreslistschemas.go @@ -168,7 +168,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sliceParams := params.AsSlice() results, err := t.pool.Query(ctx, listSchemasStatement, sliceParams...) @@ -216,7 +216,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslistsequences/postgreslistsequences.go b/internal/tools/postgres/postgreslistsequences/postgreslistsequences.go index 9b42e4f527..2115e1a298 100644 --- a/internal/tools/postgres/postgreslistsequences/postgreslistsequences.go +++ b/internal/tools/postgres/postgreslistsequences/postgreslistsequences.go @@ -143,7 +143,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sliceParams := params.AsSlice() results, err := t.pool.Query(ctx, listSequencesStatement, sliceParams...) @@ -191,7 +191,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslisttables/postgreslisttables.go b/internal/tools/postgres/postgreslisttables/postgreslisttables.go index 8266d10b7c..470495ac13 100644 --- a/internal/tools/postgres/postgreslisttables/postgreslisttables.go +++ b/internal/tools/postgres/postgreslisttables/postgreslisttables.go @@ -191,7 +191,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() tableNames, ok := paramsMap["table_names"].(string) @@ -247,7 +247,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslisttriggers/postgreslisttriggers.go b/internal/tools/postgres/postgreslisttriggers/postgreslisttriggers.go index f1fe102911..1b90ff8cd6 100644 --- a/internal/tools/postgres/postgreslisttriggers/postgreslisttriggers.go +++ b/internal/tools/postgres/postgreslisttriggers/postgreslisttriggers.go @@ -170,7 +170,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sliceParams := params.AsSlice() results, err := t.pool.Query(ctx, listTriggersStatement, sliceParams...) @@ -218,7 +218,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslistviews/postgreslistviews.go b/internal/tools/postgres/postgreslistviews/postgreslistviews.go index e4d046589d..47aa44668d 100644 --- a/internal/tools/postgres/postgreslistviews/postgreslistviews.go +++ b/internal/tools/postgres/postgreslistviews/postgreslistviews.go @@ -129,7 +129,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newParams, err := parameters.GetParams(t.allParams, paramsMap) @@ -183,7 +183,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgreslongrunningtransactions/postgreslongrunningtransactions.go b/internal/tools/postgres/postgreslongrunningtransactions/postgreslongrunningtransactions.go index bba3ecea28..1286bd57f6 100644 --- a/internal/tools/postgres/postgreslongrunningtransactions/postgreslongrunningtransactions.go +++ b/internal/tools/postgres/postgreslongrunningtransactions/postgreslongrunningtransactions.go @@ -157,7 +157,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newParams, err := parameters.GetParams(t.allParams, paramsMap) @@ -206,7 +206,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.authRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgresreplicationstats/postgresreplicationstats.go b/internal/tools/postgres/postgresreplicationstats/postgresreplicationstats.go index 569cd339f1..2ef3e7fe3e 100644 --- a/internal/tools/postgres/postgresreplicationstats/postgresreplicationstats.go +++ b/internal/tools/postgres/postgresreplicationstats/postgresreplicationstats.go @@ -144,7 +144,7 @@ func (t Tool) ToConfig() tools.ToolConfig { return t.Config } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newParams, err := parameters.GetParams(t.allParams, paramsMap) @@ -193,7 +193,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.authRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/postgres/postgressql/postgressql.go b/internal/tools/postgres/postgressql/postgressql.go index 597790c6d1..5e8d871372 100644 --- a/internal/tools/postgres/postgressql/postgressql.go +++ b/internal/tools/postgres/postgressql/postgressql.go @@ -116,7 +116,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -172,7 +172,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/redis/redis.go b/internal/tools/redis/redis.go index c8cc21f2a2..a530eec167 100644 --- a/internal/tools/redis/redis.go +++ b/internal/tools/redis/redis.go @@ -104,7 +104,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { cmds, err := replaceCommandsParams(t.Commands, t.Parameters, params) if err != nil { return nil, fmt.Errorf("error replacing commands' parameters: %s", err) @@ -165,7 +165,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/serverlessspark/serverlesssparkcancelbatch/serverlesssparkcancelbatch.go b/internal/tools/serverlessspark/serverlesssparkcancelbatch/serverlesssparkcancelbatch.go index a0e36574ae..f0240f5ebd 100644 --- a/internal/tools/serverlessspark/serverlesssparkcancelbatch/serverlesssparkcancelbatch.go +++ b/internal/tools/serverlessspark/serverlesssparkcancelbatch/serverlesssparkcancelbatch.go @@ -108,7 +108,7 @@ type Tool struct { } // Invoke executes the tool's operation. -func (t *Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t *Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { client, err := t.Source.GetOperationsClient(ctx) if err != nil { return nil, fmt.Errorf("failed to get operations client: %w", err) @@ -152,7 +152,7 @@ func (t *Tool) Authorized(services []string) bool { return tools.IsAuthorized(t.AuthRequired, services) } -func (t *Tool) RequiresClientAuthorization() bool { +func (t *Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { // Client OAuth not supported, rely on ADCs. return false } diff --git a/internal/tools/serverlessspark/serverlesssparkgetbatch/serverlesssparkgetbatch.go b/internal/tools/serverlessspark/serverlesssparkgetbatch/serverlesssparkgetbatch.go index 4970dc1217..b94581d903 100644 --- a/internal/tools/serverlessspark/serverlesssparkgetbatch/serverlesssparkgetbatch.go +++ b/internal/tools/serverlessspark/serverlesssparkgetbatch/serverlesssparkgetbatch.go @@ -110,7 +110,7 @@ type Tool struct { } // Invoke executes the tool's operation. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { client := t.Source.GetBatchControllerClient() paramMap := params.AsMap() @@ -161,7 +161,7 @@ func (t Tool) Authorized(services []string) bool { return tools.IsAuthorized(t.AuthRequired, services) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { // Client OAuth not supported, rely on ADCs. return false } diff --git a/internal/tools/serverlessspark/serverlesssparklistbatches/serverlesssparklistbatches.go b/internal/tools/serverlessspark/serverlesssparklistbatches/serverlesssparklistbatches.go index 0dddfd8db8..a456e5fdbb 100644 --- a/internal/tools/serverlessspark/serverlesssparklistbatches/serverlesssparklistbatches.go +++ b/internal/tools/serverlessspark/serverlesssparklistbatches/serverlesssparklistbatches.go @@ -127,7 +127,7 @@ type Batch struct { } // Invoke executes the tool's operation. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { client := t.Source.GetBatchControllerClient() parent := fmt.Sprintf("projects/%s/locations/%s", t.Source.Project, t.Source.Location) @@ -197,7 +197,7 @@ func (t Tool) Authorized(services []string) bool { return tools.IsAuthorized(t.AuthRequired, services) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { // Client OAuth not supported, rely on ADCs. return false } diff --git a/internal/tools/singlestore/singlestoreexecutesql/singlestoreexecutesql.go b/internal/tools/singlestore/singlestoreexecutesql/singlestoreexecutesql.go index d0a891b815..64f3ac68cb 100644 --- a/internal/tools/singlestore/singlestoreexecutesql/singlestoreexecutesql.go +++ b/internal/tools/singlestore/singlestoreexecutesql/singlestoreexecutesql.go @@ -117,7 +117,7 @@ func (t Tool) ToConfig() tools.ToolConfig { } // Invoke executes the provided SQL query using the tool's database connection and returns the results. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -199,7 +199,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/singlestore/singlestoresql/singlestoresql.go b/internal/tools/singlestore/singlestoresql/singlestoresql.go index 4a7047d27f..bdb3e9f8b6 100644 --- a/internal/tools/singlestore/singlestoresql/singlestoresql.go +++ b/internal/tools/singlestore/singlestoresql/singlestoresql.go @@ -145,7 +145,7 @@ func (t Tool) ToConfig() tools.ToolConfig { // Returns: // - A slice of maps, where each map represents a row with column names as keys. // - An error if template resolution, parameter extraction, query execution, or result processing fails. -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -226,7 +226,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/spanner/spannerexecutesql/spannerexecutesql.go b/internal/tools/spanner/spannerexecutesql/spannerexecutesql.go index 5cd1f1230e..528e633fba 100644 --- a/internal/tools/spanner/spannerexecutesql/spannerexecutesql.go +++ b/internal/tools/spanner/spannerexecutesql/spannerexecutesql.go @@ -137,7 +137,7 @@ func processRows(iter *spanner.RowIterator) ([]any, error) { return out, nil } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -193,7 +193,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/spanner/spannerlistgraphs/spannerlistgraphs.go b/internal/tools/spanner/spannerlistgraphs/spannerlistgraphs.go index 434fe93d18..d4fd0843fa 100644 --- a/internal/tools/spanner/spannerlistgraphs/spannerlistgraphs.go +++ b/internal/tools/spanner/spannerlistgraphs/spannerlistgraphs.go @@ -165,7 +165,7 @@ func processRows(iter *spanner.RowIterator) ([]any, error) { return out, nil } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() graphNames, _ := paramsMap["graph_names"].(string) @@ -210,7 +210,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/spanner/spannerlisttables/spannerlisttables.go b/internal/tools/spanner/spannerlisttables/spannerlisttables.go index 24c054e454..f3096cd713 100644 --- a/internal/tools/spanner/spannerlisttables/spannerlisttables.go +++ b/internal/tools/spanner/spannerlisttables/spannerlisttables.go @@ -172,7 +172,7 @@ func (t Tool) getStatement() string { } } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() // Get the appropriate SQL statement based on dialect @@ -236,7 +236,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/spanner/spannersql/spannersql.go b/internal/tools/spanner/spannersql/spannersql.go index 9c5deebc0e..42cdd6559c 100644 --- a/internal/tools/spanner/spannersql/spannersql.go +++ b/internal/tools/spanner/spannersql/spannersql.go @@ -152,7 +152,7 @@ func processRows(iter *spanner.RowIterator) ([]any, error) { return out, nil } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -236,7 +236,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/sqlite/sqliteexecutesql/sqliteexecutesql.go b/internal/tools/sqlite/sqliteexecutesql/sqliteexecutesql.go index 113d1e6d84..848ae87125 100644 --- a/internal/tools/sqlite/sqliteexecutesql/sqliteexecutesql.go +++ b/internal/tools/sqlite/sqliteexecutesql/sqliteexecutesql.go @@ -109,7 +109,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sql, ok := params.AsMap()["sql"].(string) if !ok { return nil, fmt.Errorf("missing or invalid 'sql' parameter") @@ -201,7 +201,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/sqlite/sqliteexecutesql/sqliteexecutesql_test.go b/internal/tools/sqlite/sqliteexecutesql/sqliteexecutesql_test.go index da4a0a7139..acce6527e4 100644 --- a/internal/tools/sqlite/sqliteexecutesql/sqliteexecutesql_test.go +++ b/internal/tools/sqlite/sqliteexecutesql/sqliteexecutesql_test.go @@ -311,7 +311,7 @@ func TestTool_Invoke(t *testing.T) { Parameters: tt.fields.Parameters, DB: tt.fields.DB, } - got, err := tr.Invoke(tt.args.ctx, tt.args.params, tt.args.accessToken) + got, err := tr.Invoke(tt.args.ctx, nil, tt.args.params, tt.args.accessToken) if (err != nil) != tt.wantErr { t.Errorf("Tool.Invoke() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/internal/tools/sqlite/sqlitesql/sqlitesql.go b/internal/tools/sqlite/sqlitesql/sqlitesql.go index 39f2e5fb68..7a2f32ed40 100644 --- a/internal/tools/sqlite/sqlitesql/sqlitesql.go +++ b/internal/tools/sqlite/sqlitesql/sqlitesql.go @@ -113,7 +113,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -200,7 +200,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/sqlite/sqlitesql/sqlitesql_test.go b/internal/tools/sqlite/sqlitesql/sqlitesql_test.go index 47befc6d57..d446e20496 100644 --- a/internal/tools/sqlite/sqlitesql/sqlitesql_test.go +++ b/internal/tools/sqlite/sqlitesql/sqlitesql_test.go @@ -313,7 +313,7 @@ func TestTool_Invoke(t *testing.T) { AllParams: tt.fields.AllParams, Db: tt.fields.Db, } - got, err := tr.Invoke(tt.args.ctx, tt.args.params, tt.args.accessToken) + got, err := tr.Invoke(tt.args.ctx, nil, tt.args.params, tt.args.accessToken) if (err != nil) != tt.wantErr { t.Errorf("Tool.Invoke() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/internal/tools/tidb/tidbexecutesql/tidbexecutesql.go b/internal/tools/tidb/tidbexecutesql/tidbexecutesql.go index 38eecca684..45b53714df 100644 --- a/internal/tools/tidb/tidbexecutesql/tidbexecutesql.go +++ b/internal/tools/tidb/tidbexecutesql/tidbexecutesql.go @@ -108,7 +108,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() sql, ok := paramsMap["sql"].(string) if !ok { @@ -194,7 +194,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/tidb/tidbsql/tidbsql.go b/internal/tools/tidb/tidbsql/tidbsql.go index 6148978e7e..01c6ef2cd0 100644 --- a/internal/tools/tidb/tidbsql/tidbsql.go +++ b/internal/tools/tidb/tidbsql/tidbsql.go @@ -113,7 +113,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -206,7 +206,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/tools.go b/internal/tools/tools.go index 6985dadd24..bf99b3f33a 100644 --- a/internal/tools/tools.go +++ b/internal/tools/tools.go @@ -85,16 +85,23 @@ func (token AccessToken) ParseBearerToken() (string, error) { } type Tool interface { - Invoke(context.Context, parameters.ParamValues, AccessToken) (any, error) + Invoke(context.Context, SourceProvider, parameters.ParamValues, AccessToken) (any, error) ParseParams(map[string]any, map[string]map[string]any) (parameters.ParamValues, error) Manifest() Manifest McpManifest() McpManifest Authorized([]string) bool - RequiresClientAuthorization() bool + RequiresClientAuthorization(SourceProvider) bool ToConfig() ToolConfig GetAuthTokenHeaderName() string } +// SourceProvider defines the minimal view of the server.ResourceManager +// that the Tool package needs. +// This is implemented to prevent import cycles. +type SourceProvider interface { + GetSource(sourceName string) (sources.Source, bool) +} + // Manifest is the representation of tools sent to Client SDKs. type Manifest struct { Description string `json:"description"` diff --git a/internal/tools/trino/trinoexecutesql/trinoexecutesql.go b/internal/tools/trino/trinoexecutesql/trinoexecutesql.go index cb1ad24f31..771a880d81 100644 --- a/internal/tools/trino/trinoexecutesql/trinoexecutesql.go +++ b/internal/tools/trino/trinoexecutesql/trinoexecutesql.go @@ -107,7 +107,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { sliceParams := params.AsSlice() sql, ok := sliceParams[0].(string) if !ok { @@ -179,7 +179,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/trino/trinosql/trinosql.go b/internal/tools/trino/trinosql/trinosql.go index 776f1509fe..9528b6dc33 100644 --- a/internal/tools/trino/trinosql/trinosql.go +++ b/internal/tools/trino/trinosql/trinosql.go @@ -112,7 +112,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -188,7 +188,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/utility/wait/wait.go b/internal/tools/utility/wait/wait.go index 43480dcf89..8c49762b34 100644 --- a/internal/tools/utility/wait/wait.go +++ b/internal/tools/utility/wait/wait.go @@ -80,7 +80,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() durationStr, ok := paramsMap["duration"].(string) @@ -114,7 +114,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return true } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/valkey/valkey.go b/internal/tools/valkey/valkey.go index 5d6d46a36f..8b350f6375 100644 --- a/internal/tools/valkey/valkey.go +++ b/internal/tools/valkey/valkey.go @@ -103,7 +103,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { // Replace parameters commands, err := replaceCommandsParams(t.Commands, t.Parameters, params) if err != nil { @@ -193,7 +193,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/internal/tools/yugabytedbsql/yugabytedbsql.go b/internal/tools/yugabytedbsql/yugabytedbsql.go index 9bfb90e4ff..4564a62e05 100644 --- a/internal/tools/yugabytedbsql/yugabytedbsql.go +++ b/internal/tools/yugabytedbsql/yugabytedbsql.go @@ -109,7 +109,7 @@ type Tool struct { mcpManifest tools.McpManifest } -func (t Tool) Invoke(ctx context.Context, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { +func (t Tool) Invoke(ctx context.Context, resourceMgr tools.SourceProvider, params parameters.ParamValues, accessToken tools.AccessToken) (any, error) { paramsMap := params.AsMap() newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap) if err != nil { @@ -165,7 +165,7 @@ func (t Tool) Authorized(verifiedAuthServices []string) bool { return tools.IsAuthorized(t.AuthRequired, verifiedAuthServices) } -func (t Tool) RequiresClientAuthorization() bool { +func (t Tool) RequiresClientAuthorization(resourceMgr tools.SourceProvider) bool { return false } diff --git a/tests/clickhouse/clickhouse_integration_test.go b/tests/clickhouse/clickhouse_integration_test.go index 0e81402c6a..5391590edc 100644 --- a/tests/clickhouse/clickhouse_integration_test.go +++ b/tests/clickhouse/clickhouse_integration_test.go @@ -403,7 +403,7 @@ func TestClickHouseSQLTool(t *testing.T) { t.Fatalf("Failed to initialize tool: %v", err) } - result, err := tool.Invoke(ctx, parameters.ParamValues{}, "") + result, err := tool.Invoke(ctx, nil, parameters.ParamValues{}, "") if err != nil { t.Fatalf("Failed to invoke tool: %v", err) } @@ -444,7 +444,7 @@ func TestClickHouseSQLTool(t *testing.T) { {Name: "min_age", Value: 28}, } - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Fatalf("Failed to invoke tool: %v", err) } @@ -485,7 +485,7 @@ func TestClickHouseSQLTool(t *testing.T) { {Name: "id", Value: 999}, // Non-existent ID } - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Fatalf("Failed to invoke tool: %v", err) } @@ -519,7 +519,7 @@ func TestClickHouseSQLTool(t *testing.T) { t.Fatalf("Failed to initialize tool: %v", err) } - _, err = tool.Invoke(ctx, parameters.ParamValues{}, "") + _, err = tool.Invoke(ctx, nil, parameters.ParamValues{}, "") if err == nil { t.Error("Expected error for invalid SQL, got nil") } @@ -574,7 +574,7 @@ func TestClickHouseExecuteSQLTool(t *testing.T) { {Name: "sql", Value: createSQL}, } - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Fatalf("Failed to create table: %v", err) } @@ -612,7 +612,7 @@ func TestClickHouseExecuteSQLTool(t *testing.T) { {Name: "sql", Value: insertSQL}, } - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Fatalf("Failed to insert data: %v", err) } @@ -650,7 +650,7 @@ func TestClickHouseExecuteSQLTool(t *testing.T) { {Name: "sql", Value: selectSQL}, } - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Fatalf("Failed to select data: %v", err) } @@ -688,7 +688,7 @@ func TestClickHouseExecuteSQLTool(t *testing.T) { {Name: "sql", Value: dropSQL}, } - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Fatalf("Failed to drop table: %v", err) } @@ -726,7 +726,7 @@ func TestClickHouseExecuteSQLTool(t *testing.T) { {Name: "sql", Value: ""}, } - _, err = tool.Invoke(ctx, params, "") + _, err = tool.Invoke(ctx, nil, params, "") if err == nil { t.Error("Expected error for empty SQL parameter, got nil") } else { @@ -758,7 +758,7 @@ func TestClickHouseExecuteSQLTool(t *testing.T) { {Name: "sql", Value: injectionSQL}, } - _, err = tool.Invoke(ctx, params, "") + _, err = tool.Invoke(ctx, nil, params, "") // This should either fail or only execute the first statement // dont check the specific error as behavior may vary _ = err // We're not checking the error intentionally @@ -807,7 +807,7 @@ func TestClickHouseEdgeCases(t *testing.T) { {Name: "sql", Value: longQuery}, } - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Fatalf("Failed to execute long query: %v", err) } @@ -862,7 +862,7 @@ func TestClickHouseEdgeCases(t *testing.T) { t.Fatalf("Failed to initialize tool: %v", err) } - result, err := tool.Invoke(ctx, parameters.ParamValues{}, "") + result, err := tool.Invoke(ctx, nil, parameters.ParamValues{}, "") if err != nil { t.Fatalf("Failed to select null values: %v", err) } @@ -916,7 +916,7 @@ func TestClickHouseEdgeCases(t *testing.T) { {Name: "limit", Value: n + 1}, } - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Errorf("Concurrent query %d failed: %v", n, err) return @@ -1056,7 +1056,7 @@ func TestClickHouseListDatabasesTool(t *testing.T) { params := parameters.ParamValues{} - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Fatalf("Failed to list databases: %v", err) } @@ -1170,7 +1170,7 @@ func TestClickHouseListTablesTool(t *testing.T) { {Name: "database", Value: testDBName}, } - result, err := tool.Invoke(ctx, params, "") + result, err := tool.Invoke(ctx, nil, params, "") if err != nil { t.Fatalf("Failed to list tables: %v", err) } @@ -1234,7 +1234,7 @@ func TestClickHouseListTablesTool(t *testing.T) { params := parameters.ParamValues{} - _, err = tool.Invoke(ctx, params, "") + _, err = tool.Invoke(ctx, nil, params, "") if err == nil { t.Error("Expected error for missing database parameter, got nil") } else { diff --git a/tests/cloudmonitoring/cloud_monitoring_integration_test.go b/tests/cloudmonitoring/cloud_monitoring_integration_test.go index e451e9686c..40bfa26234 100644 --- a/tests/cloudmonitoring/cloud_monitoring_integration_test.go +++ b/tests/cloudmonitoring/cloud_monitoring_integration_test.go @@ -64,7 +64,7 @@ func TestTool_Invoke(t *testing.T) { } // Invoke the tool - result, err := tool.Invoke(context.Background(), params, "") + result, err := tool.Invoke(context.Background(), nil, params, "") if err != nil { t.Fatalf("Invoke() error = %v", err) } @@ -110,7 +110,7 @@ func TestTool_Invoke_Error(t *testing.T) { } // Invoke the tool - _, err := tool.Invoke(context.Background(), params, "") + _, err := tool.Invoke(context.Background(), nil, params, "") if err == nil { t.Fatal("Invoke() error = nil, want error") }