krx-cli 1.7.0 → 1.7.2
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 +18 -14
- package/dist/cli.js.map +2 -2
- package/dist/mcp.js +12 -13
- package/dist/mcp.js.map +2 -2
- package/package.json +1 -1
package/dist/mcp.js
CHANGED
|
@@ -31157,7 +31157,7 @@ function applyPipeline(data, options) {
|
|
|
31157
31157
|
if (options.sort) {
|
|
31158
31158
|
result = sortData(result, options.sort, options.direction ?? "desc");
|
|
31159
31159
|
}
|
|
31160
|
-
if (options.offset && options.offset > 0) {
|
|
31160
|
+
if (options.offset !== void 0 && options.offset > 0) {
|
|
31161
31161
|
result = result.slice(options.offset);
|
|
31162
31162
|
}
|
|
31163
31163
|
if (options.limit && options.limit > 0) {
|
|
@@ -31167,7 +31167,7 @@ function applyPipeline(data, options) {
|
|
|
31167
31167
|
}
|
|
31168
31168
|
|
|
31169
31169
|
// src/mcp/tools/result.ts
|
|
31170
|
-
var MAX_RESULT_BYTES =
|
|
31170
|
+
var MAX_RESULT_BYTES = 5e5;
|
|
31171
31171
|
function successResult(data) {
|
|
31172
31172
|
const text = JSON.stringify(data, null, 2);
|
|
31173
31173
|
if (Buffer.byteLength(text, "utf-8") <= MAX_RESULT_BYTES) {
|
|
@@ -31178,7 +31178,7 @@ function successResult(data) {
|
|
|
31178
31178
|
while (lo < hi) {
|
|
31179
31179
|
const mid = Math.ceil((lo + hi) / 2);
|
|
31180
31180
|
const candidate = JSON.stringify(data.slice(0, mid), null, 2);
|
|
31181
|
-
if (Buffer.byteLength(candidate, "utf-8") <= MAX_RESULT_BYTES -
|
|
31181
|
+
if (Buffer.byteLength(candidate, "utf-8") <= MAX_RESULT_BYTES - 2e3) {
|
|
31182
31182
|
lo = mid;
|
|
31183
31183
|
} else {
|
|
31184
31184
|
hi = mid - 1;
|
|
@@ -31222,7 +31222,8 @@ Notes:
|
|
|
31222
31222
|
- Data is T-1 (previous trading day)
|
|
31223
31223
|
- All response values are strings
|
|
31224
31224
|
- Rate limit: 10,000 calls/day
|
|
31225
|
-
- IMPORTANT:
|
|
31225
|
+
- IMPORTANT: When querying a specific stock, ALWAYS pass 'isuCd' to filter. Without it, all stocks in the market are returned.
|
|
31226
|
+
- Full market listings can exceed the result size limit. Use 'fields' to select only needed columns, or 'limit'+'offset' for pagination. If the response contains '_truncated', follow its instructions to retrieve remaining data.`;
|
|
31226
31227
|
}
|
|
31227
31228
|
function buildInputSchema(endpoints) {
|
|
31228
31229
|
const shortNames = endpoints.map((e) => getEndpointShortName(e.path));
|
|
@@ -31301,21 +31302,19 @@ function createCategoryTool(categoryId) {
|
|
|
31301
31302
|
err instanceof Error ? err.message : "Invalid date format"
|
|
31302
31303
|
);
|
|
31303
31304
|
}
|
|
31304
|
-
const extraParams = {};
|
|
31305
|
-
if (isuCd) {
|
|
31306
|
-
extraParams["isuCd"] = isuCd;
|
|
31307
|
-
}
|
|
31308
31305
|
const rangeResult = await fetchDateRange({
|
|
31309
31306
|
endpoint: endpoint.path,
|
|
31310
31307
|
from: dateFrom,
|
|
31311
31308
|
to: dateTo,
|
|
31312
|
-
apiKey
|
|
31313
|
-
extraParams
|
|
31309
|
+
apiKey
|
|
31314
31310
|
});
|
|
31315
31311
|
if (!rangeResult.success) {
|
|
31316
31312
|
return errorResult(rangeResult.error ?? "Date range fetch failed");
|
|
31317
31313
|
}
|
|
31318
31314
|
let data2 = rangeResult.data;
|
|
31315
|
+
if (isuCd) {
|
|
31316
|
+
data2 = data2.filter((row) => row["ISU_CD"] === isuCd);
|
|
31317
|
+
}
|
|
31319
31318
|
const filterExpr = args.filter;
|
|
31320
31319
|
const sortField2 = args.sort;
|
|
31321
31320
|
const sortDirection2 = args.sort_direction ?? "desc";
|
|
@@ -31343,9 +31342,6 @@ function createCategoryTool(categoryId) {
|
|
|
31343
31342
|
);
|
|
31344
31343
|
}
|
|
31345
31344
|
const params = { basDd: dateStr };
|
|
31346
|
-
if (isuCd) {
|
|
31347
|
-
params["isuCd"] = isuCd;
|
|
31348
|
-
}
|
|
31349
31345
|
const result = await krxFetch({
|
|
31350
31346
|
endpoint: endpoint.path,
|
|
31351
31347
|
params,
|
|
@@ -31360,6 +31356,9 @@ function createCategoryTool(categoryId) {
|
|
|
31360
31356
|
const offsetN = args.offset;
|
|
31361
31357
|
const limitN = args.limit;
|
|
31362
31358
|
let data = result.data;
|
|
31359
|
+
if (isuCd) {
|
|
31360
|
+
data = data.filter((row) => row["ISU_CD"] === isuCd);
|
|
31361
|
+
}
|
|
31363
31362
|
data = applyPipeline(data, {
|
|
31364
31363
|
filter: filterExpr2,
|
|
31365
31364
|
sort: sortField,
|