@cemalturkcann/mariadb-mcp-server 1.1.0 → 1.1.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/README.md +7 -13
- package/package.json +1 -1
- package/src/config.js +11 -6
- package/src/db.js +8 -8
package/README.md
CHANGED
|
@@ -96,6 +96,8 @@ Example config:
|
|
|
96
96
|
|
|
97
97
|
## MCP Client Setup
|
|
98
98
|
|
|
99
|
+
On first run, a default config is created automatically at `~/.config/mariadb-mcp/config.json` (Linux/macOS) or `%APPDATA%\mariadb-mcp\config.json` (Windows). Edit it to add your connections.
|
|
100
|
+
|
|
99
101
|
### Claude Code
|
|
100
102
|
|
|
101
103
|
Add to `~/.claude.json`:
|
|
@@ -105,10 +107,7 @@ Add to `~/.claude.json`:
|
|
|
105
107
|
"mcpServers": {
|
|
106
108
|
"mariadb": {
|
|
107
109
|
"command": "npx",
|
|
108
|
-
"args": ["-y", "@cemalturkcann/mariadb-mcp-server"]
|
|
109
|
-
"env": {
|
|
110
|
-
"DB_MCP_CONFIG_PATH": "/path/to/config.json"
|
|
111
|
-
}
|
|
110
|
+
"args": ["-y", "@cemalturkcann/mariadb-mcp-server"]
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
113
|
}
|
|
@@ -116,19 +115,14 @@ Add to `~/.claude.json`:
|
|
|
116
115
|
|
|
117
116
|
### OpenCode
|
|
118
117
|
|
|
119
|
-
Add to your
|
|
118
|
+
Add to your `opencode.json`:
|
|
120
119
|
|
|
121
120
|
```json
|
|
122
121
|
{
|
|
123
|
-
"
|
|
122
|
+
"mcp": {
|
|
124
123
|
"mariadb": {
|
|
125
124
|
"type": "local",
|
|
126
|
-
"command": "npx -y @cemalturkcann/mariadb-mcp-server"
|
|
127
|
-
"environment": {
|
|
128
|
-
"DB_MCP_CONFIG_PATH": "/path/to/config.json"
|
|
129
|
-
},
|
|
130
|
-
"enabled": true,
|
|
131
|
-
"timeout": 60000
|
|
125
|
+
"command": ["npx", "-y", "@cemalturkcann/mariadb-mcp-server"]
|
|
132
126
|
}
|
|
133
127
|
}
|
|
134
128
|
}
|
|
@@ -136,7 +130,7 @@ Add to your project-level `.opencode.json`:
|
|
|
136
130
|
|
|
137
131
|
### Other MCP Clients
|
|
138
132
|
|
|
139
|
-
Any MCP-compatible client can use this server. The binary name is `mariadb-mcp-server` and it communicates over stdio.
|
|
133
|
+
Any MCP-compatible client can use this server. The binary name is `mariadb-mcp-server` and it communicates over stdio. To use a custom config path, set `DB_MCP_CONFIG_PATH`.
|
|
140
134
|
|
|
141
135
|
## License
|
|
142
136
|
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -50,9 +50,14 @@ const DEFAULT_CONFIG = {
|
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
function getDefaultConfigPath() {
|
|
54
|
+
if (process.env.XDG_CONFIG_HOME) {
|
|
55
|
+
return join(process.env.XDG_CONFIG_HOME, "mariadb-mcp", "config.json");
|
|
56
|
+
}
|
|
57
|
+
if (process.platform === "win32" && process.env.APPDATA) {
|
|
58
|
+
return join(process.env.APPDATA, "mariadb-mcp", "config.json");
|
|
59
|
+
}
|
|
60
|
+
return join(homedir(), ".config", "mariadb-mcp", "config.json");
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
function createDefaultConfig(configPath) {
|
|
@@ -70,13 +75,13 @@ function createDefaultConfig(configPath) {
|
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
export function loadConfig() {
|
|
73
|
-
const
|
|
78
|
+
const defaultPath = getDefaultConfigPath();
|
|
74
79
|
|
|
75
80
|
const candidates = [
|
|
76
81
|
process.env.DB_MCP_CONFIG_PATH,
|
|
77
82
|
join(__dirname, "../config.json"),
|
|
78
83
|
join(process.cwd(), "config.json"),
|
|
79
|
-
|
|
84
|
+
defaultPath,
|
|
80
85
|
].filter(Boolean);
|
|
81
86
|
|
|
82
87
|
let rawConfig;
|
|
@@ -88,7 +93,7 @@ export function loadConfig() {
|
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
if (!rawConfig) {
|
|
91
|
-
rawConfig = createDefaultConfig(
|
|
96
|
+
rawConfig = createDefaultConfig(defaultPath);
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
const raw = rawConfig.connections || rawConfig.databases;
|
package/src/db.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createPool } from "mariadb";
|
|
2
2
|
|
|
3
3
|
export class DbManager {
|
|
4
4
|
constructor(config) {
|
|
@@ -12,13 +12,13 @@ export class DbManager {
|
|
|
12
12
|
|
|
13
13
|
getReadableConnections() {
|
|
14
14
|
return this.getConnectionNames().filter(
|
|
15
|
-
(name) => this.config.connections[name].read
|
|
15
|
+
(name) => this.config.connections[name].read,
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
getWritableConnections() {
|
|
20
20
|
return this.getConnectionNames().filter(
|
|
21
|
-
(name) => this.config.connections[name].write
|
|
21
|
+
(name) => this.config.connections[name].write,
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -27,7 +27,7 @@ export class DbManager {
|
|
|
27
27
|
if (!cfg) {
|
|
28
28
|
const available = this.getConnectionNames().join(", ");
|
|
29
29
|
throw new Error(
|
|
30
|
-
`Baglanti bulunamadi: '${name}'. Mevcut baglantilar: ${available}
|
|
30
|
+
`Baglanti bulunamadi: '${name}'. Mevcut baglantilar: ${available}`,
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
return cfg;
|
|
@@ -59,7 +59,7 @@ export class DbManager {
|
|
|
59
59
|
typeof c.ssl === "object" ? c.ssl : { rejectUnauthorized: false };
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
this.pools.set(poolKey,
|
|
62
|
+
this.pools.set(poolKey, createPool(poolOptions));
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
return this.pools.get(poolKey);
|
|
@@ -69,7 +69,7 @@ export class DbManager {
|
|
|
69
69
|
const cfg = this.getConnectionConfig(connectionName);
|
|
70
70
|
if (!cfg.read) {
|
|
71
71
|
throw new Error(
|
|
72
|
-
`'${connectionName}' baglantisi read (okuma) izni vermiyor
|
|
72
|
+
`'${connectionName}' baglantisi read (okuma) izni vermiyor.`,
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -78,7 +78,7 @@ export class DbManager {
|
|
|
78
78
|
const cfg = this.getConnectionConfig(connectionName);
|
|
79
79
|
if (!cfg.write) {
|
|
80
80
|
throw new Error(
|
|
81
|
-
`'${connectionName}' baglantisi write (yazma) izni vermiyor
|
|
81
|
+
`'${connectionName}' baglantisi write (yazma) izni vermiyor.`,
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -134,7 +134,7 @@ export class DbManager {
|
|
|
134
134
|
/* asil hatayi koruyoruz */
|
|
135
135
|
}
|
|
136
136
|
throw new Error(
|
|
137
|
-
`Transaction basarisiz, rollback yapildi: ${error.message}
|
|
137
|
+
`Transaction basarisiz, rollback yapildi: ${error.message}`,
|
|
138
138
|
);
|
|
139
139
|
} finally {
|
|
140
140
|
conn.release();
|