phanithlim/sql-mpc-server
3.1
If you are the rightful owner of sql-mpc-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A FastAPI-based, read-only server for managing and querying SQL databases using the Model Context Protocol (MCP).
SQL MCP Server
A FastAPI-based, read-only server for managing and querying SQL databases using the Model Context Protocol (MCP). This is a simple template for an MCP server designed to interact with SQL databases in a read-only mode.
Installation
Install UV package manager:
curl -LsSf https://astral.sh/uv/install.sh | sh
or pipx
pip install uv
Install Dependencies
uv sync
Usage
Run MCP Server Inspector:
make mcp-dev
Run the FastAPI application:
make dev
Project Structure
āāā app.py # FastAPI application entry point
āāā Dockerfile # Containerization support
āāā pyproject.toml # Project metadata and dependencies
āāā uv.lock # uv dependency lock file
āāā config.json # Configuration file for MCP server
āāā tools/
ā āāā server.py # Server logic for FastMCP
ā āāā model.py # Response models for FastMCP
ā āāā helpers.py # Helper functions for FastMCP
ā āāā __init__.py
āāā README.md # Project documentation
Features
get_all_tables
: Retrieve a list of tables in the database.get_table_info
: Get information about a specific table.get_table_description
: Retrieves the description of a specific table from the config file (useful if tables or columns have short names).get_all_table_descriptions
: Retrieves descriptions of all tables from the config file (useful if tables or columns have short names).execute_query
: Execute a SQL query and return the results.
Deployment
Docker
Build the Docker image:
docker build -t mcp-server .
Run the Docker container:
docker run -d -p 8000:8000 mcp-server
- MCP server url:
http://localhost:8000/mcp/sse