MCP Demo

MCP Demo

By tanjibpa GitHub

-

mcp-server model-context-protocol
Overview

What is MCP Demo?

MCP Demo is a demonstration implementation of a Model Context Protocol (MCP) server designed to manage organizations and devices, calculate distances between devices and their associated organizations, and provide tools for data interaction.

How to use MCP Demo?

To use MCP Demo, clone the repository, set up a virtual environment, configure the database connection in a .env file, and run the server using the provided commands.

Key features of MCP Demo?

  • Database Integration: Connects to a PostgreSQL database for managing organizations and devices.
  • Distance Calculation: Utilizes the Haversine formula for calculating distances between devices and organizations.
  • MCP Tools: Offers tools to fetch organizations, devices, and calculate distances.

Use cases of MCP Demo?

  1. Managing organizational data and device information.
  2. Calculating geographical distances for logistics and planning.
  3. Providing a backend service for applications requiring device management.

FAQ from MCP Demo?

  • What technologies are used in MCP Demo?

MCP Demo is built using Python and integrates with PostgreSQL for database management.

  • How can I set up the database?

You can set up the database by running the SQL script provided in the repository after configuring your environment variables.

  • Is there any support for additional features?

Yes, the MCP framework allows for extensibility, and additional features can be implemented as needed.

Content

MCP Demo

This repository contains a demo implementation of a Model Context Protocol (MCP) server. The server is designed to manage organizations and devices, calculate distances between devices and their associated organizations, and provide a set of tools for interacting with the data.

Features

  • Database Integration: Connects to a PostgreSQL database to manage organizations and devices.
  • Distance Calculation: Uses the Haversine formula to calculate distances between devices and their associated organizations.
  • MCP Tools: Provides tools to fetch organizations, devices, and calculate distances.

Prerequisites

  • Python 3.12.5
  • PostgreSQL database

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd mcp-demo
    
  2. Set up a virtual environment:

    uv venv
    source .venv/bin/activate
    
  3. Configure the environment variables in a .env file:

    DB_NAME=mcp
    DB_USER=mcp_user
    DB_PASSWORD=pa$$word
    DB_HOST=localhost
    DB_PORT=5432
    
  4. Set up the database:

    psql -U <username> -d <database> -f tables.sql
    

Usage

  1. Run the MCP server:

    uv run main.py
    
  2. Use the provided tools to interact with the server:

    • get_organizations: Fetch all organizations from the database.
    • get_devices: Fetch all devices from the database.
    • get_devices_by_organization: Fetch devices for a specific organization.
    • list_devices_with_distance: List devices and their distances from their associated organizations.

Project Structure

  • main.py: Main entry point for the MCP server.
  • tables.sql: SQL script to set up the database schema and seed data.
  • .env: Environment variables for database configuration.
  • pyproject.toml: Project metadata and dependencies.

Dependencies

  • httpx: HTTP client for Python.
  • mcp[cli]: MCP framework for building servers.
  • psycopg2: PostgreSQL database adapter for Python.

Claude Desktop MCP Server Configuration

To configure Claude Desktop for this MCP server project, follow these steps:

  1. Install Claude Desktop on your machine from the official website.

  2. Open Claude Desktop and navigate to the settings menu.

  3. Add a new project configuration for the MCP server:

     code ~/Library/Application\ Support/Claude/claude_desktop_config.json
    
  4. Add the mcp servers

{
    "mcpServers": {
        "devices": {
            "command": "uv",
            "args": [
                "--directory",
                "/path/to/mcp-demo",
                "run",
                "main.py"
            ],
            "env": {
                "DB_NAME": "mcp",
                "DB_USER": "mcp_user",
                "DB_PASSWORD": "pa$$word",
                "DB_HOST": "localhost",
                "DB_PORT": "5432"
            }
        }
    }
}
  1. Run query, for example: List the devices in DB and show me how far are they from their organization address. Also, add get the mac addresses of the devices.
No tools information available.

-

mcp model-context-protocol
View Details

-

mcp-server v2ex
View Details

my-mcp-server(without auth)

mcp-server cloudflare
View Details
mcp-server
mcp-server by iyerrama29

MCP demo

mcp-server demo
View Details

A Model Context Protocol (MCP) server enabling LLMs to query, analyze, and interact with Prometheus databases through predefined routes.

prometheus model-context-protocol
View Details
Next MCP server
Next MCP server by Collaborne

-

mcp-server NEXT
View Details
MCP-Server
MCP-Server by fmpoliveira

-

mcp-server meteostat
View Details