@berthojoris/mcp-mysql-server 1.44.0 → 1.45.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/CHANGELOG.md +39 -0
- package/DOCUMENTATIONS.md +674 -524
- package/README.md +468 -382
- package/bin/mcp-mysql.js +49 -3
- package/dist/config/runtimeConfig.d.ts +50 -0
- package/dist/config/runtimeConfig.js +173 -0
- package/dist/db/connection.d.ts +32 -0
- package/dist/db/connection.js +169 -8
- package/dist/mcp-server.js +219 -74
- package/dist/security/grantInspector.d.ts +5 -0
- package/dist/security/grantInspector.js +32 -0
- package/dist/server/auditLogger.d.ts +24 -0
- package/dist/server/auditLogger.js +60 -0
- package/dist/server/auth.d.ts +56 -0
- package/dist/server/auth.js +274 -0
- package/dist/server/httpServer.d.ts +22 -0
- package/dist/server/httpServer.js +320 -0
- package/dist/server/rateLimiter.d.ts +15 -0
- package/dist/server/rateLimiter.js +41 -0
- package/dist/server/requestContext.d.ts +12 -0
- package/dist/server/requestContext.js +9 -0
- package/dist/tools/toolAnnotations.d.ts +4 -0
- package/dist/tools/toolAnnotations.js +73 -0
- package/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRequestContext = exports.runWithRequestContext = void 0;
|
|
4
|
+
const async_hooks_1 = require("async_hooks");
|
|
5
|
+
const storage = new async_hooks_1.AsyncLocalStorage();
|
|
6
|
+
const runWithRequestContext = (context, fn) => storage.run(context, fn);
|
|
7
|
+
exports.runWithRequestContext = runWithRequestContext;
|
|
8
|
+
const getRequestContext = () => storage.getStore();
|
|
9
|
+
exports.getRequestContext = getRequestContext;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Tool, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
export declare const getToolAnnotations: (name: string) => ToolAnnotations;
|
|
3
|
+
export declare const hasExplicitAnnotations: (name: string) => boolean;
|
|
4
|
+
export declare const withToolAnnotations: (tools: Tool[]) => Tool[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withToolAnnotations = exports.hasExplicitAnnotations = exports.getToolAnnotations = void 0;
|
|
4
|
+
// Reads only: no data, schema, or server state changes
|
|
5
|
+
const READ_TOOLS = [
|
|
6
|
+
"list_databases", "list_tables", "get_database_summary", "get_schema_erd",
|
|
7
|
+
"get_schema_rag_context", "find_tables_by_keyword", "search_schema",
|
|
8
|
+
"search_data_across_tables", "get_column_statistics", "read_table_schema",
|
|
9
|
+
"read_records", "plan_seed_data", "generate_seed_preview",
|
|
10
|
+
"validate_seed_integrity", "infer_seed_rules", "seed_from_template",
|
|
11
|
+
"run_select_query", "repair_query", "describe_connection", "read_changelog",
|
|
12
|
+
"test_connection", "list_all_tools", "get_all_tables_relationships",
|
|
13
|
+
"get_transaction_status", "list_stored_procedures", "get_stored_procedure_info",
|
|
14
|
+
"show_create_procedure", "export_table_to_csv", "export_query_to_csv",
|
|
15
|
+
"analyze_query", "get_optimization_hints", "list_views", "get_view_info",
|
|
16
|
+
"show_create_view", "list_triggers", "get_trigger_info", "show_create_trigger",
|
|
17
|
+
"list_indexes", "get_index_info", "list_foreign_keys", "list_constraints",
|
|
18
|
+
"check_table", "get_table_status", "get_table_size", "fulltext_search",
|
|
19
|
+
"get_fulltext_info", "get_fulltext_stats",
|
|
20
|
+
];
|
|
21
|
+
// Change state but only add to it or maintain it; existing data is kept
|
|
22
|
+
const WRITE_TOOLS = [
|
|
23
|
+
"create_record", "bulk_insert", "execute_seed_plan", "begin_transaction",
|
|
24
|
+
"rollback_transaction", "create_table", "create_trigger", "create_index",
|
|
25
|
+
"add_foreign_key", "add_unique_constraint", "add_check_constraint",
|
|
26
|
+
"create_stored_procedure", "create_fulltext_index",
|
|
27
|
+
];
|
|
28
|
+
// Maintenance statements that leave the same state when repeated
|
|
29
|
+
const IDEMPOTENT_WRITE_TOOLS = [
|
|
30
|
+
"analyze_table", "analyze_index", "optimize_table", "flush_table", "optimize_fulltext",
|
|
31
|
+
];
|
|
32
|
+
// May overwrite or remove data or schema objects, or run arbitrary statements
|
|
33
|
+
const DESTRUCTIVE_TOOLS = [
|
|
34
|
+
"update_record", "delete_record", "bulk_update", "bulk_delete",
|
|
35
|
+
"execute_write_query", "alter_table", "drop_table", "execute_ddl",
|
|
36
|
+
"cursor_execute_request", "commit_transaction", "execute_in_transaction",
|
|
37
|
+
"execute_stored_procedure", "drop_stored_procedure", "create_view",
|
|
38
|
+
"alter_view", "drop_view", "drop_trigger", "drop_index", "drop_foreign_key",
|
|
39
|
+
"drop_constraint", "repair_table", "truncate_table", "drop_fulltext_index",
|
|
40
|
+
];
|
|
41
|
+
const behaviors = new Map();
|
|
42
|
+
for (const name of READ_TOOLS)
|
|
43
|
+
behaviors.set(name, { behavior: "read", idempotent: true });
|
|
44
|
+
for (const name of WRITE_TOOLS)
|
|
45
|
+
behaviors.set(name, { behavior: "write", idempotent: false });
|
|
46
|
+
for (const name of IDEMPOTENT_WRITE_TOOLS)
|
|
47
|
+
behaviors.set(name, { behavior: "write", idempotent: true });
|
|
48
|
+
for (const name of DESTRUCTIVE_TOOLS)
|
|
49
|
+
behaviors.set(name, { behavior: "destructive", idempotent: false });
|
|
50
|
+
const ACRONYMS = { csv: "CSV", erd: "ERD", rag: "RAG", ddl: "DDL" };
|
|
51
|
+
const toTitle = (name) => name
|
|
52
|
+
.split("_")
|
|
53
|
+
.map((word) => ACRONYMS[word] || word.charAt(0).toUpperCase() + word.slice(1))
|
|
54
|
+
.join(" ");
|
|
55
|
+
const getToolAnnotations = (name) => {
|
|
56
|
+
// Unknown tools are treated as destructive, the safest hint
|
|
57
|
+
const entry = behaviors.get(name) || { behavior: "destructive", idempotent: false };
|
|
58
|
+
return {
|
|
59
|
+
title: toTitle(name),
|
|
60
|
+
readOnlyHint: entry.behavior === "read",
|
|
61
|
+
destructiveHint: entry.behavior === "destructive",
|
|
62
|
+
idempotentHint: entry.idempotent,
|
|
63
|
+
openWorldHint: false,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
exports.getToolAnnotations = getToolAnnotations;
|
|
67
|
+
const hasExplicitAnnotations = (name) => behaviors.has(name);
|
|
68
|
+
exports.hasExplicitAnnotations = hasExplicitAnnotations;
|
|
69
|
+
const withToolAnnotations = (tools) => tools.map((tool) => ({
|
|
70
|
+
...tool,
|
|
71
|
+
annotations: { ...(0, exports.getToolAnnotations)(tool.name), ...(tool.annotations || {}) },
|
|
72
|
+
}));
|
|
73
|
+
exports.withToolAnnotations = withToolAnnotations;
|
package/manifest.json
CHANGED
package/package.json
CHANGED