@@ -3,8 +3,8 @@ package scan
3
3
import (
4
4
"context"
5
5
"errors"
6
+ "fmt"
6
7
"os"
7
- "strings"
8
8
9
9
"path/filepath"
10
10
@@ -16,6 +16,9 @@ import (
16
16
17
17
func (t * ScanTools ) scanWithAquaPlatform (ctx context.Context , args []string , creds creds.AquaCreds ) (* mcp.CallToolResult , error ) {
18
18
19
+ // add quiet to reduce the noise
20
+ args = append (args , "--quiet" )
21
+
19
22
logger := log .WithPrefix ("aqua" )
20
23
logger .Debug ("Scanning with args" , log .Any ("args" , args ))
21
24
logger .Info ("Using Aqua platform for scanning" )
@@ -66,14 +69,15 @@ func (t *ScanTools) scanWithAquaPlatform(ctx context.Context, args []string, cre
66
69
67
70
logger .Debug ("Environment" , log .Any ("ENV" , os .Environ ()))
68
71
69
- tempFile := filepath .Join (os .TempDir (), "trivy-mcp-scan.results.json" )
72
+ filename := "trivy-mcp-scan.results.json"
73
+ resultsFilePath := filepath .Join (os .TempDir (), filename )
70
74
defer func () {
71
- if err := os .Remove (tempFile ); err != nil {
75
+ if err := os .Remove (resultsFilePath ); err != nil {
72
76
logger .Error ("Failed to remove temp file" , log .Err (err ))
73
77
}
74
78
}()
75
79
76
- if err := os .Setenv ("AQUA_ASSURANCE_EXPORT" , tempFile ); err != nil {
80
+ if err := os .Setenv ("AQUA_ASSURANCE_EXPORT" , resultsFilePath ); err != nil {
77
81
logger .Error ("Failed to set Aqua assurance export in environment variables" , log .Err (err ))
78
82
return nil , err
79
83
}
@@ -83,11 +87,15 @@ func (t *ScanTools) scanWithAquaPlatform(ctx context.Context, args []string, cre
83
87
return nil , err
84
88
}
85
89
86
- sb := strings.Builder {}
87
- sb .WriteString ("Aqua scan results:\n " )
88
- sb .WriteString ("====================================\n " )
89
- sb .WriteString ("Scan completed successfully\n " )
90
-
91
- return mcp .NewToolResultText (sb .String ()), nil
90
+ return mcp .NewToolResultResource (
91
+ fmt .Sprintf (`The results can be found in the file "%s", which is found at "%s" \n
92
+ Summarise the contents of the file and report it back to the user in a nicely formatted way.\n
93
+ It is important that the output MUST include the ID and the severity of the issues to inform the user of the issues.
94
+ ` , filename , resultsFilePath ),
95
+ mcp.TextResourceContents {
96
+ URI : resultsFilePath ,
97
+ MIMEType : "application/json" ,
98
+ },
99
+ ), nil
92
100
93
101
}
0 commit comments