mirror of
https://github.com/executeautomation/mcp-database-server.git
synced 2025-12-09 21:12:57 +08:00
Added support for SQL Server
This commit is contained in:
279
readme.md
279
readme.md
@@ -1,202 +1,115 @@
|
||||
# ExecuteAutomation Database Server
|
||||
# MCP Database Server
|
||||
|
||||
A Model Context Protocol server that provides access to SQLite databases. This server enables LLMs like Claude to inspect database schemas and execute SQL queries.
|
||||
This MCP (Model Context Protocol) server provides database access capabilities to Claude, supporting both SQLite and SQL Server databases.
|
||||
|
||||
## Components
|
||||
## Installation
|
||||
|
||||
### Tools
|
||||
|
||||
The server offers nine core tools:
|
||||
|
||||
#### Query Tools
|
||||
- **read_query**
|
||||
- Execute SELECT queries to read data from the database
|
||||
- Input:
|
||||
- `query` (string): The SELECT SQL query to execute
|
||||
- Returns: Query results as array of objects
|
||||
|
||||
- **write_query**
|
||||
- Execute INSERT, UPDATE, or DELETE queries
|
||||
- Input:
|
||||
- `query` (string): The SQL modification query
|
||||
- Returns: `{ affected_rows: number }`
|
||||
|
||||
#### Schema Management Tools
|
||||
- **create_table**
|
||||
- Create new tables in the database
|
||||
- Input:
|
||||
- `query` (string): CREATE TABLE SQL statement
|
||||
- Returns: Confirmation of table creation
|
||||
|
||||
- **alter_table**
|
||||
- Modify existing table schema (add columns, rename tables, etc.)
|
||||
- Input:
|
||||
- `query` (string): ALTER TABLE SQL statement
|
||||
- Returns: Confirmation of table alteration
|
||||
|
||||
- **drop_table**
|
||||
- Remove a table from the database with safety confirmation
|
||||
- Input:
|
||||
- `table_name` (string): Name of the table to drop
|
||||
- `confirm` (boolean): Safety confirmation flag (must be true to actually drop)
|
||||
- Returns: Confirmation message or safety warning
|
||||
|
||||
#### Schema Information Tools
|
||||
- **list_tables**
|
||||
- Get a list of all tables in the database
|
||||
- No input required
|
||||
- Returns: Array of table names
|
||||
|
||||
- **describe_table**
|
||||
- View schema information for a specific table
|
||||
- Input:
|
||||
- `table_name` (string): Name of table to describe
|
||||
- Returns: Array of column definitions with names and types
|
||||
|
||||
#### Data Export Tools
|
||||
- **export_query**
|
||||
- Export query results to various formats
|
||||
- Input:
|
||||
- `query` (string): The SELECT SQL query to execute
|
||||
- `format` (string): Output format - either "csv" or "json"
|
||||
- Returns: Query results formatted as CSV or JSON
|
||||
|
||||
#### Insights
|
||||
- **append_insight**
|
||||
- Add a business insight to the memo
|
||||
- Input:
|
||||
- `insight` (string): Business insight discovered from data analysis
|
||||
- Returns: Confirmation message
|
||||
|
||||
### Resources
|
||||
|
||||
The server provides schema information for each table in the database:
|
||||
|
||||
- **Table Schemas** (`sqlite:///<path>/<table>/schema`)
|
||||
- JSON schema information for each table
|
||||
- Includes column names and data types
|
||||
- Automatically discovered from database metadata
|
||||
|
||||
## Usage with Claude Desktop
|
||||
|
||||
To use this server with the Claude Desktop app, add the following configuration to the "mcpServers" section of your `claude_desktop_config.json`:
|
||||
|
||||
### Docker
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"database": {
|
||||
"command": "docker",
|
||||
"args": [
|
||||
"run",
|
||||
"-i",
|
||||
"--rm",
|
||||
"executeautomation/database-server",
|
||||
"/path/to/database.db"]
|
||||
}
|
||||
}
|
||||
}
|
||||
1. Clone the repository:
|
||||
```
|
||||
git clone https://github.com/executeautomation/database-server.git
|
||||
cd database-server
|
||||
```
|
||||
|
||||
### NPX (Published Package)
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"database": {
|
||||
"command": "npx",
|
||||
"args": [
|
||||
"-y",
|
||||
"@executeautomation/database-server",
|
||||
"/path/to/database.db"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
2. Install dependencies:
|
||||
```
|
||||
|
||||
### Local Development
|
||||
|
||||
For local development and debugging, you can point directly to your compiled JavaScript file:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"database": {
|
||||
"command": "node",
|
||||
"args": [
|
||||
"/path/to/your/project/dist/index.js",
|
||||
"/path/to/your/database.db"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Example with full paths:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"database": {
|
||||
"command": "node",
|
||||
"args": [
|
||||
"/Users/username/projects/database-server/dist/index.js",
|
||||
"/Users/username/databases/mydata.db"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The Claude Desktop config file is typically located at:
|
||||
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
||||
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
||||
- Linux: `~/.config/Claude/claude_desktop_config.json`
|
||||
|
||||
Replace all paths with your actual file paths.
|
||||
|
||||
## Building and Development
|
||||
|
||||
### Quick Build
|
||||
|
||||
Use the included build script to install dependencies and build the project:
|
||||
|
||||
```sh
|
||||
chmod +x build.sh
|
||||
./build.sh
|
||||
```
|
||||
|
||||
### Manual Build Steps
|
||||
|
||||
```sh
|
||||
# Install dependencies
|
||||
npm install
|
||||
```
|
||||
|
||||
# Build the TypeScript
|
||||
3. Build the project:
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Docker Build
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
docker build -t executeautomation/database-server -f Dockerfile .
|
||||
### SQLite Database
|
||||
|
||||
To use with an SQLite database:
|
||||
|
||||
```
|
||||
node dist/src/index.js /path/to/your/database.db
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
### SQL Server Database
|
||||
|
||||
If you encounter connection issues:
|
||||
To use with a SQL Server database:
|
||||
|
||||
1. Make sure the database file path is correct and accessible
|
||||
2. Verify that the compiled JavaScript file exists at the specified path
|
||||
3. Check the Claude Desktop logs for detailed error messages
|
||||
4. Restart Claude Desktop after making configuration changes
|
||||
```
|
||||
node dist/src/index.js --sqlserver --server <server-name> --database <database-name> [--user <username> --password <password>]
|
||||
```
|
||||
|
||||
Required parameters:
|
||||
- `--server`: SQL Server host name or IP address
|
||||
- `--database`: Name of the database
|
||||
|
||||
Optional parameters:
|
||||
- `--user`: Username for SQL Server authentication (if not provided, Windows Authentication will be used)
|
||||
- `--password`: Password for SQL Server authentication
|
||||
- `--port`: Port number (default: 1433)
|
||||
|
||||
## Configuring Claude
|
||||
|
||||
Update your Claude configuration file to add the MCP Database Server:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"sqlite": {
|
||||
"command": "node",
|
||||
"args": [
|
||||
"/path/to/mcp-database-server/dist/src/index.js",
|
||||
"/path/to/your/database.db"
|
||||
]
|
||||
},
|
||||
"sqlserver": {
|
||||
"command": "node",
|
||||
"args": [
|
||||
"/path/to/mcp-database-server/dist/src/index.js",
|
||||
"--sqlserver",
|
||||
"--server", "your-server-name",
|
||||
"--database", "your-database-name",
|
||||
"--user", "your-username",
|
||||
"--password", "your-password"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Available Tools
|
||||
|
||||
The MCP Database Server provides the following tools:
|
||||
|
||||
- `read_query`: Execute SELECT queries to read data from the database
|
||||
- `write_query`: Execute INSERT, UPDATE, or DELETE queries
|
||||
- `create_table`: Create new tables in the database
|
||||
- `alter_table`: Modify existing table schema (add columns, rename tables, etc.)
|
||||
- `drop_table`: Remove a table from the database with safety confirmation
|
||||
- `export_query`: Export query results to various formats (CSV, JSON)
|
||||
- `list_tables`: Get a list of all tables in the database
|
||||
- `describe_table`: View schema information for a specific table
|
||||
- `append_insight`: Add a business insight to the memo
|
||||
- `list_insights`: List all business insights in the memo
|
||||
|
||||
## Development
|
||||
|
||||
To run the server in development mode:
|
||||
|
||||
```
|
||||
npm run dev
|
||||
```
|
||||
|
||||
To watch for changes during development:
|
||||
|
||||
```
|
||||
npm run watch
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- Node.js 18+
|
||||
- For SQL Server connectivity: SQL Server 2012 or later
|
||||
|
||||
## License
|
||||
|
||||
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License.
|
||||
|
||||
## About ExecuteAutomation
|
||||
|
||||
This server is maintained by ExecuteAutomation. Visit [executeautomation.com](https://executeautomation.com) for more tools and resources.
|
||||
MIT
|
||||
|
||||
Reference in New Issue
Block a user