
mcp server demo
An MCP server demo written in Python 🐍
Repository Info
About This Server
An MCP server demo written in Python 🐍
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 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
-
Clone the repository:
git clone <repository-url> cd mcp-demo -
Set up a virtual environment:
uv venv source .venv/bin/activate -
Configure the environment variables in a
.envfile:DB_NAME=mcp DB_USER=mcp_user DB_PASSWORD=pa$$word DB_HOST=localhost DB_PORT=5432 -
Set up the database:
psql -U <username> -d <database> -f tables.sql
Usage
-
Run the MCP server:
uv run main.py -
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:
-
Install Claude Desktop on your machine from the official website.
-
Open Claude Desktop and navigate to the settings menu.
-
Add a new project configuration for the MCP server:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json -
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"
}
}
}
}
- 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.
Quick Start
Clone the repository
git clone https://github.com/tanjibpa/mcp-server-demoInstall dependencies
cd mcp-server-demo
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.