Skip to main content
Glama
Pritrj

FastAPI MCP Server

by Pritrj

MCP Server

एक production-ready Model Context Protocol (MCP) server जो FastAPI framework का उपयोग करके बनाई गई है।

विशेषताएं (Features)

  • 🚀 FastAPI Framework: High-performance async API server

  • 🔒 Security: JWT authentication और secure coding practices

  • 🗄️ Database: PostgreSQL के साथ asyncpg

  • 📦 Caching: Redis integration

  • 🐳 Docker Ready: Production-ready containerization

  • 📊 Health Checks: Built-in health monitoring

  • 🔧 Development Ready: Comprehensive testing और development tools

आवश्यकताएं (Requirements)

  • Python 3.11+

  • PostgreSQL 13+

  • Redis 6+

  • Docker (optional)

इंस्टॉलेशन (Installation)

1. Repository Clone करें

git clone <repository-url>
cd mcp-server

2. Virtual Environment बनाएं

python -m venv venv
source venv/bin/activate  # Linux/Mac
# या
venv\\Scripts\\activate  # Windows

3. Dependencies Install करें

pip install -r requirements.txt

4. Environment Variables सेट करें

.env file बनाएं:

# Database
DATABASE_URL=postgresql://username:password@localhost:5432/mcp_db

# Redis
REDIS_URL=redis://localhost:6379/0

# Security
SECRET_KEY=your-secret-key-here
JWT_ALGORITHM=HS256
JWT_EXPIRE_MINUTES=30

# Server
HOST=0.0.0.0
PORT=8000
DEBUG=false

Usage

Development Mode

uvicorn main:app --reload --host 0.0.0.0 --port 8000

Production Mode

uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4

Docker के साथ

# Build करें
docker build -t mcp-server .

# Run करें
docker run -p 8000:8000 --env-file .env mcp-server

API Documentation

Base URL

http://localhost:8000

Interactive Documentation

Main Endpoints

Health Check

GET /health

Server की health status check करता है।

API Endpoints

GET /api/v1/status
POST /api/v1/connect
GET /api/v1/tools
POST /api/v1/tools/{tool_name}/call

Development

Code Quality

# Format code
black .

# Sort imports
isort .

# Lint code
flake8 .

# Type checking
mypy .

Testing

# सभी tests run करें
pytest

# Coverage के साथ
pytest --cov=src tests/

# Specific test file
pytest tests/test_main.py

Project Structure

mcp-server/
├── src/                    # Source code
│   ├── main.py            # FastAPI application
│   ├── models/            # Pydantic models
│   ├── routes/            # API routes
│   ├── services/          # Business logic
│   ├── database/          # Database configuration
│   └── utils/             # Utility functions
├── tests/                 # Test files
├── requirements.txt       # Python dependencies
├── Dockerfile            # Docker configuration
├── docker-compose.yml    # Docker Compose (optional)
├── .env.example          # Environment variables template
├── .gitignore           # Git ignore patterns
├── .dockerignore        # Docker ignore patterns
└── README.md            # This file

Configuration

Environment Variables

Variable

Description

Default

DATABASE_URL

PostgreSQL connection URL

Required

REDIS_URL

Redis connection URL

redis://localhost:6379/0

SECRET_KEY

JWT secret key

Required

JWT_ALGORITHM

JWT algorithm

HS256

JWT_EXPIRE_MINUTES

JWT expiration time

30

HOST

Server host

0.0.0.0

PORT

Server port

8000

DEBUG

Debug mode

false

Database Setup

-- PostgreSQL database बनाएं
CREATE DATABASE mcp_db;

-- User बनाएं (optional)
CREATE USER mcp_user WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE mcp_db TO mcp_user;

Redis Setup

# Redis start करें
redis-server

# या Docker के साथ
docker run -d -p 6379:6379 redis:alpine

Security Features

  • JWT-based authentication

  • Password hashing with bcrypt

  • CORS protection

  • Rate limiting

  • Input validation

  • SQL injection protection

  • XSS protection

Monitoring

Health Checks

# Server health check
curl http://localhost:8000/health

# Database connection check
curl http://localhost:8000/health/db

# Redis connection check
curl http://localhost:8000/health/redis

Logging

Logs /logs/ directory में store होते हैं। Production में proper logging configuration set करें।

Deployment

Docker Deployment

# Production image build करें
docker build -t mcp-server:latest .

# Docker Compose के साथ
docker-compose up -d

Manual Deployment

# Gunicorn के साथ
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker

Contributing

  1. Fork करें

  2. Feature branch बनाएं (git checkout -b feature/amazing-feature)

  3. Commit करें (git commit -m 'Add amazing feature')

  4. Push करें (git push origin feature/amazing-feature)

  5. Pull Request open करें

License

यह project MIT license के under है।

Support

समस्याओं के लिए GitHub Issues create करें या documentation पढ़ें।

Changelog

v1.0.0

  • Initial release

  • FastAPI integration

  • JWT authentication

  • Redis caching

  • Docker support

  • Comprehensive documentation

F
license - not found
Not graded
quality - not tested
Not graded
maintenance - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…

  • A Model Context Protocol server for Wix AI tools

  • Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Pritrj/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server