@@ -19,7 +19,7 @@ import (
19
19
)
20
20
21
21
// setupDeployTool configures and adds the deployment tool to the MCP server
22
- func setupDeployTool (s * server.MCPServer , cluster string ) {
22
+ func setupDeployTool (s * server.MCPServer , cluster string , providerId cliClient. ProviderID ) {
23
23
term .Debug ("Creating deployment tool" )
24
24
composeUpTool := mcp .NewTool ("deploy" ,
25
25
mcp .WithDescription ("Deploy services using defang" ),
@@ -65,13 +65,18 @@ func setupDeployTool(s *server.MCPServer, cluster string) {
65
65
client .Track ("MCP Deploy Tool" )
66
66
67
67
term .Debug ("Function invoked: cli.NewProvider" )
68
- provider , err := cli .NewProvider (ctx , cliClient . ProviderDefang , client )
68
+ provider , err := cli .NewProvider (ctx , providerId , client )
69
69
if err != nil {
70
70
term .Error ("Failed to get new provider" , "error" , err )
71
-
72
71
return mcp .NewToolResultErrorFromErr ("Failed to get new provider" , err ), nil
73
72
}
74
73
74
+ err = canIUseProvider (ctx , client , project .Name , provider )
75
+ if err != nil {
76
+ term .Error ("Failed to use provider" , "error" , err )
77
+ return mcp .NewToolResultErrorFromErr ("Failed to use provider" , err ), nil
78
+ }
79
+
75
80
// Deploy the services
76
81
term .Debugf ("Deploying services for project %s..." , project .Name )
77
82
@@ -99,27 +104,34 @@ func setupDeployTool(s *server.MCPServer, cluster string) {
99
104
return mcp .NewToolResultText (fmt .Sprintf ("Failed to deploy services: %v" , errors .New ("no services deployed" ))), nil
100
105
}
101
106
102
- // Get the portal URL for browser preview
103
- portalURL := "https://portal.defang.io/"
104
-
105
- // Open the portal URL in the browser
106
- term .Debugf ("Opening portal URL in browser: %s" , portalURL )
107
- go func () {
108
- err := browser .OpenURL (portalURL )
109
- if err != nil {
110
- term .Error ("Failed to open URL in browser" , "error" , err , "url" , portalURL )
111
- }
112
- }()
113
-
114
107
// Success case
115
108
term .Debugf ("Successfully started deployed services with etag: %s" , deployResp .Etag )
116
109
117
110
// Log deployment success
118
111
term .Debug ("Deployment Started!" )
119
112
term .Debugf ("Deployment ID: %s" , deployResp .Etag )
120
113
121
- // Log browser preview information
122
- term .Debugf ("🌐 %s available" , portalURL )
114
+ var portal string
115
+ if providerId == cliClient .ProviderDefang {
116
+ // Get the portal URL for browser preview
117
+ portalURL := "https://portal.defang.io/"
118
+
119
+ // Open the portal URL in the browser
120
+ term .Debugf ("Opening portal URL in browser: %s" , portalURL )
121
+ go func () {
122
+ err := browser .OpenURL (portalURL )
123
+ if err != nil {
124
+ term .Error ("Failed to open URL in browser" , "error" , err , "url" , portalURL )
125
+ }
126
+ }()
127
+
128
+ // Log browser preview information
129
+ term .Debugf ("🌐 %s available" , portalURL )
130
+ portal = "Please use the web portal url: %s" + portalURL
131
+ } else {
132
+ // portalURL := fmt.Sprintf("https://%s.signin.aws.amazon.com/console")
133
+ portal = fmt .Sprintf ("Please use the %s console" , providerId )
134
+ }
123
135
124
136
// Log service details
125
137
term .Debug ("Services:" )
@@ -130,6 +142,6 @@ func setupDeployTool(s *server.MCPServer, cluster string) {
130
142
}
131
143
132
144
// Return the etag data as text
133
- return mcp .NewToolResultText (fmt .Sprintf ("Please use the web portal url: %s to follow the deployment of %s, with the deployment ID of %s" , portalURL , project .Name , deployResp .Etag )), nil
145
+ return mcp .NewToolResultText (fmt .Sprintf ("%s to follow the deployment of %s, with the deployment ID of %s" , portal , project .Name , deployResp .Etag )), nil
134
146
})
135
147
}
0 commit comments