@rex0220/kintone-sql-tools 1.10.0 → 1.11.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/README.md +1 -0
- package/dist-cli/ksql.js +15 -1
- package/dist-mcp/ksql-mcp.js +20 -8
- package/dist-mcpb/ksql-mcp.mcpb +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -125,6 +125,7 @@ Options:
|
|
|
125
125
|
--max-records <n> Max records to fetch (default: 500)
|
|
126
126
|
--fetch-parallel <n> Parallel page fetches per query: 1-10 (default: 3)
|
|
127
127
|
--on-limit <mode> On record limit: error | truncate
|
|
128
|
+
--temp-table-max-rows <n> Max rows per temp table (default: 10000, always errors on overflow)
|
|
128
129
|
--timeout <ms> Request timeout in milliseconds (default: 30000)
|
|
129
130
|
--max-concurrent <n> Max concurrent kintone requests: 1-50 (default: 10)
|
|
130
131
|
(process-wide; fixed at first resolution; KSQL_MAX_CONCURRENT wins)
|
package/dist-cli/ksql.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
buildBatchDmlConfirmMessage: () => buildBatchDmlConfirmMessage,
|
|
26
26
|
buildBatchStatementSummary: () => buildBatchStatementSummary,
|
|
27
27
|
buildOutput: () => buildOutput,
|
|
28
|
+
buildReplExecArgv: () => buildReplExecArgv,
|
|
28
29
|
extractAppIds: () => extractAppIds,
|
|
29
30
|
normalizeAppKey: () => normalizeAppKey,
|
|
30
31
|
normalizeSqlAppProfiles: () => normalizeSqlAppProfiles,
|
|
@@ -6310,7 +6311,7 @@ function buildBatchStatementPlan(stmt, info) {
|
|
|
6310
6311
|
return [
|
|
6311
6312
|
`CREATE TEMP TABLE ${stmt.name}`,
|
|
6312
6313
|
` scope: batch\uFF08\u30D0\u30C3\u30C1\u7D42\u4E86\u6642\u306B\u81EA\u52D5\u7834\u68C4\uFF09`,
|
|
6313
|
-
` rows: \u5B9F\u4F53\u5316\u524D\u306E\u305F\u3081\u4E0D\u660E\uFF08\u4E0A\u9650 ${TEMP_TABLE_MAX_ROWS} \u884C\u3001\u8D85\u904E\u306F\u30A8\u30E9\u30FC\uFF09`,
|
|
6314
|
+
` rows: \u5B9F\u4F53\u5316\u524D\u306E\u305F\u3081\u4E0D\u660E\uFF08\u65E2\u5B9A\u4E0A\u9650 ${TEMP_TABLE_MAX_ROWS} \u884C\u3001tempTableMaxRows \u3067\u5909\u66F4\u53EF\u3001\u8D85\u904E\u306F\u30A8\u30E9\u30FC\uFF09`,
|
|
6314
6315
|
...buildPlanForBatchQuery(stmt.query, info).map((l) => ` ${l}`)
|
|
6315
6316
|
];
|
|
6316
6317
|
}
|
|
@@ -7469,6 +7470,7 @@ Options:
|
|
|
7469
7470
|
--max-records <n> Max records to fetch (default: 500)
|
|
7470
7471
|
--fetch-parallel <n> Parallel page fetches per query: 1-10 (default: 3)
|
|
7471
7472
|
--on-limit <mode> On record limit: error | truncate
|
|
7473
|
+
--temp-table-max-rows <n> Max rows per temp table (default: 10000, always errors on overflow)
|
|
7472
7474
|
--timeout <ms> Request timeout in milliseconds (default: 30000)
|
|
7473
7475
|
--max-concurrent <n> Max concurrent kintone requests: 1-50 (default: 10)
|
|
7474
7476
|
(process-wide; fixed at first resolution; KSQL_MAX_CONCURRENT wins)
|
|
@@ -7521,6 +7523,7 @@ function parseArgs(argv) {
|
|
|
7521
7523
|
maxRecords: null,
|
|
7522
7524
|
fetchParallel: null,
|
|
7523
7525
|
onLimit: null,
|
|
7526
|
+
tempTableMaxRows: null,
|
|
7524
7527
|
timeout: null,
|
|
7525
7528
|
configPath: null,
|
|
7526
7529
|
profile: null,
|
|
@@ -7743,6 +7746,13 @@ function parseArgs(argv) {
|
|
|
7743
7746
|
i++;
|
|
7744
7747
|
continue;
|
|
7745
7748
|
}
|
|
7749
|
+
if (a === "--temp-table-max-rows") {
|
|
7750
|
+
const n = Number(v);
|
|
7751
|
+
if (!Number.isInteger(n) || n <= 0) throw new Error("ArgumentError: --temp-table-max-rows must be a positive integer.");
|
|
7752
|
+
out.tempTableMaxRows = n;
|
|
7753
|
+
i++;
|
|
7754
|
+
continue;
|
|
7755
|
+
}
|
|
7746
7756
|
if (a === "--fetch-parallel") {
|
|
7747
7757
|
const n = Number(v);
|
|
7748
7758
|
if (!Number.isInteger(n) || n < 1 || n > 10) throw new Error("ArgumentError: --fetch-parallel must be an integer between 1 and 10.");
|
|
@@ -8187,6 +8197,7 @@ function buildReplExecArgv(base, sql, dryRun, format) {
|
|
|
8187
8197
|
pushOpt(argv, "--max-records", base.maxRecords);
|
|
8188
8198
|
pushOpt(argv, "--fetch-parallel", base.fetchParallel);
|
|
8189
8199
|
pushOpt(argv, "--on-limit", base.onLimit);
|
|
8200
|
+
pushOpt(argv, "--temp-table-max-rows", base.tempTableMaxRows);
|
|
8190
8201
|
pushOpt(argv, "--timeout", base.timeout);
|
|
8191
8202
|
pushOpt(argv, "--output", base.outputPath);
|
|
8192
8203
|
pushOpt(argv, "--user-format", base.userFormat);
|
|
@@ -8739,6 +8750,7 @@ async function run() {
|
|
|
8739
8750
|
const fetchParallel = args.fetchParallel ?? envInt2("KSQL_FETCH_PARALLEL") ?? profile.query?.fetchParallel ?? 3;
|
|
8740
8751
|
const onLimit = args.onLimit ?? envOnLimit("KSQL_ON_LIMIT") ?? profile.query?.onLimit ?? "error";
|
|
8741
8752
|
const timeout = args.timeout ?? envInt2("KSQL_TIMEOUT") ?? profile.query?.timeout ?? 3e4;
|
|
8753
|
+
const tempTableMaxRows = args.tempTableMaxRows ?? envInt2("KSQL_TEMP_TABLE_MAX_ROWS") ?? profile.query?.tempTableMaxRows ?? void 0;
|
|
8742
8754
|
if (!Number.isInteger(fetchParallel) || fetchParallel < 1 || fetchParallel > 10) {
|
|
8743
8755
|
process.stderr.write("ArgumentError: fetch-parallel must be an integer between 1 and 10.\n");
|
|
8744
8756
|
return 2;
|
|
@@ -9095,6 +9107,7 @@ query=${label}`);
|
|
|
9095
9107
|
onLimitReached: onLimit,
|
|
9096
9108
|
cacheContext,
|
|
9097
9109
|
continueOnError: args.continueOnError,
|
|
9110
|
+
tempTableMaxRows,
|
|
9098
9111
|
timeoutMs: timeout,
|
|
9099
9112
|
confirm: batchContainsDml ? async (count, operation) => {
|
|
9100
9113
|
if (count > dmlMaxRows) {
|
|
@@ -9165,6 +9178,7 @@ if (isDirectCliRun()) {
|
|
|
9165
9178
|
buildBatchDmlConfirmMessage,
|
|
9166
9179
|
buildBatchStatementSummary,
|
|
9167
9180
|
buildOutput,
|
|
9181
|
+
buildReplExecArgv,
|
|
9168
9182
|
extractAppIds,
|
|
9169
9183
|
normalizeAppKey,
|
|
9170
9184
|
normalizeSqlAppProfiles,
|
package/dist-mcp/ksql-mcp.js
CHANGED
|
@@ -37213,7 +37213,7 @@ function buildBatchStatementPlan(stmt, info) {
|
|
|
37213
37213
|
return [
|
|
37214
37214
|
`CREATE TEMP TABLE ${stmt.name}`,
|
|
37215
37215
|
` scope: batch\uFF08\u30D0\u30C3\u30C1\u7D42\u4E86\u6642\u306B\u81EA\u52D5\u7834\u68C4\uFF09`,
|
|
37216
|
-
` rows: \u5B9F\u4F53\u5316\u524D\u306E\u305F\u3081\u4E0D\u660E\uFF08\u4E0A\u9650 ${TEMP_TABLE_MAX_ROWS} \u884C\u3001\u8D85\u904E\u306F\u30A8\u30E9\u30FC\uFF09`,
|
|
37216
|
+
` rows: \u5B9F\u4F53\u5316\u524D\u306E\u305F\u3081\u4E0D\u660E\uFF08\u65E2\u5B9A\u4E0A\u9650 ${TEMP_TABLE_MAX_ROWS} \u884C\u3001tempTableMaxRows \u3067\u5909\u66F4\u53EF\u3001\u8D85\u904E\u306F\u30A8\u30E9\u30FC\uFF09`,
|
|
37217
37217
|
...buildPlanForBatchQuery(stmt.query, info).map((l) => ` ${l}`)
|
|
37218
37218
|
];
|
|
37219
37219
|
}
|
|
@@ -38236,6 +38236,7 @@ async function createKsqlRuntime(serverOptions, input) {
|
|
|
38236
38236
|
}
|
|
38237
38237
|
const onLimit2 = input.onLimit ?? envOnLimit("KSQL_ON_LIMIT") ?? profile2.query?.onLimit ?? "error";
|
|
38238
38238
|
const timeout2 = input.timeout ?? envInt("KSQL_TIMEOUT") ?? profile2.query?.timeout ?? 3e4;
|
|
38239
|
+
const tempTableMaxRows2 = input.tempTableMaxRows ?? envInt("KSQL_TEMP_TABLE_MAX_ROWS") ?? profile2.query?.tempTableMaxRows;
|
|
38239
38240
|
const appIds = extractAppIds(sql);
|
|
38240
38241
|
const defaultApp = envInt("KSQL_APP") ?? profile2.app ?? null;
|
|
38241
38242
|
if (appIds.length === 0 && defaultApp !== null) appIds.push(defaultApp);
|
|
@@ -38376,7 +38377,8 @@ async function createKsqlRuntime(serverOptions, input) {
|
|
|
38376
38377
|
maxRecords: maxRecords2,
|
|
38377
38378
|
fetchParallel: fetchParallel2,
|
|
38378
38379
|
onLimit: onLimit2,
|
|
38379
|
-
timeout: timeout2
|
|
38380
|
+
timeout: timeout2,
|
|
38381
|
+
tempTableMaxRows: tempTableMaxRows2
|
|
38380
38382
|
};
|
|
38381
38383
|
}
|
|
38382
38384
|
|
|
@@ -38817,7 +38819,8 @@ function createKsqlMcpTools(serverOptions, deps = {}) {
|
|
|
38817
38819
|
maxRecords: input.maxRecords,
|
|
38818
38820
|
fetchParallel: input.fetchParallel,
|
|
38819
38821
|
onLimit: input.onLimit,
|
|
38820
|
-
timeout: input.timeout
|
|
38822
|
+
timeout: input.timeout,
|
|
38823
|
+
tempTableMaxRows: input.tempTableMaxRows
|
|
38821
38824
|
});
|
|
38822
38825
|
const batchResult = await executeBatchSql(runtime2.sql, runtime2.client, {
|
|
38823
38826
|
maxRecords: runtime2.maxRecords,
|
|
@@ -38825,6 +38828,9 @@ function createKsqlMcpTools(serverOptions, deps = {}) {
|
|
|
38825
38828
|
onLimitReached: runtime2.onLimit,
|
|
38826
38829
|
cacheContext: runtime2.cacheContext,
|
|
38827
38830
|
continueOnError: input.continueOnError,
|
|
38831
|
+
// 一時テーブル実体化上限(未指定 = エンジン既定 TEMP_TABLE_MAX_ROWS)。
|
|
38832
|
+
// 実体化は onLimit 設定によらず常に error(src/execute.ts の実体化経路で固定)
|
|
38833
|
+
tempTableMaxRows: runtime2.tempTableMaxRows,
|
|
38828
38834
|
// バッチでは timeout を合計タイムアウトとして扱う(仕様 §5.7)。
|
|
38829
38835
|
// runtime.timeout は env / profile / 既定 30000ms を解決済みの値で、
|
|
38830
38836
|
// HTTP クライアント側の per-request タイムアウトと同値になる
|
|
@@ -38902,7 +38908,8 @@ function createKsqlMcpTools(serverOptions, deps = {}) {
|
|
|
38902
38908
|
maxRecords: resolveMutateRuntimeMaxRecords(validation.statements, dmlMaxRows),
|
|
38903
38909
|
fetchParallel: input.fetchParallel,
|
|
38904
38910
|
onLimit: DEFAULT_ON_LIMIT,
|
|
38905
|
-
timeout: input.timeout
|
|
38911
|
+
timeout: input.timeout,
|
|
38912
|
+
tempTableMaxRows: input.tempTableMaxRows
|
|
38906
38913
|
});
|
|
38907
38914
|
let totalAffected = staticInsertTotal;
|
|
38908
38915
|
const batchResult = await executeBatchSql(runtime.sql, runtime.client, {
|
|
@@ -38910,6 +38917,8 @@ function createKsqlMcpTools(serverOptions, deps = {}) {
|
|
|
38910
38917
|
fetchParallel: runtime.fetchParallel,
|
|
38911
38918
|
onLimitReached: runtime.onLimit,
|
|
38912
38919
|
cacheContext: runtime.cacheContext,
|
|
38920
|
+
// 一時テーブル実体化上限(未指定 = エンジン既定 TEMP_TABLE_MAX_ROWS)
|
|
38921
|
+
tempTableMaxRows: runtime.tempTableMaxRows,
|
|
38913
38922
|
// 合計タイムアウト(解決済みの runtime.timeout。per-request と同値)
|
|
38914
38923
|
timeoutMs: runtime.timeout,
|
|
38915
38924
|
confirm: async (count, operation) => {
|
|
@@ -39140,6 +39149,7 @@ var profile = external_exports.string().min(1).describe("kintone connection prof
|
|
|
39140
39149
|
var maxRecords = external_exports.number().int().positive().describe("Maximum records fetched per SELECT (default 500).").optional();
|
|
39141
39150
|
var fetchParallel = external_exports.number().int().min(1).max(10).describe("Number of parallel kintone record-fetch requests (1-10).").optional();
|
|
39142
39151
|
var onLimit = external_exports.enum(["error", "truncate"]).describe("Behavior when maxRecords is exceeded: 'error' rejects, 'truncate' returns the first maxRecords rows (default 'error').").optional();
|
|
39152
|
+
var tempTableMaxRows = external_exports.number().int().positive().describe("Per-temp-table cap on materialized rows for CREATE TEMP TABLE ... AS SELECT (default 10000). Overflow always errors \u2014 'truncate' never applies to temp tables, so downstream statements never see silently truncated data. Raising this increases memory use (up to 16 temp tables per batch); prefer narrowing the SELECT with WHERE.").optional();
|
|
39143
39153
|
var timeout = external_exports.number().int().positive().describe("Request timeout in milliseconds. For multi-statement batches this also acts as the total batch deadline.").optional();
|
|
39144
39154
|
var savedQueryName = external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/).describe("Saved query name (alphanumeric, '_' and '-', up to 64 chars).");
|
|
39145
39155
|
var savedQueryTags = external_exports.array(external_exports.string().min(1)).describe("Tags for organizing saved queries.").optional();
|
|
@@ -39157,6 +39167,7 @@ var queryInputSchema = external_exports.object({
|
|
|
39157
39167
|
maxRecords,
|
|
39158
39168
|
fetchParallel,
|
|
39159
39169
|
onLimit,
|
|
39170
|
+
tempTableMaxRows,
|
|
39160
39171
|
timeout,
|
|
39161
39172
|
continueOnError: external_exports.boolean().describe("Batch (multi-statement) only: keep executing subsequent statements after a runtime error (default false = fail-fast).").optional(),
|
|
39162
39173
|
maxTotalRecords: external_exports.number().int().positive().describe("Batch (multi-statement) only: cap on total rows returned across all result sets (default: unlimited).").optional()
|
|
@@ -39166,8 +39177,9 @@ var mutateInputSchema = external_exports.object({
|
|
|
39166
39177
|
profile,
|
|
39167
39178
|
allowDml: external_exports.literal(true).describe("Must be true to acknowledge that this call writes to kintone."),
|
|
39168
39179
|
confirmText: external_exports.literal("yes").describe('Must be the literal string "yes" to confirm execution.'),
|
|
39169
|
-
dmlMaxRows: external_exports.number().int().positive().describe("Per-statement cap on affected rows. The call fails before writing if any statement would exceed it; for UPSERT it counts inserts + updates. It does NOT limit source reads of INSERT/UPSERT ... SELECT: those follow the runtime maxRecords resolution (KSQL_MAX_RECORDS / profile query.maxRecords, default 500; temp tables hold at most 10000 rows), so choose it by intended write count only."),
|
|
39180
|
+
dmlMaxRows: external_exports.number().int().positive().describe("Per-statement cap on affected rows. The call fails before writing if any statement would exceed it; for UPSERT it counts inserts + updates. It does NOT limit source reads of INSERT/UPSERT ... SELECT: those follow the runtime maxRecords resolution (KSQL_MAX_RECORDS / profile query.maxRecords, default 500; temp tables hold at most 10000 rows by default, adjustable via tempTableMaxRows), so choose it by intended write count only."),
|
|
39170
39181
|
fetchParallel,
|
|
39182
|
+
tempTableMaxRows,
|
|
39171
39183
|
timeout,
|
|
39172
39184
|
dmlTotalMaxRows: external_exports.number().int().positive().describe("Batch (multi-statement) only: cap on total affected rows across the whole batch (default: per-statement dmlMaxRows only). DML batches always run fail-fast.").optional()
|
|
39173
39185
|
});
|
|
@@ -39209,7 +39221,7 @@ var runSavedQueryInputSchema = external_exports.object({
|
|
|
39209
39221
|
timeout,
|
|
39210
39222
|
allowDml: external_exports.literal(true).describe("Required for DML saved queries: must be true to acknowledge writes.").optional(),
|
|
39211
39223
|
confirmText: external_exports.literal("yes").describe('Required for DML saved queries: must be the literal string "yes".').optional(),
|
|
39212
|
-
dmlMaxRows: external_exports.number().int().positive().describe("Required for DML saved queries: per-statement cap on affected rows; for UPSERT it counts inserts + updates. It does NOT limit source reads of INSERT/UPSERT ... SELECT: those follow the runtime maxRecords resolution (KSQL_MAX_RECORDS / profile query.maxRecords, default 500
|
|
39224
|
+
dmlMaxRows: external_exports.number().int().positive().describe("Required for DML saved queries: per-statement cap on affected rows; for UPSERT it counts inserts + updates. It does NOT limit source reads of INSERT/UPSERT ... SELECT: those follow the runtime maxRecords resolution (KSQL_MAX_RECORDS / profile query.maxRecords, default 500). Saved queries are single-statement, so temp tables do not apply here. Note: this tool's maxRecords / onLimit inputs apply to read-only saved queries only.").optional()
|
|
39213
39225
|
});
|
|
39214
39226
|
var validateInputShape = validateInputSchema.shape;
|
|
39215
39227
|
var explainInputShape = explainInputSchema.shape;
|
|
@@ -39258,7 +39270,7 @@ Options:
|
|
|
39258
39270
|
-h, --help Show help
|
|
39259
39271
|
`);
|
|
39260
39272
|
}
|
|
39261
|
-
var SERVER_VERSION = true ? "1.
|
|
39273
|
+
var SERVER_VERSION = true ? "1.11.0" : "0.0.0-dev";
|
|
39262
39274
|
function createServer(args) {
|
|
39263
39275
|
const server = new McpServer({
|
|
39264
39276
|
name: "ksql-mcp",
|
|
@@ -39285,7 +39297,7 @@ function createServer(args) {
|
|
|
39285
39297
|
}, tools.queryTool);
|
|
39286
39298
|
server.registerTool("ksql_mutate", {
|
|
39287
39299
|
title: "Run mutating kSQL",
|
|
39288
|
-
description: "Execute DML kSQL with explicit allowDml, confirmText, and dmlMaxRows safety controls. Supports multi-statement DML batches with temp tables. INSERT/UPSERT INTO app ... SELECT supports app sources, temp tables, or joins of both. For UPSERT, dmlMaxRows counts inserts + updates. dmlMaxRows caps affected rows only, not source reads: the source SELECT reads up to the runtime maxRecords (KSQL_MAX_RECORDS / profile query.maxRecords, default 500); temp tables hold at most 10000 rows.",
|
|
39300
|
+
description: "Execute DML kSQL with explicit allowDml, confirmText, and dmlMaxRows safety controls. Supports multi-statement DML batches with temp tables. INSERT/UPSERT INTO app ... SELECT supports app sources, temp tables, or joins of both. For UPSERT, dmlMaxRows counts inserts + updates. dmlMaxRows caps affected rows only, not source reads: the source SELECT reads up to the runtime maxRecords (KSQL_MAX_RECORDS / profile query.maxRecords, default 500); temp tables hold at most 10000 rows by default (adjustable via tempTableMaxRows).",
|
|
39289
39301
|
inputSchema: mutateInputShape
|
|
39290
39302
|
}, tools.mutateTool);
|
|
39291
39303
|
server.registerTool("ksql_describe_app", {
|
package/dist-mcpb/ksql-mcp.mcpb
CHANGED
|
Binary file
|