feiguazhitou-mcp-cli 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.
- package/README.md +260 -0
- package/USER-GUIDE.md +139 -0
- package/dist/agent-guide.js +278 -0
- package/dist/agent-guide.js.map +1 -0
- package/dist/cli-error.js +30 -0
- package/dist/cli-error.js.map +1 -0
- package/dist/cli.js +952 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants.js +42 -0
- package/dist/constants.js.map +1 -0
- package/dist/fs-utils.js +40 -0
- package/dist/fs-utils.js.map +1 -0
- package/dist/i18n.js +9 -0
- package/dist/i18n.js.map +1 -0
- package/dist/lease-lock.js +57 -0
- package/dist/lease-lock.js.map +1 -0
- package/dist/mcporter.js +249 -0
- package/dist/mcporter.js.map +1 -0
- package/dist/profile.js +262 -0
- package/dist/profile.js.map +1 -0
- package/dist/refresh.js +180 -0
- package/dist/refresh.js.map +1 -0
- package/dist/schema.js +39 -0
- package/dist/schema.js.map +1 -0
- package/dist/skills.js +139 -0
- package/dist/skills.js.map +1 -0
- package/dist/tool-catalog.js +126 -0
- package/dist/tool-catalog.js.map +1 -0
- package/package.json +42 -0
- package/skills/feiguazhitou-mcp-cli/SKILL.en.md +99 -0
- package/skills/feiguazhitou-mcp-cli/SKILL.md +130 -0
- package/skills/feiguazhitou-mcp-cli/skill.en.json +39 -0
- package/skills/feiguazhitou-mcp-cli/skill.json +39 -0
package/dist/skills.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { COMMAND_NAME } from "./constants.js";
|
|
5
|
+
import { outputLanguage, t } from "./i18n.js";
|
|
6
|
+
export const SKILL_PROTOCOL = "feiguazhitou-mcp-cli.skills/v1";
|
|
7
|
+
export const SKILL_PROTOCOL_VERSION = 1;
|
|
8
|
+
const skillNamePattern = /^[a-z][a-z0-9-]{0,63}$/;
|
|
9
|
+
function packageDirectory() {
|
|
10
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
|
+
}
|
|
12
|
+
function skillsDirectory() {
|
|
13
|
+
return path.join(packageDirectory(), "skills");
|
|
14
|
+
}
|
|
15
|
+
function isRecord(value) {
|
|
16
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
function requiredString(value, key, context) {
|
|
19
|
+
const candidate = value[key];
|
|
20
|
+
if (typeof candidate !== "string" || !candidate.trim()) {
|
|
21
|
+
throw new Error(t(`${context}.${key} 必须是非空字符串。`, `${context}.${key} must be a non-empty string.`));
|
|
22
|
+
}
|
|
23
|
+
return candidate;
|
|
24
|
+
}
|
|
25
|
+
function optionalString(value, key, context) {
|
|
26
|
+
const candidate = value[key];
|
|
27
|
+
if (candidate === undefined) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
if (typeof candidate !== "string" || !candidate.trim()) {
|
|
31
|
+
throw new Error(t(`${context}.${key} 存在时必须是非空字符串。`, `${context}.${key} must be a non-empty string when present.`));
|
|
32
|
+
}
|
|
33
|
+
return candidate;
|
|
34
|
+
}
|
|
35
|
+
function requiredStringArray(value, key, context) {
|
|
36
|
+
const candidate = value[key];
|
|
37
|
+
if (!Array.isArray(candidate) || !candidate.every((item) => typeof item === "string" && item.trim())) {
|
|
38
|
+
throw new Error(t(`${context}.${key} 必须是由非空字符串组成的数组。`, `${context}.${key} must be an array of non-empty strings.`));
|
|
39
|
+
}
|
|
40
|
+
return [...candidate];
|
|
41
|
+
}
|
|
42
|
+
function resolveEntrypoint(directory, entrypoint) {
|
|
43
|
+
if (path.isAbsolute(entrypoint)) {
|
|
44
|
+
throw new Error(t("Skill entrypoint 必须是包内相对路径。", "Skill entrypoint must be package-relative."));
|
|
45
|
+
}
|
|
46
|
+
const resolved = path.resolve(directory, entrypoint);
|
|
47
|
+
const relative = path.relative(directory, resolved);
|
|
48
|
+
if (relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
49
|
+
throw new Error(t("Skill entrypoint 必须位于对应的 Skill 目录内。", "Skill entrypoint must remain inside its skill directory."));
|
|
50
|
+
}
|
|
51
|
+
return resolved;
|
|
52
|
+
}
|
|
53
|
+
function parseSkillDescriptor(value, directoryName) {
|
|
54
|
+
const context = t(`Skill 清单 ${directoryName}`, `Skill manifest ${directoryName}`);
|
|
55
|
+
if (!isRecord(value)) {
|
|
56
|
+
throw new Error(t(`${context} 必须是 JSON 对象。`, `${context} must be a JSON object.`));
|
|
57
|
+
}
|
|
58
|
+
if (value.protocol !== SKILL_PROTOCOL || value.protocolVersion !== SKILL_PROTOCOL_VERSION) {
|
|
59
|
+
throw new Error(t(`${context} 未实现 ${SKILL_PROTOCOL}。`, `${context} does not implement ${SKILL_PROTOCOL}.`));
|
|
60
|
+
}
|
|
61
|
+
const name = requiredString(value, "name", context);
|
|
62
|
+
if (!skillNamePattern.test(name) || name !== directoryName) {
|
|
63
|
+
throw new Error(t(`${context}.name 必须匹配其小写 kebab-case 目录名。`, `${context}.name must match its lowercase kebab-case directory name.`));
|
|
64
|
+
}
|
|
65
|
+
if (value.apply !== "available") {
|
|
66
|
+
throw new Error(t(`${context}.apply 必须为 \"available\"。`, `${context}.apply must be \"available\".`));
|
|
67
|
+
}
|
|
68
|
+
if (!isRecord(value.requirements)) {
|
|
69
|
+
throw new Error(t(`${context}.requirements 必须是 JSON 对象。`, `${context}.requirements must be a JSON object.`));
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
protocol: SKILL_PROTOCOL,
|
|
73
|
+
protocolVersion: SKILL_PROTOCOL_VERSION,
|
|
74
|
+
skillVersion: requiredString(value, "skillVersion", context),
|
|
75
|
+
name,
|
|
76
|
+
description: requiredString(value, "description", context),
|
|
77
|
+
...(optionalString(value, "argumentHint", context) ? { argumentHint: optionalString(value, "argumentHint", context) } : {}),
|
|
78
|
+
apply: "available",
|
|
79
|
+
entrypoint: requiredString(value, "entrypoint", context),
|
|
80
|
+
capabilities: requiredStringArray(value, "capabilities", context),
|
|
81
|
+
requirements: {
|
|
82
|
+
command: requiredString(value.requirements, "command", context),
|
|
83
|
+
runtimeEnvironment: requiredStringArray(value.requirements, "runtimeEnvironment", context),
|
|
84
|
+
optionalRuntimeEnvironment: requiredStringArray(value.requirements, "optionalRuntimeEnvironment", context),
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async function readSkill(directoryName) {
|
|
89
|
+
if (!skillNamePattern.test(directoryName)) {
|
|
90
|
+
throw new Error(t(`未知的内置 Skill '${directoryName}'。`, `Unknown bundled skill '${directoryName}'.`));
|
|
91
|
+
}
|
|
92
|
+
const directory = path.join(skillsDirectory(), directoryName);
|
|
93
|
+
const manifestCandidates = outputLanguage() === "en" ? ["skill.en.json", "skill.json"] : ["skill.json"];
|
|
94
|
+
let manifestText;
|
|
95
|
+
for (const filename of manifestCandidates) {
|
|
96
|
+
try {
|
|
97
|
+
manifestText = await readFile(path.join(directory, filename), "utf8");
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (error.code !== "ENOENT") {
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (manifestText === undefined) {
|
|
107
|
+
throw new Error(t(`未知的内置 Skill '${directoryName}'。`, `Unknown bundled skill '${directoryName}'.`));
|
|
108
|
+
}
|
|
109
|
+
let descriptor;
|
|
110
|
+
try {
|
|
111
|
+
descriptor = parseSkillDescriptor(JSON.parse(manifestText), directoryName);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
throw new Error(t(`内置 Skill '${directoryName}' 无效:${error instanceof Error ? error.message : String(error)}`, `Invalid bundled skill '${directoryName}': ${error instanceof Error ? error.message : String(error)}`));
|
|
115
|
+
}
|
|
116
|
+
const markdown = await readFile(resolveEntrypoint(directory, descriptor.entrypoint), "utf8");
|
|
117
|
+
return { ...descriptor, markdown };
|
|
118
|
+
}
|
|
119
|
+
export function skillProtocolDocument() {
|
|
120
|
+
return {
|
|
121
|
+
protocol: SKILL_PROTOCOL,
|
|
122
|
+
protocolVersion: SKILL_PROTOCOL_VERSION,
|
|
123
|
+
commands: {
|
|
124
|
+
list: `${COMMAND_NAME} skills list --output json`,
|
|
125
|
+
show: `${COMMAND_NAME} skills show NAME [--output json|markdown]`,
|
|
126
|
+
},
|
|
127
|
+
transport: "local-package",
|
|
128
|
+
execution: t("CLI 只暴露 Skill metadata 和 Markdown,不会执行 Skill 内容。", "The CLI exposes skill metadata and Markdown only; it does not execute skill content."),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export async function listBundledSkills() {
|
|
132
|
+
const entries = await readdir(skillsDirectory(), { withFileTypes: true });
|
|
133
|
+
const skills = await Promise.all(entries.filter((entry) => entry.isDirectory()).map((entry) => readSkill(entry.name)));
|
|
134
|
+
return skills.map(({ markdown: _markdown, ...descriptor }) => descriptor).sort((left, right) => left.name.localeCompare(right.name));
|
|
135
|
+
}
|
|
136
|
+
export async function showBundledSkill(name) {
|
|
137
|
+
return await readSkill(name);
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,CAAC,MAAM,cAAc,GAAG,gCAAgC,CAAC;AAC/D,MAAM,CAAC,MAAM,sBAAsB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iguazhitou-mcp-cli.tools/v1";
|
|
4
|
+
export const TOOL_CATALOG_PROTOCOL_VERSION = 1;
|
|
5
|
+
export function catalogFreshness(lastCheckedAt, now = Date.now()) {
|
|
6
|
+
const checkedAt = lastCheckedAt ? Date.parse(lastCheckedAt) : Number.NaN;
|
|
7
|
+
return {
|
|
8
|
+
lastCheckedAt: lastCheckedAt ?? null,
|
|
9
|
+
staleAfterMs: CATALOG_STALE_AFTER_MS,
|
|
10
|
+
isStale: !Number.isFinite(checkedAt) || now - checkedAt > CATALOG_STALE_AFTER_MS,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function generatedCommandName(mcpTool) {
|
|
14
|
+
return mcpTool.replaceAll("_", "-");
|
|
15
|
+
}
|
|
16
|
+
function descriptorFor(tool, autoApprove) {
|
|
17
|
+
return {
|
|
18
|
+
mcpTool: tool.name,
|
|
19
|
+
command: generatedCommandName(tool.name),
|
|
20
|
+
autoApproved: autoApprove.has(tool.name) || autoApprove.has(generatedCommandName(tool.name)),
|
|
21
|
+
...(tool.title ? { title: tool.title } : {}),
|
|
22
|
+
...(tool.description ? { description: tool.description } : {}),
|
|
23
|
+
inputSchema: tool.inputSchema ?? { type: "object", properties: {} },
|
|
24
|
+
...(tool.outputSchema === undefined ? {} : { outputSchema: tool.outputSchema }),
|
|
25
|
+
...(tool.annotations === undefined ? {} : { annotations: tool.annotations }),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function toolCatalog(manifest, currentTimeoutMs, autoApprove = [], lastCheckedAt) {
|
|
29
|
+
const autoApprovedTools = new Set(autoApprove);
|
|
30
|
+
const freshness = catalogFreshness(lastCheckedAt);
|
|
31
|
+
return {
|
|
32
|
+
protocol: TOOL_CATALOG_PROTOCOL,
|
|
33
|
+
protocolVersion: TOOL_CATALOG_PROTOCOL_VERSION,
|
|
34
|
+
artifact: {
|
|
35
|
+
id: manifest.artifactId,
|
|
36
|
+
generatedAt: manifest.generatedAt,
|
|
37
|
+
server: manifest.server,
|
|
38
|
+
timeoutMs: manifest.timeoutMs,
|
|
39
|
+
currentTimeoutMs,
|
|
40
|
+
executionTimeoutMs: currentTimeoutMs,
|
|
41
|
+
currentTimeoutMatches: manifest.timeoutMs === currentTimeoutMs,
|
|
42
|
+
failureExitPolicyVersion: manifest.failureExitPolicyVersion ?? null,
|
|
43
|
+
requiredFailureExitPolicyVersion: GENERATED_FAILURE_EXIT_POLICY_VERSION,
|
|
44
|
+
currentFailureExitPolicyMatches: manifest.failureExitPolicyVersion === GENERATED_FAILURE_EXIT_POLICY_VERSION,
|
|
45
|
+
...freshness,
|
|
46
|
+
},
|
|
47
|
+
tools: manifest.tools.map((tool) => descriptorFor(tool, autoApprovedTools)).sort((left, right) => left.command.localeCompare(right.command)),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function findTool(catalog, name) {
|
|
51
|
+
return catalog.tools.find((tool) => tool.command === name || tool.mcpTool === name);
|
|
52
|
+
}
|
|
53
|
+
export function toolInvocationTemplate(tool) {
|
|
54
|
+
return `feiguazhitou-mcp-cli run ${tool.command} --raw '<JSON matching inputSchema>' --output json`;
|
|
55
|
+
}
|
|
56
|
+
export function toolCatalogText(catalog) {
|
|
57
|
+
const lines = [
|
|
58
|
+
t(`已生成工具(${catalog.tools.length} 个):`, `Generated tools (${catalog.tools.length}):`),
|
|
59
|
+
...(catalog.artifact.currentTimeoutMatches
|
|
60
|
+
? []
|
|
61
|
+
: [
|
|
62
|
+
t(`注意:生成产物的默认超时为 ${catalog.artifact.timeoutMs}ms;当前 run 会使用 ${catalog.artifact.executionTimeoutMs}ms,无需 refresh。`, `Note: the generated artifact default timeout is ${catalog.artifact.timeoutMs}ms; the current run uses ${catalog.artifact.executionTimeoutMs}ms without requiring refresh.`),
|
|
63
|
+
]),
|
|
64
|
+
...(catalog.artifact.currentFailureExitPolicyMatches
|
|
65
|
+
? []
|
|
66
|
+
: [
|
|
67
|
+
t("注意:本地生成 CLI 不包含当前失败退出码策略;执行前必须 refresh。", "Note: the local generated CLI does not include the current failure-exit policy; refresh is required before execution."),
|
|
68
|
+
]),
|
|
69
|
+
...(catalog.artifact.isStale
|
|
70
|
+
? [
|
|
71
|
+
t(`注意:本地工具目录已超过 ${CATALOG_STALE_AFTER_DAYS} 天未检查;当前命令没有连接 MCP。如需检查最新工具,执行 feiguazhitou-mcp-cli tools list --refresh。`, `Note: the local tool catalog has not been checked for over ${CATALOG_STALE_AFTER_DAYS} days; this command did not contact MCP. Run feiguazhitou-mcp-cli tools list --refresh to check for updated tools.`),
|
|
72
|
+
]
|
|
73
|
+
: []),
|
|
74
|
+
...catalog.tools.map((tool) => ` ${tool.command}${tool.autoApproved ? t(" [已自动批准]", " [auto-approved]") : ""}${tool.description ? ` - ${tool.description}` : ""}`),
|
|
75
|
+
"",
|
|
76
|
+
t("查看精确 schema:feiguazhitou-mcp-cli tools show NAME --output json", "Read an exact schema: feiguazhitou-mcp-cli tools show NAME --output json"),
|
|
77
|
+
t("执行工具:feiguazhitou-mcp-cli run COMMAND --raw '<JSON matching inputSchema>' --output json", "Run a tool: feiguazhitou-mcp-cli run COMMAND --raw '<JSON matching inputSchema>' --output json"),
|
|
78
|
+
t("复杂 JSON 也可使用 --raw @FILE,或通过 --raw - 从标准输入读取。", "Complex JSON can also use --raw @FILE, or --raw - to read from standard input."),
|
|
79
|
+
t("查看工作流指南:feiguazhitou-mcp-cli skills show feiguazhitou-mcp-cli", "Read the workflow guide: feiguazhitou-mcp-cli skills show feiguazhitou-mcp-cli"),
|
|
80
|
+
];
|
|
81
|
+
return `${lines.join("\n")}\n`;
|
|
82
|
+
}
|
|
83
|
+
export function toolMarkdown(catalog, tool) {
|
|
84
|
+
const sections = [
|
|
85
|
+
`# ${tool.command}`,
|
|
86
|
+
"",
|
|
87
|
+
t(`- MCP 工具:\`${tool.mcpTool}\``, `- MCP tool: \`${tool.mcpTool}\``),
|
|
88
|
+
t(`- 自动批准:${tool.autoApproved ? "是" : "否"}`, `- Auto-approved: ${tool.autoApproved ? "yes" : "no"}`),
|
|
89
|
+
...(catalog.artifact.currentTimeoutMatches
|
|
90
|
+
? []
|
|
91
|
+
: [
|
|
92
|
+
t(`- 执行超时:生成默认值为 ${catalog.artifact.timeoutMs}ms;当前 run 使用 ${catalog.artifact.executionTimeoutMs}ms,无需 refresh。`, `- Execution timeout: the generated default is ${catalog.artifact.timeoutMs}ms; the current run uses ${catalog.artifact.executionTimeoutMs}ms without requiring refresh.`),
|
|
93
|
+
]),
|
|
94
|
+
...(catalog.artifact.currentFailureExitPolicyMatches
|
|
95
|
+
? []
|
|
96
|
+
: [
|
|
97
|
+
t("- 执行状态:本地生成 CLI 不包含当前失败退出码策略;执行前需要 refresh。", "- Execution status: the local generated CLI does not include the current failure-exit policy; refresh is required before execution."),
|
|
98
|
+
]),
|
|
99
|
+
...(catalog.artifact.isStale
|
|
100
|
+
? [
|
|
101
|
+
t(`- 目录状态:已超过 ${CATALOG_STALE_AFTER_DAYS} 天未检查;当前命令没有连接 MCP。需要检查最新工具时执行 \`feiguazhitou-mcp-cli tools list --refresh\`。`, `- Catalog status: it has not been checked for over ${CATALOG_STALE_AFTER_DAYS} days; this command did not contact MCP. Run \`feiguazhitou-mcp-cli tools list --refresh\` when a live check is needed.`),
|
|
102
|
+
]
|
|
103
|
+
: []),
|
|
104
|
+
...(tool.title ? [t(`- 标题:${tool.title}`, `- Title: ${tool.title}`)] : []),
|
|
105
|
+
...(tool.description ? [t(`- 描述:${tool.description}`, `- Description: ${tool.description}`)] : []),
|
|
106
|
+
"",
|
|
107
|
+
t("## 调用方式", "## Invocation"),
|
|
108
|
+
"",
|
|
109
|
+
"```bash",
|
|
110
|
+
toolInvocationTemplate(tool),
|
|
111
|
+
"```",
|
|
112
|
+
"",
|
|
113
|
+
t("复杂 JSON 可改为 `--raw @FILE`,或使用 `--raw -` 从标准输入读取。", "For complex JSON, use `--raw @FILE`, or use `--raw -` to read standard input."),
|
|
114
|
+
"",
|
|
115
|
+
t("## 输入 Schema", "## Input Schema"),
|
|
116
|
+
"",
|
|
117
|
+
"```json",
|
|
118
|
+
JSON.stringify(tool.inputSchema, null, 2),
|
|
119
|
+
"```",
|
|
120
|
+
];
|
|
121
|
+
if (tool.outputSchema !== undefined) {
|
|
122
|
+
sections.push("", t("## 输出 Schema", "## Output Schema"), "", "```json", JSON.stringify(tool.outputSchema, null, 2), "```");
|
|
123
|
+
}
|
|
124
|
+
return `${sections.join("\n")}\n`;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=tool-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-catalog.js","sourceRoot":"","sources":["../src/tool-catalog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,qCAAqC,EAAE,MAAM,gBAAgB,CAAC;AACzH,OAAO,EAAE,CAAC,EAAE,MAAM,WAAW,CAAC;AAE9B,MAAM,CAAC,MAAM,qBAAqB,GAAG,+BAA+B,CAAC;AACrE,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAwC/C,MAAM,UAAU,gBAAgB,CAAC,aAAiC,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAClF,MAAM,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACzE,OAAO;QACL,aAAa,EAAE,aAAa,IAAI,IAAI;QACpC,YAAY,EAAE,sBAAsB;QACpC,OAAO,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,GAAG,GAAG,SAAS,GAAG,sBAAsB;KACjF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,aAAa,CAAC,IAAkB,EAAE,WAA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CAAC,CAAC,QAAQ,IAAI,CAAC,WAAW,EAAE,EAAE,kBAAkB,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAClG,EAAE;QACF,CAAC,CAAC,SAAS,EAAE,eAAe,CAAC;QAC7B,EAAE;QACF,SAAS;QACT,sBAAsB,CAAC,IAAI,CAAC;QAC5B,KAAK;QACL,EAAE;QACF,CAAC,CAAC,kDAAkD,EAAE,+EAA+E,CAAC;QACtI,EAAE;QACF,CAAC,CAAC,cAAc,EAAE,iBAAiB,CAAC;QACpC,EAAE;QACF,SAAS;QACT,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,KAAK;KACN,CAAC;IACF,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,EAAE,kBAAkB,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7H,CAAC;IACD,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACpC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "feiguazhitou-mcp-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Runtime schema discovery and MCPorter-generated CLI bridge for the local Feiguazhitou MCP service.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"feiguazhitou-mcp-cli": "./dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"USER-GUIDE.md",
|
|
13
|
+
"skills"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20.19"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"package": "npm run build && node scripts/package.mjs",
|
|
21
|
+
"test": "npm run build && tsx --test tests/schema.test.ts tests/skills.test.ts tests/agent-protocol.test.ts",
|
|
22
|
+
"test:mcp": "tsx tests/fixtures/test-mcp-server.ts",
|
|
23
|
+
"test:integration": "npm run build && tsx --test tests/integration.test.ts",
|
|
24
|
+
"test:pack": "npm run build && tsx tests/pack.test.ts",
|
|
25
|
+
"test:e2e:mock": "npm run build && tsx --test tests/feiguazhitou-mcp.fixture.e2e.test.ts",
|
|
26
|
+
"test:e2e:fixture": "npm run test:e2e:mock",
|
|
27
|
+
"test:e2e:real": "npm run build && tsx --test tests/feiguazhitou-mcp.real.e2e.test.ts",
|
|
28
|
+
"test:all": "npm run test && npm run test:integration && npm run test:pack && npm run test:e2e:mock",
|
|
29
|
+
"mcporter:help": "mcporter generate-cli --help"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@modelcontextprotocol/client": "2.0.0",
|
|
33
|
+
"mcporter": "0.13.7"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@modelcontextprotocol/server": "2.0.0",
|
|
37
|
+
"@types/node": "24.10.0",
|
|
38
|
+
"tsx": "4.21.0",
|
|
39
|
+
"typescript": "5.9.3",
|
|
40
|
+
"zod": "4.4.3"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: feiguazhitou-mcp-cli
|
|
3
|
+
description: Install, configure, refresh, diagnose, and safely use the local Feiguazhitou MCP through its dynamic CLI.
|
|
4
|
+
argument_hint: Feiguazhitou client status, MCP endpoint, or the CLI issue to troubleshoot
|
|
5
|
+
metadata:
|
|
6
|
+
pre_input: Describe the Feiguazhitou client status, MCP endpoint, or the CLI issue to troubleshoot:
|
|
7
|
+
apply: available
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Feiguazhitou MCP CLI Setup and Connection
|
|
11
|
+
|
|
12
|
+
This Skill is based on the Feiguazhitou MCP service guide. The service runs only on the same computer as the Feiguazhitou desktop client.
|
|
13
|
+
It covers installation, connection, refresh, and troubleshooting. Do not assume or hard-code MCP tools; use the current local tool catalog.
|
|
14
|
+
|
|
15
|
+
## Mandatory Transport Boundary
|
|
16
|
+
|
|
17
|
+
Agents, scripts, and other callers **must not connect directly** to the local Feiguazhitou MCP endpoint or invoke tools through another MCP client. Use only canonical `feiguazhitou-mcp-cli` commands, especially `feiguazhitou-mcp-cli run COMMAND ...`. The CLI connects to MCP internally; this restriction applies to callers, not to the CLI's own MCP connection.
|
|
18
|
+
|
|
19
|
+
## Prerequisites
|
|
20
|
+
|
|
21
|
+
1. Start the Feiguazhitou client and verify its MCP address and port in client settings.
|
|
22
|
+
2. Sign in to Compass for the target live account and keep its monitor online.
|
|
23
|
+
3. Run the CLI on the same computer as the client. The service normally listens on `127.0.0.1`, so it is not reachable from another computer.
|
|
24
|
+
|
|
25
|
+
## Installation and First Connection
|
|
26
|
+
|
|
27
|
+
Install the npm package and use the endpoint shown in client settings. The usual default is `http://127.0.0.1:19528/mcp`, but the user may change the port:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install --global feiguazhitou-mcp-cli
|
|
31
|
+
|
|
32
|
+
export FEIGUAZHITOU_CLI_MCP_URL="http://127.0.0.1:19528/mcp"
|
|
33
|
+
export FEIGUAZHITOU_CLI_API_KEY="<only-when-your-client-requires-it>"
|
|
34
|
+
|
|
35
|
+
feiguazhitou-mcp-cli refresh
|
|
36
|
+
feiguazhitou-mcp-cli doctor --output text
|
|
37
|
+
feiguazhitou-mcp-cli describe --output json
|
|
38
|
+
feiguazhitou-mcp-cli tools list --output json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
By default, `FEIGUAZHITOU_CLI_API_KEY` is used only in the process environment. When a user sends a standard `mcpServers` JSON document in a conversation, the CLI does **not** read or parse the complete JSON document. This Skill tells the Agent to understand it and call the CLI one setting at a time. The Agent first reads `feiguazhitou-mcp-cli describe --output json`, then applies fields supported by the current CLI for the user-selected server. When several servers exist and the target is unclear, ask instead of guessing.
|
|
42
|
+
|
|
43
|
+
For a currently usable endpoint, the Agent runs `feiguazhitou-mcp-cli config set endpoint URL`. For every Header in the selected server, unless the user opted out, it runs `feiguazhitou-mcp-cli config set header HEADER --value-stdin` and supplies the value only through standard input, never in a command-line argument. The command saves one Header in a local unencrypted credential file; systems with POSIX permissions restrict it to the current user, and the Agent must tell the user. Actual Header values never enter ordinary config, this Skill, a tool catalog, a generated bundle, or command output. When the user opts out, for each Header run `config unset header HEADER`, then `config set header-env HEADER ENV_VAR`; the actual value exists only in the environment of later CLI processes. Do not put tokens, cookies, account data, or Header values in project config, this Skill, or command examples.
|
|
44
|
+
|
|
45
|
+
When the user configuration includes `autoApprove`, the Agent must place its raw JSON array in `FEIGUAZHITOU_CLI_AUTO_APPROVE` for later CLI processes. It is client-side catalog metadata, never an HTTP Header sent to MCP, and it does not replace explicit authorization for unfamiliar or high-impact actions. Additional or future fields are reference information, not errors: this Skill is not a field allowlist. An Agent maps them only when the current `describe` defines a corresponding CLI setting or environment variable; it must not invent mappings, discard fields, or directly connect to the configuration URL. After individual configuration, the Agent explicitly runs `feiguazhitou-mcp-cli refresh --output json`, then reads `tools list`, `tools show`, and uses `run`.
|
|
46
|
+
|
|
47
|
+
Set `FEIGUAZHITOU_CLI_LANG=en` when English launcher output is wanted. MCP tool descriptions, schemas, parameters, and returned business data remain unchanged.
|
|
48
|
+
|
|
49
|
+
## Dynamic Tool Discovery
|
|
50
|
+
|
|
51
|
+
Use the stable launcher protocol. Do not guess top-level dynamic commands. Read the local contract and catalog first:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
feiguazhitou-mcp-cli describe --output json
|
|
55
|
+
feiguazhitou-mcp-cli tools list --output json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If `tools list` returns `ARTIFACT_MISSING`, or an explicit live schema check is needed, run:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
feiguazhitou-mcp-cli refresh --output json
|
|
62
|
+
feiguazhitou-mcp-cli tools list --output json
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Run `refresh` whenever the service adds, removes, or changes a tool. When the local catalog has not been checked for over 7 days, `tools list` and `tools show` suggest `tools list --refresh`, but never connect automatically. Use `refresh --force` after a schema or HTTP header-name change. After changing `FEIGUAZHITOU_CLI_MCP_TIMEOUT` or `config set timeout`, the next `run` uses the new timeout without refresh. Do not manually edit a generated CLI bundle in the local data directory; the next refresh replaces it.
|
|
66
|
+
|
|
67
|
+
Before calling a tool, read its current schema. `NAME` can be a raw underscore-separated MCP tool name or a hyphenated CLI command name:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
feiguazhitou-mcp-cli tools show NAME --output json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Invocation Rules
|
|
74
|
+
|
|
75
|
+
- Use the canonical form: `feiguazhitou-mcp-cli run COMMAND ...`.
|
|
76
|
+
- Use the local Feiguazhitou MCP as a single session. Do not run `run`, `refresh`, or `doctor` concurrently; wait for each MCP-connecting command to finish before starting the next one. The CLI does not queue concurrent calls automatically.
|
|
77
|
+
- Prefer `--raw '<json>' --output json` for objects, arrays, and optional-parameter combinations. For complex JSON, use `--raw @INPUT.json` to read a file, or `cat INPUT.json | feiguazhitou-mcp-cli run COMMAND --raw - --output json` to read standard input. When generated-command `--help` exposes scalar flags, Chinese and space-containing values work with normal shell quoting; `--raw` is not a workaround for Chinese parameters.
|
|
78
|
+
- Output preserves the MCP response container and fields. Amounts, counts, and ratios may be raw numbers, strings, or `{ "unit", "value" }`; inspect the current response before converting or aggregating them.
|
|
79
|
+
- For dependent workflows, read each preceding response before creating the next `--raw` input. Do not guess identifiers, page numbers, or time ranges.
|
|
80
|
+
- `run` does not implicitly connect for schema discovery or refresh. On `ARTIFACT_MISSING`, `ARTIFACT_REFRESH_REQUIRED`, or `TOOL_NOT_FOUND`, read the JSON error remediation and then run the requested `refresh` or `tools list` action.
|
|
81
|
+
- When MCP standard `isError: true`, Feiguazhitou `ok: false`, or non-zero `BaseResp.StatusCode` signals a failed call, the CLI preserves the MCP output and exits with code `1`. Scripts and Agents should check the exit code first.
|
|
82
|
+
- If a generated command fails before it produces an MCP response, such as a timeout, a call with `--output json` returns `COMMAND_FAILED`; the raw error text is in `error.details.stderr`. The CLI does not retry the call.
|
|
83
|
+
|
|
84
|
+
## Troubleshooting
|
|
85
|
+
|
|
86
|
+
| Symptom | Action |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| Connection failure or no tools | Confirm that the client is running and its port matches settings, then run `doctor`. |
|
|
89
|
+
| A remote computer cannot connect | This is a local loopback service. Run the CLI on the same computer as the Feiguazhitou client. |
|
|
90
|
+
| A data tool reports no account or monitor | Check Compass sign-in and monitor state. This is a data-source prerequisite, not a CLI schema failure. |
|
|
91
|
+
| Request timeout | The CLI does not retry. When a timeout occurs before an MCP response, `--output json` returns `COMMAND_FAILED` and preserves the raw timeout text in `error.details.stderr`. Check client and monitor state. The default is 90000ms; use `config set timeout MILLISECONDS` when a different limit is needed, and it takes effect on the next `run`. |
|
|
92
|
+
| A new tool or parameter is absent | Run `refresh`, or `refresh --force` when required, then inspect the latest `tools list` and `tools show`. |
|
|
93
|
+
|
|
94
|
+
## Safety Boundaries
|
|
95
|
+
|
|
96
|
+
- `describe`, `tools list`, `tools show`, and `run` do not write live-account, order, or query results to project configuration or generated artifacts.
|
|
97
|
+
- Unless the user opted out, the Agent saves each Header credential with `config set header HEADER --value-stdin`; that local file is unencrypted and the CLI reports this to the user. When the user opts out, the Agent uses `config unset header` and `config set header-env`.
|
|
98
|
+
- Query data only from a user-approved local client and target account.
|
|
99
|
+
- Future schemas may include high-impact operations. Read help and parameters first, and obtain explicit authorization before an action can change account state, publish content, delete data, or trigger external effects.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: feiguazhitou-mcp-cli
|
|
3
|
+
description: 使用飞瓜智投本机 MCP 的动态 CLI 完成安装、配置、刷新、诊断与排障。适用于飞瓜智投客户端的 MCP 端点连接、本机鉴权、端口变更、工具 schema 更新或调用失败的场景。
|
|
4
|
+
argument_hint: 飞瓜智投客户端状态、端点或要排查的 CLI 问题
|
|
5
|
+
metadata:
|
|
6
|
+
pre_input: 请说明飞瓜智投客户端状态、MCP 端点或需要排查的 CLI 问题:
|
|
7
|
+
apply: available
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# 飞瓜智投 MCP CLI 安装与连接
|
|
11
|
+
|
|
12
|
+
本 Skill 来源于飞瓜智投 MCP 服务使用指南,服务仅运行在启动飞瓜智投客户端的本机。
|
|
13
|
+
它只指导安装、连接、刷新和排障;不要假设或写死可用的 MCP tool,工具列表以当前
|
|
14
|
+
本地 tool catalog 为准。
|
|
15
|
+
|
|
16
|
+
## 强制调用边界
|
|
17
|
+
|
|
18
|
+
Agent、脚本和其他调用方**不得直接连接**飞瓜智投本机 MCP endpoint,也不得通过其他 MCP client
|
|
19
|
+
调用 tool。只能使用 `feiguazhitou-mcp-cli` 的规范命令,尤其是
|
|
20
|
+
`feiguazhitou-mcp-cli run COMMAND ...`。CLI 会在内部连接 MCP;此约束仅限制调用方,不影响 CLI
|
|
21
|
+
自身的 MCP 连接。
|
|
22
|
+
|
|
23
|
+
## 前置检查
|
|
24
|
+
|
|
25
|
+
1. 飞瓜智投客户端已启动,并在客户端设置中确认 MCP 服务地址和端口。
|
|
26
|
+
2. 目标直播号已在客户端完成罗盘登录,且监视器在线。
|
|
27
|
+
3. CLI 与飞瓜智投客户端运行在同一台电脑。服务通常只监听 `127.0.0.1`,不能把本机
|
|
28
|
+
endpoint 当作可从其他机器访问的地址。
|
|
29
|
+
|
|
30
|
+
## 安装与首次连接
|
|
31
|
+
|
|
32
|
+
安装 npm 包后,使用客户端设置页显示的 endpoint。默认值通常为
|
|
33
|
+
`http://127.0.0.1:19528/mcp`,但端口可能被用户修改:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install --global feiguazhitou-mcp-cli
|
|
37
|
+
|
|
38
|
+
export FEIGUAZHITOU_CLI_MCP_URL="http://127.0.0.1:19528/mcp"
|
|
39
|
+
export FEIGUAZHITOU_CLI_API_KEY="<only-when-your-client-requires-it>"
|
|
40
|
+
|
|
41
|
+
feiguazhitou-mcp-cli refresh
|
|
42
|
+
feiguazhitou-mcp-cli doctor --output text
|
|
43
|
+
feiguazhitou-mcp-cli describe --output json
|
|
44
|
+
feiguazhitou-mcp-cli tools list --output json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
默认情况下,`FEIGUAZHITOU_CLI_API_KEY` 只在环境变量中使用。当用户在对话中直接发送标准
|
|
48
|
+
`mcpServers` JSON 时,CLI **不会**读取或解析整份 JSON;Skill 只指导 Agent 自己理解配置,并逐项调用
|
|
49
|
+
CLI。Agent 先读取 `feiguazhitou-mcp-cli describe --output json`,根据用户指定的 server 和当前 CLI 契约处理
|
|
50
|
+
可映射字段;多个 server 而目标不清楚时先询问,不能猜测。
|
|
51
|
+
|
|
52
|
+
对当前可用 endpoint,Agent 执行 `feiguazhitou-mcp-cli config set endpoint URL`。对所选 server 中的每个
|
|
53
|
+
Header,用户未要求不保存时,Agent 默认执行 `feiguazhitou-mcp-cli config set header HEADER --value-stdin`,并只用
|
|
54
|
+
标准输入提供该 Header 值,绝不把值放进命令行参数。该命令把单个 Header 保存到本机未加密凭据文件;支持 POSIX
|
|
55
|
+
权限的系统会限制为当前用户读写,Agent 必须告知用户。实际 Header 值不会进入普通配置、Skill、tool catalog、
|
|
56
|
+
生成 bundle 或命令输出。用户要求不保存时,Agent 对每个 Header 执行 `config unset header HEADER`,再执行
|
|
57
|
+
`config set header-env HEADER ENV_VAR`;实际值只在后续 CLI 进程的环境变量中提供。不要把 Token、Cookie、账号
|
|
58
|
+
数据或 Header 值写入项目配置、Skill 或命令示例。
|
|
59
|
+
|
|
60
|
+
若用户配置含 `autoApprove`,Agent 必须把其中的原始 JSON 数组设置为后续 CLI 进程的
|
|
61
|
+
`FEIGUAZHITOU_CLI_AUTO_APPROVE`。它是客户端侧目录标记,不会作为 HTTP Header 发往 MCP,也不替代对未知或
|
|
62
|
+
高影响操作的明确授权。额外或未来新增字段是参考信息,不是错误:本 Skill 不是字段白名单,Agent 只能在当前
|
|
63
|
+
`describe` 已定义对应 CLI 配置或环境变量时映射,不能自行臆造映射、删除字段或直连配置中的 URL。逐项配置后,
|
|
64
|
+
Agent 显式运行 `feiguazhitou-mcp-cli refresh --output json`,再读取 `tools list`、`tools show` 并使用 `run`。
|
|
65
|
+
|
|
66
|
+
launcher 文案默认输出中文。需要英文时设置 `FEIGUAZHITOU_CLI_LANG=en`;MCP 的 tool 描述、schema、
|
|
67
|
+
参数和业务数据不会被翻译或改写。
|
|
68
|
+
|
|
69
|
+
`FEIGUAZHITOU_CLI_AUTO_APPROVE` 接受 MCP 原始 tool 名或生成 command 名组成的 JSON 数组;`tools list` 和
|
|
70
|
+
`tools show` 会为匹配项标出 `autoApproved: true`。
|
|
71
|
+
|
|
72
|
+
## 动态工具发现
|
|
73
|
+
|
|
74
|
+
使用稳定 launcher 协议,不要猜测顶层动态命令。先读取本地契约和 catalog:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
feiguazhitou-mcp-cli describe --output json
|
|
78
|
+
feiguazhitou-mcp-cli tools list --output json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
如果 `tools list` 返回 `ARTIFACT_MISSING`,或明确需要读取服务的最新 schema,再执行:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
feiguazhitou-mcp-cli refresh --output json
|
|
85
|
+
feiguazhitou-mcp-cli tools list --output json
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
服务新增、下线或调整 tool 后也执行 `refresh`。若本地目录超过 7 天未检查,`tools list` 和
|
|
89
|
+
`tools show` 会提示执行 `tools list --refresh`,但不会自动联网。若 schema 或 HTTP Header 名称变更,执行
|
|
90
|
+
`refresh --force`。修改 `FEIGUAZHITOU_CLI_MCP_TIMEOUT` 或 `config set timeout` 后,下一次 `run` 会直接使用
|
|
91
|
+
新超时,不需要 refresh。不要手动修改本地数据目录下生成的 CLI bundle;该产物会在下次 refresh 时被替换。
|
|
92
|
+
|
|
93
|
+
调用某个工具前,读取它的实时 schema。`NAME` 可为 MCP 原始 tool 名(下划线)或 CLI command
|
|
94
|
+
名(连字符):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
feiguazhitou-mcp-cli tools show NAME --output json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 调用约定
|
|
101
|
+
|
|
102
|
+
- 使用 canonical 调用:`feiguazhitou-mcp-cli run COMMAND ...`。
|
|
103
|
+
- 飞瓜本机 MCP 按单会话使用。不要并发执行 `run`、`refresh` 或 `doctor`;必须等待上一条会连接 MCP 的命令完全结束后,再执行下一条。CLI 不会自动排队。
|
|
104
|
+
- 对对象、数组或可选参数组合,优先使用 `--raw '<json>' --output json`。复杂 JSON 可使用 `--raw @INPUT.json` 从文件读取,或用 `cat INPUT.json | feiguazhitou-mcp-cli run COMMAND --raw - --output json` 从标准输入读取。若生成 command 的 `--help` 暴露标量 flag,中文和带空格的值可按正常 shell 引号规则直接传入;`--raw` 不是中文参数的绕过方式。
|
|
105
|
+
- 输出保留 MCP 服务的原始 JSON 容器和字段。金额、计数和比例可能是原始数值、文本,或
|
|
106
|
+
`{ "unit", "value" }` 结构;先读取当前返回结构,再做换算或汇总。
|
|
107
|
+
- 对依赖前一步结果的工作流,先读取上一步返回值,再构造下一次 `--raw` 参数;不要猜测
|
|
108
|
+
标识符、页面号或时间范围。
|
|
109
|
+
- `run` 不会自动联网或刷新。若返回 `ARTIFACT_MISSING`、`ARTIFACT_REFRESH_REQUIRED` 或
|
|
110
|
+
`TOOL_NOT_FOUND`,读取 JSON 错误里的 remediation 后执行相应的 `refresh` 或 `tools list`。
|
|
111
|
+
- MCP 标准 `isError: true`、飞瓜业务响应 `ok: false` 或非零 `BaseResp.StatusCode` 表示调用失败时,CLI 保持 MCP 输出不变并以退出码 `1` 结束。脚本和 Agent 应优先检查退出码。
|
|
112
|
+
- 若生成命令在产生 MCP 响应前失败(例如超时),带 `--output json` 的调用会返回 `COMMAND_FAILED`;原始错误文本位于 `error.details.stderr`。CLI 不重试该调用。
|
|
113
|
+
|
|
114
|
+
## 常见排障
|
|
115
|
+
|
|
116
|
+
| 现象 | 处理 |
|
|
117
|
+
| --- | --- |
|
|
118
|
+
| 连接失败或工具为空 | 确认客户端正在运行、端口与设置页一致,然后运行 `doctor`。 |
|
|
119
|
+
| 远程机器无法连接 | 这是本机回环服务,应在运行飞瓜智投客户端的同一台机器执行 CLI。 |
|
|
120
|
+
| 数据工具报无账号或监视器错误 | 检查罗盘登录和监视器在线状态;这是数据源前置条件,不是 CLI schema 错误。 |
|
|
121
|
+
| 请求超时 | CLI 不重试。若超时前没有 MCP 输出,`--output json` 返回 `COMMAND_FAILED`,原始超时文本在 `error.details.stderr`;检查客户端和监视器状态。默认 90000ms;需要不同等待上限时使用 `config set timeout MILLISECONDS`,新值在下一次 `run` 生效。 |
|
|
122
|
+
| 新工具或参数未出现 | 运行 `refresh`,必要时使用 `refresh --force`,再读取最新 `tools list` 和 `tools show`。 |
|
|
123
|
+
|
|
124
|
+
## 安全边界
|
|
125
|
+
|
|
126
|
+
- `describe`、`tools list`、`tools show` 与 `run` 不会把直播账号、订单或查询结果写入项目配置或 artifact。
|
|
127
|
+
- 用户未选择不保存时,Agent 通过 `config set header HEADER --value-stdin` 逐个保存 Header 凭据;该文件未加密,CLI 会在输出中告知用户。用户要求不保存时,Agent 使用 `config unset header` 与 `config set header-env`。
|
|
128
|
+
- 只在用户确认的本地客户端和目标账号上运行数据查询。
|
|
129
|
+
- 未来 schema 可能引入高影响操作。遇到不熟悉的生成命令时,先阅读 help 和参数说明,
|
|
130
|
+
并在执行会改变账号、发布内容、删除数据或触发外部动作的命令前取得明确授权。
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": "feiguazhitou-mcp-cli.skills/v1",
|
|
3
|
+
"protocolVersion": 1,
|
|
4
|
+
"skillVersion": "1.6.0",
|
|
5
|
+
"name": "feiguazhitou-mcp-cli",
|
|
6
|
+
"description": "Install, configure, refresh, diagnose, and safely use the dynamically generated Feiguazhitou MCP CLI.",
|
|
7
|
+
"argumentHint": "Feiguazhitou client status, MCP endpoint, or the CLI issue to troubleshoot",
|
|
8
|
+
"apply": "available",
|
|
9
|
+
"entrypoint": "SKILL.en.md",
|
|
10
|
+
"capabilities": [
|
|
11
|
+
"local-mcp-installation",
|
|
12
|
+
"streamable-http-configuration",
|
|
13
|
+
"runtime-schema-refresh",
|
|
14
|
+
"agent-cli-bootstrap",
|
|
15
|
+
"local-tool-catalog",
|
|
16
|
+
"canonical-tool-execution",
|
|
17
|
+
"runtime-approval-policy",
|
|
18
|
+
"credential-environment-setup",
|
|
19
|
+
"granular-cli-configuration",
|
|
20
|
+
"secure-header-stdin-configuration",
|
|
21
|
+
"agent-standard-mcp-config-interpretation",
|
|
22
|
+
"connection-troubleshooting",
|
|
23
|
+
"complex-raw-input",
|
|
24
|
+
"structured-failure-exit"
|
|
25
|
+
],
|
|
26
|
+
"requirements": {
|
|
27
|
+
"command": "feiguazhitou-mcp-cli",
|
|
28
|
+
"runtimeEnvironment": [],
|
|
29
|
+
"optionalRuntimeEnvironment": [
|
|
30
|
+
"FEIGUAZHITOU_CLI_MCP_URL",
|
|
31
|
+
"FEIGUAZHITOU_CLI_API_KEY",
|
|
32
|
+
"FEIGUAZHITOU_CLI_MCP_HEADERS",
|
|
33
|
+
"FEIGUAZHITOU_CLI_AUTO_APPROVE",
|
|
34
|
+
"FEIGUAZHITOU_CLI_MCP_TIMEOUT",
|
|
35
|
+
"FEIGUAZHITOU_CLI_DATA_DIR",
|
|
36
|
+
"FEIGUAZHITOU_CLI_LANG"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|