@@ -2,21 +2,20 @@ package tools
2
2
3
3
import (
4
4
"context"
5
- "encoding/json"
6
5
"fmt"
7
6
8
- "github.com/mark3labs/mcp-go/mcp"
9
7
"github.com/mark3labs/mcp-go/server"
10
8
11
9
"github.com/grafana/grafana-openapi-client-go/client/search"
10
+ "github.com/grafana/grafana-openapi-client-go/models"
12
11
mcpgrafana "github.com/grafana/mcp-grafana"
13
12
)
14
13
15
14
type SearchDashboardsParams struct {
16
15
Query string `json:"query" jsonschema:"description=The query to search for"`
17
16
}
18
17
19
- func searchDashboards (ctx context.Context , args SearchDashboardsParams ) (* mcp. CallToolResult , error ) {
18
+ func searchDashboards (ctx context.Context , args SearchDashboardsParams ) (models. HitList , error ) {
20
19
c := mcpgrafana .GrafanaClientFromContext (ctx )
21
20
params := search .NewSearchParamsWithContext (ctx )
22
21
if args .Query != "" {
@@ -26,11 +25,7 @@ func searchDashboards(ctx context.Context, args SearchDashboardsParams) (*mcp.Ca
26
25
if err != nil {
27
26
return nil , fmt .Errorf ("search dashboards for %+v: %w" , c , err )
28
27
}
29
- b , err := json .Marshal (search .Payload )
30
- if err != nil {
31
- return nil , fmt .Errorf ("marshal search results: %w" , err )
32
- }
33
- return mcp .NewToolResultText (string (b )), nil
28
+ return search .Payload , nil
34
29
}
35
30
36
31
var SearchDashboards = mcpgrafana .MustTool (
0 commit comments