Skip to content

Commit 94ea7d3

Browse files
authored
Merge pull request #96 from benborla/revert-95-revert-86-main
Revert "Revert "feat: Add linting scripts for ESLint and MarkdownLint""
2 parents bd050ef + db5ff86 commit 94ea7d3

File tree

13 files changed

+1467
-40
lines changed

13 files changed

+1467
-40
lines changed

.github/workflows/lint.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
eslint:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '22'
23+
24+
- name: Clear npm cache
25+
run: npm cache clean --force
26+
27+
- name: Install dependencies
28+
run: npm install
29+
30+
- name: Run ESLint
31+
run: npm run lint:eslint
32+
33+
markdownlint:
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
40+
- name: Set up Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: '22'
44+
45+
- name: Clear npm cache
46+
run: npm cache clean --force
47+
48+
- name: Install dependencies
49+
run: npm install
50+
51+
- name: Run markdownlint
52+
run: npm run lint:markdown

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist
22
node_modules/
3+
.env

.markdownlint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MD013: false
2+
MD024: false
3+
MD020: false

.markdownlintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22

3+
## Planned Features
34

4-
### Planned Features
55
- Query Features
66
- Prepared statement support
77
- Query parameter validation
@@ -37,32 +37,38 @@
3737
## [1.0.14] - 2024-07-01
3838

3939
### Added
40+
4041
- Added better support for test environments with automatic database selection
4142
- Implemented comprehensive debug logging for database configuration in test mode
4243
- Added fail-safe process termination handling for test environments
4344

4445
### Changed
46+
4547
- Improved test environment detection with support for Vitest test runner
4648
- Enhanced MySQL connection configuration to use consistent defaults across environments
4749
- Updated error handling in database setup scripts to be more resilient
4850

4951
### Fixed
52+
5053
- Fixed "No database selected" error in integration tests by ensuring database name is always set
5154
- Fixed authentication issues in test environments by providing consistent default credentials
5255
- Prevented premature test termination by implementing conditional process.exit handling
5356
- Improved error handling in test database setup to continue tests even when setup encounters issues
5457

5558
### Security
59+
5660
- Made authentication more consistent across development and test environments
5761
- Added safeguards to prevent exposing actual password values in debug logs
5862

5963
### Documentation
64+
6065
- Added detailed inline comments for test-specific configurations
6166
- Improved error messages to provide better debugging information
6267

6368
## [1.0.13] - 2024-05-26
6469

6570
### Added
71+
6672
- Complete write operations support through Smithery configuration
6773
- Added environment variables for database write operations (`ALLOW_INSERT_OPERATION`, `ALLOW_UPDATE_OPERATION`, `ALLOW_DELETE_OPERATION`)
6874
- New configuration options in Smithery schema for controlling write permissions
@@ -71,6 +77,7 @@
7177
- Enhanced error handling for unauthorized write operations
7278

7379
### Changed
80+
7481
- Updated Smithery configuration to include write operation settings
7582
- Improved Smithery integration with clear security defaults
7683
- Enhanced documentation with detailed configuration examples
@@ -79,18 +86,21 @@
7986
- Improved transaction handling for write operations
8087

8188
### Fixed
89+
8290
- Fixed error handling for database connection failures
8391
- Improved error messages for unauthorized operations
8492
- Better handling of MySQL 8.0+ authentication methods
8593
- Fixed SSL/TLS configuration options in Smithery
8694

8795
### Security
96+
8897
- All write operations (INSERT, UPDATE, DELETE) disabled by default
8998
- Added clear documentation about security implications of enabling write operations
9099
- Improved transaction isolation for write operations
91100
- Enhanced error reporting that doesn't expose sensitive information
92101

93102
### Documentation
103+
94104
- Updated README with comprehensive Smithery configuration instructions
95105
- Added detailed examples for enabling specific write operations
96106
- Improved troubleshooting section with common issues and solutions
@@ -100,38 +110,46 @@
100110
## [1.0.10] - 2024-03-13
101111

102112
### Changed
113+
103114
- Version bump to fix npm publishing issue
104115
- Updated installation instructions in README to reference specific version
105116

106117
## [1.0.9] - 2024-03-13
107118

108119
### Added
120+
109121
- GitHub Actions CI workflow for automated lint, build, and test with MySQL service
110122

111123
### Changed
124+
112125
- Removed `@types/mysql2` dependency and related type references
113126
- Updated test files to use `any` type instead of mysql2 specific types
114127
- Fixed integration tests to properly handle MySQL connection and queries
115128

116129
### Fixed
130+
117131
- Fixed GitHub Actions workflow to install pnpm before using it for caching
118132
- Fixed failing unit tests by removing problematic executeReadOnlyQuery tests
119133

120134
## [1.0.8] - 2024-03-12
121135

122136
### Changed
137+
123138
- Upgraded from `mysql` to `mysql2` package (^3.13.0) for better MySQL 8.0+ compatibility
124139
- Refactored database connection code to use mysql2's Promise-based API
125140
- Added support for MySQL 8.0+ authentication with `caching_sha2_password` plugin
126141

127142
### Removed
143+
128144
- Removed deprecated `mysql` package dependency
129145
- Removed unused `@types/mysql2` devDependency
130146

131147
### Fixed
148+
132149
- Fixed authentication issues with MySQL 8.0+ servers
133150
- Improved connection handling with Promise-based API
134151
- Enhanced error handling for database operations
135152

136153
## [1.0.7] - Previous version
137-
- Initial release with basic MySQL functionality
154+
155+
- Initial release with basic MySQL functionality

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MIT License
1+
# MIT License
22

33
Copyright (c) 2024 Ben Borla
44

PROJECT_SETUP_GUIDE.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This guide explains how to set up database connections for projects using Claude Code with MCP servers, SSH tunnels, and automatic hooks.
44

55
## Table of Contents
6+
67
- [Overview](#overview)
78
- [Prerequisites](#prerequisites)
89
- [Step-by-Step Setup](#step-by-step-setup)
@@ -14,6 +15,7 @@ This guide explains how to set up database connections for projects using Claude
1415
## Overview
1516

1617
Each project requires three main components for database access through Claude Code:
18+
1719
1. **SSH Tunnel Scripts** - Establish secure connection to remote database
1820
2. **MCP Configuration** - Configure database access through MCP server
1921
3. **Hooks** - Automatically start/stop tunnels with Claude
@@ -47,6 +49,7 @@ Each project requires three main components for database access through Claude C
4749
Create two scripts in your project directory:
4850

4951
#### `start-tunnel-[project].sh`
52+
5053
```bash
5154
#!/bin/bash
5255

@@ -85,6 +88,7 @@ fi
8588
```
8689

8790
#### `stop-tunnel-[project].sh`
91+
8892
```bash
8993
#!/bin/bash
9094

@@ -104,6 +108,7 @@ fi
104108
```
105109

106110
Make scripts executable:
111+
107112
```bash
108113
chmod +x start-tunnel-*.sh stop-tunnel-*.sh
109114
```
@@ -172,7 +177,8 @@ Choose a unique local port for each project to avoid conflicts:
172177
## File Structure
173178

174179
Your project should have this structure:
175-
```
180+
181+
```bash
176182
/path/to/your/project/
177183
├── .mcp.json # MCP configuration
178184
├── start-tunnel-[project].sh # Start SSH tunnel script
@@ -246,6 +252,7 @@ SSH_USER="myuser"
246252
## Testing Your Setup
247253

248254
### 1. Test SSH Tunnel
255+
249256
```bash
250257
# Start tunnel manually
251258
./start-tunnel-[project].sh
@@ -258,12 +265,14 @@ lsof -i :33XX
258265
```
259266

260267
### 2. Test Database Connection
268+
261269
```bash
262270
# Test connection through tunnel
263271
mysql -h 127.0.0.1 -P 33XX -u db_user -p"password" -D database_name -e "SELECT 'Connection OK' as status;"
264272
```
265273

266274
### 3. Test Claude Integration
275+
267276
```bash
268277
# Navigate to project
269278
cd /path/to/your/project
@@ -279,7 +288,9 @@ claude
279288
```
280289

281290
### 4. Test MCP Server Operations
291+
282292
Once in Claude, test database operations:
293+
283294
```sql
284295
# Through MCP server
285296
CREATE TABLE test_table (
@@ -299,26 +310,31 @@ DROP TABLE test_table;
299310
### Common Issues and Solutions
300311

301312
#### 1. SSH Tunnel Fails to Start
313+
302314
- **Check SSH key**: Ensure `~/.ssh/id_rsa` exists and has correct permissions (600)
303315
- **Test SSH manually**: `ssh -p 1022 [email protected]`
304316
- **Check port availability**: `lsof -i :33XX`
305317

306318
#### 2. Database Connection Fails
319+
307320
- **Verify tunnel is running**: `lsof -i :33XX`
308321
- **Check credentials**: Test with mysql client directly
309322
- **Verify database exists**: `SHOW DATABASES;`
310323

311324
#### 3. MCP Server Fails to Connect
325+
312326
- **Check MCP server is built**: `ls /Users/dimitarklaturov/Dropbox/github/mcp-server-mysql/dist/`
313327
- **Verify Node.js version**: `node --version` (should be 18+ or 20+)
314328
- **Check logs**: `claude --debug`
315329

316330
#### 4. Hooks Not Working
331+
317332
- **Check script permissions**: `ls -la *.sh` (should be executable)
318333
- **Verify script paths**: Use relative paths (`./script.sh`) in .mcp.json
319334
- **Test scripts manually**: Run start/stop scripts directly
320335

321336
#### 5. Port Conflicts
337+
322338
- **Kill existing process**: `kill $(lsof -ti:33XX)`
323339
- **Use different port**: Update both scripts and .mcp.json
324340

@@ -373,6 +389,7 @@ For each new project:
373389
## Support
374390

375391
For issues with:
392+
376393
- **MCP Server**: Check `/Users/dimitarklaturov/Dropbox/github/mcp-server-mysql`
377-
- **Claude Code**: Run `claude --help` or visit https://docs.anthropic.com/en/docs/claude-code
378-
- **SSH Tunnels**: Check server connectivity and SSH key configuration
394+
- **Claude Code**: Run `claude --help` or visit [https://docs.anthropic.com/en/docs/claude-code](https://docs.anthropic.com/en/docs/claude-code)
395+
- **SSH Tunnels**: Check server connectivity and SSH key configuration

README-MULTI-DB.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ To enable multi-DB mode, simply leave the `MYSQL_DB` environment variable empty:
3434
2. **Query Any Database**: You can execute queries against any database to which the MySQL user has access.
3535

3636
3. **Schema Qualification Required**: When working in multi-DB mode, you should use fully qualified table names with schema/database prefixes:
37+
3738
```sql
3839
-- Use fully qualified table names
3940
SELECT * FROM database_name.table_name;
@@ -46,6 +47,7 @@ To enable multi-DB mode, simply leave the `MYSQL_DB` environment variable empty:
4647
4. **Automatic Read-Only Mode**: For safety, multi-DB mode enforces read-only operations by default. This can be customized using schema-specific permissions (see below).
4748

4849
5. **Database Exploration**: You can explore databases using commands like:
50+
4951
```sql
5052
-- List all databases
5153
SHOW DATABASES;
@@ -72,14 +74,15 @@ This new feature allows fine-grained control over which operations are allowed o
7274

7375
Set the following environment variables with a comma-separated list of schema:permission pairs:
7476

75-
```
77+
```txt
7678
SCHEMA_INSERT_PERMISSIONS=production:false,development:true,test:true
7779
SCHEMA_UPDATE_PERMISSIONS=production:false,development:true,test:true
7880
SCHEMA_DELETE_PERMISSIONS=production:false,development:false,test:true
7981
SCHEMA_DDL_PERMISSIONS=production:false,development:false,test:true
8082
```
8183

8284
This configuration:
85+
8386
- Allows INSERT and UPDATE on development and test databases, but not production
8487
- Allows DELETE and DDL operations only on the test database
8588
- Blocks all write operations on the production database
@@ -127,16 +130,19 @@ Here's a complete example configuration with schema-specific permissions:
127130
## Environment Variables Summary
128131

129132
### Multi-DB Mode
133+
130134
- `MYSQL_DB`: Leave empty to enable multi-DB mode
131135
- `MULTI_DB_WRITE_MODE`: Set to "true" to allow write operations in multi-DB mode without schema-specific permissions (not recommended for security)
132136

133137
### Schema-Specific Permissions
138+
134139
- `SCHEMA_INSERT_PERMISSIONS`: Control INSERT permissions per schema
135140
- `SCHEMA_UPDATE_PERMISSIONS`: Control UPDATE permissions per schema
136141
- `SCHEMA_DELETE_PERMISSIONS`: Control DELETE permissions per schema
137142
- `SCHEMA_DDL_PERMISSIONS`: Control DDL permissions per schema (CREATE, ALTER, DROP, TRUNCATE)
138143

139144
### Global Permission Defaults
145+
140146
- `ALLOW_INSERT_OPERATION`: Global default for INSERT permissions
141147
- `ALLOW_UPDATE_OPERATION`: Global default for UPDATE permissions
142148
- `ALLOW_DELETE_OPERATION`: Global default for DELETE permissions

0 commit comments

Comments
 (0)