A powerful Model Context Protocol (MCP) server that provides contextual database schema information for large Oracle databases, enabling AI assistants to understand and work with databases containing thousands of tables.
- Overview
- Features
- Usage
- Architecture
- System Requirements
- Performance Considerations
- Contributing
- License
- Support
The MCP Oracle DB Context server solves a critical challenge when working with very large Oracle databases: how to provide AI models with accurate, relevant database schema information without overwhelming them with tens of thousands of tables and relationships.
By intelligently caching and serving database schema information, this server allows AI assistants to:
- Look up specific table schemas on demand
- Search for tables that match specific patterns
- Understand table relationships and foreign keys
- Get database vendor information
- Smart Schema Caching: Builds and maintains a local cache of your database schema to minimize database queries
- Targeted Schema Lookup: Retrieve schema for specific tables without loading the entire database structure
- Table Search: Find tables by name pattern matching
- Relationship Mapping: Understand foreign key relationships between tables
- Oracle Database Support: Built specifically for Oracle databases
- MCP Integration: Works seamlessly with GitHub Copilot in VSCode, Claude, ChatGPT, and other AI assistants that support MCP
To use this MCP server with GitHub Copilot in VSCode Insiders, follow these steps:
-
Install VSCode Insiders
- Download and install the latest version of VSCode Insiders
-
Install GitHub Copilot Extension
- Open VSCode Insiders
- Go to the Extensions marketplace
- Search for and install "GitHub Copilot"
-
Configure MCP Server
- Recommended: Using Docker
- Alternative: Using UV
-
Enable Agent Mode
- Open Copilot chat in VSCode Insiders
- Click on "Copilot Edits"
- Choose "Agent mode"
- Click the refresh button in the chat input to load the available tools
After completing these steps, you'll have access to all database context tools through GitHub Copilot's chat interface.
"mcp": {
"inputs": [],
"servers": {
"db-context": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"ORACLE_CONNECTION_STRING",
"-e",
"TARGET_SCHEMA",
"-e",
"CACHE_DIR",
"dmeppiel/mcp-db-context"
],
"env": {
"ORACLE_CONNECTION_STRING":"user/pass@localhost:1521/mydb",
"TARGET_SCHEMA":"",
"CACHE_DIR":".cache",
}
}
}
}
This option requires installing and setting up the project locally:
-
Prerequisites
- Python 3.12 or higher
- Oracle database access
- Oracle instant client (required for the
oracledb
Python package)
-
Install UV
# Install uv using curl (macOS/Linux) curl -LsSf https://astral.sh/uv/install.sh | sh # Or using PowerShell (Windows) irm https://astral.sh/uv/install.ps1 | iex
Make sure to restart your terminal after installing uv.
-
Project Setup
# Clone repository git clone https://github.com/yourusername/mcp-db-context.git cd mcp-db-context # Create and activate virtual environment uv venv # Activate (On Unix/macOS) source .venv/bin/activate # Activate (On Windows) .venv\Scripts\activate # Install dependencies uv pip install -e .
-
Configure VSCode Settings
"mcp": { "inputs": [], "servers": { "db-context": { "command": "/path/to/your/.local/bin/uv", "args": [ "--directory", "/path/to/your/mcp-db-context", "run", "main.py" ], "env": { "ORACLE_CONNECTION_STRING":"user/pass@localhost:1521/mydb", "TARGET_SCHEMA":"", "CACHE_DIR":".cache", } } } }
- Replace the paths with your actual uv binary path and mcp-db-context directory path
For both options:
- Replace the
ORACLE_CONNECTION_STRING
with your actual database connection string - The
TARGET_SCHEMA
is optional, it will default to the user's schema - The
CACHE_DIR
is optional, defaulting to.cache
within the MCP server root folder
To run the MCP server directly:
uv run main.py
For development and testing:
# Install the MCP Inspector
uv pip install mcp-cli
# Test with MCP Inspector
mcp dev main.py
# Or install in Claude Desktop
mcp install main.py
When connected to an AI assistant like GitHub Copilot in VSCode Insiders or Claude, the following tools will be available:
Get detailed schema information for a specific table including columns, data types, nullability, and relationships. Example:
Can you show me the schema for the EMPLOYEES table?
Get schema information for multiple tables at once. More efficient than calling get_table_schema multiple times. Example:
Please provide the schemas for both EMPLOYEES and DEPARTMENTS tables.
Search for tables by name pattern and retrieve their schemas. Example:
Find all tables that might be related to customers and show their schemas.
Force a rebuild of the schema cache. Use sparingly as this is resource-intensive. Example:
The database structure has changed. Could you rebuild the schema cache?
Get information about the connected Oracle database version and schema. Example:
What Oracle database version are we running?
Search for tables containing columns that match a specific term. Useful when you know what data you need but aren't sure which tables contain it. Example:
Which tables have columns related to customer_id?
Get information about PL/SQL objects like procedures, functions, packages, triggers, etc. Example:
Show me all stored procedures that start with 'CUSTOMER_'
Retrieve the source code for a PL/SQL object. Useful for debugging and understanding database logic. Example:
Can you show me the source code for the CUSTOMER_UPDATE_PROC procedure?
Get all constraints (primary keys, foreign keys, unique constraints, check constraints) for a table. Example:
What constraints are defined on the ORDERS table?
Get all indexes defined on a table, helpful for query optimization. Example:
Show me all indexes on the CUSTOMERS table.
Find all objects that depend on a specified database object. Example:
What objects depend on the CUSTOMER_VIEW view?
Get information about user-defined types in the database. Example:
Show me all custom types defined in the schema.
Get all tables that are related to a specified table through foreign keys, showing both incoming and outgoing relationships. Example:
What tables are related to the ORDERS table?
This MCP server employs a three-layer architecture optimized for large-scale Oracle databases:
-
DatabaseConnector Layer
- Manages Oracle database connections and query execution
- Implements connection pooling and retry logic
- Handles raw SQL operations
-
SchemaManager Layer
- Implements intelligent schema caching
- Provides optimized schema lookup and search
- Manages the persistent cache on disk
-
DatabaseContext Layer
- Exposes high-level MCP tools and interfaces
- Handles authorization and access control
- Provides schema optimization for AI consumption
- Python: Version 3.12 or higher (required for optimal performance)
- Memory: 4GB+ available RAM for large databases (10,000+ tables)
- Disk: Minimum 500MB free space for schema cache
- Oracle: Compatible with Oracle Database 11g and higher
- Network: Stable connection to Oracle database server
- Initial cache building may take 5-10 minutes for very large databases
- Subsequent startups typically take less than 30 seconds
- Schema lookups are generally sub-second after caching
- Memory usage scales with active schema size
We welcome contributions! Please see our Contributing Guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Create an issue in this GitHub repository