@@ -16,12 +16,12 @@ import (
1616 "github.com/spf13/cobra"
1717)
1818
19- //go:embed docs
20- var docs embed.FS
21-
2219//go:embed prompts/update.md
2320var updatePrompt string
2421
22+ //go:embed docs
23+ var docs embed.FS
24+
2525var cmd = & cobra.Command {
2626 Use : "goreleaser-mcp" ,
2727 Short : "The GoReleaser MCP server" ,
@@ -49,6 +49,11 @@ var cmd = &cobra.Command{
4949 }, nil
5050 })
5151
52+ mcp .AddTool (server , & mcp.Tool {
53+ Name : "check" ,
54+ Description : "Checks a GoReleaser configuration for errors or deprecations" ,
55+ }, checkTool )
56+
5257 fsys , err := fs .Sub (docs , "docs" )
5358 if err != nil {
5459 return err
@@ -83,11 +88,6 @@ var cmd = &cobra.Command{
8388 return err
8489 }
8590
86- mcp .AddTool (server , & mcp.Tool {
87- Name : "check" ,
88- Description : "Checks a GoReleaser configuration for errors or deprecations" ,
89- }, checkTool )
90-
9191 return server .Run (cmd .Context (), & mcp.StdioTransport {})
9292 },
9393}
@@ -113,7 +113,9 @@ type (
113113 Configuration string `json:"configuration,omitempty" jsonschema:"Path to the goreleaser YAML configuration file. If empty will use the default."`
114114 }
115115 checkOutput struct {
116- Message string `json:"message"`
116+ Message string `json:"message"`
117+ Filepath string `json:"filepath"`
118+ Instructions string `json:"instructions,omitempty"`
117119 }
118120)
119121
@@ -144,12 +146,17 @@ func openConfig(name string) (string, []byte, error) {
144146 return "" , nil , fmt .Errorf ("could not find any configuration file" )
145147}
146148
147- func checkTool (ctx context.Context , _ * mcp.CallToolRequest , args checkArgs ) (* mcp.CallToolResult , checkOutput , error ) {
149+ func checkTool (ctx context.Context , req * mcp.CallToolRequest , args checkArgs ) (* mcp.CallToolResult , checkOutput , error ) {
148150 name , bts , err := openConfig (args .Configuration )
149151 if err != nil {
150152 return nil , checkOutput {}, fmt .Errorf ("could not check configuration: %w" , err )
151153 }
152154
155+ _ = req .Session .Log (ctx , & mcp.LoggingMessageParams {
156+ Data : fmt .Sprintf ("using configuration file at %s" , name ),
157+ Level : mcp .LoggingLevel ("info" ),
158+ })
159+
153160 var cfg config.Project
154161 if err := yaml .UnmarshalStrict (bts , & cfg ); err != nil {
155162 return nil , checkOutput {}, fmt .Errorf ("invalid configuration file: %s: %w" , name , err )
@@ -158,16 +165,32 @@ func checkTool(ctx context.Context, _ *mcp.CallToolRequest, args checkArgs) (*mc
158165 deprecations := findDeprecated (cfg )
159166 if len (deprecations ) == 0 {
160167 return nil , checkOutput {
161- Message : fmt .Sprintf ("Configuration at %q is valid!" , name ),
168+ Message : "Configuration is valid!" ,
169+ Filepath : name ,
170+ }, nil
171+ }
172+
173+ res , err := req .Session .Elicit (ctx , & mcp.ElicitParams {
174+ Message : "You have deprecated configuration options in your GoReleaser config. Do you want to fix it?" ,
175+ RequestedSchema : nil ,
176+ })
177+ if err != nil || res .Action == "decline" {
178+ return nil , checkOutput {
179+ Message : "Configuration is valid, but uses deprecated options" ,
180+ Filepath : name ,
162181 }, nil
163182 }
164183
184+ // if action is 'cancel' let's just add the instructions anyway...
165185 var sb strings.Builder
166- sb .WriteString ("Configuration is valid, but uses the following deprecated properties:\n " )
186+ sb .WriteString ("# Deprecated Options\n \n " )
187+ sb .WriteString ("Here's the instructions to fix each of deprecation:\n \n " )
167188 for _ , key := range slices .Collect (maps .Keys (deprecations )) {
168189 sb .WriteString (fmt .Sprintf ("## %s\n \n Instructions: %s\n \n " , key , instructions [key ]))
169190 }
170191 return nil , checkOutput {
171- Message : sb .String (),
192+ Message : "Configuration is valid, but uses deprecated options" ,
193+ Instructions : sb .String (),
194+ Filepath : name ,
172195 }, nil
173196}
0 commit comments