Sync local OpenClaw skills to a remote NanoClaw agent on the Mysta platform via MCP (Model Context Protocol).
The user needs a Mysta API key (starts with mysta_) stored in the MYSTA_API_KEY environment variable.
if [ -n "${MYSTA_API_KEY}" ]; then echo "Key is set"; else echo "Key not set"; fi
# Cross-platform browser open
if command -v xdg-open &>/dev/null; then
xdg-open "https://app.staging.mysta.tech/en/profile#api-keys"
elif command -v open &>/dev/null; then
open "https://app.staging.mysta.tech/en/profile#api-keys"
else
echo "Please visit: https://app.staging.mysta.tech/en/profile#api-keys"
fi
export MYSTA_API_KEY=mysta_..."Once the key is set, configure the variables for all subsequent commands:
# API key from environment (required)
: "${MYSTA_API_KEY:?Please set MYSTA_API_KEY environment variable}"
# MCP server URL (defaults to staging, override with MYSTA_MCP_URL for other envs)
MCP_URL="${MYSTA_MCP_URL:-https://api.staging.mysta.tech/api/v2/mcp}"
All communication uses the MCP Streamable HTTP transport over HTTPS. Each request is a JSON-RPC call via HTTP POST. No temporary files are written — session IDs are extracted from response headers in-memory. The flow is:
# Extract session ID from response headers without writing temp files
MCP_SESSION=$(curl -sf -X POST "${MCP_URL}" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer ${MYSTA_API_KEY}" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"openclaw","version":"1.0.0"}}}' \
-D- -o /dev/null 2>/dev/null | grep -i "mcp-session-id" | tr -d '\r' | awk '{print $2}')
Then send the initialized notification:
curl -sf -X POST "${MCP_URL}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${MYSTA_API_KEY}" \
-H "Mcp-Session-Id: ${MCP_SESSION}" \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
RESULT=$(curl -sf -X POST "${MCP_URL}" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer ${MYSTA_API_KEY}" \
-H "Mcp-Session-Id: ${MCP_SESSION}" \
-d "$(jq -n --arg name "TOOL_NAME" --argjson args 'ARGS_JSON' \
'{jsonrpc:"2.0",id:2,method:"tools/call",params:{name:$name,arguments:$args}}')")
The response may be SSE (text/event-stream) — parse data: lines for JSON-RPC results.
curl -sf -X DELETE "${MCP_URL}" \
-H "Authorization: Bearer ${MYSTA_API_KEY}" \
-H "Mcp-Session-Id: ${MCP_SESSION}"
Initialize using the protocol above. Store MCP_SESSION for all subsequent calls.
Call the mysta_list_agents tool:
RESULT=$(curl -sf -X POST "${MCP_URL}" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer ${MYSTA_API_KEY}" \
-H "Mcp-Session-Id: ${MCP_SESSION}" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"mysta_list_agents","arguments":{}}}')
Parse the response to find agent IDs and names.
Find all SKILL.md files in the OpenClaw skills directories:
find ~/.openclaw/skills ~/Workspace/openclaw/skills -maxdepth 2 -name "SKILL.md" -type f 2>/dev/null
For each skill, the name is the parent directory name.
Present the list and ask:
For each selected skill, read the content and call mysta_sync_skill:
SKILL_CONTENT=$(cat "$SKILL_PATH")
RESULT=$(curl -sf -X POST "${MCP_URL}" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer ${MYSTA_API_KEY}" \
-H "Mcp-Session-Id: ${MCP_SESSION}" \
-d "$(jq -n --arg name "$SKILL_NAME" --arg content "$SKILL_CONTENT" --arg agentId "$AGENT_ID" \
'{jsonrpc:"2.0",id:3,method:"tools/call",params:{name:"mysta_sync_skill",arguments:{agentId:$agentId,skillName:$name,content:$content}}}')")
Alternatively, use mysta_sync_all_skills to batch upload:
# Build skills JSON array
SKILLS_JSON=$(for skill_path in $SELECTED_SKILLS; do
name=$(basename $(dirname "$skill_path"))
content=$(cat "$skill_path")
jq -n --arg name "$name" --arg content "$content" '{name:$name,content:$content}'
done | jq -s '.')
RESULT=$(curl -sf -X POST "${MCP_URL}" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "Authorization: Bearer ${MYSTA_API_KEY}" \
-H "Mcp-Session-Id: ${MCP_SESSION}" \
-d "$(jq -n --arg agentId "$AGENT_ID" --argjson skills "$SKILLS_JSON" \
'{jsonrpc:"2.0",id:3,method:"tools/call",params:{name:"mysta_sync_all_skills",arguments:{agentId:$agentId,skills:$skills}}}')")
Close the MCP session, then show a summary:
MYSTA_API_KEY must be stored as an environment variable, never hardcoded in scripts. Use limited-scope keys and revoke after use.共 1 个版本