Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions sample-apps/MedLink/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Python
__pycache__/
*.py[cod]
*.pyo
*.pyd

# Virtual Environment
venv/
env/
.venv/

# Django
db.sqlite3
media/
staticfiles/

# VS Code
.vscode/

# Python environment
.env

# macOS
.DS_Store

# Logs
*.log

# PyCharm
.idea/

# Migrations cache
*.pyc
1 change: 1 addition & 0 deletions sample-apps/MedLink/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn config.wsgi:application
Empty file.
16 changes: 16 additions & 0 deletions sample-apps/MedLink/config/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for config project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')

application = get_asgi_application()
139 changes: 139 additions & 0 deletions sample-apps/MedLink/config/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
"""
Django settings for config project.

Generated by 'django-admin startproject' using Django 5.2.16.

For more information on this file, see
https://docs.djangoproject.com/en/5.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.2/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-6q52p-0y5k6)4ecd_o4=q2ttb1)rd@f7rv*w#w9*h&&9v_pz^*'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['*']


# Application definition
INSTALLED_APPS = [

'medlink',

'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'rest_framework',


]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'config.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / "medlink/templates"],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'config.wsgi.application'


# Database
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/5.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.2/howto/static-files/

STATIC_URL = "/static/"

STATICFILES_DIRS = [
BASE_DIR / "medlink/static",
]

STATIC_ROOT = BASE_DIR / "staticfiles"

MEDIA_URL = "/media/"

MEDIA_ROOT = BASE_DIR / "media"

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

LOGIN_URL = "login"
LOGIN_REDIRECT_URL = "dashboard_redirect"
LOGOUT_REDIRECT_URL = "home"
7 changes: 7 additions & 0 deletions sample-apps/MedLink/config/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path("admin/", admin.site.urls),
path("", include("medlink.urls")),
]
16 changes: 16 additions & 0 deletions sample-apps/MedLink/config/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for config project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')

application = get_wsgi_application()
22 changes: 22 additions & 0 deletions sample-apps/MedLink/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions sample-apps/MedLink/mcp_servers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# MediFind MCP Servers Package
49 changes: 49 additions & 0 deletions sample-apps/MedLink/mcp_servers/geonav_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import os
import sys
import django
from pathlib import Path

# Add project root to sys.path and setup Django environment
BASE_DIR = Path(__file__).resolve().parent.parent
sys.path.append(str(BASE_DIR))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
django.setup()

from fastmcp import FastMCP
from medifind.models import Pharmacy

mcp = FastMCP("MediFind GeoNav Engine")

@mcp.tool()
def generate_google_maps_directions(latitude: float, longitude: float) -> str:
"""Generates a 1-click turn-by-turn Google Maps navigation URL for pharmacy GPS coordinates."""
return f"https://www.google.com/maps/dir/?api=1&destination={latitude},{longitude}"

@mcp.tool()
def find_nearby_pharmacies(city: str = "Chennai", must_be_open: bool = True) -> list:
"""Filters registered pharmacies in a specified city by active status and live OPEN/CLOSED state."""
query = Pharmacy.objects.filter(city__icontains=city, is_active=True)
if must_be_open:
query = query.filter(is_open=True)

results = []
for p in query:
directions_url = generate_google_maps_directions(float(p.latitude), float(p.longitude))
results.append({
"pharmacy_id": p.id,
"name": p.name,
"owner_name": p.owner_name,
"address": p.address,
"city": p.city,
"phone": p.phone,
"latitude": float(p.latitude),
"longitude": float(p.longitude),
"opening_time": str(p.opening_time),
"closing_time": str(p.closing_time),
"is_open": p.is_open,
"google_maps_directions_url": directions_url
})
return results

if __name__ == "__main__":
mcp.run()
Loading