Skip to content

Instantly share code, notes, and snippets.

View cdbkr's full-sized avatar

Francesco Paolo Vitullo cdbkr

View GitHub Profile
@cdbkr
cdbkr / index.js
Created December 11, 2025 15:06
buildEndpointDescription function
const buildEndpointDescription = (endpoint) => {
const parts = [
`## ${endpoint.id}`,
`${endpoint.method} ${endpoint.path}`,
endpoint.summary,
endpoint.description,
].filter(Boolean);
if (endpoint.parameters.length > 0) {
parts.push('\nParameters:', ...endpoint.parameters.map(parameter => ` - ${parameter}`));
@cdbkr
cdbkr / index.js
Created December 11, 2025 15:06
buildToolDescription function
const buildToolDescription = (resource, endpoints, operations) => {
const endpointDescriptions = endpoints.map(buildEndpointDescription).join('\n');
return [
`Operations for ${resource} resource:\n`,
endpointDescriptions,
'\nUsage:',
`- Set "operation" to one of: ${operations.join(', ')}`,
'- Set "parameters" object with path/query/header parameters as needed',
'- Set "body" object with request body data as needed',
@cdbkr
cdbkr / index.js
Created December 11, 2025 15:05
createResourceTool function
const createResourceTool = (resource, endpoints, baseUrl) => {
const operations = endpoints.map(endpoint => endpoint.id);
return {
name: `${resource}_operations`,
description: buildToolDescription(resource, endpoints, operations),
parameters: z.object({
operation: z.enum(operations),
parameters: z.record(z.any()).optional(),
body: z.record(z.any()).optional(),
@cdbkr
cdbkr / index.js
Created December 11, 2025 15:04
groupEndpoints function
const groupEndpoints = (spec) => {
const groups = new Map();
Object.entries(spec.paths || {}).forEach(([path, methods]) => {
const resource = path.split('/').filter(Boolean)[0] || 'root';
if (!groups.has(resource)) {
groups.set(resource, []);
}
@cdbkr
cdbkr / index.js
Created December 11, 2025 15:04
main function
async function main() {
const spec = await loadSpec(CONFIG.specPath);
const baseUrl = spec.servers?.[0]?.url || '';
const groups = groupEndpoints(spec);
const mcp = new FastMCP({
name: 'mcp-example',
version: '1.0.0',
});
FROM k8s.gcr.io/kustomize/kustomize:v3.8.7
RUN apk update && apk add --no-cache git
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
@cdbkr
cdbkr / action.yml
Last active November 23, 2025 15:22
name: "Update Kustomize Image"
description: "Updates a Kubernetes image reference in a kustomization.yaml file and commits the change."
inputs:
path:
description: "Path to the directory containing the kustomization.yaml file."
required: true
new-image-service:
description: "The logical name of the image as referenced in Kustomize (the key before =)."
required: true
@cdbkr
cdbkr / entrypoint.sh
Created November 23, 2025 15:19
entrypoint.sh
#!/bin/sh
set -euo pipefail
# Usage: script.sh <path> <image_name> <image_repo> <version>
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <path> <image_name> <image_repo> <version>"
exit 1
fi
TARGET_DIR="$1"
@cdbkr
cdbkr / kustomization.yaml
Created December 13, 2024 20:19
app kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: services
resources:
- ingress.yaml
- deployment.yaml
images:
@cdbkr
cdbkr / kustomization.yaml
Created December 13, 2024 20:17
root kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./apps/simple-api/prod