krx-cli 1.7.1 → 1.7.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/SKILL.md +1 -1
- package/dist/cli.js +37 -11
- package/dist/cli.js.map +3 -3
- package/dist/mcp.js +25 -10
- package/dist/mcp.js.map +3 -3
- package/package.json +1 -1
package/dist/mcp.js
CHANGED
|
@@ -31202,6 +31202,17 @@ function errorResult(message) {
|
|
|
31202
31202
|
};
|
|
31203
31203
|
}
|
|
31204
31204
|
|
|
31205
|
+
// src/utils/isin.ts
|
|
31206
|
+
var KRX_ISIN_RE = /^KR\d{10}$/;
|
|
31207
|
+
function matchesIsuCode(isuCd, srtCd, query) {
|
|
31208
|
+
if (isuCd === query || srtCd === query) return true;
|
|
31209
|
+
if (KRX_ISIN_RE.test(query)) {
|
|
31210
|
+
const short = query.slice(3, 9);
|
|
31211
|
+
return isuCd === short || srtCd === short;
|
|
31212
|
+
}
|
|
31213
|
+
return false;
|
|
31214
|
+
}
|
|
31215
|
+
|
|
31205
31216
|
// src/mcp/tools/index.ts
|
|
31206
31217
|
function getEndpointShortName(path5) {
|
|
31207
31218
|
return path5.split("/").pop() ?? path5;
|
|
@@ -31238,7 +31249,9 @@ function buildInputSchema(endpoints) {
|
|
|
31238
31249
|
date_to: external_exports.string().optional().describe(
|
|
31239
31250
|
"End date for range query (YYYYMMDD). Use with date_from for multi-day data."
|
|
31240
31251
|
),
|
|
31241
|
-
isuCd: external_exports.string().optional().describe(
|
|
31252
|
+
isuCd: external_exports.string().optional().describe(
|
|
31253
|
+
"Stock/item code to filter. Accepts both ISIN (e.g., KR7005930003) and short code (e.g., 005930)."
|
|
31254
|
+
),
|
|
31242
31255
|
sort: external_exports.string().optional().describe("Sort results by this field name"),
|
|
31243
31256
|
sort_direction: external_exports.enum(["asc", "desc"]).optional().describe("Sort direction (default: desc)"),
|
|
31244
31257
|
offset: external_exports.number().optional().describe("Skip first N results (use with limit for pagination)"),
|
|
@@ -31302,21 +31315,21 @@ function createCategoryTool(categoryId) {
|
|
|
31302
31315
|
err instanceof Error ? err.message : "Invalid date format"
|
|
31303
31316
|
);
|
|
31304
31317
|
}
|
|
31305
|
-
const extraParams = {};
|
|
31306
|
-
if (isuCd) {
|
|
31307
|
-
extraParams["isuCd"] = isuCd;
|
|
31308
|
-
}
|
|
31309
31318
|
const rangeResult = await fetchDateRange({
|
|
31310
31319
|
endpoint: endpoint.path,
|
|
31311
31320
|
from: dateFrom,
|
|
31312
31321
|
to: dateTo,
|
|
31313
|
-
apiKey
|
|
31314
|
-
extraParams
|
|
31322
|
+
apiKey
|
|
31315
31323
|
});
|
|
31316
31324
|
if (!rangeResult.success) {
|
|
31317
31325
|
return errorResult(rangeResult.error ?? "Date range fetch failed");
|
|
31318
31326
|
}
|
|
31319
31327
|
let data2 = rangeResult.data;
|
|
31328
|
+
if (isuCd) {
|
|
31329
|
+
data2 = data2.filter(
|
|
31330
|
+
(row) => matchesIsuCode(row["ISU_CD"] ?? "", row["ISU_SRT_CD"] ?? "", isuCd)
|
|
31331
|
+
);
|
|
31332
|
+
}
|
|
31320
31333
|
const filterExpr = args.filter;
|
|
31321
31334
|
const sortField2 = args.sort;
|
|
31322
31335
|
const sortDirection2 = args.sort_direction ?? "desc";
|
|
@@ -31344,9 +31357,6 @@ function createCategoryTool(categoryId) {
|
|
|
31344
31357
|
);
|
|
31345
31358
|
}
|
|
31346
31359
|
const params = { basDd: dateStr };
|
|
31347
|
-
if (isuCd) {
|
|
31348
|
-
params["isuCd"] = isuCd;
|
|
31349
|
-
}
|
|
31350
31360
|
const result = await krxFetch({
|
|
31351
31361
|
endpoint: endpoint.path,
|
|
31352
31362
|
params,
|
|
@@ -31361,6 +31371,11 @@ function createCategoryTool(categoryId) {
|
|
|
31361
31371
|
const offsetN = args.offset;
|
|
31362
31372
|
const limitN = args.limit;
|
|
31363
31373
|
let data = result.data;
|
|
31374
|
+
if (isuCd) {
|
|
31375
|
+
data = data.filter(
|
|
31376
|
+
(row) => matchesIsuCode(row["ISU_CD"] ?? "", row["ISU_SRT_CD"] ?? "", isuCd)
|
|
31377
|
+
);
|
|
31378
|
+
}
|
|
31364
31379
|
data = applyPipeline(data, {
|
|
31365
31380
|
filter: filterExpr2,
|
|
31366
31381
|
sort: sortField,
|