-
Notifications
You must be signed in to change notification settings - Fork 2
add new tool for cloud run #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
414b078
7cdfa0d
cbef7fa
b7692ec
4627257
f694197
ebdc3d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,6 +36,7 @@ func (h *Handler) Register(server *mcp.Server) { | |||||||||||||||||||||||||||||||||||||||
| addListServicesTool(server, h.CrClient) | ||||||||||||||||||||||||||||||||||||||||
| addDeployToCloudRunFromImageTool(server, h.CrClient) | ||||||||||||||||||||||||||||||||||||||||
| addDeployToCloudRunFromSourceTool(server, h.CrClient) | ||||||||||||||||||||||||||||||||||||||||
| addGetServiceStatusTool(server, h.CrClient) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| type ListServicesArgs struct { | ||||||||||||||||||||||||||||||||||||||||
|
|
@@ -134,3 +135,22 @@ func addDeployToCloudRunFromSourceTool(server *mcp.Server, crClient cloudrunclie | |||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| mcp.AddTool(server, &mcp.Tool{Name: "cloudrun.deploy_to_cloud_run_from_source", Description: "Creates a new Cloud Run service or updates an existing one from source. This tool may take a couple minutes to finish running."}, deployToCloudRunFromSourceToolFunc) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| type GetServiceStatusArgs struct{ | ||||||||||||||||||||||||||||||||||||||||
| ProjectID string `json:"project_id" jsonschema:"The Google Cloud project ID."` | ||||||||||||||||||||||||||||||||||||||||
| Location string `json:"location" jsonschema:"The Google Cloud location."` | ||||||||||||||||||||||||||||||||||||||||
| ServiceName string `json:"service_name" jsonschema:"The Cloud Run service name"` | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| var getServiceStatusToolFunc func(ctx context.Context, req *mcp.CallToolRequest, args GetServiceStatusArgs) (*mcp.CallToolResult, any, error) | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| func addGetServiceStatusTool(server *mcp.Server, crClient cloudrunclient.CloudRunClient) { | ||||||||||||||||||||||||||||||||||||||||
| getServiceStatusToolFunc = func(ctx context.Context, req *mcp.CallToolRequest, args GetServiceStatusArgs) (*mcp.CallToolResult, any, error) { | ||||||||||||||||||||||||||||||||||||||||
| state, err := crClient.GetServiceStatus(ctx, args.ProjectID, args.Location, args.ServiceName) | ||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||
| return &mcp.CallToolResult{}, nil, fmt.Errorf("failed to get service state: %w", err) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| return &mcp.CallToolResult{}, state, nil | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| mcp.AddTool(server, &mcp.Tool{Name: "cloudrun.service_status", Description: "Gets the current status of a Cloud Run service."}, getServiceStatusToolFunc) | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
147
to
156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new function to add the service status tool is incomplete and has several issues that will cause compilation and runtime errors:
Here is a corrected version of the function. Please note you will also need to add
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.