Skip to content

Commit b751603

Browse files
lionelloKevyVo
andauthored
fix(mcp): return URLs to agent (#1433)
Co-authored-by: Kevin Vo <[email protected]>
1 parent 4994bc7 commit b751603

File tree

8 files changed

+16
-8
lines changed

8 files changed

+16
-8
lines changed

src/pkg/mcp/tools/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func CanIUseProvider(ctx context.Context, grpcClient client.FabricClient, provid
8484
func providerNotConfiguredError(providerId client.ProviderID) error {
8585
if providerId == client.ProviderAuto {
8686
term.Error("No provider configured")
87-
return errors.New("No provider configured, please use the appropriate prompts and type /mcp.defang.AWS_Setup for AWS, /mcp.defang.GCP_Setup for GCP, or /mcp.defang.Playground_Setup for Playground in the chat.")
87+
return errors.New("no provider is configured; please type in the chat /defang.AWS_Setup for AWS, /defang.GCP_Setup for GCP, or /defang.Playground_Setup for Playground.")
8888
}
8989
return nil
9090
}

src/pkg/mcp/tools/deploy.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"os"
8+
"strings"
89

910
"github.com/pkg/browser"
1011

@@ -182,6 +183,13 @@ func handleDeployTool(ctx context.Context, request mcp.CallToolRequest, provider
182183
term.Debugf(" Status: %s", serviceInfo.Status)
183184
}
184185

186+
urls := strings.Builder{}
187+
for _, serviceInfo := range deployResp.Services {
188+
if serviceInfo.PublicFqdn != "" {
189+
urls.WriteString(fmt.Sprintf("- %s: %s %s\n", serviceInfo.Service.Name, serviceInfo.PublicFqdn, serviceInfo.Domainname))
190+
}
191+
}
192+
185193
// Return the etag data as text
186-
return mcp.NewToolResultText(fmt.Sprintf("%s to follow the deployment of %s, with the deployment ID of %s", portal, project.Name, deployResp.Etag)), nil
194+
return mcp.NewToolResultText(fmt.Sprintf("%s to follow the deployment of %s, with the deployment ID of %s:\n%s", portal, project.Name, deployResp.Etag, urls.String())), nil
187195
}

src/pkg/mcp/tools/deploy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func TestHandleDeployTool(t *testing.T) {
213213
providerID: client.ProviderAuto,
214214
setupMock: func(m *MockDeployCLI) {},
215215
expectError: true,
216-
expectedErrorContains: "No provider configured",
216+
expectedErrorContains: "no provider is configured",
217217
},
218218
}
219219

src/pkg/mcp/tools/destroy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func TestHandleDestroyTool(t *testing.T) {
180180
providerID: client.ProviderAuto,
181181
setupMock: func(m *MockDestroyCLI) {},
182182
expectError: true,
183-
expectedErrorContains: "No provider configured",
183+
expectedErrorContains: "no provider is configured",
184184
},
185185
}
186186

src/pkg/mcp/tools/listConfig_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestHandleListConfigTool(t *testing.T) {
9797
setupMock: func(m *MockListConfigCLI) {},
9898
expectError: true,
9999
expectErrorResult: true,
100-
expectedErrorContains: "No provider configured",
100+
expectedErrorContains: "no provider is configured",
101101
},
102102
{
103103
name: "connect_error",

src/pkg/mcp/tools/removeConfig_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func TestHandleRemoveConfigTool(t *testing.T) {
8181
setupMock: func(m *MockRemoveConfigCLI) {},
8282
expectError: true,
8383
expectErrorResult: true,
84-
expectedErrorContains: "No provider configured",
84+
expectedErrorContains: "no provider is configured",
8585
},
8686
{
8787
name: "missing_working_directory",

src/pkg/mcp/tools/services_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestHandleServicesToolWithMockCLI(t *testing.T) {
145145
mockDeploymentInfo: &MockDeploymentInfo{},
146146
expectedError: true,
147147
expectedResultError: true,
148-
errorMessage: "No provider configured",
148+
errorMessage: "no provider is configured",
149149
expectedGetServices: false,
150150
},
151151
{

src/pkg/mcp/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
)
1212

1313
const DocumentationEndpoint = "data"
14-
// AskDefangBaseURL is a var so tests can override it
1514

15+
// AskDefangBaseURL is a var so tests can override it
1616
var AskDefangBaseURL = "https://ask.defang.io"
1717
var KnowledgeBaseDir = client.StateDir
1818

0 commit comments

Comments
 (0)