Oracle MCP Server
README.md
# Oracle MCP Server
A standalone Model Context Protocol (MCP) server for Oracle Database operations, built following the Deer Flow configuration standards.
## Features
- **Query Execution**: Execute SQL queries with result streaming
- **Schema Discovery**: List schemas, tables, and describe table structures
- **Stored Procedures**: Execute Oracle stored procedures and functions
- **Statistics**: Get table and index statistics
- **Connection Pooling**: Efficient connection management
- **Security**: Optional read-only mode and query validation
- **Configuration**: Flexible YAML and environment-based configuration
## Installation
### Prerequisites
- Python 3.12 or higher
- Oracle Database (11g or higher)
- Oracle Instant Client (optional, for thick mode)
### Using uv (Recommended)
```bash
# Clone the repository
git clone <repository-url>
cd oracle-mcp-server
# Install dependencies
uv sync
# Copy configuration files
cp .env.example .env
cp conf.yaml.example conf.yaml
# Edit configuration
nano .env # or your preferred editor
nano conf.yaml
```
### Using pip
```bash
pip install -e .
```
## Configuration
### Environment Variables (.env)
The server can be configured using environment variables:
```bash
ORACLE_DB_CONNECTION_STRING=system/password@localhost:1521/XEPDB1
ORACLE_DB_READ_ONLY=false
ORACLE_DB_MAX_ROWS=1000
```
See `.env.example` for all available options.
### YAML Configuration (conf.yaml)
For more detailed configuration, use the YAML file:
```yaml
database:
connection_string: system/password@localhost:1521/XEPDB1
pool:
min: 1
max: 5
read_only: false
tools:
enabled:
- query_database
- describe_table
- list_tables
```
See `conf.yaml.example` for all available options.
## Usage
### Running the Server
#### Stdio Mode (Default)
```bash
# Using uv
uv run oracle-mcp-server
# Or directly
python -m oracle_mcp.server
```
#### SSE Mode (HTTP Server)
```bash
uv run oracle-mcp-server --mode sse --port 3000
```
### Integration with Deer Flow
Add to your Deer Flow MCP settings:
```json
{
"mcp_settings": {
"servers": {
"oracle-db": {
"transport": "stdio",
"command": "uv",
"args": ["run", "oracle-mcp-server"],
"env": {
"ORACLE_DB_CONNECTION_STRING": "user/pass@host:1521/service"
},
"enabled_tools": [
"query_database",
"describe_table",
"list_tables"
],
"add_to_agents": ["researcher", "coder"]
}
}
}
}
```
### Integration with Claude Desktop
Add to `claude_desktop_config.json`:
```json
{
"mcpServers": {
"oracle": {
"command": "uv",
"args": ["run", "oracle-mcp-server"],
"env": {
"ORACLE_DB_CONNECTION_STRING": "system/password@localhost:1521/XEPDB1"
}
}
}
}
```
## Available Tools
### 1. query_database
Execute SQL queries and return results.
**Parameters:**
- `query` (string): SQL query to execute
- `max_rows` (optional, int): Maximum rows to return
**Example:**
```sql
SELECT * FROM employees WHERE department_id = 10
```
### 2. describe_table
Get detailed information about a table structure.
**Parameters:**
- `table_name` (string): Name of the table
- `schema_name` (optional, string): Schema name
**Example:**
```
EMPLOYEES
```
### 3. list_tables
List all tables in a schema.
**Parameters:**
- `schema_name` (optional, string): Schema name (defaults to current user)
- `pattern` (optional, string): Filter tables by pattern
**Example:**
```
schema_name: HR
pattern: EMP%
```
### 4. list_schemas
List all schemas accessible to the current user.
### 5. execute_procedure
Execute Oracle stored procedures and functions.
**Parameters:**
- `procedure_name` (string): Name of the procedure/function
- `parameters` (optional, dict): Input parameters
### 6. get_table_stats
Get statistics for a table (row count, size, indexes).
**Parameters:**
- `table_name` (string): Name of the table
- `schema_name` (optional, string): Schema name
## Security Considerations
### Read-Only Mode
Enable read-only mode to prevent DDL/DML operations:
```yaml
database:
read_only: true
```
### Connection Security
- Use strong passwords
- Configure Oracle network encryption
- Use Oracle Wallet for credential management
- Restrict network access with firewalls
### Query Validation
The server validates queries to prevent:
- SQL injection attempts
- Dangerous operations in read-only mode
- Excessive resource consumption
## Development
### Running Tests
```bash
# Install dev dependencies
uv sync --extra dev
# Run tests
pytest
# Run with coverage
pytest --cov=src/oracle_mcp --cov-report=term-missing
```
### Code Formatting
```bash
# Format code
ruff format .
# Lint code
ruff check .
```
## Troubleshooting
### Connection Issues
1. Verify Oracle Database is running
2. Check connection string format
3. Ensure network access to database server
4. Verify Oracle client installation
### Thick Mode Issues
If using thick mode:
```bash
# Install Oracle Instant Client
# Download from: https://www.oracle.com/database/technologies/instant-client.html
# Set environment variable
export ORACLE_DB_THICK_LIB_DIR=/path/to/instantclient
```
### Performance Issues
- Adjust connection pool settings
- Enable connection pooling
- Optimize queries
- Use result pagination
## License
MIT License - See LICENSE file for details
## Contributing
Contributions are welcome! Please:
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request
## References
- [Model Context Protocol](https://modelcontextprotocol.io/)
- [Oracle python-oracledb Documentation](https://python-oracledb.readthedocs.io/)
- [Deer Flow Project](https://github.com/bytedance/deer-flow)
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessOutdated data