FastMCP SQLite Server
Provides tools for managing and inspecting a SQLite database, including retrieving database stats and schema, listing/searching/creating/updating/deleting user records, and executing safe read-only SQL queries (SELECT, PRAGMA, EXPLAIN) against the database.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@FastMCP SQLite Servershow me the database schema and total user count"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
FastMCP SQLite Server š
A production-ready Model Context Protocol (MCP) server built with FastMCP and FastAPI, providing database management tools for AI assistants alongside a RESTful HTTP administration API and a modern web user signup portal.
⨠Features
š§ Model Context Protocol (MCP) Integration: Exposes standard MCP tools (
get_database_stats,inspect_database_schema,list_users,get_user_by_id,create_new_user,update_user,delete_user,run_readonly_sql) for AI assistants (Cursor, Claude Desktop, Gemini, MCP Inspector).š RESTful HTTP API: Custom HTTP routes under
/mcp/db/...to query, create, update, delete, and inspect SQLite records directly using standard HTTP clients (curl, browser, frontend).šØ Modern Web UI: Responsive sign-up page (
/auth/signupand/signup) featuring Plus Jakarta Sans typography, live password strength indicator, show/hide password toggle, and asynchronous form submission.š Security & Safety:
Passwords hashed before database persistence.
Guarded read-only SQL endpoint (
SELECT,PRAGMA,EXPLAINonly) preventing unintended database modifications.Parameterized queries via SQLAlchemy preventing SQL injection.
ā” Dual Mode Execution: Run as a unified FastAPI web server (with MCP mounted at
/mcp) or as an independent standalone FastMCP server.
Related MCP server: mcp-to-db
š Project Structure
āāā main.py # FastAPI application entrypoint with mounted routers & FastMCP
āāā mcp_server.py # FastMCP server with MCP tools and HTTP database management routes
āāā user_signup.py # User registration route and template server
āāā get_user.py # User query and pagination route
āāā init_data.py # Database initialization and mock data generator
āāā templates/
ā āāā signup.html # Responsive, glassmorphic sign-up page UI
āāā requirements.txt # Python package dependencies
āāā .env.example # Sample environment variables template
āāā .gitignore # Ignored files (virtual environments, database, secrets)š Getting Started
1. Prerequisites
Python 3.10+
uv(recommended) or standardpip
2. Installation
Clone the repository and install dependencies:
git clone https://github.com/saadsh15/FastMCP_sqlite_server.git
cd FastMCP_sqlite_server
# Using uv (recommended)
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt
# Or using standard pip
python -m venv env
source env/bin/activate
pip install -r requirements.txt3. Initialize the Database (Optional)
To initialize the SQLite database (arzonama.db) and populate it with sample mock user records:
python init_data.pyš„ļø Running the Application
Option A: Run Unified FastAPI Server (Default)
Runs the main FastAPI web application, mounting the web UI, REST API, and FastMCP server on port 8000:
uv run fastapi dev
# or
uvicorn main:app --reloadOnce running:
Web Sign-up Page: http://127.0.0.1:8000/auth/signup (or
/signup)FastAPI OpenAPI Docs: http://127.0.0.1:8000/docs
FastMCP HTTP Routes: http://127.0.0.1:8000/mcp/db/stats
MCP Protocol Endpoint: http://127.0.0.1:8000/mcp/mcp
Option B: Run FastMCP Standalone
Runs the FastMCP server independently on port 8001:
python mcp_server.pyOption C: Run FastMCP Dev Inspector
Use the FastMCP developer inspector UI:
fastmcp dev mcp_server.pyš ļø MCP Tools Reference
When connecting an MCP-compatible client (such as Claude Desktop or Cursor), the following tools are available:
Tool Name | Parameters | Description |
| None | Returns database size, user counts, and latest signup. |
| None | Introspects tables, columns, constraints, and indexes. |
|
| Queries users with search and pagination filters. |
|
| Fetches details of a single user by ID. |
|
| Inserts a new user with hashed password. |
|
| Updates user attributes. |
|
| Deletes a user by ID. |
|
| Executes safe |
š” HTTP API Reference
All database management HTTP endpoints are available under /mcp/db:
1. Database Stats
GET /mcp/db/stats
curl -s http://127.0.0.1:8000/mcp/db/stats{
"database": "arzonama.db",
"file_size_mb": 8.24,
"total_users": 50000,
"premium_users": 0,
"standard_users": 50000,
"newest_signup": "2026-10-07T17:22:31"
}2. Schema Introspection
GET /mcp/db/schema
curl -s http://127.0.0.1:8000/mcp/db/schema3. List / Search Users
GET /mcp/db/users?search=alice&limit=10&offset=0
curl -s "http://127.0.0.1:8000/mcp/db/users?search=alice&limit=2"4. Create User
POST /mcp/db/users
curl -X POST http://127.0.0.1:8000/mcp/db/users \
-H "Content-Type: application/json" \
-d '{
"full_name": "Alice Johnson",
"email": "alice.johnson@example.com",
"password": "SecurePassword123!",
"is_premium": true
}'5. Update User
PATCH /mcp/db/users/{id}
curl -X PATCH http://127.0.0.1:8000/mcp/db/users/1 \
-H "Content-Type: application/json" \
-d '{"is_premium": true}'6. Delete User
DELETE /mcp/db/users/{id}
curl -X DELETE http://127.0.0.1:8000/mcp/db/users/17. Run Read-Only SQL Query
POST /mcp/db/query
curl -X POST http://127.0.0.1:8000/mcp/db/query \
-H "Content-Type: application/json" \
-d '{"query": "SELECT count(*) AS total FROM user WHERE is_premium = 1"}'š Security Notes
SQLite database files (
*.db) and secrets (.env) are excluded from version control via.gitignore.Password hashes are stored using SHA-256.
The SQL query endpoint strictly forbids non-readonly queries (
INSERT,UPDATE,DELETE,DROP,ALTER,CREATE).
š License
MIT License. See LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
- UnifAPIOAuthcom.unifapi
Hosted MCP server for live public-data APIs and Skills for AI agents.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage and query SQLite databases through MCP tools, supporting CRUD operations, schema management, and saved views.4 npmMIT
- FlicenseNot gradedqualityCmaintenanceExposes any SQLite database as read-only MCP tools for AI assistants, enabling listing tables, describing schemas, and running SELECT queries with filtering, ordering, and pagination.-
- AlicenseNot gradedqualityDmaintenanceMCP tool server providing SQLite database access for AI agents.MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server providing SQLite database access for AI agents, enabling SQL execution, schema inspection, CRUD operations, and data export.MIT