tyc-cli 0.3.1 → 0.3.3

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/CHANGELOG.md CHANGED
@@ -58,7 +58,7 @@
58
58
  - `tyc <group> <method>` 命令形态与 0.1.0 完全一致
59
59
  - `--pretty / --md / --verbose` 三种输出模式
60
60
  - tyc 英文 key 透传(由 MCP Server 保证)
61
- - 6 分类 / 163 工具全量覆盖
61
+ - 6 分类 / 162 工具全量覆盖
62
62
 
63
63
  ## [0.1.0] - 2026-04-25
64
64
 
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ## 📖 项目简介
13
13
 
14
14
  `tyc-cli` 是天眼查 MCP Server 的官方命令行客户端。通过 MCP 协议(JSON-RPC 2.0 over
15
- Streamable HTTP)调用天眼查 163 个业务语义聚合工具,覆盖企业工商、知产、司法风险、
15
+ Streamable HTTP)调用天眼查 162 个业务语义聚合工具,覆盖企业工商、知产、司法风险、
16
16
  董监高等全维度商业数据。
17
17
 
18
18
  **核心特点**:
@@ -22,7 +22,7 @@ Streamable HTTP)调用天眼查 163 个业务语义聚合工具,覆盖企业
22
22
  - 🔌 **即插即用**:默认连接官方 MCP 端点 `https://mcp.tianyancha.com/v1`;
23
23
  支持 `--url` 指向私有部署
24
24
  - 🔄 **Session 复用**:`Mcp-Session-Id` 本地缓存 24 小时,后续调用零 initialize 开销
25
- - 🎯 **6 大业务分类 / 163 个工具**:企业基础信息 · 风险合规 · 知识产权 · 经营与公示 · 历史信息 · 董监高
25
+ - 🎯 **6 大业务分类 / 162 个工具**:企业基础信息 · 风险合规 · 知识产权 · 经营与公示 · 历史信息 · 董监高
26
26
  - 🤖 **AI Agent 友好**:tyc 英文 key 透传 / 时间戳格式化 / `_summary / _empty / _warnings` 元数据
27
27
 
28
28
  ---
@@ -344,7 +344,7 @@ tyc-cli/
344
344
  | 职责 | 命令树 · 参数透传 · 格式化输出 | 多源聚合 · 时间戳格式化 · 元数据注入 · Authorization 透传至 OpenAPI |
345
345
  | 运维 | 用户本地安装 | 官方托管 `mcp.tianyancha.com`,或用户自建 |
346
346
 
347
- CLI 和 MCP Server 共享同一 163 工具清单;工具元数据从打包内的 `catalog.json`
347
+ CLI 和 MCP Server 共享同一 162 工具清单;工具元数据从打包内的 `catalog.json`
348
348
  读取,保证命令树冷启动零网络开销。
349
349
 
350
350
  ---
package/dist/catalog.json CHANGED
@@ -5,12 +5,12 @@
5
5
  {
6
6
  "group": "company",
7
7
  "name_zh": "企业基础信息",
8
- "tool_count": 52
8
+ "tool_count": 49
9
9
  },
10
10
  {
11
11
  "group": "risk",
12
12
  "name_zh": "风险合规",
13
- "tool_count": 36
13
+ "tool_count": 35
14
14
  },
15
15
  {
16
16
  "group": "intellectual_property",
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { registerInitCommand } from "./commands/init.js";
4
4
  import { registerCategoryCommands } from "./commands/category.js";
5
5
  import { registerLayerCommands } from "./commands/layers.js";
6
6
  import { getCategories, getLayerCount, getPriorityTools, getTotalCount, } from "./registry.js";
7
+ import { VERSION } from "./version.js";
7
8
  // 顶层 help:把"最懂 AI 的 CLI"落在 4 层架构 + 调用顺序 + 可发现性上。
8
9
  // Agent 看 tyc --help 时应立刻读懂"先 L0 锚定企业,再 L1 概览,再 L2 下钻,最后 L3 详情"这条主线。
9
10
  const helpText = `
@@ -114,7 +115,7 @@ function renderPriorityLines() {
114
115
  const program = new Command()
115
116
  .name("tyc")
116
117
  .description(`Tianyan AI CLI — ${getTotalCount()} commercial-data tools · L0=${getLayerCount("L0")} L1=${getLayerCount("L1")} L2=${getLayerCount("L2")} L3=${getLayerCount("L3")} · the AI-native gateway (pair with the TA MCP Server)`)
117
- .version("0.4.0")
118
+ .version(VERSION)
118
119
  .option("--pretty", "缩进 JSON 输出(默认行为,flag 保留以保持向后兼容)")
119
120
  .option("--md", "Markdown 表格化输出(适合人类阅读 / Agent 上屏)")
120
121
  .option("--compact", "紧凑单行 JSON(管道 / jq 场景;为旧默认行为)")
package/dist/mcpClient.js CHANGED
@@ -10,6 +10,7 @@
10
10
  // - 不做业务聚合/时间戳格式化(由 MCP Server 完成)
11
11
  // - 不做 Authorization 解析/验签
12
12
  import { clearSession, isSessionFresh, loadSession, saveSession } from "./session.js";
13
+ import { VERSION } from "./version.js";
13
14
  const PROTOCOL_VERSION = "2024-11-05";
14
15
  function maskToken(v) {
15
16
  if (!v)
@@ -28,31 +29,19 @@ function logVerbose(cfg, title, extra) {
28
29
  if (extra)
29
30
  console.error(extra);
30
31
  }
31
- /** 解析 MCP Streamable HTTP 响应:纯 JSON 或 SSE(`event:` + `data:` 行)。 */
32
+ /** 解析 MCP Streamable HTTP 响应——server 端实测固定回 application/json 单包,
33
+ * 无论 client Accept 头声明什么。SSE 路径不存在,所以只解析 JSON。 */
32
34
  function parseJsonRpc(raw) {
33
35
  const trimmed = raw.trim();
34
- if (trimmed.startsWith("{")) {
35
- return JSON.parse(trimmed);
36
+ if (!trimmed.startsWith("{")) {
37
+ throw new Error(`Unparseable MCP response: ${trimmed.slice(0, 200)}`);
36
38
  }
37
- // SSE 解析:抓第一个解析成功的 data 行
38
- for (const line of trimmed.split(/\r?\n/)) {
39
- const s = line.trim();
40
- if (!s.startsWith("data:"))
41
- continue;
42
- const body = s.slice(5).trim();
43
- if (!body.startsWith("{"))
44
- continue;
45
- try {
46
- return JSON.parse(body);
47
- }
48
- catch { /* try next */ }
49
- }
50
- throw new Error(`Unparseable MCP response: ${trimmed.slice(0, 200)}`);
39
+ return JSON.parse(trimmed);
51
40
  }
52
41
  async function httpPost(url, headers, body, verbose) {
53
42
  const h = {
54
43
  "Content-Type": "application/json",
55
- "Accept": "application/json, text/event-stream",
44
+ "Accept": "application/json",
56
45
  ...headers,
57
46
  };
58
47
  if (verbose) {
@@ -86,7 +75,7 @@ async function doInitialize(cfg, verbose) {
86
75
  params: {
87
76
  protocolVersion: PROTOCOL_VERSION,
88
77
  capabilities: {},
89
- clientInfo: { name: "tyc-cli", version: "0.2.0" },
78
+ clientInfo: { name: "tyc-cli", version: VERSION },
90
79
  },
91
80
  }, verbose);
92
81
  if (status < 200 || status >= 300) {
@@ -0,0 +1,22 @@
1
+ // CLI 版本号单一来源:从 package.json 读取
2
+ //
3
+ // 历史上 index.ts 与 mcpClient.ts 各自硬编码版本字符串,多处漂移。
4
+ // 收敛到 package.json 一处后,bump 版本只需 npm version <x>。
5
+ // 运行时 fs 读:dev (`tsx src/version.ts`) 与 dist (`dist/version.js`) 与
6
+ // package.json 都同级 (cli/t1_1/{src,dist} ↔ cli/t1_1/package.json),
7
+ // resolve(__dirname, "..", "package.json") 在两种场景下都指向同一文件。
8
+ import { readFileSync } from "node:fs";
9
+ import { resolve, dirname } from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ const PKG_PATH = resolve(__dirname, "..", "package.json");
13
+ function readVersion() {
14
+ try {
15
+ const raw = readFileSync(PKG_PATH, "utf-8");
16
+ return JSON.parse(raw).version || "0.0.0";
17
+ }
18
+ catch {
19
+ return "0.0.0";
20
+ }
21
+ }
22
+ export const VERSION = readVersion();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tyc-cli",
3
- "version": "0.3.1",
4
- "description": "天眼查 MCP CLI — 163 个业务语义聚合工具 · 命令行直达企业数据 · 通过 MCP Server 调用",
3
+ "version": "0.3.3",
4
+ "description": "天眼查 MCP CLI — 162 个业务语义聚合工具 · 命令行直达企业数据 · 通过 MCP Server 调用",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
7
  "tyc": "./dist/index.js"