dsh-tencent-lighthouse 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +80 -2
  3. package/cordis.patch.yml +10 -0
  4. package/lib/index.js +251 -0
  5. package/package.json +38 -4
  6. package/skills/lighthouse-ops/SKILL.md +166 -0
  7. package/skills/lighthouse-ops/_meta.json +6 -0
  8. package/skills/lighthouse-ops/references/architecture.md +96 -0
  9. package/skills/lighthouse-ops/references/oauth-flow.md +142 -0
  10. package/skills/lighthouse-ops/references/platform-adapters.md +261 -0
  11. package/skills/lighthouse-ops/references/token-lifecycle.md +84 -0
  12. package/skills/lighthouse-ops/references/usage/application-deployment/SKILL.md +263 -0
  13. package/skills/lighthouse-ops/references/usage/domain-management/SKILL.md +154 -0
  14. package/skills/lighthouse-ops/references/usage/firewall-management/SKILL.md +59 -0
  15. package/skills/lighthouse-ops/references/usage/instance-management/SKILL.md +192 -0
  16. package/skills/lighthouse-ops/references/usage/instance-management/references/purchase-links.md +92 -0
  17. package/skills/lighthouse-ops/references/usage/monitoring/SKILL.md +128 -0
  18. package/skills/lighthouse-ops/references/usage/remote-command/SKILL.md +141 -0
  19. package/skills/lighthouse-ops/references/usage/snapshot-management/SKILL.md +91 -0
  20. package/skills/lighthouse-ops/references/usage/ssl-certificate/SKILL.md +196 -0
  21. package/skills/lighthouse-ops/references/usage/ssl-certificate/references/nginx-https.md +87 -0
  22. package/skills/lighthouse-ops/references/usage/ssl-certificate/references/troubleshooting.md +34 -0
  23. package/skills/lighthouse-ops/scripts/mcp_oauth_client.py +1470 -0
package/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 念念 (ynlp0624)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---------------------------------------------------------------------------
24
+ Bundled third-party content:
25
+ skills/lighthouse-ops/ — 腾讯云「轻量云专家」发布物(含 mcp_oauth_client.py)。
26
+ 版权归原发布者所有,本包原样分发,仅新增 DSH 适配说明;MIT 仅覆盖 lib/ 与
27
+ 其余为本包新写的文件。
package/README.md CHANGED
@@ -1,3 +1,81 @@
1
- # Temporary Holding Version
1
+ # dsh-tencent-lighthouse
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 把**腾讯云轻量应用服务器(Lighthouse)**接进 [DeepSeek Harness](https://github.com/deepseek-ai) 的插件包:
4
+ 三个原生工具 + 一份完整运维技能(实例 / 防火墙 / 快照 / 监控 / 部署 / 远程命令 / 域名解析 / HTTPS 证书)。
5
+
6
+ 连接层用腾讯云「轻量云专家 MCP」(OAuth 2.1 + PKCE + DCR),由包内零依赖 Python 脚本完成,
7
+ 令牌落在本机固定目录,临近过期自动刷新。
8
+
9
+ ## 前置条件
10
+
11
+ | 项 | 说明 |
12
+ |---|---|
13
+ | Node | ≥ 20(插件本身零运行时依赖) |
14
+ | Python | ≥ 3.8,`python` 或 `python3` 在 PATH 里(脚本只用标准库) |
15
+ | 网络 | 能访问 `https://lightai.cloud.tencent.com` |
16
+ | 账号 | 首次使用需在浏览器里用腾讯云账号完成一次 OAuth 授权 |
17
+
18
+ ## 安装
19
+
20
+ ```bash
21
+ dsh plugin install dsh-tencent-lighthouse
22
+ ```
23
+
24
+ 或手工装进 profile:
25
+
26
+ ```bash
27
+ npm i dsh-tencent-lighthouse
28
+ ```
29
+
30
+ bundle 层会在 profile 组合树里插入一行:
31
+
32
+ ```yaml
33
+ - id: dsh-tencent-lighthouse
34
+ name: "dsh-tencent-lighthouse"
35
+ config:
36
+ pythonPath: "python" # 或 python3 / 绝对路径
37
+ platform: "deepseek" # MCP 端点后缀 → .../workbuddy/mcp/deepseek
38
+ oauthHome: "" # 空 = 默认 ~/.mcp-oauth-connector
39
+ timeoutMs: 180000
40
+ ```
41
+
42
+ ## 工具
43
+
44
+ | 工具 | 作用 |
45
+ |---|---|
46
+ | `tencent_lighthouse_auth` | `preflight` 自检 · `status` 看令牌 · `connect` 开始浏览器授权(需真人同意)· `refresh` 换令牌 · `logout` 清除 |
47
+ | `tencent_lighthouse_tools` | 列出 MCP 侧 60 个工具(实例/防火墙/快照/监控/部署/命令/DNS/证书) |
48
+ | `tencent_lighthouse_call` | 调用其中一个工具,`tool` + `args` 两个参数 |
49
+
50
+ 返回值统一带 `ok` 字段:**`ok=false` 是失败,不是空结果**。远程命令类工具另有 `command.status`,
51
+ `RUNNING` / `RUNNING_ASYNC` 表示仍在执行,应按 `command.next` 轮询 `describe_command_tasks`,不要重复下发。
52
+
53
+ ## 技能
54
+
55
+ 包内 `skills/lighthouse-ops/` 是一份完整技能:连接机制说明(architecture / oauth-flow / token-lifecycle /
56
+ platform-adapters)+ 各业务场景的操作规范(实例、防火墙、快照、监控、应用部署、远程命令、域名、SSL 证书)。
57
+ DSH 安装本包后会把它作为技能资料提供给 Agent。
58
+
59
+ ## 第一次使用
60
+
61
+ ```
62
+ tencent_lighthouse_auth action=preflight # 解释器/TLS/端点/令牌目录自检
63
+ tencent_lighthouse_auth action=connect # 打开浏览器 → 登录腾讯云 → 同意
64
+ tencent_lighthouse_tools # 确认工具清单
65
+ tencent_lighthouse_call tool=describe_instances args={"Region":"ap-guangzhou","Offset":0,"Limit":100}
66
+ ```
67
+
68
+ 令牌默认存在 `~/.mcp-oauth-connector/tokens.json`(0600)。换机器/换用户要重新 `connect`。
69
+
70
+ ## 安全与边界
71
+
72
+ - 本包不接触你的腾讯云 AK/SK,只持有 OAuth access / refresh token,且只在本地存储。
73
+ - 高危操作(删除实例、回滚快照、删镜像、删域名)不可逆 —— 插件不会替你决定,调用前请人工确认。
74
+ - `describe_*` 列表接口默认只回 20 条、`Limit` 上限 100;做规模性判断前必须翻页拉全。
75
+ - Lighthouse 与 CVM 是两套 API,互不通用。
76
+
77
+ ## 许可
78
+
79
+ 代码部分 MIT(见 `LICENSE`)。
80
+ `skills/lighthouse-ops/` 内的技能文本与 `mcp_oauth_client.py` 来自腾讯云「轻量云专家」发布物,
81
+ 版权归原发布者所有,此处按其原样分发、仅做 DSH 适配说明,不改变其授权。
@@ -0,0 +1,10 @@
1
+ # dsh-tencent-lighthouse bundle layer: 把插件行插进 profile 组合树。
2
+ # 依赖:python 3.8+(脚本零第三方依赖)、能访问 https://lightai.cloud.tencent.com
3
+ - insert:
4
+ - id: dsh-tencent-lighthouse
5
+ name: "dsh-tencent-lighthouse"
6
+ config:
7
+ pythonPath: "python"
8
+ platform: "deepseek"
9
+ oauthHome: ""
10
+ timeoutMs: 180000
package/lib/index.js ADDED
@@ -0,0 +1,251 @@
1
+ /**
2
+ * dsh-tencent-lighthouse — 把腾讯云轻量应用服务器(Lighthouse)的「轻量云专家 MCP」
3
+ * 接成 DeepSeek Harness 的原生工具。
4
+ *
5
+ * 连接层由包内 `skills/lighthouse-ops/scripts/mcp_oauth_client.py` 完成
6
+ * (OAuth 2.1 + PKCE + DCR,零第三方依赖),本插件只负责:
7
+ * 1. 用固定的 MCP_OAUTH_HOME 落盘并复用令牌;
8
+ * 2. 把 `tools/list` / `tools/call` / 授权动作包成 DSH 工具;
9
+ * 3. 把调用结果规整成 `{ ok, ... }`,失败不被当成空结果。
10
+ *
11
+ * 不引入任何运行时依赖,Node 20+。
12
+ */
13
+ import { execFileSync } from 'node:child_process'
14
+ import { existsSync } from 'node:fs'
15
+ import { dirname, join } from 'node:path'
16
+ import { fileURLToPath } from 'node:url'
17
+
18
+ /** Cordis 插件名(Loader 行 id)。 */
19
+ export const name = 'dsh-tencent-lighthouse'
20
+
21
+ /** 需要先就位的服务。 */
22
+ export const inject = ['tools']
23
+
24
+ const HERE = dirname(fileURLToPath(import.meta.url))
25
+ const SCRIPT_PATH = join(HERE, '..', 'skills', 'lighthouse-ops', 'scripts', 'mcp_oauth_client.py')
26
+
27
+ const DEFAULTS = {
28
+ pythonPath: 'python',
29
+ platform: 'deepseek',
30
+ oauthHome: '',
31
+ timeoutMs: 180000,
32
+ }
33
+
34
+ /** 合并用户配置。 */
35
+ function resolveConfig(raw) {
36
+ const cfg = raw && typeof raw === 'object' ? raw : {}
37
+ const timeout = Number(cfg.timeoutMs)
38
+ return {
39
+ pythonPath: typeof cfg.pythonPath === 'string' && cfg.pythonPath !== '' ? cfg.pythonPath : DEFAULTS.pythonPath,
40
+ platform: typeof cfg.platform === 'string' && cfg.platform !== '' ? cfg.platform : DEFAULTS.platform,
41
+ oauthHome: typeof cfg.oauthHome === 'string' ? cfg.oauthHome : DEFAULTS.oauthHome,
42
+ timeoutMs: Number.isFinite(timeout) && timeout > 0 ? Math.floor(timeout) : DEFAULTS.timeoutMs,
43
+ }
44
+ }
45
+
46
+ /** 逐条参数跑一次连接器脚本,返回解析后的 JSON(解析不出来就原样包起来当失败)。 */
47
+ function runClient(config, argv, timeoutOverrideMs) {
48
+ if (!existsSync(SCRIPT_PATH)) {
49
+ return { ok: false, error: `connector script missing: ${SCRIPT_PATH}` }
50
+ }
51
+ const env = { ...process.env, PYTHONIOENCODING: 'utf-8' }
52
+ if (config.oauthHome !== '') env.MCP_OAUTH_HOME = config.oauthHome
53
+ let stdout
54
+ try {
55
+ stdout = execFileSync(config.pythonPath, [SCRIPT_PATH, ...argv, '--platform', config.platform], {
56
+ encoding: 'utf8',
57
+ timeout: timeoutOverrideMs ?? config.timeoutMs,
58
+ maxBuffer: 64 * 1024 * 1024,
59
+ env,
60
+ windowsHide: true,
61
+ })
62
+ } catch (error) {
63
+ // 连接器用退出码表达语义:1 调用失败 / 3 令牌问题 / 4 客户端错误 / 6 远程命令失败
64
+ const status = typeof error?.status === 'number' ? error.status : null
65
+ const raw = String(error?.stdout ?? '')
66
+ const parsed = parseJson(raw)
67
+ if (parsed) return { ...parsed, exitCode: status }
68
+ return {
69
+ ok: false,
70
+ exitCode: status,
71
+ error: status === 3
72
+ ? '令牌失效,需要重新授权(tencent_lighthouse_auth action=connect)'
73
+ : (raw.trim() !== '' ? raw.trim() : String(error?.message ?? error)),
74
+ }
75
+ }
76
+ const parsed = parseJson(stdout)
77
+ if (!parsed) return { ok: false, error: `连接器返回了非 JSON 输出:${stdout.slice(0, 400)}` }
78
+ return parsed
79
+ }
80
+
81
+ /** 容错解析 JSON。 */
82
+ function parseJson(text) {
83
+ const trimmed = String(text ?? '').trim()
84
+ if (trimmed === '') return null
85
+ try {
86
+ return JSON.parse(trimmed)
87
+ } catch {
88
+ const first = trimmed.indexOf('{')
89
+ const last = trimmed.lastIndexOf('}')
90
+ if (first >= 0 && last > first) {
91
+ try {
92
+ return JSON.parse(trimmed.slice(first, last + 1))
93
+ } catch {
94
+ return null
95
+ }
96
+ }
97
+ return null
98
+ }
99
+ }
100
+
101
+ /** 从 call 信封里取出 MCP result。 */
102
+ function unwrap(envelope) {
103
+ if (!envelope || typeof envelope !== 'object') return null
104
+ return envelope.response ?? envelope.result ?? null
105
+ }
106
+
107
+ /** 把工具清单抽成 [{name, description}]。 */
108
+ function toolList(envelope) {
109
+ const result = unwrap(envelope)
110
+ const tools = result?.result?.tools ?? result?.tools
111
+ if (!Array.isArray(tools)) return null
112
+ return tools.map((t) => ({ name: String(t?.name ?? ''), description: String(t?.description ?? '') }))
113
+ }
114
+
115
+ /** 把调用结果压成文本,避免一个表格撑爆上下文。 */
116
+ function textOf(value, limit) {
117
+ if (typeof value === 'string') return value.slice(0, limit)
118
+ try {
119
+ return JSON.stringify(value, null, 2).slice(0, limit)
120
+ } catch {
121
+ return String(value).slice(0, limit)
122
+ }
123
+ }
124
+
125
+ export function apply(ctx, rawConfig = {}) {
126
+ const config = resolveConfig(rawConfig)
127
+
128
+ ctx.tools.register({
129
+ name: 'tencent_lighthouse_auth',
130
+ description:
131
+ 'Connect or inspect the Tencent Cloud Lighthouse MCP authorization for this machine. '
132
+ + 'action=preflight (environment/TLS/endpoint self-check), status (is a token stored and how long it lasts), '
133
+ + 'connect (start the browser OAuth flow — a human must approve it), refresh (rotate the access token), '
134
+ + 'logout (drop the stored token). Tokens live under the configured oauthHome (or MCP_OAUTH_HOME) with 0600. '
135
+ + 'Run preflight before the first connect; run status instead of connect when a token already exists.',
136
+ parameters: {
137
+ type: 'object',
138
+ additionalProperties: false,
139
+ properties: {
140
+ action: {
141
+ type: 'string',
142
+ enum: ['preflight', 'status', 'connect', 'refresh', 'logout'],
143
+ description: 'Which authorization step to run.',
144
+ },
145
+ },
146
+ required: ['action'],
147
+ },
148
+ output: {
149
+ schema: {
150
+ type: 'object',
151
+ additionalProperties: true,
152
+ properties: {
153
+ ok: { type: 'boolean' },
154
+ report: { type: 'string' },
155
+ },
156
+ required: ['ok', 'report'],
157
+ },
158
+ render: (_args, value) => [{ type: 'text', text: value.report }],
159
+ },
160
+ async execute(args) {
161
+ const action = String(args.action)
162
+ const envelope = runClient(config, [action], action === 'connect' ? Math.max(config.timeoutMs, 300000) : undefined)
163
+ const ok = envelope?.ok !== false && envelope?.authorized !== false && envelope?.connected !== false
164
+ return { ok, report: textOf(envelope, 12000) }
165
+ },
166
+ })
167
+
168
+ ctx.tools.register({
169
+ name: 'tencent_lighthouse_tools',
170
+ description:
171
+ 'List the tools exposed by the Tencent Cloud Lighthouse MCP server (instance / firewall / snapshot / monitor / '
172
+ + 'deploy / remote command / DNS / SSL certificate groups). Call this first when unsure whether an operation '
173
+ + 'is supported — do not assume a tool exists.',
174
+ parameters: { type: 'object', additionalProperties: false, properties: {} },
175
+ output: {
176
+ schema: {
177
+ type: 'object',
178
+ additionalProperties: true,
179
+ properties: {
180
+ ok: { type: 'boolean' },
181
+ count: { type: 'integer' },
182
+ tools: { type: 'array', items: { type: 'string' } },
183
+ report: { type: 'string' },
184
+ },
185
+ required: ['ok', 'count', 'tools', 'report'],
186
+ },
187
+ render: (_args, value) => [{
188
+ type: 'text',
189
+ text: value.ok ? `${value.count} tools: ${value.tools.join(', ')}` : value.report,
190
+ }],
191
+ },
192
+ async execute() {
193
+ const envelope = runClient(config, ['call', '--method', 'tools/list'])
194
+ const list = toolList(envelope)
195
+ if (!envelope?.ok || !list) {
196
+ return { ok: false, count: 0, tools: [], report: textOf(envelope, 4000) }
197
+ }
198
+ return { ok: true, count: list.length, tools: list.map((t) => t.name), report: `${list.length} tools available` }
199
+ },
200
+ })
201
+
202
+ ctx.tools.register({
203
+ name: 'tencent_lighthouse_call',
204
+ description:
205
+ 'Call one Tencent Cloud Lighthouse MCP tool. Pass the exact tool name from tencent_lighthouse_tools and its '
206
+ + 'arguments as an object. Read the returned `ok` first: ok=false is a failure, never an empty result. '
207
+ + 'For remote-command tools also check command.status — RUNNING / RUNNING_ASYNC means keep polling '
208
+ + 'describe_command_tasks instead of re-executing. Query state with describe_* before any mutation, and '
209
+ + 'confirm irreversible actions (delete instance / snapshot / image / domain) with the human first.',
210
+ parameters: {
211
+ type: 'object',
212
+ additionalProperties: false,
213
+ properties: {
214
+ tool: { type: 'string', description: 'Exact MCP tool name, e.g. describe_instances.' },
215
+ args: {
216
+ type: 'object',
217
+ description: 'Tool arguments as an object, e.g. {"Region":"ap-guangzhou","Offset":0,"Limit":100}.',
218
+ },
219
+ },
220
+ required: ['tool'],
221
+ },
222
+ output: {
223
+ schema: {
224
+ type: 'object',
225
+ additionalProperties: true,
226
+ properties: {
227
+ ok: { type: 'boolean' },
228
+ report: { type: 'string' },
229
+ },
230
+ required: ['ok', 'report'],
231
+ },
232
+ render: (_args, value) => [{ type: 'text', text: value.report }],
233
+ },
234
+ async execute(args) {
235
+ const tool = String(args.tool)
236
+ if (!/^[A-Za-z0-9_]+$/.test(tool)) {
237
+ return { ok: false, report: `tool "${tool}" is not a plain MCP tool name` }
238
+ }
239
+ const toolArgs = args.args && typeof args.args === 'object' ? args.args : {}
240
+ const envelope = runClient(config, ['call', '--tool', tool, '--args', JSON.stringify(toolArgs)])
241
+ const result = unwrap(envelope)
242
+ const mcpError = Boolean(result?.result?.isError) || Boolean(result?.error)
243
+ const ok = envelope?.ok === true && !mcpError
244
+ const payload = result?.result?.content ?? result?.result ?? result?.error ?? (envelope?.error ? { error: envelope.error } : null)
245
+ const body = Array.isArray(payload)
246
+ ? payload.map((c) => (typeof c?.text === 'string' ? c.text : textOf(c, 4000))).join('\n')
247
+ : textOf(payload ?? envelope, 60000)
248
+ return { ok, report: body }
249
+ },
250
+ })
251
+ }
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "dsh-tencent-lighthouse",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "腾讯云轻量应用服务器(Lighthouse)for DeepSeek Harness:把腾讯轻量云专家 MCP(OAuth 2.1 + PKCE + DCR)包成 DSH 工具,附完整运维技能(实例/防火墙/快照/监控/部署/远程命令/域名/证书)。",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js",
9
+ "./cordis.patch.yml": "./cordis.patch.yml",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "lib",
14
+ "cordis.patch.yml",
15
+ "README.md",
16
+ "LICENSE",
17
+ "skills"
18
+ ],
19
+ "keywords": [
20
+ "dsh",
21
+ "deepseek-harness",
22
+ "dsh-plugin",
23
+ "tencent",
24
+ "tencent-cloud",
25
+ "lighthouse",
26
+ "轻量应用服务器",
27
+ "mcp",
28
+ "oauth"
29
+ ],
30
+ "license": "MIT",
31
+ "engines": {
32
+ "node": ">=20"
33
+ },
34
+ "dsh": {
35
+ "manifestVersion": 1,
36
+ "bundle": {
37
+ "patch": "./cordis.patch.yml"
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: lighthouse-ops
3
+ description: |
4
+ 腾讯云轻量应用服务器(Lighthouse)运维专家的跨平台 Agent Skill。让任意 Agent 平台
5
+ (Claude Code、Codex、Cursor、豆包、千问、Kimi、DeepSeek 等)通过 OAuth 连接腾讯云账号后,
6
+ 管理 Lighthouse:实例查询/启动/改名、购买引导、防火墙、快照、监控、应用部署、远程命令、域名解析、HTTPS 证书。
7
+ 含两大部分:
8
+ (1) 连接能力——平台自适配的 MCP + OAuth 连接器(授权流程、token 获取与定时刷新);
9
+ (2) 使用能力——各业务运维操作的编排与规范。
10
+ 触发场景:用户提到"轻量云/Lighthouse 专家"、"管理我的 Lighthouse 实例/防火墙/快照"、
11
+ "连接腾讯云账号运维"、"在某平台用腾讯轻量云专家连接器"、"选购/购买轻量应用服务器"。
12
+ user-invocable: true
13
+ ---
14
+
15
+ ## DSH 适配(DeepSeek Harness · 本机 Windows · 2026-11-29 验证通道)
16
+
17
+ DSH 没有平台原生 MCP+OAuth 连接器,所以走**模式 C(脚本自建)**:由 Agent 用 `pwsh` 驱动
18
+ `scripts/mcp_oauth_client.py` 完成授权与调用,令牌落本机固定目录。
19
+
20
+ 本机固定参数(照抄,别自己换):
21
+
22
+ | 项 | 值 |
23
+ |---|---|
24
+ | 解释器 | `C:\Python314\python.exe`(`python`,3.14.8;脚本零第三方依赖) |
25
+ | 平台取值 | `--platform deepseek` |
26
+ | MCP 端点 | `https://lightai.cloud.tencent.com/workbuddy/mcp/deepseek` |
27
+ | 令牌目录 | `E:\pix\lighthouse\.mcp-oauth-connector`(`MCP_OAUTH_HOME`,**每条命令都带**) |
28
+ | 脚本 | `C:\Users\mynlp\.agents\skills\lighthouse-ops\scripts\mcp_oauth_client.py` |
29
+ | 封装 | `E:\pix\lighthouse\lh.ps1`(自动注入 `MCP_OAUTH_HOME` 与 `--platform deepseek`) |
30
+
31
+ ```powershell
32
+ & E:\pix\lighthouse\lh.ps1 preflight
33
+ & E:\pix\lighthouse\lh.ps1 connect
34
+ & E:\pix\lighthouse\lh.ps1 call --method tools/list
35
+ & E:\pix\lighthouse\lh.ps1 call --tool describe_instances --args '{"Region":"ap-guangzhou","Offset":0,"Limit":100}'
36
+ ```
37
+
38
+ DSH 内额外规矩:
39
+
40
+ - `call` 的输出是 JSON,**先判 `ok`**;`ok=false` 一律当失败上报,别当空结果。
41
+ - 远端命令类工具再看 `command.status`:`RUNNING` / `RUNNING_ASYNC` 是在跑,按 `command.next` 轮询,别重复执行。
42
+ - 停止/重启、改防火墙、远程命令、部署、改解析、配证书 → 动手前先讲清范围;删除类必须二次确认。
43
+ - `MCP_OAUTH_HOME` 只在命令范围内设置,不写进全局环境。
44
+
45
+ ---
46
+
47
+ # 腾讯轻量云专家(跨平台 Agent Skill)
48
+
49
+ 腾讯云轻量应用服务器(Lighthouse)运维专家的可移植封装。用户用 OAuth 连接腾讯云账号后,
50
+ Agent 即可在任意平台管理 Lighthouse 实例、防火墙、快照、监控与应用部署。本 skill 分两层:
51
+
52
+ 1. **连接层**:平台自适配的 MCP + OAuth 连接器——触发授权、获取并定时刷新 token、以 Bearer 代理 MCP 调用。
53
+ 2. **使用层**:Lighthouse 各运维场景的操作编排与安全规范。
54
+
55
+ ## 两步走
56
+
57
+ ### 第 1 步 · 连接(OAuth 连接腾讯云账号)
58
+ 按使用平台选择 MCP 端点并完成 OAuth 授权。完整机制见 `references/`:
59
+ - `references/platform-adapters.md` — 平台能力探测与三种适配模式(A 原生 / B 令牌提供 / C 脚本自建),
60
+ 以及 **§0 平台端点对照表**(已内置 30+ 平台,`--platform` 取值权威来源,禁止臆造后缀)。
61
+ - `references/oauth-flow.md` — 授权触发完整实现(发现/DCR/PKCE/本地回调/换 token)。
62
+ - `references/token-lifecycle.md` — token 获取与定时/按需自动刷新机制。
63
+ - `references/architecture.md` — 双层 OAuth 模型与端到端流程。
64
+
65
+ **端点按平台补后缀**(完整表见 platform-adapters.md §0;基础前缀 `https://lightai.cloud.tencent.com`):
66
+
67
+ | 使用平台 | `--platform` | MCP 端点 |
68
+ |----------|--------------|----------|
69
+ | 千问办公 / 千问 / 豆包 | `qwen` / `qianwen` / `doubao` | `.../workbuddy/mcp/<平台名>` |
70
+ | Claude Code / Cursor / Codex / Copilot … | `claudecode` / `cursor` / `codex` / `copilot` … | `.../workbuddy/mcp/<平台名>` |
71
+ | 腾讯元宝 / Kimi / DeepSeek / 智谱 … | `yuanbao` / `kimi` / `deepseek` / `zhipu` … | `.../workbuddy/mcp/<平台名>` |
72
+ | 通用 / 表外平台 | `default` | `.../workbuddy/mcp`(基础端点,无后缀) |
73
+
74
+ - **模式 A(平台原生支持 MCP+OAuth,如 Claude Code)**:注册 MCP URL,授权/刷新交给平台。
75
+ - **模式 B/C(其它平台)**:用 `scripts/mcp_oauth_client.py` 自建连接器:
76
+ ```bash
77
+ # 沙箱/受限环境:先把令牌目录指到可写目录,并在之后每条命令都带上同一个 MCP_OAUTH_HOME
78
+ export MCP_OAUTH_HOME=$PWD/.mcp-oauth-connector
79
+
80
+ python3 scripts/mcp_oauth_client.py preflight --platform <平台> # 自检(含是否支持设备流程 device_flow)
81
+ python3 scripts/mcp_oauth_client.py connect --platform <平台> # 默认自动择优授权(见下)
82
+ python3 scripts/mcp_oauth_client.py call --platform <平台> --method tools/list
83
+ python3 scripts/mcp_oauth_client.py call --platform <平台> --tool describe_instances --args '{"Region":"ap-guangzhou","Offset":0,"Limit":100}'
84
+ python3 scripts/mcp_oauth_client.py daemon --platform <平台> & # 可选:常驻定时刷新
85
+ ```
86
+ 令牌本地存于 `MCP_OAUTH_HOME`(默认 `~/.mcp-oauth-connector/tokens.json`,0600),临近过期自动刷新,遇 401 刷新重试一次。
87
+ 解析 `call` 输出时**先看 `ok`/`error` 字段**,失败不要当成空结果。HTTP 异常、非 JSON-RPC 响应、
88
+ JSON-RPC `error`、工具 `result.isError=true` 都会输出 `ok=false`。远程命令另有 `command.status`:
89
+ `execute_command` 退出码非 0 → `ok=false`、退出码 **6**;`RUNNING_ASYNC` / `RUNNING` 仍在运行,勿重复执行,按 `command.next` 轮询;
90
+ `describe_command_tasks` 查到 `FAILED` 是"查询成功、任务失败"(`ok=true`)。
91
+
92
+ `call` 进程退出码:`0` 成功 · `1` 调用失败 · `3` 令牌问题(`needs_reauth=true` 时本地失效记录已清除,需重新 connect)· `4` 客户端错误 · `6` 远程命令执行失败。
93
+ 远端端点必须是 HTTPS(仅回环地址允许 HTTP),跨来源重定向不会被跟随。
94
+
95
+ - **授权路径(`connect` 自动判定,无需手动选)**:仅当 **云端/远端环境** 且 **服务端支持设备流程** 时
96
+ 才自动切换到设备流程;本地桌面保持原有回环监听流程不变。
97
+
98
+ | 环境 | 服务端设备流程 | 实际走法 |
99
+ |------|----------------|----------|
100
+ | 本地(有 GUI、端口可达) | 支持 / 不支持 | `connect` 回环监听(行为不变) |
101
+ | **云端 / 远端** | 支持 | `connect` 自动走设备流程——用户打开验证链接点"同意"即可,**免回调、免复制 URL** |
102
+ | **云端 / 远端** | 不支持 | 回环大概率不可达 → 两段式 `connect --manual` → `connect --callback '<回环回调URL>'`<br>(提示用户"跳到 127.0.0.1 的页面打不开是正常的,复制地址栏整条 URL 回来") |
103
+
104
+ - 远端判定信号:SSH 会话 / 容器 / 无 `DISPLAY` / 无可用浏览器(任一命中)。
105
+ - 覆盖开关:`--loopback` 强制回环、`--device` 强制设备流程;非流式云端 Agent 可用
106
+ `--device-start`(先出链接)+ `--device-poll`(再轮询)。
107
+ - `preflight` 的 `remote_env` / `device_flow` / `recommended_connect` 可预览判定结果。
108
+ - 详见 `references/platform-adapters.md §4.1 / §4.2`。
109
+
110
+ > **⚠️ 沙箱化 / 远程 Agent 平台(如千问办公、云端 Agent)必读**——详见 `references/platform-adapters.md §4.1、§4.2`:
111
+ > 1. **解释器要有 CA 证书**:TLS 报 `CERTIFICATE_VERIFY_FAILED` 时优先改用系统 `/usr/bin/python3`(Framework 版 Python 不读 `SSL_CERT_FILE`)。
112
+ > 2. **令牌目录**:禁止写主目录时设 `MCP_OAUTH_HOME` 到可写目录,且**每条命令都带上**。
113
+ > 3. **云端回调打不通**:`connect` 已会自动识别云端并切设备流程(需服务端支持);若服务端不支持,
114
+ > 用两段式 `--manual`/`--callback`,别用回环监听干等。
115
+ > 4. 拿不准就先跑 `preflight` 一键定位(含 `device_flow` 是否可用)。
116
+
117
+ > 购买引导(选购/新购实例)**无需连接**,直接返回链接,见使用层 instance-management。
118
+
119
+ ### 第 2 步 · 使用(腾讯轻量云专家编排)
120
+ 连接成功后,按下方场景路由加载对应使用说明(`references/usage/<名称>/SKILL.md`),
121
+ 用 MCP 工具执行;模式 B/C 下即通过 `mcp_oauth_client.py call --tool <工具名> --args '{...}'` 调用。
122
+
123
+ ```
124
+ 用户想要...
125
+ ├─ 查询 / 启动 / 改名实例、查看镜像 → references/usage/instance-management/SKILL.md
126
+ ├─ 停止 / 重启实例、重置密码(当前无工具,引导控制台)→ references/usage/instance-management/SKILL.md
127
+ ├─ 新购 / 购买 / 创建 / 开通实例(购买引导) → references/usage/instance-management/SKILL.md
128
+ ├─ 部署应用 / 安装环境 / Docker / Nginx 反代 → references/usage/application-deployment/SKILL.md
129
+ ├─ 在实例上执行命令 / 诊断排障(TAT) → references/usage/remote-command/SKILL.md
130
+ ├─ 查看 CPU / 内存 / 带宽指标、流量包使用 → references/usage/monitoring/SKILL.md
131
+ ├─ 管理防火墙规则(查询 / 添加 / 删除) → references/usage/firewall-management/SKILL.md
132
+ ├─ 查询 / 创建 / 重命名快照(删除、回滚引导控制台) → references/usage/snapshot-management/SKILL.md
133
+ ├─ 添加 / 删除域名、把域名解析到服务器、域名巡检 → references/usage/domain-management/SKILL.md
134
+ ├─ HTTPS / SSL 证书配置、到期巡检与续期 → references/usage/ssl-certificate/SKILL.md
135
+ └─ 其他 → 询问用户具体需求
136
+ ```
137
+
138
+ ## 核心规则(使用层)
139
+
140
+ - **先查后改**:任何修改前先 `describe_*` 查询当前状态,使用真实 ID(实例 `lhins-`、快照 `lhsnap-`、镜像 `lhbp-`),不臆造。
141
+ - **列表必分页,拉全再下结论**:`describe_instances` 等列表接口默认只回 **20 条**、`Limit` 上限 **100**。
142
+ 对"账号有多少台/分布在哪些地域/是否都停了"这类规模性结论,**必须先按 `Offset/Limit` 翻页拉全**(返回不含总数,满页就继续翻,直到不满页或返回"暂无数据"),
143
+ 否则会把第一页当全量而严重误判(典型错误:只看广州 20 台就断言"全账号 20 台")。跨地域统计要遍历 `describe_regions` 返回的全部地域。
144
+ - **时间按 UTC 换算**:接口时间多为 UTC(`Z` 结尾,如 `2026-10-27T22:00:30Z`)。展示给用户前**换算为用户本地时区**(东八区 +8h),避免把北京时间次日早上误报成"已过期"。
145
+ **监控查询的入参也是 UTC**:用户给北京时间要先减 8 小时再传,返回的时间列同样是 UTC(见 monitoring)。
146
+ - **地域以接口为准**:Lighthouse 支持地域以 `describe_regions` 返回为准(**不含 `ap-shenzhen`**,但含 `ap-qingyuan` 清远);传错地域会报 `The action does not support this region.`,不要凭直觉猜地域。
147
+ - **调用结果先判对错**:模式 B/C 下解析 `call` 输出先看 `ok`/`error`,失败勿当空结果;远程命令再看 `command.status`。
148
+ - **安全分级**:
149
+ - 🔴 高危(删除实例、回滚快照、删除快照/镜像、删除域名)→ 必须二次确认并说明不可逆性。
150
+ - 🟡 中(停止/重启、改防火墙、远程命令、装软件、部署、增删改解析、配置证书)→ 需用户确认。
151
+ - 🟢 低(查询/列表/描述)→ 直接执行。
152
+ - **购买与部署分流**:新购/开通实例返回国内站购买链接由用户下单;已有实例部署走 application-deployment。
153
+ - **能力以工具清单为准**:用户要的操作在 `tools/list` 中不存在(如停止 / 重启、重置密码、删除 / 回滚快照、自定义镜像),如实说明当前连接不支持并给控制台入口,不声称已完成。
154
+ - **执行后复查**:成功响应仅代表请求被接受,用 `describe_*` 复查最终状态再向用户交付。
155
+ - **Lighthouse ≠ CVM**:两产品 API 不互通。
156
+ - **凭证安全**:不向用户索要/展示腾讯云 token、密码、AK/SK;令牌仅本地存储、日志脱敏。
157
+
158
+ ## 未连接 / 授权失效降级
159
+ MCP 未连接、未授权或工具缺失时,如实说明需先完成 OAuth 授权(连接腾讯云账号),引导用户重新 `connect`;
160
+ 不编造实例、套餐或任何 ID。购买引导链接不受此限制。
161
+
162
+ ## 目录
163
+ - `scripts/mcp_oauth_client.py` — 零依赖(Python 3.8+ 标准库)连接器客户端,含平台端点注册表。
164
+ - `references/` — 连接器机制(architecture / oauth-flow / token-lifecycle / platform-adapters)。
165
+ - `references/usage/` — 各业务运维使用说明(实例/防火墙/快照/监控/部署/远程命令),
166
+ 每个 skill 一个子目录(含其 `SKILL.md` 及自带 `references/`,如购买链接契约),由打包时从 `skills/` 整目录装配。
@@ -0,0 +1,6 @@
1
+ {
2
+ "ownerId": "819300",
3
+ "slug": "tencent-lighthouse-expert",
4
+ "version": "1.0.0",
5
+ "publishedAt": 1794381993629
6
+ }