From 2b0ce1a6936cb336c1eaae5f4f55aecdbfda8353 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Wed, 18 Mar 2026 01:36:05 +0530 Subject: [PATCH 01/25] added cms search skills --- skills/SKILL.md | 86 ++++++ skills/build_cms_search_input.py | 179 ++++++++++++ skills/build_cms_search_input.sh | 145 ++++++++++ skills/check_mcp.py | 444 ++++++++++++++++++++++++++++++ skills/check_mcp.sh | 448 +++++++++++++++++++++++++++++++ 5 files changed, 1302 insertions(+) create mode 100644 skills/SKILL.md create mode 100644 skills/build_cms_search_input.py create mode 100644 skills/build_cms_search_input.sh create mode 100644 skills/check_mcp.py create mode 100644 skills/check_mcp.sh diff --git a/skills/SKILL.md b/skills/SKILL.md new file mode 100644 index 0000000..0581ed6 --- /dev/null +++ b/skills/SKILL.md @@ -0,0 +1,86 @@ +--- +name: cms-media-options +description: REQUIRED entry point for ALL media and image searches. Every request to find, search, locate, retrieve, browse, get, look up, or use images, photos, pictures, media, icons, illustrations, hero images, banners, thumbnails, logos MUST go through this skill first. Checks which search sources are available, presents only those options, and delegates to the appropriate search skill based on the user's choice. Never search for media directly — always start here. +license: Apache-2.0 +compatibility: Python 3.x or Python 2.7+ recommended, bash 3.2+ (Git Bash/WSL on Windows). Cross-platform: Mac, Windows (Git Bash/WSL), Linux, POSIX. +metadata: + author: afv-library + version: "1.0" +--- + +# CMS Media Search — Source Selection + +**This is the mandatory entry point for ALL media searches.** When the user asks to **find**, **search for**, **locate**, **retrieve**, **browse**, **get**, **look up**, or **use** any kind of visual content — **always start here**. Do not assume a source or call a search tool directly. Check what is available, present only those options, and delegate to the matching search skill. + +## When to Use This Skill + +Activate whenever the user's request involves any visual content, including but not limited to: + +- Images, photos, pictures, media, visuals, graphics +- Icons, illustrations, banners, thumbnails, logos +- Hero images, background images, feature images, cover images +- Any asset described as visual (e.g. "something for the carousel", "a picture for the header") + +Example triggers: + +- "Find a modern luxury apartment exterior and use it in the hero section" +- "I need a hero image for the landing page" +- "Search for family lifestyle photos for the carousel" +- "Get me a logo for the about page" +- "Look up some banner graphics" +- "Can you find product images?" + +--- + +## Step 1: Check Source Availability + +**Before presenting any options**, run the MCP availability check script: + +```bash +python3 scripts/check_mcp.py +``` + +Or if Python is not available: + +```bash +bash scripts/check_mcp.sh +``` + +The script returns JSON: +```json +{"cms_search": true, "data_cloud": false, "unsplash": true} +``` + +**Only present sources that are `true` in the output**, plus **Other** (always available). + +### Example: All sources available +> I can help you find that image. Where would you like to search? +> 1. **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** +> 2. **CMS Keyword Search (Salesforce CMS)** +> 3. **Unsplash** +> 4. **Other** (please specify) + +### Example: Only CMS available +> I can help you find that image. Where would you like to search? +> 1. **CMS Keyword Search (Salesforce CMS)** +> 2. **Other** (please specify) + +## Step 2: Delegate to Search Skill + +Only after the user selects an option, follow the matching skill by **source name** (not number — numbers change based on availability): + +| User selects | Action | +|---|---| +| **CMS Keyword Search (Salesforce CMS)** | Read and follow `../cms-keyword-search/SKILL.md` | +| **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** | Read and follow `../cms-d360-search/SKILL.md` | +| **Unsplash** | Invoke the Unsplash MCP tools +| **Other** | Ask the user for the source URL or asset library details, then retrieve accordingly | + +## Step 3: Present Results + +After the delegated skill returns results: + +- Display returned assets with preview thumbnails when available. +- Include asset title, source system, and relevance score or tags. +- Let the user confirm which asset to use before inserting it into the page or component. +- Do **not** automatically use the first result — user selection is required. diff --git a/skills/build_cms_search_input.py b/skills/build_cms_search_input.py new file mode 100644 index 0000000..05d750c --- /dev/null +++ b/skills/build_cms_search_input.py @@ -0,0 +1,179 @@ +#!/usr/bin/env python3 +""" +Build CMS Search Input JSON + +Generates properly formatted input JSON for search_media_cms_channels MCP tool. + +Usage: + python3 build_cms_search_input.py --keywords "car,automobile,vehicle" --taxonomies "Modern,Luxury" --locale "en_US" + + # With empty keywords + python3 build_cms_search_input.py --keywords "" --taxonomies "Bright,Spacious" --locale "en_US" + + # With empty taxonomies + python3 build_cms_search_input.py --keywords "logo,brand" --taxonomies "" --locale "en_US" + + # With page parameters + python3 build_cms_search_input.py --keywords "car" --taxonomies "Luxury" --locale "en_US" --limit 10 --offset 0 +""" + +import argparse +import json +import sys + + +def build_search_keyword(keywords): + """ + Convert comma-separated keywords to OR-separated format. + + Args: + keywords: Comma-separated string of keywords, or empty string + + Returns: + OR-separated keyword string, or empty string + + Examples: + "car,automobile,vehicle" -> "car OR automobile OR vehicle" + "" -> "" + "logo" -> "logo" + """ + if not keywords or keywords.strip() == "": + return "" + + # Split by comma, strip whitespace, filter empty + keyword_list = [k.strip() for k in keywords.split(',') if k.strip()] + + if not keyword_list: + return "" + + # Join with OR + return " OR ".join(keyword_list) + + +def build_taxonomy_expression(taxonomies): + """ + Convert comma-separated taxonomies to JSON string format. + + Args: + taxonomies: Comma-separated string of taxonomy labels, or empty string + + Returns: + JSON string in format: {"OR": ["Label1", "Label2", "Label3"]}, or "{}" + + Examples: + "Modern,Luxury,Premium" -> "{\"OR\": [\"Modern\", \"Luxury\", \"Premium\"]}" + "" -> "{}" + "Bright" -> "{\"OR\": [\"Bright\"]}" + """ + if not taxonomies or taxonomies.strip() == "": + return "{}" + + # Split by comma, strip whitespace, filter empty + taxonomy_list = [t.strip() for t in taxonomies.split(',') if t.strip()] + + if not taxonomy_list: + return "{}" + + # Build JSON object and convert to string + taxonomy_obj = {"OR": taxonomy_list} + return json.dumps(taxonomy_obj) + + +def build_cms_search_input(keywords, taxonomies, locale="en_US", page_offset=0, page_limit=5): + """ + Build the complete input JSON for search_media_cms_channels. + + Args: + keywords: Comma-separated string of keywords + taxonomies: Comma-separated string of taxonomy labels + locale: Language locale (e.g., "en_US", "es_MX", "fr_CA") + page_offset: Starting offset for pagination (default: 0) + page_limit: Number of results to return (default: 5) + + Returns: + Dictionary with properly formatted input + """ + return { + "inputs": [{ + "searchKeyword": build_search_keyword(keywords), + "taxonomyExpression": build_taxonomy_expression(taxonomies), + "searchLanguage": locale, + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": page_offset, + "pageLimit": page_limit + }] + } + + +def main(): + parser = argparse.ArgumentParser( + description='Build properly formatted input JSON for CMS image search', + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +Examples: + # Basic search + python3 build_cms_search_input.py --keywords "car,automobile,vehicle" --taxonomies "Modern,Luxury" --locale "en_US" + + # Search with only taxonomies (no keywords) + python3 build_cms_search_input.py --keywords "" --taxonomies "Bright,Spacious,Airy" --locale "en_US" + + # Search with only keywords (no taxonomies) + python3 build_cms_search_input.py --keywords "logo,brand,corporate" --taxonomies "" --locale "en_US" + + # With custom page limit + python3 build_cms_search_input.py --keywords "apartment" --taxonomies "Luxury" --locale "en_US" --limit 20 + """ + ) + + parser.add_argument( + '--keywords', + required=True, + help='Comma-separated keywords (e.g., "car,automobile,vehicle"). Use empty string "" for no keywords.' + ) + + parser.add_argument( + '--taxonomies', + required=True, + help='Comma-separated taxonomy labels (e.g., "Modern,Luxury,Premium"). Use empty string "" for no taxonomies.' + ) + + parser.add_argument( + '--locale', + default='en_US', + help='Language locale (e.g., "en_US", "es_MX", "fr_CA"). Default: "en_US"' + ) + + parser.add_argument( + '--offset', + type=int, + default=0, + help='Page offset for pagination. Default: 0' + ) + + parser.add_argument( + '--limit', + type=int, + default=5, + help='Number of results to return. Default: 5' + ) + + args = parser.parse_args() + + # Build the input + input_json = build_cms_search_input( + keywords=args.keywords, + taxonomies=args.taxonomies, + locale=args.locale, + page_offset=args.offset, + page_limit=args.limit + ) + + # Output JSON + print(json.dumps(input_json, indent=2)) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/skills/build_cms_search_input.sh b/skills/build_cms_search_input.sh new file mode 100644 index 0000000..2b3fd66 --- /dev/null +++ b/skills/build_cms_search_input.sh @@ -0,0 +1,145 @@ +#!/usr/bin/env bash +# Build CMS Search Input JSON +# +# Generates properly formatted input JSON for search_media_cms_channels MCP tool. +# Cross-platform compatible: Mac, Windows (Git Bash/MSYS/Cygwin), Linux, POSIX +# +# Usage: +# bash build_cms_search_input.sh --keywords "car,automobile,vehicle" --taxonomies "Modern,Luxury" --locale "en_US" +# bash build_cms_search_input.sh --keywords "car" --taxonomies "Luxury" +# +# Examples: +# # With empty keywords +# bash build_cms_search_input.sh --keywords "" --taxonomies "Bright,Spacious" --locale "en_US" +# +# # With empty taxonomies +# bash build_cms_search_input.sh --keywords "logo,brand" --taxonomies "" --locale "en_US" +# +# # With page parameters +# bash build_cms_search_input.sh --keywords "car" --taxonomies "Luxury" --locale "en_US" --limit 10 --offset 0 + +set -e + +# Default values +KEYWORDS="" +TAXONOMIES="" +LOCALE="en_US" +PAGE_OFFSET=0 +PAGE_LIMIT=5 + +# Parse arguments +while [[ $# -gt 0 ]]; do + case $1 in + --keywords) + KEYWORDS="$2" + shift 2 + ;; + --taxonomies) + TAXONOMIES="$2" + shift 2 + ;; + --locale) + LOCALE="$2" + shift 2 + ;; + --offset) + PAGE_OFFSET="$2" + shift 2 + ;; + --limit) + PAGE_LIMIT="$2" + shift 2 + ;; + -h|--help) + echo "Usage: $0 --keywords KEYWORDS --taxonomies TAXONOMIES [--locale LOCALE] [--offset OFFSET] [--limit LIMIT]" + echo "" + echo "Required arguments:" + echo " --keywords KEYWORDS Comma-separated keywords (e.g., 'car,automobile,vehicle')" + echo " Use empty string '' for no keywords" + echo " --taxonomies TAXONOMIES Comma-separated taxonomy labels (e.g., 'Modern,Luxury')" + echo " Use empty string '' for no taxonomies" + echo "" + echo "Optional arguments:" + echo " --locale LOCALE Language locale (default: 'en_US')" + echo " --offset OFFSET Page offset for pagination (default: 0)" + echo " --limit LIMIT Number of results to return (default: 5)" + echo "" + echo "Examples:" + echo " $0 --keywords 'car,automobile,vehicle' --taxonomies 'Modern,Luxury' --locale 'en_US'" + echo " $0 --keywords '' --taxonomies 'Bright,Spacious' --locale 'en_US'" + echo " $0 --keywords 'logo,brand' --taxonomies '' --locale 'en_US' --limit 10" + exit 0 + ;; + *) + echo "Unknown argument: $1" + echo "Use --help for usage information" + exit 1 + ;; + esac +done + +# Function to build search keyword (OR-separated) +build_search_keyword() { + local keywords="$1" + + if [[ -z "$keywords" ]]; then + echo "" + return + fi + + # Replace commas with " OR " + local result=$(echo "$keywords" | sed 's/,/ OR /g' | sed 's/ */ /g') + echo "$result" +} + +# Function to build taxonomy expression (JSON string) +build_taxonomy_expression() { + local taxonomies="$1" + + if [[ -z "$taxonomies" ]]; then + echo "{}" + return + fi + + # Split by comma and build JSON array + IFS=',' read -ra taxonomy_array <<< "$taxonomies" + + # Build JSON array string + local json_array="[" + local first=true + for tax in "${taxonomy_array[@]}"; do + tax=$(echo "$tax" | xargs) # Trim whitespace + if [[ -n "$tax" ]]; then + if [[ "$first" == true ]]; then + first=false + else + json_array+=", " + fi + json_array+="\"$tax\"" + fi + done + json_array+="]" + + # Build complete JSON string + echo "{\"OR\": $json_array}" +} + +# Build components +SEARCH_KEYWORD=$(build_search_keyword "$KEYWORDS") +TAXONOMY_EXPRESSION=$(build_taxonomy_expression "$TAXONOMIES") + +# Output JSON +cat <" + if auth_header.startswith('Authorization: Bearer '): + return auth_header.replace('Authorization: Bearer ', '') + + return None + + +def get_base_headers(): + """Get base headers for MCP requests (without session ID).""" + headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json, text/event-stream' + } + token = get_bearer_token() + if token: + headers['Authorization'] = f'Bearer {token}' + return headers + + +def initialize_mcp_session(endpoint_url): + """ + Initialize MCP session and get session ID. + Args: + endpoint_url: The MCP server endpoint URL + Returns session ID or None if initialization fails. + """ + headers = get_base_headers() + + # Step 1: Initialize + payload = { + "jsonrpc": "2.0", + "method": "initialize", + "id": "0", + "params": { + "protocolVersion": "2025-03-26", + "capabilities": {}, + "clientInfo": {"name": "CheckMCPScript", "version": "1.0.0"} + } + } + + try: + status, resp_headers, data = _http_post_json(endpoint_url, headers, payload, TIMEOUT) + if status == 200 and data is not None: + # Try to get from Mcp-Session-Id header + session_id = resp_headers.get('Mcp-Session-Id') if resp_headers else None + if session_id: + return session_id + + # Try to get from response body + if 'result' in data and isinstance(data['result'], dict): + session_id = data['result'].get('sessionId') or data['result'].get('session_id') + if session_id: + return session_id + except Exception: + pass + + return None + + +def send_initialized_notification(endpoint_url, session_id): + """ + Send initialized notification to MCP server. + Args: + endpoint_url: The MCP server endpoint URL + session_id: The session ID from initialization + Returns True if successful, False otherwise. + """ + headers = get_base_headers() + headers['Mcp-Session-Id'] = session_id + + payload = { + "jsonrpc": "2.0", + "method": "notifications/initialized" + } + + try: + status, _, _ = _http_post_json(endpoint_url, headers, payload, TIMEOUT) + return status in [200, 202] # Accept both 200 and 202 + except Exception: + return False + + +def list_available_tools(): + """ + List all available tools from MCP server using JSON-RPC. + Follows proper MCP initialization flow. + Returns a list of tool names, or empty list if unavailable. + """ + # Get the endpoint URL + endpoint_url = get_contentmcp_url() + if not endpoint_url: + # stdio type or no URL configured + return [] + + # Step 1: Initialize and get session ID + session_id = initialize_mcp_session(endpoint_url) + if not session_id: + return [] + + # Step 2: Send initialized notification + if not send_initialized_notification(endpoint_url, session_id): + return [] + + # Step 3: List tools + headers = get_base_headers() + headers['Mcp-Session-Id'] = session_id + + payload = { + "jsonrpc": "2.0", + "method": "tools/list", + "id": "1", + "params": {} + } + + try: + status, _, data = _http_post_json(endpoint_url, headers, payload, TIMEOUT) + if status == 200 and data and 'result' in data and 'tools' in data['result']: + tools = data['result']['tools'] + tool_names = [tool.get('name') for tool in tools if isinstance(tool, dict) and 'name' in tool] + return tool_names + except Exception: + pass + + return [] + + +def check_mcp_health(): + """Check if MCP server is reachable by attempting to list tools.""" + tools = list_available_tools() + return len(tools) > 0 + + +def check_tool_available(tool_name): + """ + Check if a specific tool is available via MCP server. + Uses JSON-RPC to list tools and searches for the tool name. + """ + available_tools = list_available_tools() + return tool_name in available_tools + + +def main(): + """Main execution.""" + result = { + "cms_search": False, + "data_cloud": False, + "unsplash": False + } + + # First check if contentmcp server is enabled in settings + if not is_contentmcp_enabled(): + # contentmcp is disabled, return all false + print(json.dumps(result)) + return 0 + + # Check if it's stdio type + content_config = get_content_server_config() + + if content_config.get('type') == 'stdio': + # For stdio type, we can't check via URL + # Assume tools are available if the server is enabled + # The IDE/extension manages the connection + result["cms_search"] = True + result["data_cloud"] = True + else: + # For non-stdio (like mcp-remote), check via URL + if check_mcp_health(): + # Check for CMS search tool + if check_tool_available("search_media_cms_channels"): + result["cms_search"] = True + + # Check for Data Cloud search tool + if check_tool_available("search_electronic_media"): + result["data_cloud"] = True + + # Check for Unsplash MCP server separately + if is_unsplash_mcp_enabled(): + result["unsplash"] = True + + # Output JSON result + print(json.dumps(result)) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/skills/check_mcp.sh b/skills/check_mcp.sh new file mode 100644 index 0000000..fb7f94d --- /dev/null +++ b/skills/check_mcp.sh @@ -0,0 +1,448 @@ +#!/bin/bash + +# Check MCP Content Server Availability and Tools +# +# Returns JSON with availability status for each media source: +# { +# "cms_search": true|false, +# "data_cloud": true|false, +# "unsplash": true|false +# } + +set -e + +TIMEOUT=5 + +# URL patterns that identify the content MCP endpoint (name-agnostic) +CONTENT_ENDPOINT_PATTERN="platform/content" +CONTENT_READONLY_PATTERN="content-readonly" + +# Args pattern that identifies the Unsplash MCP server (name-agnostic) +UNSPLASH_MCP_ARGS_PATTERN="unsplash-mcp-server" + + +# --------------------------------------------------------------------------- +# Platform detection and settings path +# --------------------------------------------------------------------------- +get_ide_config_root() { + if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then + local appdata="${APPDATA:-$HOME/AppData/Roaming}" + echo "$appdata/Code" + elif [[ "$OSTYPE" == "darwin"* ]]; then + echo "$HOME/Library/Application Support/Code" + else + local xdg="${XDG_CONFIG_HOME:-$HOME/.config}" + echo "$xdg/Code" + fi +} + +SETTINGS_PATH="$(get_ide_config_root)/User/globalStorage/salesforce.salesforcedx-einstein-gpt/settings/a4d_mcp_settings.json" + +# --------------------------------------------------------------------------- +# JSON helpers — jq preferred, grep/sed fallback +# --------------------------------------------------------------------------- + +_has_jq() { command -v jq &> /dev/null; } + +# Get the full raw settings as a string (only useful with jq) +_settings_exists() { [[ -f "$SETTINGS_PATH" ]]; } + +# --------------------------------------------------------------------------- +# Name-agnostic content server detection +# Scans ALL mcpServers entries for args containing CONTENT_ENDPOINT_PATTERN +# or CONTENT_READONLY_PATTERN. Returns the server key (name) or empty. +# --------------------------------------------------------------------------- +get_content_server_key() { + if ! _settings_exists; then echo ""; return; fi + + if _has_jq; then + local key + key=$(jq -r ' + .mcpServers // {} | to_entries[] | + select(.value.args? // [] | map(select(type == "string")) | + any(contains("'"$CONTENT_ENDPOINT_PATTERN"'") or contains("'"$CONTENT_READONLY_PATTERN"'"))) + | .key' "$SETTINGS_PATH" 2>/dev/null | head -n 1) + echo "$key" + else + # grep fallback: look for any args line containing the patterns + local key + key=$(grep -B 20 "$CONTENT_ENDPOINT_PATTERN\|$CONTENT_READONLY_PATTERN" "$SETTINGS_PATH" 2>/dev/null \ + | grep -o '"[^"]*": *{' | tail -n 1 | sed 's/[": {]//g') + echo "$key" + fi +} + +# --------------------------------------------------------------------------- +# Content server config queries (all name-agnostic via get_content_server_key) +# --------------------------------------------------------------------------- +is_content_server_disabled() { + local key + key=$(get_content_server_key) + [[ -z "$key" ]] && return 0 # no server found → treat as disabled + + if _has_jq; then + local disabled + disabled=$(jq -r ".mcpServers[\"$key\"].disabled // false" "$SETTINGS_PATH" 2>/dev/null) + [[ "$disabled" == "true" ]] && return 0 + return 1 + else + if grep -A 5 "\"$key\"" "$SETTINGS_PATH" 2>/dev/null | grep -q '"disabled": *true'; then + return 0 + fi + return 1 + fi +} + +is_contentmcp_enabled() { + if ! _settings_exists; then return 1; fi + + local key + key=$(get_content_server_key) + [[ -z "$key" ]] && return 1 + + if is_content_server_disabled; then return 1; fi + return 0 +} + +is_stdio_type() { + if ! _settings_exists; then return 1; fi + + local key + key=$(get_content_server_key) + [[ -z "$key" ]] && return 1 + + if _has_jq; then + local stype + stype=$(jq -r ".mcpServers[\"$key\"].type // empty" "$SETTINGS_PATH" 2>/dev/null) + [[ "$stype" == "stdio" ]] && return 0 + else + if grep -A 10 "\"$key\"" "$SETTINGS_PATH" 2>/dev/null | grep -q '"type": *"stdio"'; then + return 0 + fi + fi + return 1 +} + +# --------------------------------------------------------------------------- +# Extract the MCP content endpoint URL from settings args (name-agnostic). +# Returns empty if not found — no localhost or env var fallback. +# --------------------------------------------------------------------------- +get_contentmcp_url() { + local key + key=$(get_content_server_key) + [[ -z "$key" ]] && { echo ""; return; } + + if _has_jq; then + local url + url=$(jq -r " + .mcpServers[\"$key\"].args // [] | map(select(type == \"string\")) | + map(select(contains(\"$CONTENT_ENDPOINT_PATTERN\") or contains(\"$CONTENT_READONLY_PATTERN\"))) + | .[0] // empty" "$SETTINGS_PATH" 2>/dev/null) + if [[ -n "$url" ]]; then echo "$url"; return; fi + else + local url + url=$(grep -o 'http[s]*://[^"]*' "$SETTINGS_PATH" 2>/dev/null \ + | grep -E "$CONTENT_ENDPOINT_PATTERN|$CONTENT_READONLY_PATTERN" | head -n 1) + if [[ -n "$url" ]]; then echo "$url"; return; fi + fi + + echo "" +} + +# --------------------------------------------------------------------------- +# Name-agnostic Unsplash detection. +# Checks (1) root-level "unsplash" key and (2) any mcpServers entry whose +# args contain "unsplash-mcp-server". +# --------------------------------------------------------------------------- +get_unsplash_server_key() { + if ! _settings_exists; then echo ""; return; fi + + if _has_jq; then + # Check root-level "unsplash" key first + local root_unsplash + root_unsplash=$(jq -r '.unsplash // empty' "$SETTINGS_PATH" 2>/dev/null) + if [[ -n "$root_unsplash" && "$root_unsplash" != "null" ]]; then + echo "__root__" + return + fi + + # Scan mcpServers for any server with unsplash-mcp-server in args + local key + key=$(jq -r ' + .mcpServers // {} | to_entries[] | + select(.value.args? // [] | map(select(type == "string")) | + any(contains("'"$UNSPLASH_MCP_ARGS_PATTERN"'"))) + | .key' "$SETTINGS_PATH" 2>/dev/null | head -n 1) + echo "$key" + else + # grep fallback: check root "unsplash" or args containing the pattern + if grep -q "\"unsplash\"" "$SETTINGS_PATH" 2>/dev/null; then + echo "unsplash" + return + fi + if grep -q "$UNSPLASH_MCP_ARGS_PATTERN" "$SETTINGS_PATH" 2>/dev/null; then + local key + key=$(grep -B 20 "$UNSPLASH_MCP_ARGS_PATTERN" "$SETTINGS_PATH" 2>/dev/null \ + | grep -o '"[^"]*": *{' | tail -n 1 | sed 's/[": {]//g') + echo "$key" + fi + fi +} + +is_unsplash_mcp_enabled() { + if ! _settings_exists; then return 1; fi + + local key + key=$(get_unsplash_server_key) + [[ -z "$key" ]] && return 1 + + if [[ "$key" == "__root__" ]]; then + # Root-level unsplash: check disabled + if _has_jq; then + local disabled + disabled=$(jq -r '.unsplash.disabled // false' "$SETTINGS_PATH" 2>/dev/null) + [[ "$disabled" == "true" ]] && return 1 + fi + return 0 + fi + + # mcpServers entry + if _has_jq; then + local disabled + disabled=$(jq -r ".mcpServers[\"$key\"].disabled // false" "$SETTINGS_PATH" 2>/dev/null) + [[ "$disabled" == "true" ]] && return 1 + return 0 + else + if grep -A 5 "\"$key\"" "$SETTINGS_PATH" 2>/dev/null | grep -q '"disabled": *true'; then + return 1 + fi + return 0 + fi +} + +# --------------------------------------------------------------------------- +# Bearer token extraction (name-agnostic: from the matched content server) +# Looks for --header arg followed by "Authorization: Bearer ". +# --------------------------------------------------------------------------- +get_bearer_token() { + if ! _settings_exists; then echo ""; return; fi + + local key + key=$(get_content_server_key) + [[ -z "$key" ]] && { echo ""; return; } + + if _has_jq; then + # Find the arg after "--header" that starts with "Authorization: Bearer " + local token + token=$(jq -r " + .mcpServers[\"$key\"].args // [] | to_entries | + map(select(.value == \"--header\")) | + .[0].key as \$idx | + if \$idx then + .mcpServers[\"$key\"].args[\$idx + 1] // empty + else empty end + " "$SETTINGS_PATH" 2>/dev/null) + + # jq path above is tricky; simpler approach: iterate pairs + token=$(jq -r " + [.mcpServers[\"$key\"].args // []] | .[0] | . as \$args | + [range(0; length - 1)] | + map(select(\$args[.] == \"--header\" and (\$args[. + 1] | startswith(\"Authorization: Bearer \")))) | + .[0] as \$i | + if \$i then \$args[\$i + 1] | sub(\"Authorization: Bearer \"; \"\") else empty end + " "$SETTINGS_PATH" 2>/dev/null) + echo "$token" + else + local token + token=$(grep -o 'Authorization: Bearer [^"]*' "$SETTINGS_PATH" 2>/dev/null \ + | sed 's/Authorization: Bearer //' | head -n 1) + echo "$token" + fi +} + +# --------------------------------------------------------------------------- +# HTTP helpers +# --------------------------------------------------------------------------- +MCP_ENDPOINT="" +BEARER_TOKEN="" + +_curl_post() { + local url="$1" + local payload="$2" + local include_headers="${3:-false}" + + local -a curl_args=(-s -m "$TIMEOUT") + + if [[ "$include_headers" == "true" ]]; then + curl_args+=(-i) + fi + + if [[ -n "$BEARER_TOKEN" ]]; then + curl_args+=(-H "Authorization: Bearer $BEARER_TOKEN") + fi + curl_args+=(-H "Content-Type: application/json") + curl_args+=(-H "Accept: application/json, text/event-stream") + + if [[ -n "${SESSION_ID:-}" ]]; then + curl_args+=(-H "Mcp-Session-Id: $SESSION_ID") + fi + + curl_args+=(-X POST -d "$payload" "$url") + curl "${curl_args[@]}" 2>/dev/null +} + +_curl_post_status() { + local url="$1" + local payload="$2" + + local -a curl_args=(-s -o /dev/null -w "%{http_code}" -m "$TIMEOUT") + + if [[ -n "$BEARER_TOKEN" ]]; then + curl_args+=(-H "Authorization: Bearer $BEARER_TOKEN") + fi + curl_args+=(-H "Content-Type: application/json") + curl_args+=(-H "Accept: application/json, text/event-stream") + + if [[ -n "${SESSION_ID:-}" ]]; then + curl_args+=(-H "Mcp-Session-Id: $SESSION_ID") + fi + + curl_args+=(-X POST -d "$payload" "$url") + curl "${curl_args[@]}" 2>/dev/null +} + +# --------------------------------------------------------------------------- +# MCP JSON-RPC session flow +# --------------------------------------------------------------------------- +SESSION_ID="" + +initialize_mcp_session() { + if ! command -v curl &> /dev/null; then echo ""; return 1; fi + + local payload='{"jsonrpc":"2.0","method":"initialize","id":"0","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"CheckMCPScript","version":"1.0.0"}}}' + + local response + response=$(_curl_post "$MCP_ENDPOINT" "$payload" "true") + + # Try Mcp-Session-Id from response headers + local sid + sid=$(echo "$response" | grep -i "^Mcp-Session-Id:" | sed 's/^[^:]*: *//' | tr -d '\r\n ') + if [[ -n "$sid" ]]; then echo "$sid"; return 0; fi + + # Try from response body: result.sessionId or result.session_id + local body + body=$(echo "$response" | sed -n '/^\r*$/,$p' | tail -n +2) + if [[ -n "$body" ]] && _has_jq; then + sid=$(echo "$body" | jq -r '.result.sessionId // .result.session_id // empty' 2>/dev/null) + if [[ -n "$sid" ]]; then echo "$sid"; return 0; fi + elif [[ -n "$body" ]]; then + sid=$(echo "$body" | grep -o '"sessionId":"[^"]*"' | sed 's/"sessionId":"//;s/"//' | head -n 1) + if [[ -z "$sid" ]]; then + sid=$(echo "$body" | grep -o '"session_id":"[^"]*"' | sed 's/"session_id":"//;s/"//' | head -n 1) + fi + if [[ -n "$sid" ]]; then echo "$sid"; return 0; fi + fi + + echo "" + return 1 +} + +send_initialized_notification() { + local sid="$1" + if ! command -v curl &> /dev/null; then return 1; fi + + SESSION_ID="$sid" + local payload='{"jsonrpc":"2.0","method":"notifications/initialized"}' + + local status_code + status_code=$(_curl_post_status "$MCP_ENDPOINT" "$payload") + + # Accept both 200 and 202 (matching Python) + if [[ "$status_code" == "200" || "$status_code" == "202" ]]; then + return 0 + fi + return 1 +} + +list_available_tools() { + if ! command -v curl &> /dev/null; then echo ""; return 1; fi + + local sid + sid=$(initialize_mcp_session) + if [[ -z "$sid" ]]; then echo ""; return 1; fi + + if ! send_initialized_notification "$sid"; then echo ""; return 1; fi + + SESSION_ID="$sid" + local payload='{"jsonrpc":"2.0","method":"tools/list","id":"1","params":{}}' + + local response + response=$(_curl_post "$MCP_ENDPOINT" "$payload") + + if [[ -n "$response" ]]; then + echo "$response" + return 0 + fi + echo "" + return 1 +} + +check_mcp_health() { + local response + response=$(list_available_tools) + if [[ -n "$response" ]] && echo "$response" | grep -q '"tools"'; then + return 0 + fi + return 1 +} + +check_tool_available() { + local tool_name="$1" + local tools_response + tools_response=$(list_available_tools) + + if [[ -n "$tools_response" ]]; then + if echo "$tools_response" | grep -q "\"name\": *\"$tool_name\""; then + return 0 + fi + if echo "$tools_response" | grep -q "\"name\":\"$tool_name\""; then + return 0 + fi + fi + return 1 +} + +# =========================================================================== +# Main +# =========================================================================== +cms_search=false +data_cloud=false +unsplash=false + +if ! is_contentmcp_enabled; then + echo '{"cms_search": false, "data_cloud": false, "unsplash": false}' + exit 0 +fi + +if is_stdio_type; then + cms_search=true + data_cloud=true +else + MCP_ENDPOINT=$(get_contentmcp_url) + BEARER_TOKEN=$(get_bearer_token) + + if check_mcp_health; then + if check_tool_available "search_media_cms_channels"; then + cms_search=true + fi + if check_tool_available "search_electronic_media"; then + data_cloud=true + fi + fi +fi + +if is_unsplash_mcp_enabled; then + unsplash=true +fi + +echo "{\"cms_search\": $cms_search, \"data_cloud\": $data_cloud, \"unsplash\": $unsplash}" From f0f1c64fefb60f6abaa34dd2b8ac0e252c820e21 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Wed, 18 Mar 2026 01:37:34 +0530 Subject: [PATCH 02/25] added cms search rule --- rules/a4d-image-search-routing-rule.md | 299 +++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 rules/a4d-image-search-routing-rule.md diff --git a/rules/a4d-image-search-routing-rule.md b/rules/a4d-image-search-routing-rule.md new file mode 100644 index 0000000..5aaa06b --- /dev/null +++ b/rules/a4d-image-search-routing-rule.md @@ -0,0 +1,299 @@ +--- +name: Image Search Routing Protocol +description: Enforce consistent image search routing through MCP-based media sources +tags: vibe-coding, cms, image-search, mcp, routing +--- + +# Image Search Routing Protocol + +## 🚨 STOP: READ THIS FIRST + +**When a user mentions ANYTHING related to images, photos, pictures, media, visuals, or graphics:** + +**YOU MUST IMMEDIATELY INVOKE THE `cms-media-search` SKILL.** + +**DO NOT:** +- ❌ Present search options directly to the user +- ❌ Ask "Would you like to search CMS, Data Cloud, or Unsplash?" +- ❌ Respond with "I can help you search for images. Where would you like to search?" +- ❌ Make ANY assumptions about available sources +- ❌ Show ANY options before invoking the skill + +**WHY:** You do not know which sources are available until the skill runs the availability check script. Presenting options without checking will show unavailable sources and create a broken user experience. + +--- + +## Mandatory Execution Sequence + +### Step 1: Detect Image Request +User mentions: search, find, get, fetch, retrieve, use, need, want + images/photos/pictures/media/visuals/graphics/logos/icons/hero image/banner + +### Step 2: IMMEDIATELY Invoke Skill +**STOP ALL OTHER ACTIONS. Invoke `cms-media-search` skill NOW.** + +Do NOT: +- Acknowledge the request first +- Ask clarifying questions about source +- Present any options +- Say anything about where to search + +**Just invoke the skill immediately.** + +### Step 3: Skill Executes +The skill will: +1. Run `check_mcp.py` to determine available sources +2. Present ONLY available options to the user +3. Wait for user selection +4. Route to the appropriate search skill + +### Step 4: User Selects +User chooses from the options presented by the skill. + +### Step 5: Execute Search +The skill routes to the correct search implementation. + +--- + +## Absolute Prohibitions + +### ❌ FORBIDDEN: Presenting Options Directly + +**YOU CANNOT DO THIS:** +``` +User: "Find me an apartment image" +Agent: "I can help! Would you like to search: + 1. CMS + 2. Data Cloud + 3. Unsplash + Which would you prefer?" +``` + +**WHY FORBIDDEN:** You don't know if these sources are available. The skill must check first. + +### ❌ FORBIDDEN: Delaying Skill Invocation + +**YOU CANNOT DO THIS:** +``` +User: "Find me an apartment image" +Agent: "I can help you find an apartment image. Let me check what's available..." +[Presents options] +[THEN invokes skill later] +``` + +**WHY FORBIDDEN:** The skill must run BEFORE any response to the user. + +### ❌ FORBIDDEN: Making Assumptions + +**YOU CANNOT DO THIS:** +``` +User: "Find me an apartment image" +Agent: [Assumes CMS is available] +Agent: [Invokes cms-keyword-search directly without cms-media-search] +``` + +**WHY FORBIDDEN:** You don't know availability without running the check script. + +--- + +## ✅ CORRECT Flow + +**User Request:** +"Find me a modern luxury apartment image for the hero section" + +**Your IMMEDIATE Action:** +[Invoke `cms-media-search` skill with NO prior response] + +**What the skill does:** +1. Runs `check_mcp.py` → determines CMS and Unsplash are available +2. Presents to user: + ``` + I can search for that image. Which source would you like to use? + 1. CMS Image Search + 2. Unsplash + 3. Other + ``` +3. User selects "1. CMS Image Search" +4. Skill invokes `cms-keyword-search` +5. Search executes and returns results + +--- + +## Why This Strict Sequence Matters + +**You cannot know availability without running the check script:** +- MCP servers may be disabled in settings +- MCP servers may be offline +- Tools may not be configured +- Environment variables may not be set + +**The `cms-media-search` skill is the ONLY way to:** +- Determine actual availability +- Present accurate options +- Route correctly +- Provide consistent UX + +--- + +## Rule Compliance Checklist + +Before responding to ANY image request, verify: + +- [ ] Did I invoke `cms-media-search` skill IMMEDIATELY? +- [ ] Did I avoid presenting any options directly? +- [ ] Did I avoid making assumptions about availability? +- [ ] Did I let the skill handle all routing and option presentation? + +**If you answered NO to any question, you violated this rule.** + +## Trigger Patterns + +**IMMEDIATE skill invocation required when user mentions:** + +### Primary Triggers (Image/Media Requests) +- "search for" + [images/photos/pictures/media/visuals/graphics] +- "find" + [images/photos/pictures/media/visuals] +- "get" + [images/photos/pictures/media] +- "fetch" + [images/photos/media/visuals] +- "retrieve" + [images/photos/content/media] +- "use" + [images/photos/pictures] + "from [CMS/anywhere]" +- "need" + [hero image/logo/banner/icon/visual/graphic] +- "want" + [image/photo/picture/visual] +- "show me" + [images/photos/pictures] +- "I need" + [image/photo/visual/graphic] +- "add" + [image/photo/picture] +- "insert" + [image/photo/visual] + +### Context-Based Triggers +- User mentions "hero section" or "hero image" +- User mentions "logo" or "branding" in context of adding visuals +- User mentions "banner" or "header" in context of visuals +- User mentions "carousel" or "gallery" in context of content +- User mentions "thumbnail" or "preview image" + +### Content Type Triggers +- Any mention of: apartment/car/product/person/landscape/office/kitchen images +- Any mention of: lifestyle/corporate/professional photos +- Any mention of: stock photos or stock imagery + +--- + +## Detailed Examples + +### ✅ CORRECT: Immediate Skill Invocation + +**Example 1:** +``` +User: "Find me a luxury apartment image for the hero" +Agent: [Immediately invokes cms-media-search skill - NO text response first] +Skill: [Runs check_mcp.py] +Skill: "I can search for that. Which source? + 1. CMS Image Search + 2. Unsplash + 3. Other" +User: [Selects option] +Skill: [Executes search] +``` + +**Example 2:** +``` +User: "I need a professional office photo" +Agent: [Immediately invokes cms-media-search skill] +Skill: [Checks availability and presents options] +User: [Selects] +Skill: [Executes] +``` + +**Example 3:** +``` +User: "Can you get me some car images?" +Agent: [Immediately invokes cms-media-search skill] +Skill: [Handles everything] +``` + +--- + +### ❌ WRONG: Presenting Options Without Skill + +**Example 1 - VIOLATION:** +``` +User: "Find me an apartment image" +Agent: "I can help! Where would you like to search? + - CMS + - Data Cloud + - Unsplash" +❌ WRONG: Presented options without checking availability +``` + +**Example 2 - VIOLATION:** +``` +User: "I need a hero image" +Agent: "Sure! Let me help you search for a hero image. + Would you like to search CMS or Unsplash?" +❌ WRONG: Responded to user before invoking skill +``` + +**Example 3 - VIOLATION:** +``` +User: "Get me a logo" +Agent: "I can search for logos. Let me check what's available..." +Agent: "You can search CMS, Data Cloud, or Unsplash" +[Later invokes cms-media-search] +❌ WRONG: Delayed skill invocation and presented options too early +``` + +**Example 4 - VIOLATION:** +``` +User: "Find kitchen images" +Agent: [Invokes cms-keyword-search directly] +❌ WRONG: Bypassed cms-media-search routing, assumed CMS availability +``` + +--- + +### ✅ CORRECT: Immediate Invocation Even With Context + +**Example:** +``` +User: "I'm building a real estate page. Find me a luxury apartment exterior." +Agent: [Immediately invokes cms-media-search skill] +Skill: [Handles availability check and options] +``` + +**Not:** +``` +User: "I'm building a real estate page. Find me a luxury apartment exterior." +Agent: "Great! For a real estate page, I can search for luxury apartment images. + Would you like CMS or Unsplash?" +❌ WRONG: Responded without invoking skill first +``` + +--- + +## No Exceptions + +**Even if user specifies a source:** + +``` +User: "Search CMS for apartment images" +Agent: [Still invokes cms-media-search skill] +Skill: [Verifies CMS is available] +Skill: [If available, proceeds with CMS search] +Skill: [If unavailable, informs user and shows alternatives] +``` + +**The skill MUST still validate availability.** + +--- + +## Summary: The One Rule + +**When user wants images → Immediately invoke `cms-media-search` skill.** + +**Do NOT:** +- Talk first +- Present options first +- Check anything first +- Ask questions first +- Make assumptions + +**Just invoke the skill.** The skill handles everything correctly. From e0529fd42f566c91025dfaaa819834521eff8e87 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 09:00:37 +0530 Subject: [PATCH 03/25] Created cms-d360-search --- skills/cms-d360-search/SKILL.md | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 skills/cms-d360-search/SKILL.md diff --git a/skills/cms-d360-search/SKILL.md b/skills/cms-d360-search/SKILL.md new file mode 100644 index 0000000..833bebc --- /dev/null +++ b/skills/cms-d360-search/SKILL.md @@ -0,0 +1,40 @@ +--- +name: cms-d360-search +description: Data Cloud AI Hybrid Search via search_electronic_media or search_content_in_d360 MCP tool. Performs semantic search across Salesforce CMS and 3rd-party DAMs using natural language queries. Invoked from cms-media-search when the user selects Data Cloud – AI Hybrid Search. +license: Apache-2.0 +compatibility: Requires content MCP server with search_electronic_media or search_content_in_d360 tool. +metadata: + author: afv-library + version: "2.0" +--- + +# Data Cloud – AI Hybrid Search + +Semantic search across Salesforce CMS and connected 3rd-party DAMs. Invoked by `cms-media-search` when the user selects **Data Cloud – AI Hybrid Search**. + +Best for natural language queries, cross-system searches, and semantic similarity (vs exact keyword matching). + +## Step 1: Build the Query + +Use the user's original request **as-is**. No keyword extraction, taxonomy splitting, or translation needed — the tool handles semantic interpretation. + +## Step 2: Call the MCP Tool + +Call **one** of these tools (try primary first, fall back to legacy): + +| Priority | Tool name | +|----------|-----------| +| Primary | `search_content_in_d360` | +| Fallback | `search_electronic_media` | + +Input: `query` = the user's search query string. Refer to the tool's schema for additional parameters. + +## Step 3: Present Results and Handle Selection + +- Present **every** result as a numbered option with title, URL, and source. Never auto-select. +- Wait for the user to choose by number or name. +- After selection: confirm, apply the URL in code, show what changed, offer next steps. + +## Errors + +On any error (no results, tool unavailable, tool returns error): inform the user and offer to (1) retry with different terms, (2) try a different source via `cms-media-options`, or (3) provide their own image URL. Do not retry automatically. From 4fbd0e01662c1faa5ea74ba4c0bb2e3d67a9a448 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 09:02:22 +0530 Subject: [PATCH 04/25] Created cms-d360-search --- skills/cms-keyword-search/SKILL.md | 350 +++++++++++++++++++++++++++++ 1 file changed, 350 insertions(+) create mode 100644 skills/cms-keyword-search/SKILL.md diff --git a/skills/cms-keyword-search/SKILL.md b/skills/cms-keyword-search/SKILL.md new file mode 100644 index 0000000..1121687 --- /dev/null +++ b/skills/cms-keyword-search/SKILL.md @@ -0,0 +1,350 @@ +--- +name: cms-keyword-search +description: Search Salesforce CMS for images by keywords and taxonomies via the search_media_cms_channels MCP tool. Delegated from cms-media-search when the user selects CMS Image Search. Analyzes the user query, extracts keywords and taxonomies, builds the search payload using the exact template and format rules defined in this skill, calls the tool, and presents results for user selection. Do NOT invoke this skill directly for initial image requests — it is always reached through cms-media-search. +license: Apache-2.0 +metadata: + author: afv-library + version: "6.0" +--- + +# CMS Keyword Search + +Search Salesforce CMS for images using keywords and taxonomies. **Delegated from `cms-media-search`** when the user selects "CMS Image Search". + +## Execution Flow + +Follow these steps **in order**. Do NOT call `search_media_cms_channels` until Step 5. + +1. Analyze the user's query and ng expand with domain-specific terms +2. Extract keywords (concrete nouns) +3. Extract taxonomies (descriptive attributes) +4. Determine locale +5. Build the payload using the **Payload Template** +6. Call `search_media_cms_channels` with the payload +7. Present results and wait for user selection + +--- + +## Step 1: Analyze and Expand the Query + +Understand the user's intent and expand with domain knowledge: + +- **Main subject** — what are they searching for? (apartments, cars, logos) +- **Attributes** — how should it look? (luxury, modern, spacious) +- **Domain** — what context? (real estate, automotive, corporate) + +Expand with synonyms and domain-specific terms: + +| Domain | Query term | Expansion | +|---|---|---| +| Real Estate | "luxury apartments" | villa, penthouse, residence, condo, duplex | +| Automotive | "cars" | automobile, vehicle, auto, SUV | +| Corporate | "company logo" | logo, brand, corporate logo, branding | +| Home/Interior | "modern kitchen" | kitchen, contemporary kitchen, kitchen interior | + +## Step 2: Extract Keywords + +Keywords are **concrete, searchable nouns** that would appear in image titles or metadata. + +Rules: +- Only nouns and noun phrases — no verbs, adjectives, or stop words +- Include domain-specific synonyms from Step 1 +- Maximum 10 terms +- If the query has no concrete nouns (e.g. "something bright"), use **empty string** + +| Query | Keywords | +|---|---| +| "luxury apartments" | apartment, villa, penthouse, residence, condo | +| "company logo" | logo, brand, corporate logo, branding | +| "modern kitchen" | kitchen, contemporary kitchen | +| "bright spacious room" | _(empty — no concrete nouns)_ | +| "car images" | car, automobile, vehicle, auto | + +## Step 3: Extract Taxonomies + +Taxonomies are **descriptive qualities, styles, moods, or categories** — how the image should look or feel, or what category it belongs to. + +Rules: +- Only adjectives, attributes, and categorical terms +- Include domain-relevant descriptors from Step 1 +- If the query has no descriptive terms (e.g. "car"), use **empty string** + +| Query | Taxonomies | +|---|---| +| "luxury apartment with river view" | Luxury, Premium, Waterfront, Riverside, Panoramic, Real Estate | +| "company logo" | Corporate, Business, Professional, Branding | +| "bright spacious room" | Bright, Spacious, Open, Airy, Light | +| "car" | _(empty — no descriptive terms)_ | + +**Never mix**: descriptive terms like "modern", "luxury", "warm" go in taxonomies, NOT keywords. Exception: compound domain terms like "Luxury Apartments" can appear in keywords. + +## Step 4: Determine Locale + +Use **locale format with underscore** (e.g. `en_US`, `es_MX`, `fr_FR`). Default: `en_US`. + +Priority: +1. Explicit language/region in query → use that locale +2. Query in non-English → infer locale with region +3. Context clues from conversation → include region +4. Default: `en_US` + +--- + +## Step 5: Build the Payload + +Construct the JSON payload for `search_media_cms_channels` using the template below. Follow every format rule exactly. + +### Payload Template + +```json +{ + "inputs": [{ + "searchKeyword": "", + "taxonomyExpression": "", + "searchLanguage": "", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "pageLimit": 5 + }] +} +``` + +### Critical: Single Input Object Only + +The `inputs` array must contain **exactly ONE object**. All keywords go into a single `searchKeyword` field, OR-separated. Do NOT create multiple input objects. + +``` +✅ "inputs": [{ "searchKeyword": "logo OR brand OR emblem OR branding", ... }] +❌ "inputs": [{ "searchKeyword": "logo", ... }, { "searchKeyword": "brand", ... }] +``` + +### Format Rules + +#### `searchKeyword` — Join keywords with ` OR ` (uppercase, space-padded) + +``` +✅ "logo OR brand OR emblem OR branding OR corporate logo" +✅ "car OR automobile OR vehicle OR auto" +✅ "" ← no keywords +❌ "logo, brand, emblem" ← comma-separated +❌ "logo brand emblem" ← space-separated +❌ "logo or brand" ← lowercase "or" +``` + +#### `taxonomyExpression` — Stringified JSON object, NOT a raw object or plain string + +Build the object `{"OR": ["term1", "term2"]}`, then **convert it to a string**. The value must be a **string**, not an object. + +``` +✅ "{\"OR\": [\"Corporate\", \"Business\", \"Professional\", \"Branding\"]}" +✅ "{\"OR\": [\"Luxury\", \"Premium\", \"High-end\"]}" +✅ "{\"OR\": [\"Bright\"]}" ← single term +✅ "{}" ← no taxonomies +❌ {"OR": ["Corporate", "Business"]} ← raw object +❌ "Corporate OR Business OR Professional" ← OR-separated +❌ "Corporate, Business, Professional" ← CSV +``` + +#### `searchLanguage` — Locale with underscore, never language-only + +``` +✅ "en_US" "fr_CA" "es_MX" "ja_JP" "de_DE" +❌ "en" "fr" "es" "ja" "de" +``` + +#### Hardcoded fields — never change these values + +| Field | Value | Notes | +|---|---|---| +| `channelIds` | `""` | Always empty string | +| `channelType` | `"PublicUnauthenticated"` | Exact capitalization required | +| `contentTypeFqns` | `"sfdc_cms__image"` | Double underscore, all lowercase | +| `pageOffset` | `0` | Default start position | +| `pageLimit` | `5` | Default; user can request more | + +--- + +### Worked Examples + +**Query: "Look for logo and apply it to the header"** + +- Keywords: logo, brand, emblem, branding, corporate logo +- Taxonomies: Corporate, Business, Professional, Branding +- Locale: en_US + +```json +{ + "inputs": [{ + "searchKeyword": "logo OR brand OR emblem OR branding OR corporate logo", + "taxonomyExpression": "{\"OR\": [\"Corporate\", \"Business\", \"Professional\", \"Branding\"]}", + "searchLanguage": "en_US", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "pageLimit": 5 + }] +} +``` + +**Query: "Find luxury car images"** + +- Keywords: car, automobile, vehicle, auto +- Taxonomies: Luxury, Premium, High-end +- Locale: en_US + +```json +{ + "inputs": [{ + "searchKeyword": "car OR automobile OR vehicle OR auto", + "taxonomyExpression": "{\"OR\": [\"Luxury\", \"Premium\", \"High-end\"]}", + "searchLanguage": "en_US", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "pageLimit": 5 + }] +} +``` + +**Query: "Something bright and spacious" (no concrete nouns)** + +- Keywords: _(empty)_ +- Taxonomies: Bright, Spacious, Open, Airy, Light +- Locale: en_US + +```json +{ + "inputs": [{ + "searchKeyword": "", + "taxonomyExpression": "{\"OR\": [\"Bright\", \"Spacious\", \"Open\", \"Airy\", \"Light\"]}", + "searchLanguage": "en_US", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "pageLimit": 5 + }] +} +``` + +**Query: "Car images" (no descriptive terms)** + +- Keywords: car, automobile, vehicle, auto +- Taxonomies: _(empty)_ +- Locale: en_US + +```json +{ + "inputs": [{ + "searchKeyword": "car OR automobile OR vehicle OR auto", + "taxonomyExpression": "{}", + "searchLanguage": "en_US", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "pageLimit": 5 + }] +} +``` + +**Query: "Luxury apartment with river view"** + +- Keywords: apartment, villa, penthouse, residence, condo, suite +- Taxonomies: Waterfront, Riverside, Panoramic, Luxury, Premium, Real Estate +- Locale: en_US + +```json +{ + "inputs": [{ + "searchKeyword": "apartment OR villa OR penthouse OR residence OR condo OR suite", + "taxonomyExpression": "{\"OR\": [\"Waterfront\", \"Riverside\", \"Panoramic\", \"Luxury\", \"Premium\", \"Real Estate\"]}", + "searchLanguage": "en_US", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "pageLimit": 5 + }] +} +``` + +**Query: "Cherche des images de voiture de luxe" (French)** + +- Keywords: voiture, automobile, véhicule +- Taxonomies: Luxe, Premium, Haut de gamme +- Locale: fr_FR + +```json +{ + "inputs": [{ + "searchKeyword": "voiture OR automobile OR véhicule", + "taxonomyExpression": "{\"OR\": [\"Luxe\", \"Premium\", \"Haut de gamme\"]}", + "searchLanguage": "fr_FR", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "pageLimit": 5 + }] +} +``` + +--- + +## Step 6: Call the MCP Tool + +Call `search_media_cms_channels` with the exact JSON payload from Step 5. + +## Step 7: Present Results + +Parse the response and present **all** results as numbered options. For each result, show: +- Image title or name (`title` or `name` field) +- Media URL (`mediaUrl` or from `deliveryInfo.urls`) + +**Never auto-select an image.** Always wait for the user to choose. + +Example: + +``` +I found 3 images in Salesforce CMS. Which one would you like to use? + +1. **Stainless Steel Kitchen Utensils** + URL: https://cms.example.com/media/kitchen-utensils.jpg + +2. **Modern Cookware Set** + URL: https://cms.example.com/media/modern-cookware.jpg + +3. **Professional Kitchen Tools** + URL: https://cms.example.com/media/professional-tools.jpg +``` + +### After User Selection + +1. Confirm the selection with image name and URL +2. Apply the URL to the user's code or component +3. Show what was changed (file and line) +4. Offer next steps (alt text, styling, more images) + +--- + +## Search Behavior + +- When both keyword and taxonomy are provided: results match keyword OR (keyword + taxonomy) +- Empty keyword → search by taxonomy only +- Empty taxonomy → search by keyword only +- Default `pageLimit` is 5; user can request more +- Use `pageOffset` for pagination (increment by `pageLimit`) + +## Error Handling + +| Error | Response | +|---|---| +| `search_media_cms_channels` unavailable | Inform user; offer Data Cloud, Unsplash, or Other via `cms-media-search` | +| Tool returns an error | Show error message; offer retry with different terms or alternative source | +| No results found | Suggest broader keywords, removing taxonomies, or trying Data Cloud/Unsplash | +| Invalid user selection | Re-display the options and ask again | From 4c1395817a8acbef4f7a5cf140fae8fb5d960021 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 09:03:06 +0530 Subject: [PATCH 05/25] Created cms-media-search --- skills/cms-media-search/SKILL.md | 128 +++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 skills/cms-media-search/SKILL.md diff --git a/skills/cms-media-search/SKILL.md b/skills/cms-media-search/SKILL.md new file mode 100644 index 0000000..fa80424 --- /dev/null +++ b/skills/cms-media-search/SKILL.md @@ -0,0 +1,128 @@ +--- +name: cms-media-search +description: REQUIRED first step for ALL image and media requests. Activate IMMEDIATELY when the user asks to find, search, get, fetch, retrieve, browse, look up, use, add, insert, or need any image, photo, picture, media, visual, graphic, icon, illustration, hero image, banner, thumbnail, logo, background image, cover image, feature image, stock photo, or visual asset. This skill discovers which search sources (Salesforce CMS, Data Cloud, Unsplash) are available by checking MCP tool presence, presents only available options to the user, and delegates to the correct search skill. NEVER call search_media_cms_channels, search_content_in_d360, search_electronic_media, or any image search tool directly — always route through this skill first. +license: Apache-2.0 +metadata: + author: afv-library + version: "3.0" +--- + +# CMS Media Search — Source Selection + +**MANDATORY ENTRY POINT for every media and image search.** Do not assume a source. Do not call any search tool directly. Discover what is available, present only those options, and delegate to the matching search skill. + +## When to Use This Skill + +Activate **immediately** — before any other response — whenever the user's request involves any visual content: + +- Images, photos, pictures, media, visuals, graphics +- Icons, illustrations, banners, thumbnails, logos +- Hero images, background images, feature images, cover images +- Any asset described as visual (e.g. "something for the carousel", "a picture for the header") + +Example triggers: + +- "Find a modern luxury apartment exterior and use it in the hero section" +- "I need a hero image for the landing page" +- "Search for family lifestyle photos for the carousel" +- "Get me a logo for the about page" +- "Look up some banner graphics" +- "Can you find product images?" +- "Add an image to the header component" +- "I need some stock photos for the homepage" + +--- + +## Step 1: Discover Available Sources via MCP Tool Presence + +**Before presenting any options**, determine which search tools are available by checking the MCP tools accessible in your current environment. Do NOT skip this step. Do NOT assume any tool is available. + +Check for these specific MCP tools: + +| MCP Tool to look for | If present | Source option to show | +|---|---|---| +| `search_media_cms_channels` | ✅ Available | **CMS Image Search (Salesforce CMS)** | +| `search_content_in_d360` OR `search_electronic_media` | ✅ Available | **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** | +| Any tool from an Unsplash MCP server | ✅ Available | **Unsplash** | +| _(always)_ | — | **Other** (user provides URL or asset path) | + +### How to check + +1. List the MCP servers and tools available in your environment (e.g. browse MCP tool descriptors, or check configured MCP servers). +2. Match tool names against the table above. +3. A source is available **only** if its corresponding MCP tool is confirmed accessible. + +### Rules + +- **NEVER present a source unless its MCP tool is confirmed available.** +- If **no search tools are found** → present only **Other** and tell the user no automated media sources are currently configured. + +## Step 2: Present Source Options + +Build the options list dynamically. Include **only** sources whose MCP tool is available, plus **Other**. Number them sequentially. **Wait for the user to choose before doing anything else.** + +**All sources available:** + +> I can help you find that. Where would you like to search? +> 1. **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** — Semantic search through D360 +> 2. **CMS Image Search (Salesforce CMS)** — Search images by keywords and taxonomies +> 3. **Unsplash** — Stock images from Unsplash +> 4. **Other** (please specify) + +**Only CMS + D360 available:** + +> I can help you find that image. Where would you like to search? +> 1. **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** +> 2. **CMS Image Search (Salesforce CMS)** +> 3. **Other** (please specify) + +**No sources available:** + +> No automated media sources are currently configured. You can provide a direct URL or asset library path. +> 1. **Other** (please specify) + +## Step 3: Delegate Based on User Selection + +Only after the user selects an option, follow the matching action by **source name** (not number — numbers change based on availability): + +| User selects | Action | +|---|---| +| **CMS Image Search** | Read and follow `../cms-keyword-search/SKILL.md` | +| **Data Cloud – AI Hybrid Search** | Read and follow `../cms-d360-search/SKILL.md` | +| **Unsplash** | Invoke the Unsplash MCP tool directly (see below) | +| **Other** | Ask the user for the source URL or asset library details | + +### Unsplash: Direct MCP Tool Invocation + +When the user selects **Unsplash**, do not load a separate skill. Call the Unsplash MCP tool directly: + +1. **Build the query** from the user's request (e.g. "modern apartment exterior", "family lifestyle"). Use simple, descriptive keywords. +2. **Invoke the Unsplash MCP tool** exposed by the Unsplash MCP server. Pass the search intent as the query parameter; use the tool's schema for exact parameter names and optional fields (e.g. `per_page`, `orientation`). +3. **Present results** with preview thumbnails, photographer credit where available, and a note that Unsplash images are free to use under the [Unsplash License](https://unsplash.com/license). Let the user choose which image to use before placing it. + +## Step 4: Handle Errors + +If any MCP tool call fails (server error, token expired, connection refused): + +- **Do not silently fail.** Tell the user the search tool is currently unavailable and suggest checking MCP server status. +- Offer to retry, or fall back to **Other** (provide a direct URL or asset library path). +- Do **not** present empty results as if the search succeeded. + +## Step 5: Present Results + +After the delegated skill returns results: + +- Display returned assets with preview thumbnails when available. +- Include asset title, source system, and relevance score or tags. +- Let the user confirm which asset to use before inserting it into the page or component. +- Do **not** automatically use the first result — user selection is required. + +--- + +## Prohibitions + +- ❌ Do NOT skip source discovery — never assume a source is available +- ❌ Do NOT present source options without confirming MCP tool availability first +- ❌ Do NOT call `search_media_cms_channels`, `search_content_in_d360`, `search_electronic_media`, or any search tool directly — always go through this skill's source selection flow first +- ❌ Do NOT auto-select a source — always let the user choose +- ❌ Do NOT bypass this skill by loading `cms-keyword-search` or `cms-d360-search` directly for an initial image request From 6a4ed003f282872c290500806d66c61ac50473d4 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 09:03:51 +0530 Subject: [PATCH 06/25] Delete rules/a4d-image-search-routing-rule.md --- rules/a4d-image-search-routing-rule.md | 299 ------------------------- 1 file changed, 299 deletions(-) delete mode 100644 rules/a4d-image-search-routing-rule.md diff --git a/rules/a4d-image-search-routing-rule.md b/rules/a4d-image-search-routing-rule.md deleted file mode 100644 index 5aaa06b..0000000 --- a/rules/a4d-image-search-routing-rule.md +++ /dev/null @@ -1,299 +0,0 @@ ---- -name: Image Search Routing Protocol -description: Enforce consistent image search routing through MCP-based media sources -tags: vibe-coding, cms, image-search, mcp, routing ---- - -# Image Search Routing Protocol - -## 🚨 STOP: READ THIS FIRST - -**When a user mentions ANYTHING related to images, photos, pictures, media, visuals, or graphics:** - -**YOU MUST IMMEDIATELY INVOKE THE `cms-media-search` SKILL.** - -**DO NOT:** -- ❌ Present search options directly to the user -- ❌ Ask "Would you like to search CMS, Data Cloud, or Unsplash?" -- ❌ Respond with "I can help you search for images. Where would you like to search?" -- ❌ Make ANY assumptions about available sources -- ❌ Show ANY options before invoking the skill - -**WHY:** You do not know which sources are available until the skill runs the availability check script. Presenting options without checking will show unavailable sources and create a broken user experience. - ---- - -## Mandatory Execution Sequence - -### Step 1: Detect Image Request -User mentions: search, find, get, fetch, retrieve, use, need, want + images/photos/pictures/media/visuals/graphics/logos/icons/hero image/banner - -### Step 2: IMMEDIATELY Invoke Skill -**STOP ALL OTHER ACTIONS. Invoke `cms-media-search` skill NOW.** - -Do NOT: -- Acknowledge the request first -- Ask clarifying questions about source -- Present any options -- Say anything about where to search - -**Just invoke the skill immediately.** - -### Step 3: Skill Executes -The skill will: -1. Run `check_mcp.py` to determine available sources -2. Present ONLY available options to the user -3. Wait for user selection -4. Route to the appropriate search skill - -### Step 4: User Selects -User chooses from the options presented by the skill. - -### Step 5: Execute Search -The skill routes to the correct search implementation. - ---- - -## Absolute Prohibitions - -### ❌ FORBIDDEN: Presenting Options Directly - -**YOU CANNOT DO THIS:** -``` -User: "Find me an apartment image" -Agent: "I can help! Would you like to search: - 1. CMS - 2. Data Cloud - 3. Unsplash - Which would you prefer?" -``` - -**WHY FORBIDDEN:** You don't know if these sources are available. The skill must check first. - -### ❌ FORBIDDEN: Delaying Skill Invocation - -**YOU CANNOT DO THIS:** -``` -User: "Find me an apartment image" -Agent: "I can help you find an apartment image. Let me check what's available..." -[Presents options] -[THEN invokes skill later] -``` - -**WHY FORBIDDEN:** The skill must run BEFORE any response to the user. - -### ❌ FORBIDDEN: Making Assumptions - -**YOU CANNOT DO THIS:** -``` -User: "Find me an apartment image" -Agent: [Assumes CMS is available] -Agent: [Invokes cms-keyword-search directly without cms-media-search] -``` - -**WHY FORBIDDEN:** You don't know availability without running the check script. - ---- - -## ✅ CORRECT Flow - -**User Request:** -"Find me a modern luxury apartment image for the hero section" - -**Your IMMEDIATE Action:** -[Invoke `cms-media-search` skill with NO prior response] - -**What the skill does:** -1. Runs `check_mcp.py` → determines CMS and Unsplash are available -2. Presents to user: - ``` - I can search for that image. Which source would you like to use? - 1. CMS Image Search - 2. Unsplash - 3. Other - ``` -3. User selects "1. CMS Image Search" -4. Skill invokes `cms-keyword-search` -5. Search executes and returns results - ---- - -## Why This Strict Sequence Matters - -**You cannot know availability without running the check script:** -- MCP servers may be disabled in settings -- MCP servers may be offline -- Tools may not be configured -- Environment variables may not be set - -**The `cms-media-search` skill is the ONLY way to:** -- Determine actual availability -- Present accurate options -- Route correctly -- Provide consistent UX - ---- - -## Rule Compliance Checklist - -Before responding to ANY image request, verify: - -- [ ] Did I invoke `cms-media-search` skill IMMEDIATELY? -- [ ] Did I avoid presenting any options directly? -- [ ] Did I avoid making assumptions about availability? -- [ ] Did I let the skill handle all routing and option presentation? - -**If you answered NO to any question, you violated this rule.** - -## Trigger Patterns - -**IMMEDIATE skill invocation required when user mentions:** - -### Primary Triggers (Image/Media Requests) -- "search for" + [images/photos/pictures/media/visuals/graphics] -- "find" + [images/photos/pictures/media/visuals] -- "get" + [images/photos/pictures/media] -- "fetch" + [images/photos/media/visuals] -- "retrieve" + [images/photos/content/media] -- "use" + [images/photos/pictures] + "from [CMS/anywhere]" -- "need" + [hero image/logo/banner/icon/visual/graphic] -- "want" + [image/photo/picture/visual] -- "show me" + [images/photos/pictures] -- "I need" + [image/photo/visual/graphic] -- "add" + [image/photo/picture] -- "insert" + [image/photo/visual] - -### Context-Based Triggers -- User mentions "hero section" or "hero image" -- User mentions "logo" or "branding" in context of adding visuals -- User mentions "banner" or "header" in context of visuals -- User mentions "carousel" or "gallery" in context of content -- User mentions "thumbnail" or "preview image" - -### Content Type Triggers -- Any mention of: apartment/car/product/person/landscape/office/kitchen images -- Any mention of: lifestyle/corporate/professional photos -- Any mention of: stock photos or stock imagery - ---- - -## Detailed Examples - -### ✅ CORRECT: Immediate Skill Invocation - -**Example 1:** -``` -User: "Find me a luxury apartment image for the hero" -Agent: [Immediately invokes cms-media-search skill - NO text response first] -Skill: [Runs check_mcp.py] -Skill: "I can search for that. Which source? - 1. CMS Image Search - 2. Unsplash - 3. Other" -User: [Selects option] -Skill: [Executes search] -``` - -**Example 2:** -``` -User: "I need a professional office photo" -Agent: [Immediately invokes cms-media-search skill] -Skill: [Checks availability and presents options] -User: [Selects] -Skill: [Executes] -``` - -**Example 3:** -``` -User: "Can you get me some car images?" -Agent: [Immediately invokes cms-media-search skill] -Skill: [Handles everything] -``` - ---- - -### ❌ WRONG: Presenting Options Without Skill - -**Example 1 - VIOLATION:** -``` -User: "Find me an apartment image" -Agent: "I can help! Where would you like to search? - - CMS - - Data Cloud - - Unsplash" -❌ WRONG: Presented options without checking availability -``` - -**Example 2 - VIOLATION:** -``` -User: "I need a hero image" -Agent: "Sure! Let me help you search for a hero image. - Would you like to search CMS or Unsplash?" -❌ WRONG: Responded to user before invoking skill -``` - -**Example 3 - VIOLATION:** -``` -User: "Get me a logo" -Agent: "I can search for logos. Let me check what's available..." -Agent: "You can search CMS, Data Cloud, or Unsplash" -[Later invokes cms-media-search] -❌ WRONG: Delayed skill invocation and presented options too early -``` - -**Example 4 - VIOLATION:** -``` -User: "Find kitchen images" -Agent: [Invokes cms-keyword-search directly] -❌ WRONG: Bypassed cms-media-search routing, assumed CMS availability -``` - ---- - -### ✅ CORRECT: Immediate Invocation Even With Context - -**Example:** -``` -User: "I'm building a real estate page. Find me a luxury apartment exterior." -Agent: [Immediately invokes cms-media-search skill] -Skill: [Handles availability check and options] -``` - -**Not:** -``` -User: "I'm building a real estate page. Find me a luxury apartment exterior." -Agent: "Great! For a real estate page, I can search for luxury apartment images. - Would you like CMS or Unsplash?" -❌ WRONG: Responded without invoking skill first -``` - ---- - -## No Exceptions - -**Even if user specifies a source:** - -``` -User: "Search CMS for apartment images" -Agent: [Still invokes cms-media-search skill] -Skill: [Verifies CMS is available] -Skill: [If available, proceeds with CMS search] -Skill: [If unavailable, informs user and shows alternatives] -``` - -**The skill MUST still validate availability.** - ---- - -## Summary: The One Rule - -**When user wants images → Immediately invoke `cms-media-search` skill.** - -**Do NOT:** -- Talk first -- Present options first -- Check anything first -- Ask questions first -- Make assumptions - -**Just invoke the skill.** The skill handles everything correctly. From 70d7406a299e894f9c878e1acf750e870f5971d3 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 09:04:26 +0530 Subject: [PATCH 07/25] Delete skills/build_cms_search_input.py --- skills/build_cms_search_input.py | 179 ------------------------------- 1 file changed, 179 deletions(-) delete mode 100644 skills/build_cms_search_input.py diff --git a/skills/build_cms_search_input.py b/skills/build_cms_search_input.py deleted file mode 100644 index 05d750c..0000000 --- a/skills/build_cms_search_input.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env python3 -""" -Build CMS Search Input JSON - -Generates properly formatted input JSON for search_media_cms_channels MCP tool. - -Usage: - python3 build_cms_search_input.py --keywords "car,automobile,vehicle" --taxonomies "Modern,Luxury" --locale "en_US" - - # With empty keywords - python3 build_cms_search_input.py --keywords "" --taxonomies "Bright,Spacious" --locale "en_US" - - # With empty taxonomies - python3 build_cms_search_input.py --keywords "logo,brand" --taxonomies "" --locale "en_US" - - # With page parameters - python3 build_cms_search_input.py --keywords "car" --taxonomies "Luxury" --locale "en_US" --limit 10 --offset 0 -""" - -import argparse -import json -import sys - - -def build_search_keyword(keywords): - """ - Convert comma-separated keywords to OR-separated format. - - Args: - keywords: Comma-separated string of keywords, or empty string - - Returns: - OR-separated keyword string, or empty string - - Examples: - "car,automobile,vehicle" -> "car OR automobile OR vehicle" - "" -> "" - "logo" -> "logo" - """ - if not keywords or keywords.strip() == "": - return "" - - # Split by comma, strip whitespace, filter empty - keyword_list = [k.strip() for k in keywords.split(',') if k.strip()] - - if not keyword_list: - return "" - - # Join with OR - return " OR ".join(keyword_list) - - -def build_taxonomy_expression(taxonomies): - """ - Convert comma-separated taxonomies to JSON string format. - - Args: - taxonomies: Comma-separated string of taxonomy labels, or empty string - - Returns: - JSON string in format: {"OR": ["Label1", "Label2", "Label3"]}, or "{}" - - Examples: - "Modern,Luxury,Premium" -> "{\"OR\": [\"Modern\", \"Luxury\", \"Premium\"]}" - "" -> "{}" - "Bright" -> "{\"OR\": [\"Bright\"]}" - """ - if not taxonomies or taxonomies.strip() == "": - return "{}" - - # Split by comma, strip whitespace, filter empty - taxonomy_list = [t.strip() for t in taxonomies.split(',') if t.strip()] - - if not taxonomy_list: - return "{}" - - # Build JSON object and convert to string - taxonomy_obj = {"OR": taxonomy_list} - return json.dumps(taxonomy_obj) - - -def build_cms_search_input(keywords, taxonomies, locale="en_US", page_offset=0, page_limit=5): - """ - Build the complete input JSON for search_media_cms_channels. - - Args: - keywords: Comma-separated string of keywords - taxonomies: Comma-separated string of taxonomy labels - locale: Language locale (e.g., "en_US", "es_MX", "fr_CA") - page_offset: Starting offset for pagination (default: 0) - page_limit: Number of results to return (default: 5) - - Returns: - Dictionary with properly formatted input - """ - return { - "inputs": [{ - "searchKeyword": build_search_keyword(keywords), - "taxonomyExpression": build_taxonomy_expression(taxonomies), - "searchLanguage": locale, - "channelIds": "", - "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", - "pageOffset": page_offset, - "pageLimit": page_limit - }] - } - - -def main(): - parser = argparse.ArgumentParser( - description='Build properly formatted input JSON for CMS image search', - formatter_class=argparse.RawDescriptionHelpFormatter, - epilog=""" -Examples: - # Basic search - python3 build_cms_search_input.py --keywords "car,automobile,vehicle" --taxonomies "Modern,Luxury" --locale "en_US" - - # Search with only taxonomies (no keywords) - python3 build_cms_search_input.py --keywords "" --taxonomies "Bright,Spacious,Airy" --locale "en_US" - - # Search with only keywords (no taxonomies) - python3 build_cms_search_input.py --keywords "logo,brand,corporate" --taxonomies "" --locale "en_US" - - # With custom page limit - python3 build_cms_search_input.py --keywords "apartment" --taxonomies "Luxury" --locale "en_US" --limit 20 - """ - ) - - parser.add_argument( - '--keywords', - required=True, - help='Comma-separated keywords (e.g., "car,automobile,vehicle"). Use empty string "" for no keywords.' - ) - - parser.add_argument( - '--taxonomies', - required=True, - help='Comma-separated taxonomy labels (e.g., "Modern,Luxury,Premium"). Use empty string "" for no taxonomies.' - ) - - parser.add_argument( - '--locale', - default='en_US', - help='Language locale (e.g., "en_US", "es_MX", "fr_CA"). Default: "en_US"' - ) - - parser.add_argument( - '--offset', - type=int, - default=0, - help='Page offset for pagination. Default: 0' - ) - - parser.add_argument( - '--limit', - type=int, - default=5, - help='Number of results to return. Default: 5' - ) - - args = parser.parse_args() - - # Build the input - input_json = build_cms_search_input( - keywords=args.keywords, - taxonomies=args.taxonomies, - locale=args.locale, - page_offset=args.offset, - page_limit=args.limit - ) - - # Output JSON - print(json.dumps(input_json, indent=2)) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) From 1db330b2f3121cd3057b5f8a2153560c7200fc9e Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 09:04:47 +0530 Subject: [PATCH 08/25] Delete skills/build_cms_search_input.sh --- skills/build_cms_search_input.sh | 145 ------------------------------- 1 file changed, 145 deletions(-) delete mode 100644 skills/build_cms_search_input.sh diff --git a/skills/build_cms_search_input.sh b/skills/build_cms_search_input.sh deleted file mode 100644 index 2b3fd66..0000000 --- a/skills/build_cms_search_input.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env bash -# Build CMS Search Input JSON -# -# Generates properly formatted input JSON for search_media_cms_channels MCP tool. -# Cross-platform compatible: Mac, Windows (Git Bash/MSYS/Cygwin), Linux, POSIX -# -# Usage: -# bash build_cms_search_input.sh --keywords "car,automobile,vehicle" --taxonomies "Modern,Luxury" --locale "en_US" -# bash build_cms_search_input.sh --keywords "car" --taxonomies "Luxury" -# -# Examples: -# # With empty keywords -# bash build_cms_search_input.sh --keywords "" --taxonomies "Bright,Spacious" --locale "en_US" -# -# # With empty taxonomies -# bash build_cms_search_input.sh --keywords "logo,brand" --taxonomies "" --locale "en_US" -# -# # With page parameters -# bash build_cms_search_input.sh --keywords "car" --taxonomies "Luxury" --locale "en_US" --limit 10 --offset 0 - -set -e - -# Default values -KEYWORDS="" -TAXONOMIES="" -LOCALE="en_US" -PAGE_OFFSET=0 -PAGE_LIMIT=5 - -# Parse arguments -while [[ $# -gt 0 ]]; do - case $1 in - --keywords) - KEYWORDS="$2" - shift 2 - ;; - --taxonomies) - TAXONOMIES="$2" - shift 2 - ;; - --locale) - LOCALE="$2" - shift 2 - ;; - --offset) - PAGE_OFFSET="$2" - shift 2 - ;; - --limit) - PAGE_LIMIT="$2" - shift 2 - ;; - -h|--help) - echo "Usage: $0 --keywords KEYWORDS --taxonomies TAXONOMIES [--locale LOCALE] [--offset OFFSET] [--limit LIMIT]" - echo "" - echo "Required arguments:" - echo " --keywords KEYWORDS Comma-separated keywords (e.g., 'car,automobile,vehicle')" - echo " Use empty string '' for no keywords" - echo " --taxonomies TAXONOMIES Comma-separated taxonomy labels (e.g., 'Modern,Luxury')" - echo " Use empty string '' for no taxonomies" - echo "" - echo "Optional arguments:" - echo " --locale LOCALE Language locale (default: 'en_US')" - echo " --offset OFFSET Page offset for pagination (default: 0)" - echo " --limit LIMIT Number of results to return (default: 5)" - echo "" - echo "Examples:" - echo " $0 --keywords 'car,automobile,vehicle' --taxonomies 'Modern,Luxury' --locale 'en_US'" - echo " $0 --keywords '' --taxonomies 'Bright,Spacious' --locale 'en_US'" - echo " $0 --keywords 'logo,brand' --taxonomies '' --locale 'en_US' --limit 10" - exit 0 - ;; - *) - echo "Unknown argument: $1" - echo "Use --help for usage information" - exit 1 - ;; - esac -done - -# Function to build search keyword (OR-separated) -build_search_keyword() { - local keywords="$1" - - if [[ -z "$keywords" ]]; then - echo "" - return - fi - - # Replace commas with " OR " - local result=$(echo "$keywords" | sed 's/,/ OR /g' | sed 's/ */ /g') - echo "$result" -} - -# Function to build taxonomy expression (JSON string) -build_taxonomy_expression() { - local taxonomies="$1" - - if [[ -z "$taxonomies" ]]; then - echo "{}" - return - fi - - # Split by comma and build JSON array - IFS=',' read -ra taxonomy_array <<< "$taxonomies" - - # Build JSON array string - local json_array="[" - local first=true - for tax in "${taxonomy_array[@]}"; do - tax=$(echo "$tax" | xargs) # Trim whitespace - if [[ -n "$tax" ]]; then - if [[ "$first" == true ]]; then - first=false - else - json_array+=", " - fi - json_array+="\"$tax\"" - fi - done - json_array+="]" - - # Build complete JSON string - echo "{\"OR\": $json_array}" -} - -# Build components -SEARCH_KEYWORD=$(build_search_keyword "$KEYWORDS") -TAXONOMY_EXPRESSION=$(build_taxonomy_expression "$TAXONOMIES") - -# Output JSON -cat < Date: Fri, 20 Mar 2026 09:05:22 +0530 Subject: [PATCH 09/25] Delete skills/check_mcp.py --- skills/check_mcp.py | 444 -------------------------------------------- 1 file changed, 444 deletions(-) delete mode 100644 skills/check_mcp.py diff --git a/skills/check_mcp.py b/skills/check_mcp.py deleted file mode 100644 index e2b9785..0000000 --- a/skills/check_mcp.py +++ /dev/null @@ -1,444 +0,0 @@ -#!/usr/bin/env python3 -""" -Check MCP Content Server Availability and Tools - -Returns JSON with availability status for each media source: -{ - "cms_search": true|false, - "data_cloud": true|false, - "unsplash": true|false -} - -Invocation: Run with `python3 check_mcp.py` or, if Python is not available, -use the Bash equivalent `bash check_mcp.sh`. Both produce identical output. -""" - -import json -import os -import sys -from pathlib import Path -from urllib.request import Request, urlopen -from urllib.error import HTTPError, URLError - -# Use only stdlib (no requests) so the script runs in minimal Vibes/CI environments - -# Timeout for HTTP requests (seconds) -TIMEOUT = 5 - -# Relative path from IDE config root (Code/Cursor) to A4D MCP settings file -_A4D_MCP_SETTINGS_REL = Path('User/globalStorage/salesforce.salesforcedx-einstein-gpt/settings/a4d_mcp_settings.json') - - -def _get_ide_config_root(): - """ - Return the IDE (Code/VS Code) config root directory for this platform. - Used to find globalStorage for the Salesforce Einstein GPT extension. - """ - if sys.platform == 'win32': - appdata = os.environ.get('APPDATA', '') - if not appdata: - appdata = Path.home() / 'AppData' / 'Roaming' - return Path(appdata) / 'Code' - if sys.platform == 'darwin': - return Path.home() / 'Library' / 'Application Support' / 'Code' - # Linux and other POSIX - xdg = os.environ.get('XDG_CONFIG_HOME') or (Path.home() / '.config') - return Path(xdg) / 'Code' - - -def get_a4d_mcp_settings_path(): - """Return the A4D MCP settings path for the current platform (Mac, Windows, Linux, etc.).""" - return _get_ide_config_root() / _A4D_MCP_SETTINGS_REL - - -# Path to A4D MCP settings (platform-agnostic) -SETTINGS_PATH = get_a4d_mcp_settings_path() - -# URL patterns that identify the content MCP endpoint (server name is irrelevant) -CONTENT_ENDPOINT_PATTERN = 'platform/content' -CONTENT_READONLY_PATTERN = 'content-readonly' - -# Args pattern that identifies the Unsplash MCP server (server name is irrelevant) -UNSPLASH_MCP_ARGS_PATTERN = 'unsplash-mcp-server' - - -def _http_post_json(url, headers, payload, timeout=TIMEOUT): - """ - POST JSON to url using stdlib only (no requests dependency). - Returns (status_code, response_headers, response_data_dict or None). - On failure returns (None, None, None). - """ - data = json.dumps(payload).encode('utf-8') - req_headers = {**headers, 'Content-Type': 'application/json'} - req = Request(url, data=data, headers=req_headers, method='POST') - try: - with urlopen(req, timeout=timeout) as resp: - body = resp.read().decode('utf-8') - result = json.loads(body) if body else None - return (resp.status, resp.headers, result) - except HTTPError as e: - try: - body = e.read().decode('utf-8') - result = json.loads(body) if body else None - except Exception: - result = None - return (e.code, e.headers, result) - except (URLError, OSError, ValueError, json.JSONDecodeError): - return (None, None, None) - - -def get_raw_settings(): - """ - Read and parse the full A4D MCP settings file. - Returns the full settings dict or None if not found / invalid. - """ - try: - if not SETTINGS_PATH.exists(): - return None - - with open(SETTINGS_PATH, 'r') as f: - return json.load(f) - except Exception: - return None - - -def get_mcp_settings(): - """ - Read and parse A4D MCP settings. - Returns the mcpServers dict or None if not found. - """ - settings = get_raw_settings() - if not settings: - return None - return settings.get('mcpServers', {}) - - -def _args_contain_content_endpoint(args): - """True if args list contains the content MCP endpoint URL (any server name).""" - if not args: - return False - for arg in args: - if isinstance(arg, str) and ( - CONTENT_ENDPOINT_PATTERN in arg or CONTENT_READONLY_PATTERN in arg - ): - return True - return False - - -def get_content_server_config(): - """ - Get the MCP server config that uses the content endpoint URL. - Does not depend on server name; finds any server whose args contain - the content endpoint (e.g. .../platform/content or .../content-readonly). - Returns the config dict or empty dict if not found. - """ - mcp_servers = get_mcp_settings() - if not mcp_servers: - return {} - for config in mcp_servers.values(): - if not isinstance(config, dict): - continue - args = config.get('args', []) - if _args_contain_content_endpoint(args): - return config - return {} - - -def get_contentmcp_url(): - """ - Extract MCP content server URL from settings. - Returns the URL or None if not found, not configured, or stdio type. - """ - content_config = get_content_server_config() - if not content_config: - return None - - if content_config.get('type') == 'stdio': - return None - - args = content_config.get('args', []) - for arg in args: - if isinstance(arg, str) and ( - CONTENT_ENDPOINT_PATTERN in arg or CONTENT_READONLY_PATTERN in arg - ): - return arg - - return None - - -def is_contentmcp_enabled(): - """ - Check if content MCP server is enabled in settings. - Returns True if enabled (disabled: false) AND not stdio type, False otherwise. - - Note: For stdio type servers, we cannot check availability via URL, - so we return False to skip URL-based checks. - """ - content_config = get_content_server_config() - if not content_config: - return False - - # Check if disabled field is explicitly false (enabled) - disabled = content_config.get('disabled', False) - if disabled: - return False - - # If it's stdio type, we can't do URL-based availability checks - # The MCP server is managed by the IDE/extension, not accessible via HTTP - if content_config.get('type') == 'stdio': - # For stdio, assume it's available if enabled - # (The IDE manages the connection) - return True - - # For non-stdio (like mcp-remote), we can check via URL - return True - - -def _args_contain_unsplash_mcp(args): - """True if args list contains the unsplash MCP server (any server name).""" - if not args: - return False - for arg in args: - if isinstance(arg, str) and UNSPLASH_MCP_ARGS_PATTERN in arg: - return True - return False - - -def get_unsplash_server_config(): - """ - Get the Unsplash MCP server config from settings. - Checks (1) root-level "unsplash" key and (2) any server in mcpServers - whose args contain "unsplash-mcp-server" (name-agnostic). - Returns the config dict or empty dict if not found. - """ - settings = get_raw_settings() - if not settings: - return {} - - # Root-level "unsplash" (some configs put it here) - root_unsplash = settings.get('unsplash') - if isinstance(root_unsplash, dict) and root_unsplash: - return root_unsplash - - # Any server in mcpServers that runs unsplash-mcp-server - mcp_servers = settings.get('mcpServers', {}) - for config in mcp_servers.values() if mcp_servers else (): - if isinstance(config, dict) and _args_contain_unsplash_mcp(config.get('args', [])): - return config - - return {} - - -def is_unsplash_mcp_enabled(): - """ - Check if Unsplash MCP server is configured and enabled. - Returns True if configured and enabled, False otherwise. - """ - unsplash_config = get_unsplash_server_config() - if not unsplash_config: - return False - - disabled = unsplash_config.get('disabled', False) - return not disabled - - -def get_bearer_token(): - """ - Extract bearer token from A4D MCP settings. - Returns the token string or None if not found. - """ - content_config = get_content_server_config() - if not content_config: - return None - - # Extract Authorization header from args - args = content_config.get('args', []) - for i, arg in enumerate(args): - if arg == '--header' and i + 1 < len(args): - auth_header = args[i + 1] - # Format: "Authorization: Bearer " - if auth_header.startswith('Authorization: Bearer '): - return auth_header.replace('Authorization: Bearer ', '') - - return None - - -def get_base_headers(): - """Get base headers for MCP requests (without session ID).""" - headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json, text/event-stream' - } - token = get_bearer_token() - if token: - headers['Authorization'] = f'Bearer {token}' - return headers - - -def initialize_mcp_session(endpoint_url): - """ - Initialize MCP session and get session ID. - Args: - endpoint_url: The MCP server endpoint URL - Returns session ID or None if initialization fails. - """ - headers = get_base_headers() - - # Step 1: Initialize - payload = { - "jsonrpc": "2.0", - "method": "initialize", - "id": "0", - "params": { - "protocolVersion": "2025-03-26", - "capabilities": {}, - "clientInfo": {"name": "CheckMCPScript", "version": "1.0.0"} - } - } - - try: - status, resp_headers, data = _http_post_json(endpoint_url, headers, payload, TIMEOUT) - if status == 200 and data is not None: - # Try to get from Mcp-Session-Id header - session_id = resp_headers.get('Mcp-Session-Id') if resp_headers else None - if session_id: - return session_id - - # Try to get from response body - if 'result' in data and isinstance(data['result'], dict): - session_id = data['result'].get('sessionId') or data['result'].get('session_id') - if session_id: - return session_id - except Exception: - pass - - return None - - -def send_initialized_notification(endpoint_url, session_id): - """ - Send initialized notification to MCP server. - Args: - endpoint_url: The MCP server endpoint URL - session_id: The session ID from initialization - Returns True if successful, False otherwise. - """ - headers = get_base_headers() - headers['Mcp-Session-Id'] = session_id - - payload = { - "jsonrpc": "2.0", - "method": "notifications/initialized" - } - - try: - status, _, _ = _http_post_json(endpoint_url, headers, payload, TIMEOUT) - return status in [200, 202] # Accept both 200 and 202 - except Exception: - return False - - -def list_available_tools(): - """ - List all available tools from MCP server using JSON-RPC. - Follows proper MCP initialization flow. - Returns a list of tool names, or empty list if unavailable. - """ - # Get the endpoint URL - endpoint_url = get_contentmcp_url() - if not endpoint_url: - # stdio type or no URL configured - return [] - - # Step 1: Initialize and get session ID - session_id = initialize_mcp_session(endpoint_url) - if not session_id: - return [] - - # Step 2: Send initialized notification - if not send_initialized_notification(endpoint_url, session_id): - return [] - - # Step 3: List tools - headers = get_base_headers() - headers['Mcp-Session-Id'] = session_id - - payload = { - "jsonrpc": "2.0", - "method": "tools/list", - "id": "1", - "params": {} - } - - try: - status, _, data = _http_post_json(endpoint_url, headers, payload, TIMEOUT) - if status == 200 and data and 'result' in data and 'tools' in data['result']: - tools = data['result']['tools'] - tool_names = [tool.get('name') for tool in tools if isinstance(tool, dict) and 'name' in tool] - return tool_names - except Exception: - pass - - return [] - - -def check_mcp_health(): - """Check if MCP server is reachable by attempting to list tools.""" - tools = list_available_tools() - return len(tools) > 0 - - -def check_tool_available(tool_name): - """ - Check if a specific tool is available via MCP server. - Uses JSON-RPC to list tools and searches for the tool name. - """ - available_tools = list_available_tools() - return tool_name in available_tools - - -def main(): - """Main execution.""" - result = { - "cms_search": False, - "data_cloud": False, - "unsplash": False - } - - # First check if contentmcp server is enabled in settings - if not is_contentmcp_enabled(): - # contentmcp is disabled, return all false - print(json.dumps(result)) - return 0 - - # Check if it's stdio type - content_config = get_content_server_config() - - if content_config.get('type') == 'stdio': - # For stdio type, we can't check via URL - # Assume tools are available if the server is enabled - # The IDE/extension manages the connection - result["cms_search"] = True - result["data_cloud"] = True - else: - # For non-stdio (like mcp-remote), check via URL - if check_mcp_health(): - # Check for CMS search tool - if check_tool_available("search_media_cms_channels"): - result["cms_search"] = True - - # Check for Data Cloud search tool - if check_tool_available("search_electronic_media"): - result["data_cloud"] = True - - # Check for Unsplash MCP server separately - if is_unsplash_mcp_enabled(): - result["unsplash"] = True - - # Output JSON result - print(json.dumps(result)) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) From 5e6352e8ca1a8254f4e9d247c8d8bf4dca02335d Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 09:05:39 +0530 Subject: [PATCH 10/25] Delete skills/check_mcp.sh --- skills/check_mcp.sh | 448 -------------------------------------------- 1 file changed, 448 deletions(-) delete mode 100644 skills/check_mcp.sh diff --git a/skills/check_mcp.sh b/skills/check_mcp.sh deleted file mode 100644 index fb7f94d..0000000 --- a/skills/check_mcp.sh +++ /dev/null @@ -1,448 +0,0 @@ -#!/bin/bash - -# Check MCP Content Server Availability and Tools -# -# Returns JSON with availability status for each media source: -# { -# "cms_search": true|false, -# "data_cloud": true|false, -# "unsplash": true|false -# } - -set -e - -TIMEOUT=5 - -# URL patterns that identify the content MCP endpoint (name-agnostic) -CONTENT_ENDPOINT_PATTERN="platform/content" -CONTENT_READONLY_PATTERN="content-readonly" - -# Args pattern that identifies the Unsplash MCP server (name-agnostic) -UNSPLASH_MCP_ARGS_PATTERN="unsplash-mcp-server" - - -# --------------------------------------------------------------------------- -# Platform detection and settings path -# --------------------------------------------------------------------------- -get_ide_config_root() { - if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then - local appdata="${APPDATA:-$HOME/AppData/Roaming}" - echo "$appdata/Code" - elif [[ "$OSTYPE" == "darwin"* ]]; then - echo "$HOME/Library/Application Support/Code" - else - local xdg="${XDG_CONFIG_HOME:-$HOME/.config}" - echo "$xdg/Code" - fi -} - -SETTINGS_PATH="$(get_ide_config_root)/User/globalStorage/salesforce.salesforcedx-einstein-gpt/settings/a4d_mcp_settings.json" - -# --------------------------------------------------------------------------- -# JSON helpers — jq preferred, grep/sed fallback -# --------------------------------------------------------------------------- - -_has_jq() { command -v jq &> /dev/null; } - -# Get the full raw settings as a string (only useful with jq) -_settings_exists() { [[ -f "$SETTINGS_PATH" ]]; } - -# --------------------------------------------------------------------------- -# Name-agnostic content server detection -# Scans ALL mcpServers entries for args containing CONTENT_ENDPOINT_PATTERN -# or CONTENT_READONLY_PATTERN. Returns the server key (name) or empty. -# --------------------------------------------------------------------------- -get_content_server_key() { - if ! _settings_exists; then echo ""; return; fi - - if _has_jq; then - local key - key=$(jq -r ' - .mcpServers // {} | to_entries[] | - select(.value.args? // [] | map(select(type == "string")) | - any(contains("'"$CONTENT_ENDPOINT_PATTERN"'") or contains("'"$CONTENT_READONLY_PATTERN"'"))) - | .key' "$SETTINGS_PATH" 2>/dev/null | head -n 1) - echo "$key" - else - # grep fallback: look for any args line containing the patterns - local key - key=$(grep -B 20 "$CONTENT_ENDPOINT_PATTERN\|$CONTENT_READONLY_PATTERN" "$SETTINGS_PATH" 2>/dev/null \ - | grep -o '"[^"]*": *{' | tail -n 1 | sed 's/[": {]//g') - echo "$key" - fi -} - -# --------------------------------------------------------------------------- -# Content server config queries (all name-agnostic via get_content_server_key) -# --------------------------------------------------------------------------- -is_content_server_disabled() { - local key - key=$(get_content_server_key) - [[ -z "$key" ]] && return 0 # no server found → treat as disabled - - if _has_jq; then - local disabled - disabled=$(jq -r ".mcpServers[\"$key\"].disabled // false" "$SETTINGS_PATH" 2>/dev/null) - [[ "$disabled" == "true" ]] && return 0 - return 1 - else - if grep -A 5 "\"$key\"" "$SETTINGS_PATH" 2>/dev/null | grep -q '"disabled": *true'; then - return 0 - fi - return 1 - fi -} - -is_contentmcp_enabled() { - if ! _settings_exists; then return 1; fi - - local key - key=$(get_content_server_key) - [[ -z "$key" ]] && return 1 - - if is_content_server_disabled; then return 1; fi - return 0 -} - -is_stdio_type() { - if ! _settings_exists; then return 1; fi - - local key - key=$(get_content_server_key) - [[ -z "$key" ]] && return 1 - - if _has_jq; then - local stype - stype=$(jq -r ".mcpServers[\"$key\"].type // empty" "$SETTINGS_PATH" 2>/dev/null) - [[ "$stype" == "stdio" ]] && return 0 - else - if grep -A 10 "\"$key\"" "$SETTINGS_PATH" 2>/dev/null | grep -q '"type": *"stdio"'; then - return 0 - fi - fi - return 1 -} - -# --------------------------------------------------------------------------- -# Extract the MCP content endpoint URL from settings args (name-agnostic). -# Returns empty if not found — no localhost or env var fallback. -# --------------------------------------------------------------------------- -get_contentmcp_url() { - local key - key=$(get_content_server_key) - [[ -z "$key" ]] && { echo ""; return; } - - if _has_jq; then - local url - url=$(jq -r " - .mcpServers[\"$key\"].args // [] | map(select(type == \"string\")) | - map(select(contains(\"$CONTENT_ENDPOINT_PATTERN\") or contains(\"$CONTENT_READONLY_PATTERN\"))) - | .[0] // empty" "$SETTINGS_PATH" 2>/dev/null) - if [[ -n "$url" ]]; then echo "$url"; return; fi - else - local url - url=$(grep -o 'http[s]*://[^"]*' "$SETTINGS_PATH" 2>/dev/null \ - | grep -E "$CONTENT_ENDPOINT_PATTERN|$CONTENT_READONLY_PATTERN" | head -n 1) - if [[ -n "$url" ]]; then echo "$url"; return; fi - fi - - echo "" -} - -# --------------------------------------------------------------------------- -# Name-agnostic Unsplash detection. -# Checks (1) root-level "unsplash" key and (2) any mcpServers entry whose -# args contain "unsplash-mcp-server". -# --------------------------------------------------------------------------- -get_unsplash_server_key() { - if ! _settings_exists; then echo ""; return; fi - - if _has_jq; then - # Check root-level "unsplash" key first - local root_unsplash - root_unsplash=$(jq -r '.unsplash // empty' "$SETTINGS_PATH" 2>/dev/null) - if [[ -n "$root_unsplash" && "$root_unsplash" != "null" ]]; then - echo "__root__" - return - fi - - # Scan mcpServers for any server with unsplash-mcp-server in args - local key - key=$(jq -r ' - .mcpServers // {} | to_entries[] | - select(.value.args? // [] | map(select(type == "string")) | - any(contains("'"$UNSPLASH_MCP_ARGS_PATTERN"'"))) - | .key' "$SETTINGS_PATH" 2>/dev/null | head -n 1) - echo "$key" - else - # grep fallback: check root "unsplash" or args containing the pattern - if grep -q "\"unsplash\"" "$SETTINGS_PATH" 2>/dev/null; then - echo "unsplash" - return - fi - if grep -q "$UNSPLASH_MCP_ARGS_PATTERN" "$SETTINGS_PATH" 2>/dev/null; then - local key - key=$(grep -B 20 "$UNSPLASH_MCP_ARGS_PATTERN" "$SETTINGS_PATH" 2>/dev/null \ - | grep -o '"[^"]*": *{' | tail -n 1 | sed 's/[": {]//g') - echo "$key" - fi - fi -} - -is_unsplash_mcp_enabled() { - if ! _settings_exists; then return 1; fi - - local key - key=$(get_unsplash_server_key) - [[ -z "$key" ]] && return 1 - - if [[ "$key" == "__root__" ]]; then - # Root-level unsplash: check disabled - if _has_jq; then - local disabled - disabled=$(jq -r '.unsplash.disabled // false' "$SETTINGS_PATH" 2>/dev/null) - [[ "$disabled" == "true" ]] && return 1 - fi - return 0 - fi - - # mcpServers entry - if _has_jq; then - local disabled - disabled=$(jq -r ".mcpServers[\"$key\"].disabled // false" "$SETTINGS_PATH" 2>/dev/null) - [[ "$disabled" == "true" ]] && return 1 - return 0 - else - if grep -A 5 "\"$key\"" "$SETTINGS_PATH" 2>/dev/null | grep -q '"disabled": *true'; then - return 1 - fi - return 0 - fi -} - -# --------------------------------------------------------------------------- -# Bearer token extraction (name-agnostic: from the matched content server) -# Looks for --header arg followed by "Authorization: Bearer ". -# --------------------------------------------------------------------------- -get_bearer_token() { - if ! _settings_exists; then echo ""; return; fi - - local key - key=$(get_content_server_key) - [[ -z "$key" ]] && { echo ""; return; } - - if _has_jq; then - # Find the arg after "--header" that starts with "Authorization: Bearer " - local token - token=$(jq -r " - .mcpServers[\"$key\"].args // [] | to_entries | - map(select(.value == \"--header\")) | - .[0].key as \$idx | - if \$idx then - .mcpServers[\"$key\"].args[\$idx + 1] // empty - else empty end - " "$SETTINGS_PATH" 2>/dev/null) - - # jq path above is tricky; simpler approach: iterate pairs - token=$(jq -r " - [.mcpServers[\"$key\"].args // []] | .[0] | . as \$args | - [range(0; length - 1)] | - map(select(\$args[.] == \"--header\" and (\$args[. + 1] | startswith(\"Authorization: Bearer \")))) | - .[0] as \$i | - if \$i then \$args[\$i + 1] | sub(\"Authorization: Bearer \"; \"\") else empty end - " "$SETTINGS_PATH" 2>/dev/null) - echo "$token" - else - local token - token=$(grep -o 'Authorization: Bearer [^"]*' "$SETTINGS_PATH" 2>/dev/null \ - | sed 's/Authorization: Bearer //' | head -n 1) - echo "$token" - fi -} - -# --------------------------------------------------------------------------- -# HTTP helpers -# --------------------------------------------------------------------------- -MCP_ENDPOINT="" -BEARER_TOKEN="" - -_curl_post() { - local url="$1" - local payload="$2" - local include_headers="${3:-false}" - - local -a curl_args=(-s -m "$TIMEOUT") - - if [[ "$include_headers" == "true" ]]; then - curl_args+=(-i) - fi - - if [[ -n "$BEARER_TOKEN" ]]; then - curl_args+=(-H "Authorization: Bearer $BEARER_TOKEN") - fi - curl_args+=(-H "Content-Type: application/json") - curl_args+=(-H "Accept: application/json, text/event-stream") - - if [[ -n "${SESSION_ID:-}" ]]; then - curl_args+=(-H "Mcp-Session-Id: $SESSION_ID") - fi - - curl_args+=(-X POST -d "$payload" "$url") - curl "${curl_args[@]}" 2>/dev/null -} - -_curl_post_status() { - local url="$1" - local payload="$2" - - local -a curl_args=(-s -o /dev/null -w "%{http_code}" -m "$TIMEOUT") - - if [[ -n "$BEARER_TOKEN" ]]; then - curl_args+=(-H "Authorization: Bearer $BEARER_TOKEN") - fi - curl_args+=(-H "Content-Type: application/json") - curl_args+=(-H "Accept: application/json, text/event-stream") - - if [[ -n "${SESSION_ID:-}" ]]; then - curl_args+=(-H "Mcp-Session-Id: $SESSION_ID") - fi - - curl_args+=(-X POST -d "$payload" "$url") - curl "${curl_args[@]}" 2>/dev/null -} - -# --------------------------------------------------------------------------- -# MCP JSON-RPC session flow -# --------------------------------------------------------------------------- -SESSION_ID="" - -initialize_mcp_session() { - if ! command -v curl &> /dev/null; then echo ""; return 1; fi - - local payload='{"jsonrpc":"2.0","method":"initialize","id":"0","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"CheckMCPScript","version":"1.0.0"}}}' - - local response - response=$(_curl_post "$MCP_ENDPOINT" "$payload" "true") - - # Try Mcp-Session-Id from response headers - local sid - sid=$(echo "$response" | grep -i "^Mcp-Session-Id:" | sed 's/^[^:]*: *//' | tr -d '\r\n ') - if [[ -n "$sid" ]]; then echo "$sid"; return 0; fi - - # Try from response body: result.sessionId or result.session_id - local body - body=$(echo "$response" | sed -n '/^\r*$/,$p' | tail -n +2) - if [[ -n "$body" ]] && _has_jq; then - sid=$(echo "$body" | jq -r '.result.sessionId // .result.session_id // empty' 2>/dev/null) - if [[ -n "$sid" ]]; then echo "$sid"; return 0; fi - elif [[ -n "$body" ]]; then - sid=$(echo "$body" | grep -o '"sessionId":"[^"]*"' | sed 's/"sessionId":"//;s/"//' | head -n 1) - if [[ -z "$sid" ]]; then - sid=$(echo "$body" | grep -o '"session_id":"[^"]*"' | sed 's/"session_id":"//;s/"//' | head -n 1) - fi - if [[ -n "$sid" ]]; then echo "$sid"; return 0; fi - fi - - echo "" - return 1 -} - -send_initialized_notification() { - local sid="$1" - if ! command -v curl &> /dev/null; then return 1; fi - - SESSION_ID="$sid" - local payload='{"jsonrpc":"2.0","method":"notifications/initialized"}' - - local status_code - status_code=$(_curl_post_status "$MCP_ENDPOINT" "$payload") - - # Accept both 200 and 202 (matching Python) - if [[ "$status_code" == "200" || "$status_code" == "202" ]]; then - return 0 - fi - return 1 -} - -list_available_tools() { - if ! command -v curl &> /dev/null; then echo ""; return 1; fi - - local sid - sid=$(initialize_mcp_session) - if [[ -z "$sid" ]]; then echo ""; return 1; fi - - if ! send_initialized_notification "$sid"; then echo ""; return 1; fi - - SESSION_ID="$sid" - local payload='{"jsonrpc":"2.0","method":"tools/list","id":"1","params":{}}' - - local response - response=$(_curl_post "$MCP_ENDPOINT" "$payload") - - if [[ -n "$response" ]]; then - echo "$response" - return 0 - fi - echo "" - return 1 -} - -check_mcp_health() { - local response - response=$(list_available_tools) - if [[ -n "$response" ]] && echo "$response" | grep -q '"tools"'; then - return 0 - fi - return 1 -} - -check_tool_available() { - local tool_name="$1" - local tools_response - tools_response=$(list_available_tools) - - if [[ -n "$tools_response" ]]; then - if echo "$tools_response" | grep -q "\"name\": *\"$tool_name\""; then - return 0 - fi - if echo "$tools_response" | grep -q "\"name\":\"$tool_name\""; then - return 0 - fi - fi - return 1 -} - -# =========================================================================== -# Main -# =========================================================================== -cms_search=false -data_cloud=false -unsplash=false - -if ! is_contentmcp_enabled; then - echo '{"cms_search": false, "data_cloud": false, "unsplash": false}' - exit 0 -fi - -if is_stdio_type; then - cms_search=true - data_cloud=true -else - MCP_ENDPOINT=$(get_contentmcp_url) - BEARER_TOKEN=$(get_bearer_token) - - if check_mcp_health; then - if check_tool_available "search_media_cms_channels"; then - cms_search=true - fi - if check_tool_available "search_electronic_media"; then - data_cloud=true - fi - fi -fi - -if is_unsplash_mcp_enabled; then - unsplash=true -fi - -echo "{\"cms_search\": $cms_search, \"data_cloud\": $data_cloud, \"unsplash\": $unsplash}" From 7650288fa75746f80c09f8c5f14bff704c5dfe9f Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 09:05:56 +0530 Subject: [PATCH 11/25] Delete skills/SKILL.md --- skills/SKILL.md | 86 ------------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 skills/SKILL.md diff --git a/skills/SKILL.md b/skills/SKILL.md deleted file mode 100644 index 0581ed6..0000000 --- a/skills/SKILL.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -name: cms-media-options -description: REQUIRED entry point for ALL media and image searches. Every request to find, search, locate, retrieve, browse, get, look up, or use images, photos, pictures, media, icons, illustrations, hero images, banners, thumbnails, logos MUST go through this skill first. Checks which search sources are available, presents only those options, and delegates to the appropriate search skill based on the user's choice. Never search for media directly — always start here. -license: Apache-2.0 -compatibility: Python 3.x or Python 2.7+ recommended, bash 3.2+ (Git Bash/WSL on Windows). Cross-platform: Mac, Windows (Git Bash/WSL), Linux, POSIX. -metadata: - author: afv-library - version: "1.0" ---- - -# CMS Media Search — Source Selection - -**This is the mandatory entry point for ALL media searches.** When the user asks to **find**, **search for**, **locate**, **retrieve**, **browse**, **get**, **look up**, or **use** any kind of visual content — **always start here**. Do not assume a source or call a search tool directly. Check what is available, present only those options, and delegate to the matching search skill. - -## When to Use This Skill - -Activate whenever the user's request involves any visual content, including but not limited to: - -- Images, photos, pictures, media, visuals, graphics -- Icons, illustrations, banners, thumbnails, logos -- Hero images, background images, feature images, cover images -- Any asset described as visual (e.g. "something for the carousel", "a picture for the header") - -Example triggers: - -- "Find a modern luxury apartment exterior and use it in the hero section" -- "I need a hero image for the landing page" -- "Search for family lifestyle photos for the carousel" -- "Get me a logo for the about page" -- "Look up some banner graphics" -- "Can you find product images?" - ---- - -## Step 1: Check Source Availability - -**Before presenting any options**, run the MCP availability check script: - -```bash -python3 scripts/check_mcp.py -``` - -Or if Python is not available: - -```bash -bash scripts/check_mcp.sh -``` - -The script returns JSON: -```json -{"cms_search": true, "data_cloud": false, "unsplash": true} -``` - -**Only present sources that are `true` in the output**, plus **Other** (always available). - -### Example: All sources available -> I can help you find that image. Where would you like to search? -> 1. **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** -> 2. **CMS Keyword Search (Salesforce CMS)** -> 3. **Unsplash** -> 4. **Other** (please specify) - -### Example: Only CMS available -> I can help you find that image. Where would you like to search? -> 1. **CMS Keyword Search (Salesforce CMS)** -> 2. **Other** (please specify) - -## Step 2: Delegate to Search Skill - -Only after the user selects an option, follow the matching skill by **source name** (not number — numbers change based on availability): - -| User selects | Action | -|---|---| -| **CMS Keyword Search (Salesforce CMS)** | Read and follow `../cms-keyword-search/SKILL.md` | -| **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** | Read and follow `../cms-d360-search/SKILL.md` | -| **Unsplash** | Invoke the Unsplash MCP tools -| **Other** | Ask the user for the source URL or asset library details, then retrieve accordingly | - -## Step 3: Present Results - -After the delegated skill returns results: - -- Display returned assets with preview thumbnails when available. -- Include asset title, source system, and relevance score or tags. -- Let the user confirm which asset to use before inserting it into the page or component. -- Do **not** automatically use the first result — user selection is required. From 6be8da95ffe09667932b4aa6bcaeb67ec12c3b32 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 16:29:42 +0530 Subject: [PATCH 12/25] Delete skills/cms-d360-search directory --- skills/cms-d360-search/SKILL.md | 40 --------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 skills/cms-d360-search/SKILL.md diff --git a/skills/cms-d360-search/SKILL.md b/skills/cms-d360-search/SKILL.md deleted file mode 100644 index 833bebc..0000000 --- a/skills/cms-d360-search/SKILL.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -name: cms-d360-search -description: Data Cloud AI Hybrid Search via search_electronic_media or search_content_in_d360 MCP tool. Performs semantic search across Salesforce CMS and 3rd-party DAMs using natural language queries. Invoked from cms-media-search when the user selects Data Cloud – AI Hybrid Search. -license: Apache-2.0 -compatibility: Requires content MCP server with search_electronic_media or search_content_in_d360 tool. -metadata: - author: afv-library - version: "2.0" ---- - -# Data Cloud – AI Hybrid Search - -Semantic search across Salesforce CMS and connected 3rd-party DAMs. Invoked by `cms-media-search` when the user selects **Data Cloud – AI Hybrid Search**. - -Best for natural language queries, cross-system searches, and semantic similarity (vs exact keyword matching). - -## Step 1: Build the Query - -Use the user's original request **as-is**. No keyword extraction, taxonomy splitting, or translation needed — the tool handles semantic interpretation. - -## Step 2: Call the MCP Tool - -Call **one** of these tools (try primary first, fall back to legacy): - -| Priority | Tool name | -|----------|-----------| -| Primary | `search_content_in_d360` | -| Fallback | `search_electronic_media` | - -Input: `query` = the user's search query string. Refer to the tool's schema for additional parameters. - -## Step 3: Present Results and Handle Selection - -- Present **every** result as a numbered option with title, URL, and source. Never auto-select. -- Wait for the user to choose by number or name. -- After selection: confirm, apply the URL in code, show what changed, offer next steps. - -## Errors - -On any error (no results, tool unavailable, tool returns error): inform the user and offer to (1) retry with different terms, (2) try a different source via `cms-media-options`, or (3) provide their own image URL. Do not retry automatically. From 71bb1d8d44e77d1a113d2c27acd6893b2b95d5c5 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 16:29:51 +0530 Subject: [PATCH 13/25] Delete skills/cms-keyword-search directory --- skills/cms-keyword-search/SKILL.md | 350 ----------------------------- 1 file changed, 350 deletions(-) delete mode 100644 skills/cms-keyword-search/SKILL.md diff --git a/skills/cms-keyword-search/SKILL.md b/skills/cms-keyword-search/SKILL.md deleted file mode 100644 index 1121687..0000000 --- a/skills/cms-keyword-search/SKILL.md +++ /dev/null @@ -1,350 +0,0 @@ ---- -name: cms-keyword-search -description: Search Salesforce CMS for images by keywords and taxonomies via the search_media_cms_channels MCP tool. Delegated from cms-media-search when the user selects CMS Image Search. Analyzes the user query, extracts keywords and taxonomies, builds the search payload using the exact template and format rules defined in this skill, calls the tool, and presents results for user selection. Do NOT invoke this skill directly for initial image requests — it is always reached through cms-media-search. -license: Apache-2.0 -metadata: - author: afv-library - version: "6.0" ---- - -# CMS Keyword Search - -Search Salesforce CMS for images using keywords and taxonomies. **Delegated from `cms-media-search`** when the user selects "CMS Image Search". - -## Execution Flow - -Follow these steps **in order**. Do NOT call `search_media_cms_channels` until Step 5. - -1. Analyze the user's query and ng expand with domain-specific terms -2. Extract keywords (concrete nouns) -3. Extract taxonomies (descriptive attributes) -4. Determine locale -5. Build the payload using the **Payload Template** -6. Call `search_media_cms_channels` with the payload -7. Present results and wait for user selection - ---- - -## Step 1: Analyze and Expand the Query - -Understand the user's intent and expand with domain knowledge: - -- **Main subject** — what are they searching for? (apartments, cars, logos) -- **Attributes** — how should it look? (luxury, modern, spacious) -- **Domain** — what context? (real estate, automotive, corporate) - -Expand with synonyms and domain-specific terms: - -| Domain | Query term | Expansion | -|---|---|---| -| Real Estate | "luxury apartments" | villa, penthouse, residence, condo, duplex | -| Automotive | "cars" | automobile, vehicle, auto, SUV | -| Corporate | "company logo" | logo, brand, corporate logo, branding | -| Home/Interior | "modern kitchen" | kitchen, contemporary kitchen, kitchen interior | - -## Step 2: Extract Keywords - -Keywords are **concrete, searchable nouns** that would appear in image titles or metadata. - -Rules: -- Only nouns and noun phrases — no verbs, adjectives, or stop words -- Include domain-specific synonyms from Step 1 -- Maximum 10 terms -- If the query has no concrete nouns (e.g. "something bright"), use **empty string** - -| Query | Keywords | -|---|---| -| "luxury apartments" | apartment, villa, penthouse, residence, condo | -| "company logo" | logo, brand, corporate logo, branding | -| "modern kitchen" | kitchen, contemporary kitchen | -| "bright spacious room" | _(empty — no concrete nouns)_ | -| "car images" | car, automobile, vehicle, auto | - -## Step 3: Extract Taxonomies - -Taxonomies are **descriptive qualities, styles, moods, or categories** — how the image should look or feel, or what category it belongs to. - -Rules: -- Only adjectives, attributes, and categorical terms -- Include domain-relevant descriptors from Step 1 -- If the query has no descriptive terms (e.g. "car"), use **empty string** - -| Query | Taxonomies | -|---|---| -| "luxury apartment with river view" | Luxury, Premium, Waterfront, Riverside, Panoramic, Real Estate | -| "company logo" | Corporate, Business, Professional, Branding | -| "bright spacious room" | Bright, Spacious, Open, Airy, Light | -| "car" | _(empty — no descriptive terms)_ | - -**Never mix**: descriptive terms like "modern", "luxury", "warm" go in taxonomies, NOT keywords. Exception: compound domain terms like "Luxury Apartments" can appear in keywords. - -## Step 4: Determine Locale - -Use **locale format with underscore** (e.g. `en_US`, `es_MX`, `fr_FR`). Default: `en_US`. - -Priority: -1. Explicit language/region in query → use that locale -2. Query in non-English → infer locale with region -3. Context clues from conversation → include region -4. Default: `en_US` - ---- - -## Step 5: Build the Payload - -Construct the JSON payload for `search_media_cms_channels` using the template below. Follow every format rule exactly. - -### Payload Template - -```json -{ - "inputs": [{ - "searchKeyword": "", - "taxonomyExpression": "", - "searchLanguage": "", - "channelIds": "", - "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", - "pageOffset": 0, - "pageLimit": 5 - }] -} -``` - -### Critical: Single Input Object Only - -The `inputs` array must contain **exactly ONE object**. All keywords go into a single `searchKeyword` field, OR-separated. Do NOT create multiple input objects. - -``` -✅ "inputs": [{ "searchKeyword": "logo OR brand OR emblem OR branding", ... }] -❌ "inputs": [{ "searchKeyword": "logo", ... }, { "searchKeyword": "brand", ... }] -``` - -### Format Rules - -#### `searchKeyword` — Join keywords with ` OR ` (uppercase, space-padded) - -``` -✅ "logo OR brand OR emblem OR branding OR corporate logo" -✅ "car OR automobile OR vehicle OR auto" -✅ "" ← no keywords -❌ "logo, brand, emblem" ← comma-separated -❌ "logo brand emblem" ← space-separated -❌ "logo or brand" ← lowercase "or" -``` - -#### `taxonomyExpression` — Stringified JSON object, NOT a raw object or plain string - -Build the object `{"OR": ["term1", "term2"]}`, then **convert it to a string**. The value must be a **string**, not an object. - -``` -✅ "{\"OR\": [\"Corporate\", \"Business\", \"Professional\", \"Branding\"]}" -✅ "{\"OR\": [\"Luxury\", \"Premium\", \"High-end\"]}" -✅ "{\"OR\": [\"Bright\"]}" ← single term -✅ "{}" ← no taxonomies -❌ {"OR": ["Corporate", "Business"]} ← raw object -❌ "Corporate OR Business OR Professional" ← OR-separated -❌ "Corporate, Business, Professional" ← CSV -``` - -#### `searchLanguage` — Locale with underscore, never language-only - -``` -✅ "en_US" "fr_CA" "es_MX" "ja_JP" "de_DE" -❌ "en" "fr" "es" "ja" "de" -``` - -#### Hardcoded fields — never change these values - -| Field | Value | Notes | -|---|---|---| -| `channelIds` | `""` | Always empty string | -| `channelType` | `"PublicUnauthenticated"` | Exact capitalization required | -| `contentTypeFqns` | `"sfdc_cms__image"` | Double underscore, all lowercase | -| `pageOffset` | `0` | Default start position | -| `pageLimit` | `5` | Default; user can request more | - ---- - -### Worked Examples - -**Query: "Look for logo and apply it to the header"** - -- Keywords: logo, brand, emblem, branding, corporate logo -- Taxonomies: Corporate, Business, Professional, Branding -- Locale: en_US - -```json -{ - "inputs": [{ - "searchKeyword": "logo OR brand OR emblem OR branding OR corporate logo", - "taxonomyExpression": "{\"OR\": [\"Corporate\", \"Business\", \"Professional\", \"Branding\"]}", - "searchLanguage": "en_US", - "channelIds": "", - "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", - "pageOffset": 0, - "pageLimit": 5 - }] -} -``` - -**Query: "Find luxury car images"** - -- Keywords: car, automobile, vehicle, auto -- Taxonomies: Luxury, Premium, High-end -- Locale: en_US - -```json -{ - "inputs": [{ - "searchKeyword": "car OR automobile OR vehicle OR auto", - "taxonomyExpression": "{\"OR\": [\"Luxury\", \"Premium\", \"High-end\"]}", - "searchLanguage": "en_US", - "channelIds": "", - "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", - "pageOffset": 0, - "pageLimit": 5 - }] -} -``` - -**Query: "Something bright and spacious" (no concrete nouns)** - -- Keywords: _(empty)_ -- Taxonomies: Bright, Spacious, Open, Airy, Light -- Locale: en_US - -```json -{ - "inputs": [{ - "searchKeyword": "", - "taxonomyExpression": "{\"OR\": [\"Bright\", \"Spacious\", \"Open\", \"Airy\", \"Light\"]}", - "searchLanguage": "en_US", - "channelIds": "", - "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", - "pageOffset": 0, - "pageLimit": 5 - }] -} -``` - -**Query: "Car images" (no descriptive terms)** - -- Keywords: car, automobile, vehicle, auto -- Taxonomies: _(empty)_ -- Locale: en_US - -```json -{ - "inputs": [{ - "searchKeyword": "car OR automobile OR vehicle OR auto", - "taxonomyExpression": "{}", - "searchLanguage": "en_US", - "channelIds": "", - "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", - "pageOffset": 0, - "pageLimit": 5 - }] -} -``` - -**Query: "Luxury apartment with river view"** - -- Keywords: apartment, villa, penthouse, residence, condo, suite -- Taxonomies: Waterfront, Riverside, Panoramic, Luxury, Premium, Real Estate -- Locale: en_US - -```json -{ - "inputs": [{ - "searchKeyword": "apartment OR villa OR penthouse OR residence OR condo OR suite", - "taxonomyExpression": "{\"OR\": [\"Waterfront\", \"Riverside\", \"Panoramic\", \"Luxury\", \"Premium\", \"Real Estate\"]}", - "searchLanguage": "en_US", - "channelIds": "", - "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", - "pageOffset": 0, - "pageLimit": 5 - }] -} -``` - -**Query: "Cherche des images de voiture de luxe" (French)** - -- Keywords: voiture, automobile, véhicule -- Taxonomies: Luxe, Premium, Haut de gamme -- Locale: fr_FR - -```json -{ - "inputs": [{ - "searchKeyword": "voiture OR automobile OR véhicule", - "taxonomyExpression": "{\"OR\": [\"Luxe\", \"Premium\", \"Haut de gamme\"]}", - "searchLanguage": "fr_FR", - "channelIds": "", - "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", - "pageOffset": 0, - "pageLimit": 5 - }] -} -``` - ---- - -## Step 6: Call the MCP Tool - -Call `search_media_cms_channels` with the exact JSON payload from Step 5. - -## Step 7: Present Results - -Parse the response and present **all** results as numbered options. For each result, show: -- Image title or name (`title` or `name` field) -- Media URL (`mediaUrl` or from `deliveryInfo.urls`) - -**Never auto-select an image.** Always wait for the user to choose. - -Example: - -``` -I found 3 images in Salesforce CMS. Which one would you like to use? - -1. **Stainless Steel Kitchen Utensils** - URL: https://cms.example.com/media/kitchen-utensils.jpg - -2. **Modern Cookware Set** - URL: https://cms.example.com/media/modern-cookware.jpg - -3. **Professional Kitchen Tools** - URL: https://cms.example.com/media/professional-tools.jpg -``` - -### After User Selection - -1. Confirm the selection with image name and URL -2. Apply the URL to the user's code or component -3. Show what was changed (file and line) -4. Offer next steps (alt text, styling, more images) - ---- - -## Search Behavior - -- When both keyword and taxonomy are provided: results match keyword OR (keyword + taxonomy) -- Empty keyword → search by taxonomy only -- Empty taxonomy → search by keyword only -- Default `pageLimit` is 5; user can request more -- Use `pageOffset` for pagination (increment by `pageLimit`) - -## Error Handling - -| Error | Response | -|---|---| -| `search_media_cms_channels` unavailable | Inform user; offer Data Cloud, Unsplash, or Other via `cms-media-search` | -| Tool returns an error | Show error message; offer retry with different terms or alternative source | -| No results found | Suggest broader keywords, removing taxonomies, or trying Data Cloud/Unsplash | -| Invalid user selection | Re-display the options and ask again | From 36e89c418584b816dade52d8f34c9c7fefa1a147 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 16:29:59 +0530 Subject: [PATCH 14/25] Delete skills/cms-media-search directory --- skills/cms-media-search/SKILL.md | 128 ------------------------------- 1 file changed, 128 deletions(-) delete mode 100644 skills/cms-media-search/SKILL.md diff --git a/skills/cms-media-search/SKILL.md b/skills/cms-media-search/SKILL.md deleted file mode 100644 index fa80424..0000000 --- a/skills/cms-media-search/SKILL.md +++ /dev/null @@ -1,128 +0,0 @@ ---- -name: cms-media-search -description: REQUIRED first step for ALL image and media requests. Activate IMMEDIATELY when the user asks to find, search, get, fetch, retrieve, browse, look up, use, add, insert, or need any image, photo, picture, media, visual, graphic, icon, illustration, hero image, banner, thumbnail, logo, background image, cover image, feature image, stock photo, or visual asset. This skill discovers which search sources (Salesforce CMS, Data Cloud, Unsplash) are available by checking MCP tool presence, presents only available options to the user, and delegates to the correct search skill. NEVER call search_media_cms_channels, search_content_in_d360, search_electronic_media, or any image search tool directly — always route through this skill first. -license: Apache-2.0 -metadata: - author: afv-library - version: "3.0" ---- - -# CMS Media Search — Source Selection - -**MANDATORY ENTRY POINT for every media and image search.** Do not assume a source. Do not call any search tool directly. Discover what is available, present only those options, and delegate to the matching search skill. - -## When to Use This Skill - -Activate **immediately** — before any other response — whenever the user's request involves any visual content: - -- Images, photos, pictures, media, visuals, graphics -- Icons, illustrations, banners, thumbnails, logos -- Hero images, background images, feature images, cover images -- Any asset described as visual (e.g. "something for the carousel", "a picture for the header") - -Example triggers: - -- "Find a modern luxury apartment exterior and use it in the hero section" -- "I need a hero image for the landing page" -- "Search for family lifestyle photos for the carousel" -- "Get me a logo for the about page" -- "Look up some banner graphics" -- "Can you find product images?" -- "Add an image to the header component" -- "I need some stock photos for the homepage" - ---- - -## Step 1: Discover Available Sources via MCP Tool Presence - -**Before presenting any options**, determine which search tools are available by checking the MCP tools accessible in your current environment. Do NOT skip this step. Do NOT assume any tool is available. - -Check for these specific MCP tools: - -| MCP Tool to look for | If present | Source option to show | -|---|---|---| -| `search_media_cms_channels` | ✅ Available | **CMS Image Search (Salesforce CMS)** | -| `search_content_in_d360` OR `search_electronic_media` | ✅ Available | **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** | -| Any tool from an Unsplash MCP server | ✅ Available | **Unsplash** | -| _(always)_ | — | **Other** (user provides URL or asset path) | - -### How to check - -1. List the MCP servers and tools available in your environment (e.g. browse MCP tool descriptors, or check configured MCP servers). -2. Match tool names against the table above. -3. A source is available **only** if its corresponding MCP tool is confirmed accessible. - -### Rules - -- **NEVER present a source unless its MCP tool is confirmed available.** -- If **no search tools are found** → present only **Other** and tell the user no automated media sources are currently configured. - -## Step 2: Present Source Options - -Build the options list dynamically. Include **only** sources whose MCP tool is available, plus **Other**. Number them sequentially. **Wait for the user to choose before doing anything else.** - -**All sources available:** - -> I can help you find that. Where would you like to search? -> 1. **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** — Semantic search through D360 -> 2. **CMS Image Search (Salesforce CMS)** — Search images by keywords and taxonomies -> 3. **Unsplash** — Stock images from Unsplash -> 4. **Other** (please specify) - -**Only CMS + D360 available:** - -> I can help you find that image. Where would you like to search? -> 1. **Data Cloud – AI Hybrid Search (Salesforce CMS + 3rd-party DAMs)** -> 2. **CMS Image Search (Salesforce CMS)** -> 3. **Other** (please specify) - -**No sources available:** - -> No automated media sources are currently configured. You can provide a direct URL or asset library path. -> 1. **Other** (please specify) - -## Step 3: Delegate Based on User Selection - -Only after the user selects an option, follow the matching action by **source name** (not number — numbers change based on availability): - -| User selects | Action | -|---|---| -| **CMS Image Search** | Read and follow `../cms-keyword-search/SKILL.md` | -| **Data Cloud – AI Hybrid Search** | Read and follow `../cms-d360-search/SKILL.md` | -| **Unsplash** | Invoke the Unsplash MCP tool directly (see below) | -| **Other** | Ask the user for the source URL or asset library details | - -### Unsplash: Direct MCP Tool Invocation - -When the user selects **Unsplash**, do not load a separate skill. Call the Unsplash MCP tool directly: - -1. **Build the query** from the user's request (e.g. "modern apartment exterior", "family lifestyle"). Use simple, descriptive keywords. -2. **Invoke the Unsplash MCP tool** exposed by the Unsplash MCP server. Pass the search intent as the query parameter; use the tool's schema for exact parameter names and optional fields (e.g. `per_page`, `orientation`). -3. **Present results** with preview thumbnails, photographer credit where available, and a note that Unsplash images are free to use under the [Unsplash License](https://unsplash.com/license). Let the user choose which image to use before placing it. - -## Step 4: Handle Errors - -If any MCP tool call fails (server error, token expired, connection refused): - -- **Do not silently fail.** Tell the user the search tool is currently unavailable and suggest checking MCP server status. -- Offer to retry, or fall back to **Other** (provide a direct URL or asset library path). -- Do **not** present empty results as if the search succeeded. - -## Step 5: Present Results - -After the delegated skill returns results: - -- Display returned assets with preview thumbnails when available. -- Include asset title, source system, and relevance score or tags. -- Let the user confirm which asset to use before inserting it into the page or component. -- Do **not** automatically use the first result — user selection is required. - ---- - -## Prohibitions - -- ❌ Do NOT skip source discovery — never assume a source is available -- ❌ Do NOT present source options without confirming MCP tool availability first -- ❌ Do NOT call `search_media_cms_channels`, `search_content_in_d360`, `search_electronic_media`, or any search tool directly — always go through this skill's source selection flow first -- ❌ Do NOT auto-select a source — always let the user choose -- ❌ Do NOT bypass this skill by loading `cms-keyword-search` or `cms-d360-search` directly for an initial image request From e515d3cfa7c96010ad46a000eea25fe43b9354eb Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 16:40:17 +0530 Subject: [PATCH 15/25] Create searching media SKILL.md --- skills/searching-media/SKILL.md | 318 ++++++++++++++++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 skills/searching-media/SKILL.md diff --git a/skills/searching-media/SKILL.md b/skills/searching-media/SKILL.md new file mode 100644 index 0000000..dc5a8af --- /dev/null +++ b/skills/searching-media/SKILL.md @@ -0,0 +1,318 @@ +--- +name: searching-media +description: Use when the user wants to FIND, SEARCH, or RETRIEVE images, photos, pictures, media, visuals, graphics, icons, illustrations, banners, thumbnails, logos, hero images, backgrounds, cover images, feature images, stock photos, product images, or visual assets from available sources. Trigger on requests to search, find, get, fetch, retrieve, browse, look up, locate, or add existing media. This is a ROUTING skill — it discovers which search sources are available (Salesforce CMS, Data Cloud, Unsplash) and lets the user choose. Use even if the user describes needing a visual without explicitly saying "search" (e.g., "I need an image for the header", "get me a background for the hero section"). DO NOT trigger for requests to GENERATE, CREATE, MAKE, DESIGN, or BUILD new images — those require different tools. +metadata: + author: afv-library + version: "1.0" +--- + +# Media Search + +Universal routing skill for searching and retrieving existing images and media. + +## Scope + +**This skill is for FINDING existing media, not CREATING new media.** + +**Use this skill when the user wants to:** +- Search for images in Salesforce CMS, Data Cloud, or Unsplash +- Find existing visual assets +- Retrieve media from connected sources +- Browse available images +- Locate specific photos or graphics + +**DO NOT use this skill when the user wants to:** +- Generate new images with AI (use image generation tools) +- Create graphics or designs from scratch +- Edit or modify existing images +- Build custom visuals or diagrams + +## Before You Search + +**This is a routing skill, not a direct search skill.** When a user requests to find an image, do NOT immediately call a search tool. Instead: + +1. Check which search tools (MCP tools) you have access to +2. Present the available search sources as numbered options +3. Wait for the user to select one +4. Then execute the selected search method + +**Never auto-select a search source.** The user must choose from the available options. Similarly, when presenting search results, **never auto-select an image** — let the user choose. + +## Workflow Overview + +1. Identify which search sources (MCP tools) are available +2. Present those options to the user +3. Wait for user selection +4. Execute the selected search method +5. Return results for the user to choose from + +## Discovering Available Search Sources + +Before presenting options, check which MCP tools you have access to and map them to search sources: + +| MCP Tool Name | Search Source | Search Type | +|---|---|---| +| `search_media_cms_channels` | Search using keywords | Keyword + taxonomy search in Salesforce CMS | +| `search_electronic_media` | Search using Data 360 hybrid search | Semantic/AI search across CMS + 3rd-party DAMs | +| Any Unsplash tool | Unsplash | Free stock photos | + +**Your first response** should identify which sources are available and present numbered options to the user. Do not call any search tools yet — just present the options and wait for the user to choose. + +### Example First Response + +``` +I'll help you find that image. Let me check which search sources are available. + +Available search sources: +1. Search using Data 360 hybrid search — Semantic search across Salesforce CMS and connected DAMs +2. Search using keywords — Search Salesforce CMS by keywords and taxonomies +3. Other — Provide your own URL or path + +Which option would you like to use? +``` + +If no automated search tools are available: +``` +No automated media sources are currently configured. Please provide a direct URL or asset library path. +``` + +**Example (all sources available):** +``` +I can help you find that image. Where would you like to search? + +1. **Search using Data 360 hybrid search** — Semantic search across Salesforce CMS and connected DAMs +2. **Search using keywords** — Search Salesforce CMS by keywords and taxonomies +3. **Unsplash** — Free stock photos +4. **Other** — Provide your own URL or path +``` + +**Example (only keyword search available):** +``` +I can help you find that image. Where would you like to search? + +1. **Search using keywords** — Search Salesforce CMS by keywords and taxonomies +2. **Other** — Provide your own URL or path +``` + +**Example (no automated sources):** +``` +No automated media sources are currently configured. Please provide: +1. **Direct URL or asset library path** +``` + +**Wait for the user to select** before proceeding. + +## Executing the Selected Search Method + +After the user selects an option, execute the corresponding search method below. + +### Search using keywords + +**Tool:** `search_media_cms_channels` + +**Process:** + +1. **Analyze the query** — Understand what the user is searching for (subject, attributes, domain) + +2. **Extract keywords** — Concrete nouns that would appear in image metadata + - Use domain-specific synonyms + - Maximum 10 terms + - Examples: + - "luxury apartments" → apartment, villa, penthouse, residence, condo + - "company logo" → logo, brand, emblem, corporate logo + - "bright room" → _(empty if no concrete nouns)_ + +3. **Extract taxonomies** — Descriptive qualities, styles, moods, categories + - Only adjectives and attributes + - Examples: + - "luxury apartment with river view" → Luxury, Premium, Waterfront, Riverside, Panoramic + - "bright spacious room" → Bright, Spacious, Open, Airy, Light + - "car" → _(empty if no descriptive terms)_ + +4. **Determine locale** — Use format `en_US`, `es_MX`, `fr_FR` (default: `en_US`) + +5. **Build the JSON payload** — Construct this exact structure: + +```json +{ + "inputs": [{ + "searchKeyword": "keyword1 OR keyword2 OR keyword3", + "taxonomyExpression": "{\"OR\": [\"Taxonomy1\", \"Taxonomy2\"]}", + "searchLanguage": "en_US", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "searchLimit": 5 + }] +} +``` + +**Field rules:** +- `searchKeyword`: Join keywords with ` OR ` (space-OR-space). Use empty string if no keywords. +- `taxonomyExpression`: Stringify JSON object `{"OR": ["term1", "term2"]}`. Use `"{}"` if no taxonomies. +- `searchLanguage`: Locale with underscore (e.g., `en_US`) +- `channelIds`: Always empty string +- `channelType`: Always `"PublicUnauthenticated"` +- `contentTypeFqns`: Always `"sfdc_cms__image"` +- `pageOffset`: Start at `0`, increment by `searchLimit` for pagination +- `searchLimit`: Default `5`, adjust if user requests more + +**Examples:** + +Query: "luxury apartment with river view" +```json +{ + "inputs": [{ + "searchKeyword": "apartment OR villa OR penthouse OR residence", + "taxonomyExpression": "{\"OR\": [\"Luxury\", \"Premium\", \"Waterfront\", \"Riverside\"]}", + "searchLanguage": "en_US", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "searchLimit": 5 + }] +} +``` + +Query: "bright spacious room" (no concrete nouns) +```json +{ + "inputs": [{ + "searchKeyword": "", + "taxonomyExpression": "{\"OR\": [\"Bright\", \"Spacious\", \"Open\", \"Airy\"]}", + "searchLanguage": "en_US", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "searchLimit": 5 + }] +} +``` + +Query: "car images" (no descriptive terms) +```json +{ + "inputs": [{ + "searchKeyword": "car OR automobile OR vehicle OR auto", + "taxonomyExpression": "{}", + "searchLanguage": "en_US", + "channelIds": "", + "channelType": "PublicUnauthenticated", + "contentTypeFqns": "sfdc_cms__image", + "pageOffset": 0, + "searchLimit": 5 + }] +} +``` + +6. **Call the tool** with the exact JSON payload + +### Search using Data 360 hybrid search + +**Tool:** `search_electronic_media` + +**Process:** + +1. Use the user's query **as-is** — no keyword extraction or transformation needed +2. Call `search_electronic_media` +3. Pass the query to the tool's search parameter (check the tool's schema for the exact parameter name - likely `query` or `search_query`) + +**Example:** +- User query: "modern luxury apartment with natural lighting" +- Tool call: `search_electronic_media(query="modern luxury apartment with natural lighting")` + (Note: Check the tool's schema - parameter might be `query` or `search_query`) + +### Unsplash + +**Process:** + +1. Extract simple, descriptive keywords from the user's query +2. Call the Unsplash MCP tool with the search query +3. Include photographer attribution in results + +### Other (User-Provided URL) + +Ask the user to provide: +- Direct URL to the image +- Asset library path +- Specific system/location to check + +## Presenting Search Results + +Parse the tool response and present **ALL** results as numbered options: + +``` +I found 4 images. Which one would you like to use? + +1. **Luxury Apartment Exterior** + URL: https://cms.example.com/media/luxury-apt-01.jpg + Source: Salesforce CMS + +2. **Modern High-Rise Building** + URL: https://cms.example.com/media/highrise-02.jpg + Source: Salesforce CMS + +3. **Waterfront Residence** + URL: https://cms.example.com/media/waterfront-03.jpg + Source: Salesforce CMS + +4. **Premium Condominium** + URL: https://cms.example.com/media/condo-04.jpg + Source: Salesforce CMS +``` + +**Never auto-select an image.** Always wait for user choice. + +## Applying the Selected Image + +After the user chooses: + +1. **Confirm** the selection with image name and URL +2. **Apply** the URL to the user's code/component +3. **Show** what was changed (file path and line number) +4. **Offer** next steps: + - Add alt text for accessibility + - Adjust styling or dimensions + - Find additional images + - Optimize image loading + +## Error Handling + +| Error | Response | +|---|---| +| Tool unavailable | "The [source name] tool is unavailable. Would you like to try a different source?" | +| Tool returns error | Show error message, offer retry with different terms or alternative source | +| No results found | "No results found. Try broader keywords, removing descriptive terms, or a different source." | +| Invalid user selection | Re-display options and ask again | + +**Never silently fail.** Always inform the user and offer alternatives. + +## Search Behavior Notes + +**Search using keywords:** +- Both keyword and taxonomy → results match keyword OR (keyword + taxonomy) +- Empty keyword → search by taxonomy only +- Empty taxonomy → search by keyword only +- Use `pageOffset` for pagination (increment by `searchLimit`) + +**Search using Data 360 hybrid search:** +- Handles natural language queries +- Semantic similarity matching +- Searches across multiple connected systems + +**Unsplash:** +- Free to use under Unsplash License +- Always include photographer credit +- Note license terms when presenting results + +## Key Principles + +1. **Always discover sources first** — Never assume a tool exists +2. **Present only available options** — Don't show unavailable sources +3. **Wait for user selection** — Never auto-select a source or image +4. **Show all results** — Let the user choose the best match +5. **Confirm before applying** — Verify the selection before modifying code +6. **Handle errors gracefully** — Provide clear feedback and alternatives From bdf0ff8f551cae38851fc9d52f30d969b81aee61 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 17:12:07 +0530 Subject: [PATCH 16/25] Update SKILL.md --- skills/searching-media/SKILL.md | 72 +++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 17 deletions(-) diff --git a/skills/searching-media/SKILL.md b/skills/searching-media/SKILL.md index dc5a8af..c12787e 100644 --- a/skills/searching-media/SKILL.md +++ b/skills/searching-media/SKILL.md @@ -1,9 +1,9 @@ --- name: searching-media -description: Use when the user wants to FIND, SEARCH, or RETRIEVE images, photos, pictures, media, visuals, graphics, icons, illustrations, banners, thumbnails, logos, hero images, backgrounds, cover images, feature images, stock photos, product images, or visual assets from available sources. Trigger on requests to search, find, get, fetch, retrieve, browse, look up, locate, or add existing media. This is a ROUTING skill — it discovers which search sources are available (Salesforce CMS, Data Cloud, Unsplash) and lets the user choose. Use even if the user describes needing a visual without explicitly saying "search" (e.g., "I need an image for the header", "get me a background for the hero section"). DO NOT trigger for requests to GENERATE, CREATE, MAKE, DESIGN, or BUILD new images — those require different tools. +description: Use when the user wants to FIND, SEARCH, or RETRIEVE images, photos, pictures, media, visuals, graphics, icons, illustrations, banners, thumbnails, logos, hero images, backgrounds, or visual assets. Trigger on search, find, get, fetch, retrieve, browse, look up, locate, or add existing media requests. ROUTING skill that presents search source options (Salesforce CMS, Data Cloud, Unsplash) and waits for user selection before calling any search tools. ALWAYS show numbered options first - NEVER call search_electronic_media or search_media_cms_channels directly. DO NOT trigger for GENERATE, CREATE, MAKE, DESIGN, or BUILD requests. metadata: author: afv-library - version: "1.0" + version: "1.2" --- # Media Search @@ -29,34 +29,68 @@ Universal routing skill for searching and retrieving existing images and media. ## Before You Search -**This is a routing skill, not a direct search skill.** When a user requests to find an image, do NOT immediately call a search tool. Instead: +**CRITICAL: This is a routing skill, not a direct search skill.** -1. Check which search tools (MCP tools) you have access to -2. Present the available search sources as numbered options -3. Wait for the user to select one -4. Then execute the selected search method +When a user requests to find an image: -**Never auto-select a search source.** The user must choose from the available options. Similarly, when presenting search results, **never auto-select an image** — let the user choose. +**DO NOT call any search tool directly.** You MUST follow this sequence: + +1. **First response MUST include:** A list of numbered search source options for the user +2. **Wait for user to reply** with their selected option number +3. **Only then** call the appropriate search tool + +**Example of what NOT to do:** +- ❌ Immediately calling `search_electronic_media` or `search_media_cms_channels` +- ❌ Deciding which search source to use without asking +- ❌ Saying "I'll search for you" and then calling a tool + +**Example of what TO do:** +- ✅ Show numbered list: "1. Search using Data 360 hybrid search, 2. Search using keywords, 3. Other" +- ✅ Ask: "Which option would you like to use?" +- ✅ Wait for user to reply with their choice +- ✅ Then call the tool they selected + +**Your first response when this skill triggers MUST present options and ask the user to choose. No exceptions.** ## Workflow Overview +**The user MUST choose the search source. You CANNOT skip this step.** + 1. Identify which search sources (MCP tools) are available -2. Present those options to the user -3. Wait for user selection +2. **Present ALL available options** to the user as a numbered list +3. **Wait for user to reply** with their selection 4. Execute the selected search method 5. Return results for the user to choose from +If you skip steps 2-3 and call a search tool directly, you are not following this skill correctly. + ## Discovering Available Search Sources -Before presenting options, check which MCP tools you have access to and map them to search sources: +**Step 1: Check your available MCP tools** -| MCP Tool Name | Search Source | Search Type | -|---|---|---| -| `search_media_cms_channels` | Search using keywords | Keyword + taxonomy search in Salesforce CMS | -| `search_electronic_media` | Search using Data 360 hybrid search | Semantic/AI search across CMS + 3rd-party DAMs | -| Any Unsplash tool | Unsplash | Free stock photos | +Look at your environment and identify which of these tools you have: +- Do you have `search_media_cms_channels`? → If YES, include "Search using keywords" +- Do you have `search_electronic_media`? → If YES, include "Search using Data 360 hybrid search" +- Do you have any Unsplash tool? → If YES, include "Unsplash" +- Always include "Other" as the last option -**Your first response** should identify which sources are available and present numbered options to the user. Do not call any search tools yet — just present the options and wait for the user to choose. +**Step 2: Build your response** + +Your first response must follow this structure exactly: + +``` +I'll help you find that image. Here are your search options: + +[NUMBER]. [SEARCH SOURCE NAME] — [Brief description] +[NUMBER]. [SEARCH SOURCE NAME] — [Brief description] +[NUMBER]. Other — Provide your own URL or path + +Which option would you like to use? +``` + +**Step 3: Stop and wait** + +After presenting options, STOP. Do not proceed until the user replies with their choice. ### Example First Response @@ -104,6 +138,10 @@ No automated media sources are currently configured. Please provide: ## Executing the Selected Search Method +**⚠️ ONLY reach this step if the user has explicitly selected an option from your numbered list.** + +If you haven't shown options yet, go back to the "Discovering Available Search Sources" section first. + After the user selects an option, execute the corresponding search method below. ### Search using keywords From e1764f5ed12d8c1cfeac8b4d73763ac2dc3246be Mon Sep 17 00:00:00 2001 From: thrylokya Date: Fri, 20 Mar 2026 17:13:53 +0530 Subject: [PATCH 17/25] Update SKILL.md --- skills/searching-media/SKILL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skills/searching-media/SKILL.md b/skills/searching-media/SKILL.md index c12787e..ae50c03 100644 --- a/skills/searching-media/SKILL.md +++ b/skills/searching-media/SKILL.md @@ -3,7 +3,7 @@ name: searching-media description: Use when the user wants to FIND, SEARCH, or RETRIEVE images, photos, pictures, media, visuals, graphics, icons, illustrations, banners, thumbnails, logos, hero images, backgrounds, or visual assets. Trigger on search, find, get, fetch, retrieve, browse, look up, locate, or add existing media requests. ROUTING skill that presents search source options (Salesforce CMS, Data Cloud, Unsplash) and waits for user selection before calling any search tools. ALWAYS show numbered options first - NEVER call search_electronic_media or search_media_cms_channels directly. DO NOT trigger for GENERATE, CREATE, MAKE, DESIGN, or BUILD requests. metadata: author: afv-library - version: "1.2" + version: "1.0" --- # Media Search From 513b27d35463feb0a30dc1e7aa76fecf1175750d Mon Sep 17 00:00:00 2001 From: thrylokya Date: Tue, 24 Mar 2026 01:39:28 +0530 Subject: [PATCH 18/25] Update use-skills.md --- rules/vibe-coding/use-skills.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/vibe-coding/use-skills.md b/rules/vibe-coding/use-skills.md index 6072939..10c668c 100644 --- a/rules/vibe-coding/use-skills.md +++ b/rules/vibe-coding/use-skills.md @@ -11,6 +11,7 @@ Before generating ANY Salesforce code or metadata, check available Skills and us - **Package.xml/deployment requests** → Use Package.xml Generator skill. - **Custom metadata questions** → Use Custom Metadata Advisor skill. - **Field-level security requests** → Use FLS Matrix Generator skill. +- **Media search requests** → Use searching-media skill. When the request involves finding, searching, getting, fetching, retrieving, locating, or adding existing visual media (images, logos, icons, photos, graphics, banners, thumbnails, hero images, backgrounds, company-logo), invoke `Skill(skill_name="searching-media")`. Never bypass by calling MCP tools directly or choosing a source on behalf of the user. Applies even for indirect requests like "need a logo" or "add a hero image". ## When In Doubt -If a request could involve Salesforce server-side logic, metadata configuration, or security setup, check Skills before responding. Prefer a Skill over general knowledge — Skills contain curated best practices specific to this org's standards. \ No newline at end of file +If a request could involve Salesforce server-side logic, metadata configuration, or security setup, check Skills before responding. Prefer a Skill over general knowledge — Skills contain curated best practices specific to this org's standards. From 3af96f7a97816bfd9de99b261ca42e687b0b3983 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Tue, 24 Mar 2026 01:39:57 +0530 Subject: [PATCH 19/25] Update SKILL.md --- skills/searching-media/SKILL.md | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/skills/searching-media/SKILL.md b/skills/searching-media/SKILL.md index ae50c03..a4a3f67 100644 --- a/skills/searching-media/SKILL.md +++ b/skills/searching-media/SKILL.md @@ -1,6 +1,6 @@ --- name: searching-media -description: Use when the user wants to FIND, SEARCH, or RETRIEVE images, photos, pictures, media, visuals, graphics, icons, illustrations, banners, thumbnails, logos, hero images, backgrounds, or visual assets. Trigger on search, find, get, fetch, retrieve, browse, look up, locate, or add existing media requests. ROUTING skill that presents search source options (Salesforce CMS, Data Cloud, Unsplash) and waits for user selection before calling any search tools. ALWAYS show numbered options first - NEVER call search_electronic_media or search_media_cms_channels directly. DO NOT trigger for GENERATE, CREATE, MAKE, DESIGN, or BUILD requests. +description: Use this skill ANY TIME the user's request involves finding, searching, getting, fetching, retrieving, grabbing, looking up, or locating existing visual media (images, logos, icons, photos, graphics, banners, thumbnails, hero images, backgrounds) from any source. This skill takes PRIORITY and should be used FIRST when ANY media search/retrieval is mentioned, regardless of what else the user wants to do with the media afterward. Trigger for requests like "search for logo", "find hero image", "get company logo", "grab banner from unsplash", "locate icons", "fetch background image", "retrieve product photos". This skill handles the search and source selection workflow. Only skip if the user wants to generate NEW images with AI, design custom graphics from scratch, or edit existing images. metadata: author: afv-library version: "1.0" @@ -10,23 +10,6 @@ metadata: Universal routing skill for searching and retrieving existing images and media. -## Scope - -**This skill is for FINDING existing media, not CREATING new media.** - -**Use this skill when the user wants to:** -- Search for images in Salesforce CMS, Data Cloud, or Unsplash -- Find existing visual assets -- Retrieve media from connected sources -- Browse available images -- Locate specific photos or graphics - -**DO NOT use this skill when the user wants to:** -- Generate new images with AI (use image generation tools) -- Create graphics or designs from scratch -- Edit or modify existing images -- Build custom visuals or diagrams - ## Before You Search **CRITICAL: This is a routing skill, not a direct search skill.** @@ -52,6 +35,23 @@ When a user requests to find an image: **Your first response when this skill triggers MUST present options and ask the user to choose. No exceptions.** +## Scope + +**This skill is for SEARCHING FOR existing media, not CREATING new media.** + +**Use this skill when the user wants to:** +- Search for images in Salesforce CMS, Data Cloud, or Unsplash +- Find existing visual assets to use in their app +- Retrieve media from connected sources +- Browse available images for their project +- Locate specific photos or graphics + +**DO NOT use this skill when the user wants to:** +- Generate new images with AI (use image generation tools) +- Create graphics or designs from scratch +- Edit or modify existing images +- Build custom visuals or diagrams + ## Workflow Overview **The user MUST choose the search source. You CANNOT skip this step.** From 1aa66ef2957a89dfaa9adbec17b8b102c1b9a64e Mon Sep 17 00:00:00 2001 From: thrylokya Date: Tue, 24 Mar 2026 09:30:00 +0530 Subject: [PATCH 20/25] Update SKILL.md --- skills/searching-media/SKILL.md | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/skills/searching-media/SKILL.md b/skills/searching-media/SKILL.md index a4a3f67..a6f8eef 100644 --- a/skills/searching-media/SKILL.md +++ b/skills/searching-media/SKILL.md @@ -1,6 +1,6 @@ --- name: searching-media -description: Use this skill ANY TIME the user's request involves finding, searching, getting, fetching, retrieving, grabbing, looking up, or locating existing visual media (images, logos, icons, photos, graphics, banners, thumbnails, hero images, backgrounds) from any source. This skill takes PRIORITY and should be used FIRST when ANY media search/retrieval is mentioned, regardless of what else the user wants to do with the media afterward. Trigger for requests like "search for logo", "find hero image", "get company logo", "grab banner from unsplash", "locate icons", "fetch background image", "retrieve product photos". This skill handles the search and source selection workflow. Only skip if the user wants to generate NEW images with AI, design custom graphics from scratch, or edit existing images. +description: Use this skill ANY TIME the user's request involves finding, searching, getting, fetching, retrieving, grabbing, looking up, or locating existing visual media (images, logos, icons, photos, graphics, banners, thumbnails, hero images, backgrounds) from any source. This skill takes PRIORITY and should be used FIRST when ANY media search/retrieval is mentioned, regardless of what else the user wants to do with the media afterward. Trigger for requests like "search for logo", "find hero image", "get company logo", "locate icons", "fetch background image", "retrieve product photos". This skill handles the search and source selection workflow. Only skip if the user wants to generate NEW images with AI, design custom graphics from scratch, or edit existing images. metadata: author: afv-library version: "1.0" @@ -40,7 +40,7 @@ When a user requests to find an image: **This skill is for SEARCHING FOR existing media, not CREATING new media.** **Use this skill when the user wants to:** -- Search for images in Salesforce CMS, Data Cloud, or Unsplash +- Search for images in Salesforce CMS, Data Cloud - Find existing visual assets to use in their app - Retrieve media from connected sources - Browse available images for their project @@ -71,7 +71,6 @@ If you skip steps 2-3 and call a search tool directly, you are not following thi Look at your environment and identify which of these tools you have: - Do you have `search_media_cms_channels`? → If YES, include "Search using keywords" - Do you have `search_electronic_media`? → If YES, include "Search using Data 360 hybrid search" -- Do you have any Unsplash tool? → If YES, include "Unsplash" - Always include "Other" as the last option **Step 2: Build your response** @@ -116,8 +115,7 @@ I can help you find that image. Where would you like to search? 1. **Search using Data 360 hybrid search** — Semantic search across Salesforce CMS and connected DAMs 2. **Search using keywords** — Search Salesforce CMS by keywords and taxonomies -3. **Unsplash** — Free stock photos -4. **Other** — Provide your own URL or path +3. **Other** — Provide your own URL or path ``` **Example (only keyword search available):** @@ -263,14 +261,6 @@ Query: "car images" (no descriptive terms) - Tool call: `search_electronic_media(query="modern luxury apartment with natural lighting")` (Note: Check the tool's schema - parameter might be `query` or `search_query`) -### Unsplash - -**Process:** - -1. Extract simple, descriptive keywords from the user's query -2. Call the Unsplash MCP tool with the search query -3. Include photographer attribution in results - ### Other (User-Provided URL) Ask the user to provide: @@ -341,11 +331,6 @@ After the user chooses: - Semantic similarity matching - Searches across multiple connected systems -**Unsplash:** -- Free to use under Unsplash License -- Always include photographer credit -- Note license terms when presenting results - ## Key Principles 1. **Always discover sources first** — Never assume a tool exists From ea830589bf650da7b23cea5090d745631bb407a0 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Tue, 24 Mar 2026 16:19:18 +0530 Subject: [PATCH 21/25] Update SKILL.md --- skills/searching-media/SKILL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skills/searching-media/SKILL.md b/skills/searching-media/SKILL.md index a6f8eef..69a7dc8 100644 --- a/skills/searching-media/SKILL.md +++ b/skills/searching-media/SKILL.md @@ -1,6 +1,6 @@ --- name: searching-media -description: Use this skill ANY TIME the user's request involves finding, searching, getting, fetching, retrieving, grabbing, looking up, or locating existing visual media (images, logos, icons, photos, graphics, banners, thumbnails, hero images, backgrounds) from any source. This skill takes PRIORITY and should be used FIRST when ANY media search/retrieval is mentioned, regardless of what else the user wants to do with the media afterward. Trigger for requests like "search for logo", "find hero image", "get company logo", "locate icons", "fetch background image", "retrieve product photos". This skill handles the search and source selection workflow. Only skip if the user wants to generate NEW images with AI, design custom graphics from scratch, or edit existing images. +description: You MUST Use this skill ANY TIME the user's request involves finding, searching, getting, fetching, retrieving, grabbing, looking up, or locating existing visual media (images, logos, icons, photos, graphics, banners, thumbnails, hero images, backgrounds) from any source. This skill takes PRIORITY and should be used FIRST when ANY media search/retrieval is mentioned, regardless of what else the user wants to do with the media afterward. Trigger for requests like "search for logo", "find hero image", "get company logo", "locate icons", "fetch background image", "retrieve product photos". This skill handles the search and source selection workflow. Only skip if the user wants to generate NEW images with AI, design custom graphics from scratch, or edit existing images. metadata: author: afv-library version: "1.0" From e3c5f1b124ac19adf66022315958ace5f4b4850b Mon Sep 17 00:00:00 2001 From: thrylokya Date: Tue, 24 Mar 2026 16:43:26 +0530 Subject: [PATCH 22/25] Update SKILL.md --- skills/searching-media/SKILL.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/skills/searching-media/SKILL.md b/skills/searching-media/SKILL.md index 69a7dc8..ab6958d 100644 --- a/skills/searching-media/SKILL.md +++ b/skills/searching-media/SKILL.md @@ -177,7 +177,7 @@ After the user selects an option, execute the corresponding search method below. "searchLanguage": "en_US", "channelIds": "", "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", + "contentTypeFqn": "sfdc_cms__image", "pageOffset": 0, "searchLimit": 5 }] @@ -190,7 +190,7 @@ After the user selects an option, execute the corresponding search method below. - `searchLanguage`: Locale with underscore (e.g., `en_US`) - `channelIds`: Always empty string - `channelType`: Always `"PublicUnauthenticated"` -- `contentTypeFqns`: Always `"sfdc_cms__image"` +- ``: Always `"sfdc_cms__image"` - `pageOffset`: Start at `0`, increment by `searchLimit` for pagination - `searchLimit`: Default `5`, adjust if user requests more @@ -205,7 +205,7 @@ Query: "luxury apartment with river view" "searchLanguage": "en_US", "channelIds": "", "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", + "": "sfdc_cms__image", "pageOffset": 0, "searchLimit": 5 }] @@ -221,7 +221,7 @@ Query: "bright spacious room" (no concrete nouns) "searchLanguage": "en_US", "channelIds": "", "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", + "": "sfdc_cms__image", "pageOffset": 0, "searchLimit": 5 }] @@ -237,7 +237,7 @@ Query: "car images" (no descriptive terms) "searchLanguage": "en_US", "channelIds": "", "channelType": "PublicUnauthenticated", - "contentTypeFqns": "sfdc_cms__image", + "": "sfdc_cms__image", "pageOffset": 0, "searchLimit": 5 }] From 5c740725b07e2f7158e82a8b93b72ba076800ba1 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Thu, 26 Mar 2026 21:01:17 +0530 Subject: [PATCH 23/25] Delete rules/vibe-coding/use-skills.md --- rules/vibe-coding/use-skills.md | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 rules/vibe-coding/use-skills.md diff --git a/rules/vibe-coding/use-skills.md b/rules/vibe-coding/use-skills.md deleted file mode 100644 index 10c668c..0000000 --- a/rules/vibe-coding/use-skills.md +++ /dev/null @@ -1,17 +0,0 @@ -# SKILLS REQUIREMENTS - -## Mandatory Skill Usage -Before generating ANY Salesforce code or metadata, check available Skills and use the matching one. Never generate Salesforce code freehand when a relevant Skill exists. - -## Skill Routing -- **Apex class requests** → Use Apex Class Writer skill. Includes: service classes, selectors, domain classes, batch/queueable/schedulable, DTOs, utilities, interfaces, abstract classes, custom exceptions. Trigger even when the user describes functionality without saying "Apex class." -- **Trigger requests** → Use Trigger Framework Scaffolder skill. -- **Validation rule requests** → Use Validation Rule Writer skill. -- **Permission/security questions** → Use Permission Set Auditor skill. -- **Package.xml/deployment requests** → Use Package.xml Generator skill. -- **Custom metadata questions** → Use Custom Metadata Advisor skill. -- **Field-level security requests** → Use FLS Matrix Generator skill. -- **Media search requests** → Use searching-media skill. When the request involves finding, searching, getting, fetching, retrieving, locating, or adding existing visual media (images, logos, icons, photos, graphics, banners, thumbnails, hero images, backgrounds, company-logo), invoke `Skill(skill_name="searching-media")`. Never bypass by calling MCP tools directly or choosing a source on behalf of the user. Applies even for indirect requests like "need a logo" or "add a hero image". - -## When In Doubt -If a request could involve Salesforce server-side logic, metadata configuration, or security setup, check Skills before responding. Prefer a Skill over general knowledge — Skills contain curated best practices specific to this org's standards. From 28cf871f50852f015c6991ee669ea33286f74311 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Thu, 26 Mar 2026 21:03:01 +0530 Subject: [PATCH 24/25] Create use-skills.md --- rules/vibe-coding/use-skills.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 rules/vibe-coding/use-skills.md diff --git a/rules/vibe-coding/use-skills.md b/rules/vibe-coding/use-skills.md new file mode 100644 index 0000000..17efe5c --- /dev/null +++ b/rules/vibe-coding/use-skills.md @@ -0,0 +1,16 @@ +# SKILLS REQUIREMENTS + +## Mandatory Skill Usage +Before generating ANY Salesforce code or metadata, check available Skills and use the matching one. Never generate Salesforce code freehand when a relevant Skill exists. + +## Skill Routing +- **Apex class requests** → Use Apex Class Writer skill. Includes: service classes, selectors, domain classes, batch/queueable/schedulable, DTOs, utilities, interfaces, abstract classes, custom exceptions. Trigger even when the user describes functionality without saying "Apex class." +- **Trigger requests** → Use Trigger Framework Scaffolder skill. +- **Validation rule requests** → Use Validation Rule Writer skill. +- **Permission/security questions** → Use Permission Set Auditor skill. +- **Package.xml/deployment requests** → Use Package.xml Generator skill. +- **Custom metadata questions** → Use Custom Metadata Advisor skill. +- **Field-level security requests** → Use FLS Matrix Generator skill. + +## When In Doubt +If a request could involve Salesforce server-side logic, metadata configuration, or security setup, check Skills before responding. Prefer a Skill over general knowledge — Skills contain curated best practices specific to this org's standards. From 81d4fc10519dbd41433ae0e95638c18ffdd17fb7 Mon Sep 17 00:00:00 2001 From: thrylokya Date: Thu, 26 Mar 2026 21:05:36 +0530 Subject: [PATCH 25/25] Update use-skills.md