Skip to content

Commit 991e539

Browse files
feat(tools/looker-run-look): modify run_look to show query origin (googleapis#1860)
… as coming from MCP Toolbox
1 parent cd4ae81 commit 991e539

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

internal/tools/looker/lookerrunlook/lookerrunlook.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,30 @@ func (t Tool) Invoke(ctx context.Context, params tools.ParamValues, accessToken
126126

127127
look_id := paramsMap["look_id"].(string)
128128
limit := int64(paramsMap["limit"].(int))
129+
limitStr := fmt.Sprintf("%d", limit)
129130

130131
sdk, err := lookercommon.GetLookerSDK(t.UseClientOAuth, t.ApiSettings, t.Client, accessToken)
131132
if err != nil {
132133
return nil, fmt.Errorf("error getting sdk: %w", err)
133134
}
134-
req := v4.RequestRunLook{
135-
LookId: look_id,
136-
ResultFormat: "json",
137-
Limit: &limit,
135+
136+
look, err := sdk.Look(look_id, "", t.ApiSettings)
137+
if err != nil {
138+
return nil, fmt.Errorf("error getting look definition: %s", err)
138139
}
139-
resp, err := sdk.RunLook(req, t.ApiSettings)
140+
141+
wq := v4.WriteQuery{
142+
Model: look.Query.Model,
143+
View: look.Query.View,
144+
Fields: look.Query.Fields,
145+
Pivots: look.Query.Pivots,
146+
Filters: look.Query.Filters,
147+
Sorts: look.Query.Sorts,
148+
QueryTimezone: look.Query.QueryTimezone,
149+
Limit: &limitStr,
150+
}
151+
152+
resp, err := lookercommon.RunInlineQuery(ctx, sdk, &wq, "json", t.ApiSettings)
140153
if err != nil {
141154
return nil, fmt.Errorf("error making run_look request: %s", err)
142155
}

0 commit comments

Comments
 (0)