Mysta Skill Sync
Sync local OpenClaw skills to a remote NanoClaw agent on the Mysta platform via MCP (Model Context Protocol).
Authentication
The user needs a Mysta API key (starts with mysta_) stored in the MYSTA_API_KEY environment variable.
- 1. Check if the key is already set:
CODEBLOCK0
- 2. If not set, open the API keys page in their browser:
CODEBLOCK1
- 3. Tell them: "Please create a new API key and set it as an environment variable:
export MYSTA_API_KEY=mysta_..."
- 4. Wait for the user to set their key.
Once the key is set, configure the variables for all subsequent commands:
CODEBLOCK2
MCP Protocol
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:
- 1. Initialize a session (get a session ID)
- Call tools using the session ID
- Close the session when done
Initialize session
CODEBLOCK3
Then send the initialized notification:
CODEBLOCK4
Call a tool
CODEBLOCK5
The response may be SSE (text/event-stream) — parse data: lines for JSON-RPC results.
Close session
CODEBLOCK6
Workflow
Step 1: Initialize MCP session
Initialize using the protocol above. Store MCP_SESSION for all subsequent calls.
Step 2: List agents
Call the mysta_list_agents tool:
CODEBLOCK7
Parse the response to find agent IDs and names.
- - If no agents found, tell the user to create one at https://app.staging.mysta.tech
- If one agent, auto-select it
- If multiple, ask which one to sync to
Step 3: Scan local skills
Find all SKILL.md files in the OpenClaw skills directories:
CODEBLOCK8
For each skill, the name is the parent directory name.
Present the list and ask:
- - "all" → sync everything
- specific names → sync only those
- "cancel" → abort
Step 4: Upload skills via MCP
For each selected skill, read the content and call mysta_sync_skill:
CODEBLOCK9
Alternatively, use mysta_sync_all_skills to batch upload:
CODEBLOCK10
Step 5: Close session and report results
Close the MCP session, then show a summary:
- - Total skills synced
- Any failures with error details
- If the agent's dev pod was running, skills are live immediately
- If not running, tell user to start the dev pod on https://app.staging.mysta.tech to apply skills
Security Notes
- - All API communication uses HTTPS. API keys are transmitted over encrypted connections only.
- The
MYSTA_API_KEY must be stored as an environment variable, never hardcoded in scripts. Use limited-scope keys and revoke after use. - No temporary files are written. Session IDs are extracted in-memory from response headers and stored only in shell variables for the duration of the session.
- SKILL.md file contents are read and uploaded to the Mysta server. Review skill files before syncing — do not include secrets, credentials, or sensitive data in SKILL.md files.
- API keys are scoped to the authenticated user's agents only.
- This skill requires explicit user consent before: opening a browser, uploading files, or connecting to the Mysta API.
Notes
- - Skills are uploaded to OSS for audit and pushed to the agent's NAS-mounted storage.
- Skills persist across pod restarts.
- Re-uploading a skill with the same name overwrites it (idempotent).
- This does NOT publish the agent. Publishing is a separate action on the Mysta platform.
- The MCP server handles auth, OSS audit, DB metadata update, and live push to running pods — all in one call.
Mysta 技能同步
通过 MCP(模型上下文协议)将本地 OpenClaw 技能同步到 Mysta 平台上的远程 NanoClaw 代理。
身份验证
用户需要将 Mysta API 密钥(以 mysta 开头)存储在 MYSTAAPI_KEY 环境变量中。
- 1. 检查密钥是否已设置:
bash
if [ -n ${MYSTAAPIKEY} ]; then echo 密钥已设置; else echo 密钥未设置; fi
- 2. 如果未设置,在浏览器中打开 API 密钥页面:
bash
跨平台浏览器打开
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 请访问:https://app.staging.mysta.tech/en/profile#api-keys
fi
- 3. 告知用户:请创建一个新的 API 密钥,并将其设置为环境变量:export MYSTAAPIKEY=mysta_...
- 4. 等待用户设置密钥。
密钥设置完成后,为所有后续命令配置变量:
bash
来自环境变量的 API 密钥(必需)
: ${MYSTA
APIKEY:?请设置 MYSTA
APIKEY 环境变量}
MCP 服务器 URL(默认为 staging,可通过 MYSTAMCPURL 覆盖其他环境)
MCP
URL=${MYSTAMCP_URL:-https://api.staging.mysta.tech/api/v2/mcp}
MCP 协议
所有通信均通过 HTTPS 使用 MCP Streamable HTTP 传输。每个请求都是通过 HTTP POST 进行的 JSON-RPC 调用。不写入临时文件——会话 ID 从响应头中内存提取。流程如下:
- 1. 初始化 会话(获取会话 ID)
- 使用会话 ID 调用工具
- 完成后 关闭 会话
初始化会话
bash
从响应头中提取会话 ID,不写入临时文件
MCP
SESSION=$(curl -sf -X POST ${MCPURL} \
-H Content-Type: application/json \
-H Accept: application/json, text/event-stream \
-H Authorization: Bearer ${MYSTA
APIKEY} \
-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})
然后发送初始化通知:
bash
curl -sf -X POST ${MCP_URL} \
-H Content-Type: application/json \
-H Authorization: Bearer ${MYSTAAPIKEY} \
-H Mcp-Session-Id: ${MCP_SESSION} \
-d {jsonrpc:2.0,method:notifications/initialized}
调用工具
bash
RESULT=$(curl -sf -X POST ${MCP_URL} \
-H Content-Type: application/json \
-H Accept: application/json, text/event-stream \
-H Authorization: Bearer ${MYSTAAPIKEY} \
-H Mcp-Session-Id: ${MCP_SESSION} \
-d $(jq -n --arg name TOOLNAME --argjson args ARGSJSON \
{jsonrpc:2.0,id:2,method:tools/call,params:{name:$name,arguments:$args}}))
响应可能是 SSE(text/event-stream)——解析 data: 行以获取 JSON-RPC 结果。
关闭会话
bash
curl -sf -X DELETE ${MCP_URL} \
-H Authorization: Bearer ${MYSTAAPIKEY} \
-H Mcp-Session-Id: ${MCP_SESSION}
工作流程
步骤 1:初始化 MCP 会话
使用上述协议进行初始化。存储 MCP_SESSION 以供所有后续调用使用。
步骤 2:列出代理
调用 mystalistagents 工具:
bash
RESULT=$(curl -sf -X POST ${MCP_URL} \
-H Content-Type: application/json \
-H Accept: application/json, text/event-stream \
-H Authorization: Bearer ${MYSTAAPIKEY} \
-H Mcp-Session-Id: ${MCP_SESSION} \
-d {jsonrpc:2.0,id:2,method:tools/call,params:{name:mystalistagents,arguments:{}}})
解析响应以查找代理 ID 和名称。
- - 如果未找到代理,告知用户在 https://app.staging.mysta.tech 创建一个
- 如果只有一个代理,自动选择它
- 如果有多个,询问要同步到哪一个
步骤 3:扫描本地技能
在 OpenClaw 技能目录中查找所有 SKILL.md 文件:
bash
find ~/.openclaw/skills ~/Workspace/openclaw/skills -maxdepth 2 -name SKILL.md -type f 2>/dev/null
对于每个技能,名称是其父目录名。
展示列表并询问:
- - all → 同步所有内容
- 特定名称 → 仅同步这些
- cancel → 中止
步骤 4:通过 MCP 上传技能
对于每个选定的技能,读取内容并调用 mystasyncskill:
bash
SKILLCONTENT=$(cat $SKILLPATH)
RESULT=$(curl -sf -X POST ${MCP_URL} \
-H Content-Type: application/json \
-H Accept: application/json, text/event-stream \
-H Authorization: Bearer ${MYSTAAPIKEY} \
-H Mcp-Session-Id: ${MCP_SESSION} \
-d $(jq -n --arg name $SKILLNAME --arg content $SKILLCONTENT --arg agentId $AGENT_ID \
{jsonrpc:2.0,id:3,method:tools/call,params:{name:mystasyncskill,arguments:{agentId:$agentId,skillName:$name,content:$content}}}))
或者,使用 mystasyncall_skills 批量上传:
bash
构建技能 JSON 数组
SKILLS
JSON=$(for skillpath 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 ${MYSTAAPIKEY} \
-H Mcp-Session-Id: ${MCP_SESSION} \
-d $(jq -n --arg agentId $AGENTID --argjson skills $SKILLSJSON \
{jsonrpc:2.0,id:3,method:tools/call,params:{name:mystasyncall_skills,arguments:{agentId:$agentId,skills:$skills}}}))
步骤 5:关闭会话并报告结果
关闭 MCP 会话,然后显示摘要:
- - 同步的技能总数
- 任何失败及其错误详情
- 如果代理的开发 pod 正在运行,技能将立即生效
- 如果未运行,告知用户在 https://app.staging.mysta.tech 上启动开发 pod 以应用技能
安全说明
- - 所有 API 通信均使用 HTTPS。API 密钥仅通过加密连接传输。
- MYSTAAPIKEY 必须存储为环境变量,切勿硬编码在脚本中。使用有限范围的密钥,并在使用后撤销。
- 不写入临时文件。会话 ID 从响应头中内存提取,仅在会话期间存储在 shell 变量中。
- SKILL.md 文件内容被读取并上传到 Mysta 服务器。在同步前审查技能文件——不要在 SKILL.md 文件中包含机密、凭据或敏感数据。
- API 密钥仅限用于已验证用户的代理。
- 此技能在以下操作前需要明确的用户同意:打开浏览器、上传文件或连接到 Mysta API。
备注