logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

unified_db_accessor_service

A comprehensive service tool enabling interaction with diverse relational database environments. It facilitates the execution of structured query language (SQL) statements, definition/modification of data schemas, and management of transactional boundaries across supported systems like SQLite, PostgreSQL, MySQL/MariaDB, and MS SQL Server, all through a standardized gateway.

Author

unified_db_accessor_service logo

georgi-terziyski

No License

Quick Info

GitHub GitHub Stars 3
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

databasesdatabasedatabase_mcp_serverterziyski database_mcp_servervarious databasedatabase systems

Universal Database Connectivity Agent (UDCA)

This Model Context Protocol (MCP) agent furnishes the necessary mechanisms for interfacing with and manipulating various backend data persistence layers.

Core Capabilities

  • Polyglot DB Support: Seamless connection to SQLite, Postgres, MySQL/MariaDB, and SQL Server instances.
  • Standardized Abstraction: Presents a consistent set of operations irrespective of the underlying database technology.
  • Platform-Specific Overrides: Allows invocation of proprietary database features when necessary.
  • Structure Definition Control: Tools for defining, amending, and erasing database constructs (tables, indexes).
  • Statement Dispatch: Capabilities for submitting both native SQL commands and utilizing abstracted data manipulation methods.
  • Transactional Control: Features to demarcate, finalize (commit), or undo (rollback) multi-step operations.

Deployment Prerequisites

Necessary Components

  • Python interpreter version 3.8 or newer is mandatory.
  • Required Python libraries (installable via pip):
  • SQLAlchemy (core dependency)
  • Database-specific drivers:
    • SQLite: Bundled with Python.
    • PostgreSQL: psycopg2-binary
    • MySQL/MariaDB: mysql-connector-python
    • SQL Server: pyodbc

Source Code Installation

bash

Obtain source repository

git clone

Install in editable mode

pip install -e .

Configuration Regimen

The agent's behavior is tunable via environment variables, a configuration file, or direct runtime specification of connection parameters.

Environment Variables Utilization

  • DB_CONFIG_PATH: Specifies the filesystem location of a JSON configuration document.
  • DB_CONNECTIONS: A list of connection identifiers or a JSON payload defining connection metadata.

Configuration File Structure (JSON)

{ "connections": { "local_sqla": { "type": "sqlite", "db_path": "/absolute/path/to/data.db" }, "remote_pg": { "type": "postgres", "host": "db.example.com", "port": 5432, "database": "production_data", "user": "app_user", "password": "secure_pwd" } } }

Operational Guidance

Launching the Agent

As an MCP Handler for a Target System

bash

Launch with default setup

python -m db_mcp_server

Reference an external configuration file

python -m db_mcp_server --config /path/to/settings.json

Adjust logging verbosity

python -m db_mcp_server --log-level INFO

As a Networked Data Service (For any consuming LLM)

bash

Initiate the HTTP endpoint service

python -m db_mcp_server.web_server

Bind to a specific network interface and port

python -m db_mcp_server.web_server --host 127.0.0.1 --port 8888

Specify configuration source and diagnostic output level

python -m db_mcp_server.web_server --config /path/to/settings.json --log-level WARNING

Exposed Toolset

Connection Lifecycle Administration

  • add_connection: Registers a new connection profile.
  • test_connection: Validates connectivity to a configured data source.
  • list_connections: Retrieves a roster of active connection identifiers.
  • remove_connection: Deactivates and discards a connection profile.

Data Manipulation & Retrieval

  • execute_query: Runs arbitrary SQL statements.
  • get_records: Fetches result sets from a specified table.
  • insert_record: Adds a new row of data.
  • update_record: Modifies existing data entries.
  • delete_record: Erases specified data entries.

Metadata and Structure Definition

  • list_tables: Enumerates all accessible tables within the selected database context.
  • get_table_schema: Retrieves the column structure definition for a given table.
  • create_table: Provisions a new table structure.
  • drop_table: Deletes an entire table.
  • create_index: Establishes an index for optimized lookups.
  • drop_index: Removes an existing index.
  • alter_table: Changes the structure (e.g., adding columns) of an existing table.

Transactional Integrity

  • begin_transaction: Initiates a new atomic unit of work.
  • commit_transaction: Permanently saves changes within the current unit.
  • rollback_transaction: Undoes all operations since the transaction began.

Operational Demonstrations

{ "connection_id": "local_sqla", "type": "sqlite", "db_path": "/data/system.db" }

Executing a Query Statement

{ "connection_id": "local_sqla", "query": "SELECT username, created_at FROM users WHERE status = ?;", "params": ["active"] }

Instantiating a Table

{ "connection_id": "local_sqla", "table": "audit_log", "columns": [ { "name": "log_id", "type": "BIGINT", "primary_key": true, "nullable": false }, { "name": "event_type", "type": "VARCHAR(50)", "nullable": false }, { "name": "details", "type": "TEXT", "nullable": true } ] }

Inputting Data Records

{ "connection_id": "local_sqla", "table": "audit_log", "data": { "event_type": "USER_LOGIN", "details": "Successful authentication for user ID 42" } }

Development Context

Automated Validation

bash

Execute the complete test suite

python -m unittest discover

Target a specific validation file

python -m unittest tests.test_postgres_integration

External LLM Interfacing

When operating in networked web service mode, external agents (like alternative LLMs) interact via standard HTTP calls. The agent exposes the following interaction points:

Network Interface Endpoints

  • /list_tools - HTTP GET or POST: Returns a structured manifest of all callable tools and their input expectations.
  • /call_tool - HTTP POST only: Used to dispatch a command to the database agent.

Example Invocation Schema (For a client LLM)

Instructing another language model (e.g., Llama 3) on how to use this database proxy:

Your interface to the database system is an HTTP service located at http://localhost:8000. Use the following methods:

  1. To enumerate available functions: Issue a POST request to: http://localhost:8000/list_tools

  2. To execute a defined operation: Issue a POST request to: http://localhost:8000/call_tool The body must be JSON, structured as: { "name": "tool_identifier", "arguments": { "parameter_a": "input_for_a", "parameter_b": "input_for_b" } }

For instance, to retrieve records from the 'products' table using connection 'store_db': POST http://localhost:8000/call_tool Content-Type: application/json

{ "name": "get_records", "arguments": { "connection_id": "store_db", "table": "products", "limit": 10 } }

Client Integration Snippet (Python Reference)

python import requests import json

Service Root URI

SERVICE_ROOT = "http://localhost:8000"

Obtain tool manifest

def fetch_tool_definitions(): response = requests.post(f"{SERVICE_ROOT}/list_tools") return response.json()

Dispatch a function call

def invoke_agent_function(function_name, parameters_dict): request_body = { "name": function_name, "arguments": parameters_dict } response = requests.post(f"{SERVICE_ROOT}/call_tool", json=request_body) return response.json()

Example: Listing tables

def check_table_inventory(conn_id): return invoke_agent_function("list_tables", {"connection_id": conn_id})

Example: Executing complex SQL

def run_custom_sql(conn_id, sql_text, input_vars=None): return invoke_agent_function("execute_query", { "connection_id": conn_id, "query": sql_text, "params": input_vars or [] })

Example: Provisioning a database link

def establish_link(conn_id, db_dialect, settings): payload = {"connection_id": conn_id, "type": db_dialect} payload.update(settings) return invoke_agent_function("add_connection", payload)

Licensing

This software is released under the terms of the MIT License

WIKIPEDIA: The XMLHttpRequest (XHR) object represents an API within JavaScript that facilitates the transmission of HTTP requests from a client-side web environment to a remote server. These methods enable web applications to asynchronously request and receive data post-initial page load. XHR is foundational to the Asynchronous JavaScript and XML (Ajax) programming paradigm. Before Ajax, the dominant methods for server communication involved full page refreshes triggered by hyperlink navigation or form submissions.

== Historical Overview == The conceptual underpinning for XMLHttpRequest originated around 2000, developed by the team responsible for Microsoft Outlook. It was first integrated into the Internet Explorer 5 browser release in 1999. However, the initial implementation did not utilize the standardized XMLHttpRequest naming; developers instead relied on COM identifiers like ActiveXObject("Msxml2.XMLHTTP") and ActiveXObject("Microsoft.XMLHTTP"). By the time Internet Explorer 7 shipped in 2006, robust support for the canonical XMLHttpRequest identifier was universal.

Today, XMLHttpRequest serves as the established convention across all major browser engines, including Mozilla's Gecko (2002 adoption), Apple's WebKit/Safari 1.2 (2004), and Opera (8.0 in 2005).

=== Standardization Efforts === The World Wide Web Consortium (W3C) published an initial Working Draft specification for the XMLHttpRequest object on April 5, 2006. This was followed by a Level 2 Working Draft published February 25, 2008, which introduced features for monitoring request progress, enabling cross-origin access, and managing binary data streams. By the close of 2011, the Level 2 enhancements were merged back into the primary specification document. Since late 2012, development authority has transitioned to the WHATWG, which maintains the current, evolving specification using Web IDL definitions.

== Standard Operational Flow == Executing a data request using XMLHttpRequest generally involves a sequence of programming steps:

  1. Instantiation: Create an instance of the XMLHttpRequest object via its constructor.
  2. Configuration: Invoke the open() method to define the request method (GET, POST, etc.), target URI, and whether the operation should be synchronous or asynchronous.
  3. Event Binding: For asynchronous operations, establish a callback function (listener) registered to handle state transitions.
  4. Transmission: Launch the request by calling the send() method, optionally passing body data.
  5. Response Handling: Monitor the state changes via the event listener. Upon reaching state 4 (the 'done' state), the server's result is typically available in the responseText property.

Beyond these core steps, XHR offers fine-grained control. Custom headers can be injected to instruct the server on response formatting. Data can be uploaded within the send() call. Responses can be immediately parsed from JSON into native JavaScript structures or streamed incrementally. Furthermore, requests can be terminated early or configured with a timeout limit.

== Cross-Origin Communications (CORS) ==

In the nascent stages of the World Wide Web, security restrictions prohibited scripts loaded from one domain from directly making requests to resources hosted on a different domain. This limitation was implemented to prevent malicious sites from snooping on user data from other services.

See Also

`