learningalways123
MCP Serverlearningalways123public

julestestmcp

通过MCP服务器作为桥梁,实现客户端与SQLite数据库的间接交互。

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
Python
Language
-
License

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 run setup_db.py.
  • requirements.txt: A text file listing the Python dependencies required for this project (primarily fastmcp).

Setup and Installation

Follow these steps to set up and run the project:

  1. Clone the Repository (if you haven't already):

    # git clone <repository-url>
    # cd <repository-directory>
    
  2. 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
      
  3. 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.db in 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
  • 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.py does not contain any direct SQLite connection code.
  • Instead, it communicates with mcp_server.py using the Minimal Control Protocol.
  • mcp_server.py is the component that directly queries database.db through its registered "query_database" tool. This abstracts the database interaction away from the client application.

Quick Start

1

Clone the repository

git clone https://github.com/learningalways123/julestestmcp
2

Install dependencies

cd julestestmcp
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerlearningalways123
Repojulestestmcp
LanguagePython
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation