
julestestmcp
通过MCP服务器作为桥梁,实现客户端与SQLite数据库的间接交互。
Repository Info
About This Server
通过MCP服务器作为桥梁,实现客户端与SQLite数据库的间接交互。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
MCP Database Interaction Demo
Overview
This project demonstrates the use of a Minimal Control Protocol (MCP) server as a bridge to interact with an SQLite database. A client application queries the database not by connecting to it directly, but by making requests to the MCP server, which then executes the database operations.
Project Structure
The repository contains the following key files:
setup_db.py: A Python script to initialize and populate the SQLite database (database.db). It creates the necessary table and inserts sample data.mcp_server.py: The MCP server application. It exposes a tool that can be called remotely to query items from the database.app.py: A client application that connects to the MCP server to fetch and display data from the database.database.db: The SQLite database file. This file is created and populated when you runsetup_db.py.requirements.txt: A text file listing the Python dependencies required for this project (primarilyfastmcp).
Setup and Installation
Follow these steps to set up and run the project:
-
Clone the Repository (if you haven't already):
# git clone <repository-url> # cd <repository-directory> -
Create and Activate a Virtual Environment (recommended):
- On macOS and Linux:
python3 -m venv venv source venv/bin/activate - On Windows:
python -m venv venv venv\Scripts\activate
- On macOS and Linux:
-
Install Dependencies: Once the virtual environment is activated, install the required Python packages:
pip install -r requirements.txt
Running the Application
To run the application, you'll need two terminal windows/tabs. Ensure your virtual environment is activated in both.
Step 1: Initialize the Database
- In your first terminal, run the database setup script:
python setup_db.py - This command will create a file named
database.dbin the project root and populate it with sample data. You should see a success message.
Step 2: Start the MCP Server
- In the same terminal (or a new one, with the virtual environment activated), start the MCP server:
python mcp_server.py - The server will start, typically listening on
http://localhost:8000. You will see log messages indicating it's running. - Keep this terminal window open and the server running.
Step 3: Run the Client Application
-
Open a new terminal window or tab.
-
Activate the virtual environment if you haven't already:
- macOS/Linux:
source venv/bin/activate - Windows:
venv\Scripts\activate
- macOS/Linux:
-
Run the client application:
python app.py -
Expected Output: The client application will connect to the MCP server, request the data, and then print the list of items retrieved from the database to your console. It will look something like this:
Attempting to connect to MCP server at http://localhost:8000 and call 'query_database' tool... Data retrieved from database via MCP: ID: 1, Name: Laptop, Description: High-performance laptop, Quantity: 10 ID: 2, Name: Mouse, Description: Wireless optical mouse, Quantity: 50 ID: 3, Name: Keyboard, Description: Mechanical gaming keyboard, Quantity: 25 ID: 4, Name: Monitor, Description: 27-inch 4K monitor, Quantity: 15 ID: 5, Name: Webcam, Description: 1080p HD webcam, Quantity: 30
Core Logic Demonstrated
The key takeaway from this project is how app.py (the client) interacts with the database.
app.pydoes not contain any direct SQLite connection code.- Instead, it communicates with
mcp_server.pyusing the Minimal Control Protocol. mcp_server.pyis the component that directly queriesdatabase.dbthrough its registered "query_database" tool. This abstracts the database interaction away from the client application.
Quick Start
Clone the repository
git clone https://github.com/learningalways123/julestestmcpInstall dependencies
cd julestestmcp
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.