-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate_skills.sh
More file actions
executable file
·112 lines (89 loc) · 4.19 KB
/
Copy pathgenerate_skills.sh
File metadata and controls
executable file
·112 lines (89 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
set -e
# Ensure VERSION is passed from the environment
if [ -z "$VERSION" ]; then
echo "Error: VERSION environment variable is not set."
exit 1
fi
# SKILL CONFIGURATION
# Format: "toolset" "description"
# The skill name is automatically generated as "cloud-sql-mysql-<toolset>"
SKILLS=(
"admin"
"Use these skills when you need to provision new Cloud SQL for MySQL instances, create databases and users, clone existing environments, and monitor the progress of infrastructure operations."
"data"
"Use these skills when you need to explore your database schema, execute SQL queries to interact with your data, and inspect how MySQL plans to execute your statements."
"monitor"
"Use these skills when you need to troubleshoot slow queries, analyze system-level PromQL metrics, and identify structural performance issues like table fragmentation or missing unique indexes."
"lifecycle"
"Use these skills when you need to manage the durability and safety of your data by creating backups, restoring from previous states, or cloning instances for recovery and testing."
)
echo "VALIDATING TOOLSETS BEFORE GENERATION"
# Dynamically build the SUPPORTED_TOOLSETS array from the SKILLS array.
# We use 'set --' to process the array in chunks without index arithmetic.
SUPPORTED_TOOLSETS=()
set -- "${SKILLS[@]}"
while [ $# -gt 0 ]; do
SUPPORTED_TOOLSETS+=("$1")
shift 2
done
echo "Currently Supported Toolsets: ${SUPPORTED_TOOLSETS[*]}"
# Fetch the upstream source of truth YAML for this specific version
RAW_URL="https://raw.githubusercontent.com/googleapis/mcp-toolbox/v${VERSION}/internal/prebuiltconfigs/tools/cloud-sql-mysql.yaml"
echo "Fetching upstream config from: $RAW_URL"
UPSTREAM_YAML=$(curl -sL --fail "$RAW_URL" || { echo "Error: Could not fetch upstream YAML for v$VERSION"; exit 1; })
# Extract the list of toolsets. Each toolset is its own YAML document:
# kind: toolset
# name: <toolset>
UPSTREAM_TOOLSETS=$(echo "$UPSTREAM_YAML" | awk '$1=="kind:" && $2=="toolset"{f=1; next} f && $1=="name:"{print $2; f=0}')
# Compare upstream toolsets against our supported list
MISSING_TOOLSETS=false
for upstream_tool in $UPSTREAM_TOOLSETS; do
if [ -z "$upstream_tool" ] || [ "$upstream_tool" == "-" ]; then continue; fi
if [[ ! " ${SUPPORTED_TOOLSETS[*]} " =~ " ${upstream_tool} " ]]; then
echo "ERROR: Upstream configuration contains a new toolset: '$upstream_tool'"
MISSING_TOOLSETS=true
fi
done
if [ "$MISSING_TOOLSETS" = true ]; then
echo "PIPELINE FAILED: Missing Toolset Generators"
echo "The source of truth file has toolsets that your script does not support."
echo "Please update the SKILLS array in generate_skills.sh to include generators"
echo "for the missing toolsets above, then commit your changes to unblock this PR."
exit 1
fi
echo "Validation passed. All upstream toolsets are supported."
echo "BEGINNING SKILL GENERATION"
LICENSE_HEADER="// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the \"License\");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an \"AS IS\" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License."
ADDITIONAL_NOTES="Note: The scripts automatically load the environment variables from various .env files. Do not ask the user to set vars unless skill executions fails due to env var absence."
# Base Command Function
generate_skill() {
local TOOLSET="$1"
local SKILL_DESC="$2"
local SKILL_NAME="cloud-sql-mysql-$TOOLSET"
echo "Generating skill: $SKILL_NAME..."
npx "@toolbox-sdk/server@${VERSION}" --prebuilt cloud-sql-mysql skills-generate \
--name "$SKILL_NAME" \
--description "$SKILL_DESC" \
--toolset="$TOOLSET" \
--license-header "$LICENSE_HEADER" \
--additional-notes="$ADDITIONAL_NOTES"
}
set -- "${SKILLS[@]}"
while [ $# -gt 0 ]; do
generate_skill "$1" "$2"
shift 2
done
echo "All skills generated successfully!"