tyc-cli 0.1.1

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 ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ 本项目遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 规范,版本号遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.1.0] - 2026-04-25
8
+
9
+ ### 新增
10
+
11
+ - 🎉 **首发版本**:天眼查 业务语义层命令行工具
12
+ - **15 个分类 / 167 个聚合工具**:覆盖企业基础信息、风险合规、知识产权、经营与公示、历史信息、董监高、股权与关系图谱、集团信息、投资机构、私募基金、建筑资质、企业搜索、财务分析、企业报告、地理与园区
13
+ - **多源并发聚合**:每个工具自动并发调用多个 tyc OpenAPI,按声明顺序做顶层 map 覆盖合并;少量场景支持 `serial` 串行执行(前一步结果注入下一步参数)
14
+ - **空结果归一化**:tyc `error_code: 300000`(经查无结果)自动归一为 `{items: [], total: 0, _empty: true}` + `_summary` 友好文案
15
+ - **时间戳格式化**:毫秒时间戳值自动转为 `Asia/Shanghai` 字符串(`yyyy-MM-dd` / `yyyy-MM-dd HH:mm:ss`),key 名保持 tyc 英文不变
16
+ - **命令名自动剥离分类前缀**:`get_company_registration_info` → `tyc company registration-info`
17
+ - **三种输出格式**:
18
+ - 默认:紧凑 JSON(适合脚本管道)
19
+ - `--pretty`:缩进 JSON(适合调试)
20
+ - `--md`:Markdown 表格(适合人类阅读 / Agent 上屏)
21
+ - **项目元数据注入**:`_summary` / `_empty` / `_warnings` 下划线前缀字段,与 tyc 业务字段区分
22
+ - **`tyc init` 命令**:保存 Authorization 到 `~/.tyc/config.json`,与同名 MCP Server 共享配置
23
+ - **`tyc list` / `tyc <category> --help`**:动态发现 15 个分类下的全部命令
24
+ - **`--verbose`**:打印 HTTP 请求详情到 stderr,便于调试
25
+
26
+ ### 数据源
27
+
28
+ - 内置 `api-registry.yaml`(167 工具 SSOT)作为构建时数据源,无需联网即可静态生成命令树
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tyc-cli contributors
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.
package/README.md ADDED
@@ -0,0 +1,518 @@
1
+ # tyc-cli
2
+
3
+ > 天眼查 OpenAPI 业务语义层命令行工具 —— 为人类与 AI Agent 而生的企业数据查询利器
4
+
5
+ [![npm version](https://img.shields.io/npm/v/tyc-cli.svg)](https://www.npmjs.com/package/tyc-cli)
6
+ [![npm download](https://img.shields.io/npm/dm/tyc-cli.svg)](https://www.npmjs.com/package/tyc-cli)
7
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
8
+ [![Node ≥ 18](https://img.shields.io/badge/node-%E2%89%A518-brightgreen.svg)](#-环境准备)
9
+
10
+ ---
11
+
12
+ ## 📖 项目简介
13
+
14
+ `tyc-cli` 是基于天眼查 OpenAPI 的命令行工具,旨在帮助开发者和 AI Agent 快速访问企业工商信息、知识产权、司法风险、董监高画像等全维度商业数据。
15
+
16
+ **核心能力**:
17
+
18
+ - 🎯 **6 大业务分类**:企业基础信息(含股权图谱 / 集团 / 企业搜索 / 财务分析 / 企业报告 / 地理园区子分类)· 风险合规 · 知识产权(含建筑资质子分类)· 经营与公示(含投资机构 / 私募基金子分类)· 历史信息 · 董监高
19
+ - 🔧 **167 个聚合工具**:每个工具内部自动并发调多个 tyc 原子 API,按业务语义合并输出
20
+ - 🤖 **AI Agent 友好**:tyc 英文 key 透传 / 时间戳自动格式化 / 自动注入 `_summary` / `_empty` / `_warnings` 元数据
21
+ - 🔒 **安全可控**:Authorization 透传不解析,配置文件本地化,敏感字段不入仓
22
+
23
+ ---
24
+
25
+ ## 🌟 为什么选择 tyc-cli?
26
+
27
+ ### 🤖 为 AI Agent 原生设计
28
+
29
+ - **tyc 英文 key 透传**:返回值顶层全为 `name` / `items` / `creditCode` / `total` 等英文字段,避免中英混用造成的 LLM 理解抖动
30
+ - **时间戳自动格式化**:毫秒时间戳值自动转为 `Asia/Shanghai` 字符串(`yyyy-MM-dd`),key 名不变,便于 Agent 直接消费
31
+ - **空结果归一化**:tyc 的 `经查无结果`(error_code 300000)自动归一为 `{items: [], total: 0, _empty: true}` + 友好摘要,便于 Agent 分支判断
32
+ - **三种输出格式**:紧凑 JSON / 缩进 JSON (`--pretty`) / Markdown 表格 (`--md`),适配不同 Agent 上屏需求
33
+ - **确定性错误码**:失败/熔断/无权限有清晰区分,可基于退出码自动重试
34
+
35
+ ### 👤 为人类开发者设计
36
+
37
+ - **简洁命令**:`tyc company registration-info "企业名称"`(自动剥离分类前缀,告别 `tyc company company-registration-info` 冗余)
38
+ - **三种输出 mode**:
39
+ - 默认紧凑 JSON:适合 `jq` 管道
40
+ - `--pretty`:缩进 2 空格的 JSON,调试友好
41
+ - `--md`:Markdown 表格,复制即用
42
+ - **`--verbose` 调试**:打印 HTTP 请求详情到 stderr,定位问题
43
+ - **`tyc --help` / `tyc <分类> --help`**:动态展开 6 分类下的全部命令
44
+
45
+ ### 🏢 为企业级应用设计
46
+
47
+ - **配置驱动**:统一配置 `~/.tyc/config.json`,支持多环境切换
48
+ - **静态命令树**:构建时从 SSOT (`api-registry.yaml`) 生成命令,无需联网自省
49
+ - **无状态**:每次调用独立鉴权,可水平扩展用于批处理脚本
50
+
51
+ ### 🚀 零门槛上手
52
+
53
+ - **3 分钟安装**:`npm install -g tyc-cli`
54
+ - **一行命令查询**:无需编写代码,命令行直达数据
55
+ - **MIT 协议**:可自由二次开发与商用分发
56
+
57
+ ### 🛡️ 安全可控
58
+
59
+ - **Authorization 透传**:CLI 不解析、不验签、不上报,原样发给天眼查 OpenAPI
60
+ - **配置本地化**:token 仅保存在 `~/.tyc/config.json`,权限 600
61
+ - **敏感字段不入仓**:`.gitignore` 排除 `.env` 与本地配置
62
+
63
+ ---
64
+
65
+ ## ⚡ 功能特性
66
+
67
+ ### 6 大业务分类
68
+
69
+ | 分类 | Go 包名 | 工具数 | 适合场景 |
70
+ |------|---------|--------|---------|
71
+ | 企业基础信息 | `company` | 52 | 工商核验、股东、年报、财务概览、股权图谱、集团、企业搜索、财务分析、信用报告、园区/经纬度 |
72
+ | 风险合规 | `risk` | 36 | 失信、被执行、行政处罚、破产、欠税 |
73
+ | 知识产权 | `intellectual_property` | 14 | 专利、商标、软著、知产出质、建筑资质 |
74
+ | 经营与公示 | `operation` | 32 | 招投标、资质、许可、舆情、招聘、投资机构、私募基金 |
75
+ | 历史信息 | `history` | 18 | 历史工商、历史司法、历史投资 |
76
+ | 董监高 | `executive` | 15 | 高管个人画像、控制企业、合作伙伴 |
77
+
78
+ 完整工具清单查看:`tyc <category> --help` 或本仓库 [`api-registry.yaml`](api-registry.yaml)。
79
+
80
+ ---
81
+
82
+ ## 🚀 快速开始
83
+
84
+ ### 1. 环境准备
85
+
86
+ - **Node.js**:≥ 18.0.0(推荐 LTS)
87
+ - **天眼查 API Token**:联系天眼查商务获取或自行注册
88
+
89
+ ### 2. 安装工具
90
+
91
+ ```bash
92
+ # 全局安装(推荐)
93
+ npm install -g tyc-cli
94
+
95
+ # 或本地安装后 npm link
96
+ git clone https://github.com/tianyancha-tech/tyc-cli.git
97
+ cd tyc-cli
98
+ npm install && npm run build && npm link
99
+ ```
100
+
101
+ ### 3. 初始化配置
102
+
103
+ ```bash
104
+ tyc init --authorization "YOUR_API_TOKEN"
105
+ # Authorization 保存在 ~/.tyc/config.json(与 MCP Server 共享)
106
+ ```
107
+
108
+ ### 4. 开启查询
109
+
110
+ ```bash
111
+ # 企业工商信息
112
+ tyc company registration-info "北京百度网讯科技有限公司"
113
+
114
+ # 董监高失信被执行(双参数)
115
+ tyc executive personnel-dishonest "北京字节跳动科技有限公司" --humanName "张一鸣"
116
+
117
+ # Markdown 友好输出
118
+ tyc company registration-info "北京百度网讯科技有限公司" --md
119
+
120
+ # 缩进 JSON 调试
121
+ tyc risk dishonest-info "..." --pretty --verbose
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 📖 命令手册
127
+
128
+ ### 基础管理命令
129
+
130
+ | 命令 | 说明 |
131
+ |------|------|
132
+ | `tyc init --authorization <token>` | 配置 Authorization,保存到 `~/.tyc/config.json` |
133
+ | `tyc --help` | 显示 6 个分类总览 |
134
+ | `tyc <category> --help` | 显示某分类下全部命令 |
135
+ | `tyc <category> <method> --help` | 显示具体命令的入参说明 |
136
+ | `tyc --version` | 显示当前版本号 |
137
+
138
+ ### 全局选项
139
+
140
+ | 选项 | 说明 |
141
+ |------|------|
142
+ | `--pretty` | 缩进 2 空格的 JSON 输出(调试友好) |
143
+ | `--md` | Markdown 表格化输出(适合人类阅读 / Agent 上屏) |
144
+ | `--verbose` | 输出 HTTP 请求详情到 stderr |
145
+
146
+ > 三个输出模式互斥优先级:`--md` > `--pretty` > 默认紧凑 JSON。
147
+
148
+ ### 数据查询调用格式
149
+
150
+ ```
151
+ tyc <分类> <方法-kebab> <位置参数> [--可选参数 值]
152
+ ```
153
+
154
+ - **分类**:6 个 Go 包名(`company` / `risk` / `intellectual_property` / `operation` / `history` / `executive`)
155
+ - **方法**:自动从 tool name 推导(`get_company_registration_info` → `registration-info`;`get_personnel_dishonest` → `personnel-dishonest`,自动剥离分类前缀)
156
+ - **位置参数**:第一个必填参数(通常是 `searchKey`)
157
+ - **可选参数**:如 `--humanName`、`--searchKey2`、`--id`、`--applicant` 等
158
+
159
+ ---
160
+
161
+ ## 📚 查询指令手册(节选典型场景)
162
+
163
+ ### 1️⃣ company(企业基础信息,52 个工具)
164
+
165
+ ```bash
166
+ # 工商登记基础(多源聚合:ic/baseinfoV2 + ic/companyType)
167
+ tyc company registration-info "北京百度网讯科技有限公司"
168
+
169
+ # 实际控制人
170
+ tyc company actual-controller "..."
171
+
172
+ # 受益所有人 (UBO)
173
+ tyc company beneficial-owners "..."
174
+
175
+ # 主要人员
176
+ tyc company key-personnel "..."
177
+
178
+ # 企业年报
179
+ tyc company annual-reports "..."
180
+
181
+ # 财务数据(5 源聚合:上市优先 stock/* + 非上市回退 ic/annualreport)
182
+ tyc company financial-data "..."
183
+
184
+ # 上市信息
185
+ tyc company listing-info "..."
186
+
187
+ # 三要素核验
188
+ tyc company accuracy "..." --legalPersonName "梁志祥"
189
+ ```
190
+
191
+ ### 2️⃣ risk(风险合规,36 个工具)
192
+
193
+ ```bash
194
+ # 失信被执行
195
+ tyc risk dishonest-info "..."
196
+
197
+ # 被执行人
198
+ tyc risk judgment-debtor-info "..."
199
+
200
+ # 限制高消费
201
+ tyc risk high-consumption-restriction "..."
202
+
203
+ # 行政处罚
204
+ tyc risk administrative-penalty "..."
205
+
206
+ # 破产重整
207
+ tyc risk bankruptcy-reorganization "..."
208
+
209
+ # 司法拍卖 / 裁判文书 / 立案信息 / ...
210
+
211
+ # 综合风险总览
212
+ tyc risk overview "..."
213
+
214
+ # 风险详情(基于 ID)
215
+ tyc risk detail "RISK_ID"
216
+
217
+ # 司法解析
218
+ tyc risk judicial-case "..."
219
+ ```
220
+
221
+ ### 3️⃣ intellectual_property(知识产权,14 个工具)
222
+
223
+ ```bash
224
+ # 专利 / 商标 / 软著 / 作品著作权
225
+ tyc intellectual_property patent-info "..."
226
+ tyc intellectual_property trademark-info "..."
227
+ tyc intellectual_property software-copyright-info "..."
228
+ tyc intellectual_property copyright-work-info "..."
229
+
230
+ # 网站备案 + 公众号
231
+ tyc intellectual_property internet-service-info "..."
232
+
233
+ # 创新力评分
234
+ tyc intellectual_property ipr-score "..."
235
+
236
+ # 专利搜索(搜索类)
237
+ tyc intellectual_property search-patents "新能源" --applicant "宁德时代"
238
+
239
+ # 商标详情(基于注册号)
240
+ tyc intellectual_property trademark-detail "TM12345"
241
+ ```
242
+
243
+ ### 4️⃣ operation(经营与公示,32 个工具)
244
+
245
+ ```bash
246
+ # 招投标
247
+ tyc operation bidding-info "..."
248
+
249
+ # 资质证书 / 行政许可 / 电信许可
250
+ tyc operation qualifications "..."
251
+ tyc operation administrative-license "..."
252
+ tyc operation telecom-license "..."
253
+
254
+ # 信用评价(纳税信用 + 债券评级)
255
+ tyc operation credit-evaluation "..."
256
+
257
+ # 融资记录
258
+ tyc operation financing-records "..."
259
+
260
+ # 新闻舆情
261
+ tyc operation news-sentiment "..."
262
+
263
+ # 招聘动态
264
+ tyc operation recruitment-info "..."
265
+
266
+ # 抽查检查 / 双随机抽查
267
+ tyc operation spot-check-info "..."
268
+ tyc operation random-check "..."
269
+ ```
270
+
271
+ ### 5️⃣ history(历史信息,18 个工具)
272
+
273
+ ```bash
274
+ # 历史工商 / 历史股东 / 历史投资
275
+ tyc history historical-registration "..."
276
+ tyc history historical-shareholders "..."
277
+ tyc history historical-investments "..."
278
+
279
+ # 历史司法
280
+ tyc history historical-judicial-docs "..."
281
+ tyc history historical-dishonest "..."
282
+ tyc history historical-judgment-debtor "..."
283
+
284
+ # 历史信息总览
285
+ tyc history historical-overview "..."
286
+ ```
287
+
288
+ ### 6️⃣ executive(董监高 · 双参数实体强锚定,15 个工具)
289
+
290
+ ```bash
291
+ # 董监高现状(11 个核心工具)
292
+ tyc executive personnel-dishonest "..." --humanName "张三"
293
+ tyc executive personnel-judgment-debtor "..." --humanName "张三"
294
+ tyc executive personnel-high-consumption-ban "..." --humanName "张三"
295
+ tyc executive personnel-controlled-companies "..." --humanName "张三"
296
+ tyc executive personnel-related-companies "..." --humanName "张三"
297
+
298
+ # 历史维度
299
+ tyc executive personnel-historical-dishonest "..." --humanName "张三"
300
+
301
+ # 人员画像深度(4 个 TYC 扩展工具)
302
+ tyc executive person-profile "..." --humanName "张三"
303
+ tyc executive person-partners "..." --humanName "张三"
304
+ tyc executive person-risk-overview "..." --humanName "张三"
305
+ tyc executive person-judicial-assistance "..." --humanName "张三"
306
+ ```
307
+
308
+ ### 7️⃣ company 子分类(33 个工具)
309
+
310
+ ```bash
311
+ # 股权与关系图谱(原 equity_relation 7 个,已并入 company)
312
+ tyc company equity-tree "..."
313
+ tyc company controlled-companies "..."
314
+ tyc company parent-company "..."
315
+ tyc company relation-graph "..."
316
+ tyc company relation-path "企业 A" --searchKey2 "企业 B" # 双企业最短路径
317
+ tyc company shareholder-change "..."
318
+
319
+ # 集团信息(原 group 4 个,serial 串行执行)
320
+ tyc company group-info "..."
321
+ tyc company group-members "..."
322
+ tyc company group-investors "..."
323
+ tyc company group-shareholders "..."
324
+
325
+ # 企业搜索(原 company_search 4 个)
326
+ tyc company companies "百度" --industry "互联网" # 关键词 / 行业地区
327
+ tyc company companies-by-tag "人工智能"
328
+ tyc company companies-by-ranking "胡润榜"
329
+
330
+ # 财务分析(原 financial_analysis 11 个,仅上市公司)
331
+ tyc company income-statement "..."
332
+ tyc company balance-sheet "..."
333
+ tyc company cash-flow-statement "..."
334
+ tyc company financial-summary "..."
335
+ tyc company financial-main-indicators "..."
336
+ tyc company share-structure "..."
337
+ tyc company stock-shareholders "..."
338
+ tyc company stock-executives "..."
339
+ tyc company stock-prospectus "..."
340
+ tyc company stock-violations "..."
341
+ tyc company listed-companies "新能源"
342
+
343
+ # 企业报告(原 enterprise_report 2 个)
344
+ tyc company enterprise-report-basic "..."
345
+ tyc company enterprise-report-professional "..."
346
+
347
+ # 地理与园区(原 geography_park 5 个)
348
+ tyc company park-info "中关村软件园"
349
+ tyc company park-companies "中关村软件园"
350
+ tyc company nearby-companies 116.391 --latitude 39.907 --radius 1000
351
+ tyc company location "..." # 企业经纬度
352
+ tyc company logo "..." # 企业 Logo
353
+ ```
354
+
355
+ ### 8️⃣ operation 子分类(合并自原 2 个分类,9 个工具)
356
+
357
+ ```bash
358
+ # 投资机构(原 investment_agency 5 个,searchKey = 投资机构名)
359
+ tyc operation invest-agency-profile "红杉资本"
360
+ tyc operation invest-agency-news "红杉资本"
361
+ tyc operation invest-agency-public-investments "红杉资本"
362
+ tyc operation invest-agency-funds "红杉资本"
363
+ tyc operation invest-agency-events "红杉资本"
364
+
365
+ # 私募基金(原 private_fund 4 个)
366
+ tyc operation private-fund-profile "..."
367
+ tyc operation private-fund-executives "..."
368
+ tyc operation private-fund-products "..."
369
+ tyc operation private-fund-related "..."
370
+ ```
371
+
372
+ ### 9️⃣ intellectual_property 子分类(合并自原 1 个分类,4 个工具)
373
+
374
+ ```bash
375
+ # 建筑资质(原 construction_qualification 4 个)
376
+ tyc intellectual_property construction-qualifications "..."
377
+ tyc intellectual_property construction-registered-personnel "..."
378
+ tyc intellectual_property construction-projects "..."
379
+ tyc intellectual_property construction-bad-conduct "..."
380
+ ```
381
+
382
+ > 完整 6 分类的命令清单可通过 `tyc <分类> --help` 实时查看,或浏览 [`api-registry.yaml`](api-registry.yaml)。
383
+
384
+ ---
385
+
386
+ ## ⚙️ 配置说明
387
+
388
+ ### 配置文件路径
389
+
390
+ ```
391
+ ~/.tyc/config.json
392
+ ```
393
+
394
+ ### 字段解析
395
+
396
+ | 字段 | 类型 | 说明 |
397
+ |------|------|------|
398
+ | `authorization` | string | 天眼查 OpenAPI Token,原样透传到下游 |
399
+ | `baseUrl` | string(可选) | 自定义 tyc OpenAPI 域名,默认 `https://open.api.tianyancha.com` |
400
+
401
+ ### 配置命令
402
+
403
+ ```bash
404
+ # 设置/更新 Authorization
405
+ tyc init --authorization "YOUR_API_TOKEN"
406
+
407
+ # 手动编辑(不推荐)
408
+ vim ~/.tyc/config.json
409
+ ```
410
+
411
+ ### 安全性提示
412
+
413
+ - 配置文件权限默认 600(用户只读写)
414
+ - token 不入 git,`.gitignore` 已排除常见敏感路径
415
+ - `--verbose` 模式下,token 在日志中以 `xxxx****xxxx` 形式打码
416
+
417
+ ---
418
+
419
+ ## 🏗️ 目录结构
420
+
421
+ ```
422
+ tyc-cli/
423
+ ├── api-registry.yaml # SSOT:167 个工具的注册元数据(构建时输入)
424
+ ├── package.json # bin: tyc / entry: dist/index.js
425
+ ├── tsconfig.json
426
+ ├── .eslintrc.cjs
427
+ ├── LICENSE # MIT
428
+ ├── README.md # 本文件
429
+ ├── CHANGELOG.md
430
+ │
431
+ ├── scripts/
432
+ │ └── build-registry.ts # 构建时:YAML → src/generated/t1_1-registry.json
433
+ │
434
+ └── src/
435
+ ├── index.ts # CLI 入口(commander 注册)
436
+ ├── types.ts # Tool / Param / Source / Registry 类型
437
+ ├── client.ts # tyc OpenAPI HTTP 客户端
438
+ ├── config.ts # ~/.tyc/config.json 读写
439
+ ├── registry.ts # 加载 t1_1-registry.json
440
+ ├── aggregator.ts # 多源并发/串行调度 + condition 求值 + params_template 渲染
441
+ ├── transformer.ts # 多源合并 + 时间戳格式化 + 元数据注入(_summary/_empty/_warnings)
442
+ ├── utils/
443
+ │ └── jsonToMarkdown.ts # JSON → Markdown 表格化(--md 选项使用)
444
+ ├── commands/
445
+ │ ├── init.ts # tyc init 命令
446
+ │ └── category.ts # 动态注册 6 分类 × N 方法子命令
447
+ └── generated/
448
+ └── t1_1-registry.json # 构建产物(gitignored,npm pack 不含)
449
+ ```
450
+
451
+ ---
452
+
453
+ ## 🔁 与 MCP Server 的关系
454
+
455
+ `tyc-cli` 配套的 MCP Server(基于 Go 实现的 [apimcp](https://github.com/tianyancha-tech/apimcp))暴露**完全相同的 167 个工具**到 AI Agent。两者:
456
+
457
+ | 维度 | tyc-cli | MCP Server (apimcp) |
458
+ |-----|--------------|---------------------|
459
+ | 协议 | 命令行 / npm 包 | JSON-RPC 2.0 over Streamable HTTP |
460
+ | 实现 | TypeScript | Go |
461
+ | SSOT | `api-registry.yaml` | 共享同一份 yaml |
462
+ | 输出结构 | 完全一致(tyc 英文 key + 时间戳格式化 + 项目元数据) | 同 |
463
+ | 用途 | 命令行直查 / 脚本批处理 / Agent 工具调用 | Agent MCP 协议接入 / Web 中间层 |
464
+
465
+ CLI 不经过 MCP Server,直接以 HTTP 客户端身份调 tyc OpenAPI;TypeScript 端用 `aggregator.ts` + `transformer.ts` 重现了 Go 端的多源合并与元数据注入逻辑,**保证两端输出 1:1 等价**。
466
+
467
+ ---
468
+
469
+ ## 📐 SSOT 同步
470
+
471
+ 本仓库的 `api-registry.yaml` 是 167 工具的 SSOT。`scripts/build-registry.ts` 在 `npm run build` 前自动读取此文件,生成 `src/generated/t1_1-registry.json` 作为 CLI 运行时数据源。
472
+
473
+ 如果你 fork 了上游 [apimcp](https://github.com/tianyancha-tech/apimcp) 大仓库做二次开发,需保持两边 yaml 同步:
474
+
475
+ ```bash
476
+ # 从 monorepo 同步(cli/t1_1 子目录视角)
477
+ cp ../../conf/api-registry.yaml ./api-registry.yaml
478
+ npm run build
479
+ ```
480
+
481
+ ---
482
+
483
+ ## 📋 错误码
484
+
485
+ | 退出码 | 含义 | 处理建议 |
486
+ |-------|------|---------|
487
+ | 0 | 成功 | — |
488
+ | 1 | 请求失败 | 查 stderr 详情,可能是网络/熔断/参数 |
489
+ | 1 | 配置缺失 | 运行 `tyc init --authorization ...` |
490
+
491
+ 下游 tyc OpenAPI 错误码:
492
+
493
+ | error_code | 含义 | CLI 表现 |
494
+ |-----------|------|---------|
495
+ | 0 | 成功 | 正常输出 |
496
+ | 300000 | 经查无结果 | 自动归一为 `{items: [], total: 0, _empty: true}` + `_summary` 友好文案 |
497
+ | 300005 | 无权限(token 不含此接口) | exit 1 + stderr 详情 |
498
+ | 其他 | 各类业务/系统错误 | exit 1 + 透传错误信息 |
499
+
500
+ ---
501
+
502
+ ## 🤝 贡献
503
+
504
+ 欢迎 Issue / PR!主要协作流程:
505
+
506
+ 1. Fork 本仓库
507
+ 2. 编辑 `api-registry.yaml` 新增工具条目(参考已有条目格式)
508
+ 3. `npm run build` 验证生成的命令树
509
+ 4. `npm run lint` 通过
510
+ 5. 提交 PR
511
+
512
+ ---
513
+
514
+ ## 📄 开源协议
515
+
516
+ 本项目采用 [MIT License](LICENSE)。
517
+
518
+ 数据来源:天眼查 OpenAPI(用户需自行获取并合规使用 token)。本工具不存储、不转发、不解析用户的查询数据,所有调用直连天眼查接口。