Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions INSTALLATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,25 @@ Completely quit and restart Claude Desktop to load the MCP server.
}
```

### MS-SQL

```json
{
"databases": {
"my_mssql": {
"type": "mssql",
"host": "localhost",
"port": 1433,
"database": "mydb",
"username": "root",
"password": "password",
"driver": "ODBC Driver 18 for SQL Server",
"read_only": true
}
}
}
```

### Multiple Databases

```json
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ Your agent will automatically use the appropriate tools to query your database.
"username": "user", // Required for most databases
"password": "pass", // Required for most databases
"read_only": true, // Optional: default true (recommended)
"driver": "ODBC Driver 17 for SQL Server",
// Optional: mssql only, default "ODBC Driver 17 for SQL Server"
"pool_size": 5, // Optional: connection pool size (default 5)
"max_overflow": 2, // Optional: max extra connections (default 2)
"pool_timeout": 30 // Optional: connection timeout (default 30s)
Expand Down
5 changes: 3 additions & 2 deletions src/db_mcp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self, name: str, config: Dict[str, Any]):
self.pool_size = config.get("pool_size", 5)
self.max_overflow = config.get("max_overflow", 2)
self.pool_timeout = config.get("pool_timeout", 30)
self.driver = config.get("driver", "ODBC Driver 17 for SQL Server") # For SQL Server

# Validate configuration
self._validate()
Expand Down Expand Up @@ -83,8 +84,8 @@ def get_connection_string(self) -> str:
return f"mysql+mysqlconnector://{auth}{self.host}{port_str}/{self.database}"
elif self.type == "mssql":
# For SQL Server, we need to specify the driver
driver = "ODBC+Driver+17+for+SQL+Server"
return f"mssql+pyodbc://{auth}{self.host}{port_str}/{self.database}?driver={driver}"
driver = self.driver.replace(" ", "+") # Encode spaces for URL
return f"mssql+pyodbc://{auth}{self.host}{port_str}/{self.database}?driver={driver}&encrypt=no"

raise ValueError(f"Unknown database type: {self.type}")

Expand Down
13 changes: 12 additions & 1 deletion src/db_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ def generate_example_config():
"type": "sqlite",
"path": "./database.db",
"read_only": False
},
"my_mssql_db": {
"type": "mssql",
"host": "localhost",
"port": 1433,
"database": "mydb",
"username": "root",
"password": "password",
"driver": "ODBC Driver 18 for SQL Server",
"read_only": True
}
}
}
Expand All @@ -207,10 +217,11 @@ def generate_example_config():
print("\n" + "="*60)
print("SUCCESS: config.json created!")
print("="*60)
print("\nGenerated example configuration file with 3 databases:")
print("\nGenerated example configuration file with 4 databases:")
print(" - my_postgres_db (PostgreSQL)")
print(" - my_mysql_db (MySQL)")
print(" - my_sqlite_db (SQLite)")
print(" - my_mssql_db (SQL Server)")
print("\nNext steps:")
print("1. Edit config.json with your actual database details")
print("2. Remove database entries you don't need")
Expand Down