@ecubelabs/mysql-mcp 2.0.0-next.2 → 2.0.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 +2 -2
- package/dist/index.js +13 -9
- package/dist/src/catalog/index.js +16 -0
- package/dist/src/config/index.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -283,7 +283,7 @@ Catalog는 기본적으로
|
|
|
283
283
|
`~/.cache/mysql-mcp/catalog/<profile>-<database-target-hash>.json`에
|
|
284
284
|
저장됩니다.
|
|
285
285
|
|
|
286
|
-
- Hash
|
|
286
|
+
- Hash는 bastion·DB 주소·MySQL user로 만들므로, 서로 다른 환경이 같은 catalog를
|
|
287
287
|
읽지 않습니다.
|
|
288
288
|
- 위치는 `--catalog-path`로 바꿀 수 있습니다.
|
|
289
289
|
- 디스크에 쓸 수 없으면 catalog만 꺼지고 query는 계속 됩니다.
|
|
@@ -338,7 +338,7 @@ credential만 [환경 변수](#환경-변수)로 받고, 나머지 설정은 모
|
|
|
338
338
|
| `--port <port>` | — | 위 주소의 포트. |
|
|
339
339
|
| `--socket-path <path>` | _(미설정)_ | Unix socket 절대 경로로 직접 접속합니다. `--host`·`--port`·`--ssh-host`와 함께 줄 수 없습니다. |
|
|
340
340
|
| `--db <schema>` | _(미설정)_ | 기본 schema. 없으면 multi-DB 모드가 켜집니다. |
|
|
341
|
-
| `--ssl` | 꺼짐 | MySQL로의 TLS(SSH tunnel과는 별개). 아래 네 인자는 이
|
|
341
|
+
| `--ssl` | 꺼짐 | MySQL로의 TLS(SSH tunnel과는 별개). 아래 네 인자는 이 플래그 없이 줄 수 없습니다. |
|
|
342
342
|
| `--ssl-reject-unauthorized` | 꺼짐 | 서버 인증서를 검증합니다. |
|
|
343
343
|
| `--ssl-ca <path>` | _(미설정)_ | CA 인증서 PEM 절대 경로. |
|
|
344
344
|
| `--ssl-cert <path>` / `--ssl-key <path>` | _(미설정)_ | mTLS용 클라이언트 인증서와 개인 키 PEM 절대 경로. |
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { log, sharedOnce, tableResourceUri } from './src/utils/index.js';
|
|
|
8
8
|
import { describeWriteCapabilities, writeCapabilities } from './src/db/permissions.js';
|
|
9
9
|
import { SCHEMA_DELETE_PERMISSIONS, SCHEMA_DDL_PERMISSIONS, SCHEMA_INSERT_PERMISSIONS, SCHEMA_UPDATE_PERMISSIONS, isMultiDbMode, mcpConfig as config, MYSQL_PROFILE, PROFILE_LABEL, IS_WRITE_FORBIDDEN_PROFILE, MYSQL_CATALOG_ENABLED, MYSQL_CATALOG_PATH, MYSQL_CATALOG_TTL_HOURS, MYSQL_DEFAULT_TIMEOUT_SECONDS, MYSQL_MAX_TIMEOUT_SECONDS, MAX_RESPONSE_ROWS, MYSQL_SSL_ENABLED, MYSQL_SSL_CA_PATH, MYSQL_SSL_CERT_PATH, MYSQL_SSL_KEY_PATH, PACKAGE_VERSION, SSH_ENABLED, ignoredEnvSummary, startupFailureMessage, } from './src/config/index.js';
|
|
10
10
|
import { codeBranchToolInstruction, codeRevisionDescription } from './src/catalog/branch.js';
|
|
11
|
-
import { catalogIdentity, SchemaCatalog } from './src/catalog/index.js';
|
|
11
|
+
import { catalogIdentity, catalogTarget, SchemaCatalog } from './src/catalog/index.js';
|
|
12
12
|
import { renderSchemasResource } from './src/catalog/render.js';
|
|
13
13
|
import { describeConnection, getPool, executeQuery, executeReadOnlyQuery, setQueryDiagnosticsSource, setCodeBranchSource, clampTimeoutSeconds, describeQueryError, poolPromise, profileBanner, } from './src/db/index.js';
|
|
14
14
|
import { describeTunnel, ensureTunnel, resolveTunnelConfig, stopTunnel } from './src/ssh/tunnel.js';
|
|
@@ -204,17 +204,21 @@ log('info', 'MySQL Configuration:', JSON.stringify({
|
|
|
204
204
|
}, null, 2));
|
|
205
205
|
export default function createMcpServer() {
|
|
206
206
|
const mysqlSettings = config.mysql;
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
const tunnel = SSH_ENABLED ? resolveTunnelConfig() : null;
|
|
208
|
+
const target = catalogTarget(tunnel
|
|
209
|
+
? {
|
|
210
|
+
kind: 'ssh',
|
|
211
|
+
sshHost: tunnel.sshHost,
|
|
212
|
+
sshPort: tunnel.sshPort,
|
|
213
|
+
remoteHost: tunnel.remoteHost,
|
|
214
|
+
remotePort: tunnel.remotePort,
|
|
215
|
+
}
|
|
212
216
|
: typeof mysqlSettings.socketPath === 'string'
|
|
213
|
-
?
|
|
214
|
-
:
|
|
217
|
+
? { kind: 'unix', socketPath: mysqlSettings.socketPath }
|
|
218
|
+
: { kind: 'tcp', host: String(mysqlSettings.host), port: Number(mysqlSettings.port) });
|
|
215
219
|
const identity = catalogIdentity({
|
|
216
220
|
profile: MYSQL_PROFILE,
|
|
217
|
-
target
|
|
221
|
+
target,
|
|
218
222
|
user: String(mysqlSettings.user ?? ''),
|
|
219
223
|
customPath: MYSQL_CATALOG_PATH,
|
|
220
224
|
});
|
|
@@ -23,6 +23,22 @@ function deadlineTimer(ms) {
|
|
|
23
23
|
});
|
|
24
24
|
return { expired, cancel: () => clearTimeout(timer) };
|
|
25
25
|
}
|
|
26
|
+
export function catalogTarget(endpoint) {
|
|
27
|
+
switch (endpoint.kind) {
|
|
28
|
+
case 'ssh':
|
|
29
|
+
return JSON.stringify([
|
|
30
|
+
'ssh',
|
|
31
|
+
endpoint.sshHost,
|
|
32
|
+
endpoint.sshPort,
|
|
33
|
+
endpoint.remoteHost,
|
|
34
|
+
endpoint.remotePort,
|
|
35
|
+
]);
|
|
36
|
+
case 'unix':
|
|
37
|
+
return JSON.stringify(['unix', endpoint.socketPath]);
|
|
38
|
+
case 'tcp':
|
|
39
|
+
return JSON.stringify(['tcp', endpoint.host, endpoint.port]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
26
42
|
function shortHash(value) {
|
|
27
43
|
return createHash('sha256').update(value).digest('hex').slice(0, 16);
|
|
28
44
|
}
|
package/dist/src/config/index.js
CHANGED
|
@@ -136,6 +136,7 @@ const SERVER_ARG_OPTIONS = {
|
|
|
136
136
|
log: { type: 'boolean' },
|
|
137
137
|
};
|
|
138
138
|
const SSH_DEPENDENT_ARGS = ['ssh-user', 'ssh-port', 'ssh-private-key-path'];
|
|
139
|
+
const TLS_DEPENDENT_ARGS = ['ssl-reject-unauthorized', 'ssl-ca', 'ssl-cert', 'ssl-key'];
|
|
139
140
|
const PORT_RANGE = { min: 1, max: 65535 };
|
|
140
141
|
const POSITIVE_RANGE = { min: 1, max: Number.MAX_SAFE_INTEGER };
|
|
141
142
|
function parseIntegerArg(name, raw, range, violations) {
|
|
@@ -257,6 +258,12 @@ export function parseServerArgs(argv) {
|
|
|
257
258
|
else if (!args.sshUser) {
|
|
258
259
|
violations.push('--ssh-host requires --ssh-user');
|
|
259
260
|
}
|
|
261
|
+
if (!args.ssl) {
|
|
262
|
+
const orphans = TLS_DEPENDENT_ARGS.filter((name) => values[name] === true || text(name) !== undefined);
|
|
263
|
+
if (orphans.length > 0) {
|
|
264
|
+
violations.push(`${orphans.map((name) => `--${name}`).join(', ')} requires --ssl`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
260
267
|
if (violations.length > 0) {
|
|
261
268
|
throw new Error(`invalid server arguments: ${violations.join('; ')}.`);
|
|
262
269
|
}
|
package/package.json
CHANGED