@apocdata-info/mcp-server 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/CHANGELOG.md +50 -0
- package/LICENSE +191 -0
- package/README.md +230 -0
- package/dist/cache.d.ts +26 -0
- package/dist/cache.js +51 -0
- package/dist/cache.js.map +1 -0
- package/dist/client.js +113 -0
- package/dist/errors.d.ts +37 -0
- package/dist/errors.js +56 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +259 -0
- package/dist/index.js.map +1 -0
- package/dist/resources.js +229 -0
- package/dist/server.d.ts +20 -0
- package/dist/server.js +69 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/factor-registry.d.ts +17 -0
- package/dist/tools/factor-registry.js +36 -0
- package/dist/tools/factor-registry.js.map +1 -0
- package/dist/tools/index.d.ts +21 -0
- package/dist/tools/index.js +45 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/macro-dashboard.d.ts +17 -0
- package/dist/tools/macro-dashboard.js +30 -0
- package/dist/tools/macro-dashboard.js.map +1 -0
- package/dist/tools/macro-indicator.d.ts +17 -0
- package/dist/tools/macro-indicator.js +45 -0
- package/dist/tools/macro-indicator.js.map +1 -0
- package/dist/tools/quotes-snapshot.d.ts +17 -0
- package/dist/tools/quotes-snapshot.js +39 -0
- package/dist/tools/quotes-snapshot.js.map +1 -0
- package/dist/tools/stock-bars-daily.d.ts +17 -0
- package/dist/tools/stock-bars-daily.js +45 -0
- package/dist/tools/stock-bars-daily.js.map +1 -0
- package/dist/tools/stock-detail.d.ts +17 -0
- package/dist/tools/stock-detail.js +38 -0
- package/dist/tools/stock-detail.js.map +1 -0
- package/dist/tools/stock-financials.d.ts +17 -0
- package/dist/tools/stock-financials.js +36 -0
- package/dist/tools/stock-financials.js.map +1 -0
- package/dist/tools/stock-list.d.ts +17 -0
- package/dist/tools/stock-list.js +39 -0
- package/dist/tools/stock-list.js.map +1 -0
- package/dist/tools/stock-news.d.ts +17 -0
- package/dist/tools/stock-news.js +36 -0
- package/dist/tools/stock-news.js.map +1 -0
- package/dist/tools/stock-quote.d.ts +17 -0
- package/dist/tools/stock-quote.js +32 -0
- package/dist/tools/stock-quote.js.map +1 -0
- package/dist/tools/top10-holders.d.ts +17 -0
- package/dist/tools/top10-holders.js +35 -0
- package/dist/tools/top10-holders.js.map +1 -0
- package/dist/tools/trade-days.d.ts +17 -0
- package/dist/tools/trade-days.js +36 -0
- package/dist/tools/trade-days.js.map +1 -0
- package/dist/tools/types.d.ts +29 -0
- package/dist/tools/types.js +16 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools.js +540 -0
- package/dist/transport.d.ts +44 -0
- package/dist/transport.js +87 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
- package/scripts/client-unit-test.mjs +147 -0
- package/scripts/contract-test.mjs +167 -0
- package/scripts/coverage-test.mjs +126 -0
- package/scripts/error-path-test.mjs +110 -0
- package/scripts/freshness-probe.mjs +144 -0
- package/scripts/integration-test.mjs +284 -0
- package/scripts/mcp-e2e-test.mjs +196 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
17
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
18
|
+
import { createTransport } from "./transport.js";
|
|
19
|
+
import { ATOMIC_TOOLS } from "./tools/index.js";
|
|
20
|
+
const VERSION = "0.1.0";
|
|
21
|
+
/**
|
|
22
|
+
* 构造 MCP server 实例,注册所有 tool。
|
|
23
|
+
*/
|
|
24
|
+
export function createMcpServer() {
|
|
25
|
+
const server = new Server({
|
|
26
|
+
name: "tianqi-mcp",
|
|
27
|
+
version: VERSION,
|
|
28
|
+
}, {
|
|
29
|
+
capabilities: { tools: {} },
|
|
30
|
+
});
|
|
31
|
+
// axios 实例在 server 构造时一次创建,所有 tool 共享
|
|
32
|
+
const client = createTransport();
|
|
33
|
+
// tool 名 → ToolDef 索引
|
|
34
|
+
const toolMap = new Map(ATOMIC_TOOLS.map((t) => [t.name, t]));
|
|
35
|
+
// 列 tool
|
|
36
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
37
|
+
tools: ATOMIC_TOOLS.map((t) => ({
|
|
38
|
+
name: t.name,
|
|
39
|
+
description: t.description,
|
|
40
|
+
inputSchema: t.inputSchema,
|
|
41
|
+
})),
|
|
42
|
+
}));
|
|
43
|
+
// 调 tool
|
|
44
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
45
|
+
const toolName = request.params.name;
|
|
46
|
+
const args = request.params.arguments ?? {};
|
|
47
|
+
const tool = toolMap.get(toolName);
|
|
48
|
+
if (!tool) {
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: "text", text: JSON.stringify({ error: true, code: "TOOL_NOT_FOUND", message: `未知 tool: ${toolName}` }) }],
|
|
51
|
+
isError: true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const result = await tool.handler(args, client);
|
|
56
|
+
return {
|
|
57
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
62
|
+
return {
|
|
63
|
+
content: [{ type: "text", text: JSON.stringify({ error: true, code: "TOOL_HANDLER_ERROR", message }) }],
|
|
64
|
+
isError: true,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return server;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;QACE,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,OAAO;KACjB,EACD;QACE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;KAC5B,CACF,CAAC;IAEF,sCAAsC;IACtC,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IAEjC,sBAAsB;IACtB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAkB,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/E,SAAS;IACT,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QAC5D,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9B,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,WAAW,EAAE,CAAC,CAAC,WAAW;SAC3B,CAAC,CAAC;KACJ,CAAC,CAAC,CAAC;IAEJ,SAAS;IACT,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChE,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;QACrC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,YAAY,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC3H,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAChD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;aAC1D,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3D,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;gBACvG,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
export declare const factorRegistry: ToolDef;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { callDataPlane } from "../transport.js";
|
|
17
|
+
import { withCache } from "../cache.js";
|
|
18
|
+
export const factorRegistry = {
|
|
19
|
+
name: "get_factor_registry",
|
|
20
|
+
description: "获取量化因子目录(脱敏后,含 factor_code/name/weight,**不含** calc_formula/conditions 等内部字段)。共 221 个因子规则,本数据极少变化,默认 1h MCP 缓存(后端 24h 缓存)。",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
limit: { type: "integer", description: "返回条数,默认 50,最大 221", default: 50 },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
handler: async (args, client) => {
|
|
28
|
+
const limit = args.limit ?? 50;
|
|
29
|
+
return withCache(`tool:get_factor_registry:${limit}`, 60 * 60 * 1000, async () => {
|
|
30
|
+
const r = await callDataPlane(client, "/v1/factors/registry", { limit });
|
|
31
|
+
if (r.error)
|
|
32
|
+
return { error: true, ...r.error };
|
|
33
|
+
return { data: r.data, meta: r.meta };
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factor-registry.js","sourceRoot":"","sources":["../../src/tools/factor-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,CAAC,MAAM,cAAc,GAAY;IACrC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,2HAA2H;IACxI,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,OAAO,EAAE,EAAE,EAAE;SAC1E;KACF;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAC9B,MAAM,KAAK,GAAI,IAAI,CAAC,KAAgB,IAAI,EAAE,CAAC;QAC3C,OAAO,SAAS,CAAC,4BAA4B,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,IAAI,EAAE;YAC/E,MAAM,CAAC,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,sBAAsB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACzE,IAAI,CAAC,CAAC,KAAK;gBAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;YAChD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
/**
|
|
18
|
+
* 12 个原子 tool 集中导出。
|
|
19
|
+
* 后续 P5-Agent-4 加 3 聚合 + 2 场景 tool 时,在此 append 即可。
|
|
20
|
+
*/
|
|
21
|
+
export declare const ATOMIC_TOOLS: ToolDef[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { stockList } from "./stock-list.js";
|
|
17
|
+
import { stockDetail } from "./stock-detail.js";
|
|
18
|
+
import { stockQuote } from "./stock-quote.js";
|
|
19
|
+
import { quotesSnapshot } from "./quotes-snapshot.js";
|
|
20
|
+
import { stockBarsDaily } from "./stock-bars-daily.js";
|
|
21
|
+
import { stockFinancials } from "./stock-financials.js";
|
|
22
|
+
import { top10Holders } from "./top10-holders.js";
|
|
23
|
+
// import { stockNews } from "./stock-news.js"; // 已停用:新闻库无可靠股票代码字段,get_stock_news 按代码搜新闻无效
|
|
24
|
+
import { macroDashboard } from "./macro-dashboard.js";
|
|
25
|
+
import { macroIndicator } from "./macro-indicator.js";
|
|
26
|
+
import { factorRegistry } from "./factor-registry.js";
|
|
27
|
+
import { tradeDays } from "./trade-days.js";
|
|
28
|
+
/**
|
|
29
|
+
* 12 个原子 tool 集中导出。
|
|
30
|
+
* 后续 P5-Agent-4 加 3 聚合 + 2 场景 tool 时,在此 append 即可。
|
|
31
|
+
*/
|
|
32
|
+
export const ATOMIC_TOOLS = [
|
|
33
|
+
stockList,
|
|
34
|
+
stockDetail,
|
|
35
|
+
stockQuote,
|
|
36
|
+
quotesSnapshot,
|
|
37
|
+
stockBarsDaily,
|
|
38
|
+
stockFinancials,
|
|
39
|
+
top10Holders,
|
|
40
|
+
// stockNews, // 已停用:新闻库无可靠股票代码字段,按股票代码搜新闻无效
|
|
41
|
+
macroDashboard,
|
|
42
|
+
macroIndicator,
|
|
43
|
+
factorRegistry,
|
|
44
|
+
tradeDays,
|
|
45
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,SAAS;IACT,WAAW;IACX,UAAU;IACV,cAAc;IACd,cAAc;IACd,eAAe;IACf,YAAY;IACZ,SAAS;IACT,cAAc;IACd,cAAc;IACd,cAAc;IACd,SAAS;CACV,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
export declare const macroDashboard: ToolDef;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { callDataPlane } from "../transport.js";
|
|
17
|
+
import { withCache } from "../cache.js";
|
|
18
|
+
export const macroDashboard = {
|
|
19
|
+
name: "get_macro_dashboard",
|
|
20
|
+
description: "获取中国宏观经济面板:GDP/CPI/PPI/M2/PMI 等核心指标的最新值与同环比。本数据按月更新,默认 5min MCP 缓存(后端 1min 缓存)。",
|
|
21
|
+
inputSchema: { type: "object", properties: {} },
|
|
22
|
+
handler: async (_args, client) => {
|
|
23
|
+
return withCache("tool:get_macro_dashboard", 5 * 60 * 1000, async () => {
|
|
24
|
+
const r = await callDataPlane(client, "/v1/macro/dashboard");
|
|
25
|
+
if (r.error)
|
|
26
|
+
return { error: true, ...r.error };
|
|
27
|
+
return { data: r.data, meta: r.meta };
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macro-dashboard.js","sourceRoot":"","sources":["../../src/tools/macro-dashboard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,CAAC,MAAM,cAAc,GAAY;IACrC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,iFAAiF;IAC9F,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAC/B,OAAO,SAAS,CAAC,0BAA0B,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,IAAI,EAAE;YACrE,MAAM,CAAC,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;YAC7D,IAAI,CAAC,CAAC,KAAK;gBAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;YAChD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
export declare const macroIndicator: ToolDef;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { callDataPlane } from "../transport.js";
|
|
17
|
+
import { withCache } from "../cache.js";
|
|
18
|
+
export const macroIndicator = {
|
|
19
|
+
name: "get_macro_indicator",
|
|
20
|
+
description: "获取单个宏观指标的时序数据(如 CPI/PPI/GDP)。indicator 为指标 code(如 'CPI' 'M2' 'GDP'),from/to 为 YYYY-MM 月度区间。默认 5min 缓存。",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
indicator: { type: "string", description: "指标 code,如 'CPI' / 'PPI' / 'M2' / 'GDP' / 'PMI'" },
|
|
25
|
+
from: { type: "string", description: "起始月 YYYY-MM,可选" },
|
|
26
|
+
to: { type: "string", description: "结束月 YYYY-MM,可选" },
|
|
27
|
+
},
|
|
28
|
+
required: ["indicator"],
|
|
29
|
+
},
|
|
30
|
+
handler: async (args, client) => {
|
|
31
|
+
const indicator = args.indicator;
|
|
32
|
+
const params = {};
|
|
33
|
+
if (args.from)
|
|
34
|
+
params.from = args.from;
|
|
35
|
+
if (args.to)
|
|
36
|
+
params.to = args.to;
|
|
37
|
+
const key = `tool:get_macro_indicator:${indicator}:${args.from ?? ""}:${args.to ?? ""}`;
|
|
38
|
+
return withCache(key, 5 * 60 * 1000, async () => {
|
|
39
|
+
const r = await callDataPlane(client, `/v1/macro/${encodeURIComponent(indicator)}`, params);
|
|
40
|
+
if (r.error)
|
|
41
|
+
return { error: true, ...r.error };
|
|
42
|
+
return { data: r.data, meta: r.meta };
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macro-indicator.js","sourceRoot":"","sources":["../../src/tools/macro-indicator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,CAAC,MAAM,cAAc,GAAY;IACrC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,wGAAwG;IACrH,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gDAAgD,EAAE;YAC5F,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE;YACvD,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE;SACtD;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,SAAmB,CAAC;QAC3C,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,IAAI,IAAI,CAAC,IAAI;YAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvC,IAAI,IAAI,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,4BAA4B,SAAS,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;QACxF,OAAO,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,IAAI,EAAE;YAC9C,MAAM,CAAC,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,aAAa,kBAAkB,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAC5F,IAAI,CAAC,CAAC,KAAK;gBAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;YAChD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
export declare const quotesSnapshot: ToolDef;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { callDataPlane } from "../transport.js";
|
|
17
|
+
export const quotesSnapshot = {
|
|
18
|
+
name: "get_quotes_snapshot",
|
|
19
|
+
description: "批量获取多只 A 股最新实时行情快照(一次 ≤ 50 只)。每只股返 last_price/change_pct/volume 等。本端点**不缓存**(实时性优先)。",
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
symbols: {
|
|
24
|
+
type: "array",
|
|
25
|
+
items: { type: "string" },
|
|
26
|
+
description: "6 位 A 股代码数组,如 ['000001','600519']",
|
|
27
|
+
maxItems: 50,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
required: ["symbols"],
|
|
31
|
+
},
|
|
32
|
+
handler: async (args, client) => {
|
|
33
|
+
const symbols = args.symbols;
|
|
34
|
+
const r = await callDataPlane(client, "/v1/quotes/snapshot", { symbols: symbols.join(",") });
|
|
35
|
+
if (r.error)
|
|
36
|
+
return { error: true, ...r.error };
|
|
37
|
+
return { data: r.data, meta: r.meta };
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotes-snapshot.js","sourceRoot":"","sources":["../../src/tools/quotes-snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,CAAC,MAAM,cAAc,GAAY;IACrC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,sFAAsF;IACnG,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,mCAAmC;gBAChD,QAAQ,EAAE,EAAE;aACb;SACF;QACD,QAAQ,EAAE,CAAC,SAAS,CAAC;KACtB;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAmB,CAAC;QACzC,MAAM,CAAC,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,qBAAqB,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7F,IAAI,CAAC,CAAC,KAAK;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;QAChD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
export declare const stockBarsDaily: ToolDef;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { callDataPlane } from "../transport.js";
|
|
17
|
+
import { withCache } from "../cache.js";
|
|
18
|
+
export const stockBarsDaily = {
|
|
19
|
+
name: "get_stock_bars_daily",
|
|
20
|
+
description: "获取单只 A 股日 K 历史(open/high/low/close/volume/amount/change_pct)。from/to 为 YYYY-MM-DD 区间,默认最近 60 个交易日。10min MCP 缓存。",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
symbol: { type: "string", description: "6 位 A 股代码" },
|
|
25
|
+
from: { type: "string", description: "起始日期 YYYY-MM-DD,默认 60 交易日前" },
|
|
26
|
+
to: { type: "string", description: "结束日期 YYYY-MM-DD,默认今天" },
|
|
27
|
+
},
|
|
28
|
+
required: ["symbol"],
|
|
29
|
+
},
|
|
30
|
+
handler: async (args, client) => {
|
|
31
|
+
const symbol = args.symbol;
|
|
32
|
+
const params = {};
|
|
33
|
+
if (args.from)
|
|
34
|
+
params.from = args.from;
|
|
35
|
+
if (args.to)
|
|
36
|
+
params.to = args.to;
|
|
37
|
+
const cacheKey = `tool:get_stock_bars_daily:${symbol}:${args.from ?? ""}:${args.to ?? ""}`;
|
|
38
|
+
return withCache(cacheKey, 10 * 60 * 1000, async () => {
|
|
39
|
+
const r = await callDataPlane(client, `/v1/stocks/${encodeURIComponent(symbol)}/bars/daily`, params);
|
|
40
|
+
if (r.error)
|
|
41
|
+
return { error: true, ...r.error };
|
|
42
|
+
return { data: r.data, meta: r.meta };
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stock-bars-daily.js","sourceRoot":"","sources":["../../src/tools/stock-bars-daily.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,CAAC,MAAM,cAAc,GAAY;IACrC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,iHAAiH;IAC9H,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE;YACpD,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,4BAA4B,EAAE;YACnE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;SAC5D;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAgB,CAAC;QACrC,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,IAAI,IAAI,CAAC,IAAI;YAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvC,IAAI,IAAI,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,6BAA6B,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;QAC3F,OAAO,SAAS,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,IAAI,EAAE;YACpD,MAAM,CAAC,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,cAAc,kBAAkB,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;YACrG,IAAI,CAAC,CAAC,KAAK;gBAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;YAChD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
export declare const stockDetail: ToolDef;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { callDataPlane } from "../transport.js";
|
|
17
|
+
import { withCache } from "../cache.js";
|
|
18
|
+
export const stockDetail = {
|
|
19
|
+
name: "get_stock_detail",
|
|
20
|
+
description: "获取单只 A 股详情:基础信息 + ST 状态 + 最新 ROE。symbol 为 6 位代码(如 '000001' '600519')。本数据每日更新,默认 1h 缓存。",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
symbol: { type: "string", description: "6 位 A 股代码,不含市场后缀,如 '000001' '600519'" },
|
|
25
|
+
},
|
|
26
|
+
required: ["symbol"],
|
|
27
|
+
},
|
|
28
|
+
handler: async (args, client) => {
|
|
29
|
+
const symbol = args.symbol;
|
|
30
|
+
const cacheKey = `tool:get_stock_detail:${symbol}`;
|
|
31
|
+
return withCache(cacheKey, 60 * 60 * 1000, async () => {
|
|
32
|
+
const r = await callDataPlane(client, `/v1/stocks/${encodeURIComponent(symbol)}`);
|
|
33
|
+
if (r.error)
|
|
34
|
+
return { error: true, ...r.error };
|
|
35
|
+
return { data: r.data, meta: r.meta };
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stock-detail.js","sourceRoot":"","sources":["../../src/tools/stock-detail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,CAAC,MAAM,WAAW,GAAY;IAClC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,wFAAwF;IACrG,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sCAAsC,EAAE;SAChF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAgB,CAAC;QACrC,MAAM,QAAQ,GAAG,yBAAyB,MAAM,EAAE,CAAC;QACnD,OAAO,SAAS,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,IAAI,EAAE;YACpD,MAAM,CAAC,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,cAAc,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAClF,IAAI,CAAC,CAAC,KAAK;gBAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;YAChD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
export declare const stockFinancials: ToolDef;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { callDataPlane } from "../transport.js";
|
|
17
|
+
import { withCache } from "../cache.js";
|
|
18
|
+
export const stockFinancials = {
|
|
19
|
+
name: "get_stock_financials",
|
|
20
|
+
description: "获取单只 A 股最新季度财务摘要(营收/净利润/毛利率/ROE/资产负债率等)。本数据按季度更新,默认 6h 缓存。",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: { symbol: { type: "string", description: "6 位 A 股代码" } },
|
|
24
|
+
required: ["symbol"],
|
|
25
|
+
},
|
|
26
|
+
handler: async (args, client) => {
|
|
27
|
+
const symbol = args.symbol;
|
|
28
|
+
const cacheKey = `tool:get_stock_financials:${symbol}`;
|
|
29
|
+
return withCache(cacheKey, 6 * 60 * 60 * 1000, async () => {
|
|
30
|
+
const r = await callDataPlane(client, `/v1/stocks/${encodeURIComponent(symbol)}/financials`);
|
|
31
|
+
if (r.error)
|
|
32
|
+
return { error: true, ...r.error };
|
|
33
|
+
return { data: r.data, meta: r.meta };
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stock-financials.js","sourceRoot":"","sources":["../../src/tools/stock-financials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,CAAC,MAAM,eAAe,GAAY;IACtC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,4DAA4D;IACzE,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE;QACpE,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAgB,CAAC;QACrC,MAAM,QAAQ,GAAG,6BAA6B,MAAM,EAAE,CAAC;QACvD,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,KAAK,IAAI,EAAE;YACxD,MAAM,CAAC,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,cAAc,kBAAkB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAC7F,IAAI,CAAC,CAAC,KAAK;gBAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;YAChD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from "./types.js";
|
|
17
|
+
export declare const stockList: ToolDef;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2099, Chill Zhuang 庄骞 (bladejava@qq.com).
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
*
|
|
14
|
+
* @author Chill
|
|
15
|
+
*/
|
|
16
|
+
import { callDataPlane } from "../transport.js";
|
|
17
|
+
import { withCache } from "../cache.js";
|
|
18
|
+
export const stockList = {
|
|
19
|
+
name: "get_stock_list",
|
|
20
|
+
description: "获取所有 A 股主数据列表(支持分页)。返回 5000+ 股的 symbol/name/full_symbol/exchange/industry 等核心字段。适用于'查询有哪些股票'、'按行业筛选'类问题。本数据每日更新,默认 1h 缓存。",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
current: { type: "integer", description: "页码,从 1 开始", default: 1 },
|
|
25
|
+
size: { type: "integer", description: "每页条数,默认 100,最大 500", default: 100 },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
handler: async (args, client) => {
|
|
29
|
+
const current = args.current ?? 1;
|
|
30
|
+
const size = args.size ?? 100;
|
|
31
|
+
const cacheKey = `tool:get_stock_list:${current}:${size}`;
|
|
32
|
+
return withCache(cacheKey, 60 * 60 * 1000, async () => {
|
|
33
|
+
const r = await callDataPlane(client, "/v1/stocks", { current, size });
|
|
34
|
+
if (r.error)
|
|
35
|
+
return { error: true, ...r.error };
|
|
36
|
+
return { data: r.data, meta: r.meta };
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|