Skip to main content
Glama
README.md4.16 kB
# MCP FastAPI Backend FastAPI backend application for MCP (Model Context Protocol) integration with external services. ## Features - FastAPI REST API with comprehensive documentation - JWT-based authentication with token blacklist - Support for multiple external services (GitHub, Vercel, Linear, Notion, Slack, Discord, Google Workspace) - PostgreSQL database integration with SQLAlchemy ORM - Redis for caching and session management - Comprehensive error handling and logging - Health check endpoints - Credential encryption/decryption ## Supported Services - **GitHub**: Repository and issue management - **Vercel**: Deployment management - **Linear**: Project management and issue tracking - **Notion**: Workspace and database integration - **Slack**: Messaging and channel management - **Discord**: Bot and server management - **Google Workspace**: File and document management ## Installation 1. Clone the repository 2. Install dependencies: ```bash pip install -r requirements.txt ``` ## Environment Variables Create a `.env` file with the following variables: ```env # Database DATABASE_URL=postgresql://user:password@localhost/mcp_db # Redis REDIS_URL=redis://localhost:6379 # Security ENCRYPTION_KEY=your-32-byte-encryption-key-here # JWT (for production) JWT_SECRET_KEY=your-jwt-secret-key JWT_ALGORITHM=HS256 JWT_EXPIRE_MINUTES=30 ``` ## Running the Application ### Development ```bash uvicorn src.main:app --reload --host 0.0.0.0 --port 8000 ``` ### Production ```bash uvicorn src.main:app --host 0.0.0.0 --port 8000 --workers 4 ``` ## API Documentation Once the application is running, you can access: - **Interactive API docs**: http://localhost:8000/docs - **ReDoc documentation**: http://localhost:8000/redoc - **OpenAPI JSON**: http://localhost:8000/openapi.json ## API Endpoints ### Health & Status - `GET /health` - Health check - `GET /api/mcp/status` - MCP service status - `GET /api/mcp/services` - List available services ### MCP Operations - `POST /api/mcp/execute` - Execute MCP request for a service ### Authentication All MCP endpoints require Bearer token authentication: ``` Authorization: Bearer <jwt_token> ``` ## Request Format ### Execute Request ```json { "service_name": "github", "payload": { "action": "create_issue", "repository": "my-org/my-repo", "title": "Bug fix needed", "body": "There's a bug in the login functionality", "labels": ["bug", "high-priority"] } } ``` ## Response Format ### Success Response ```json { "status": "success", "action": "github_issue_created", "data": { "issue_id": "123", "url": "https://github.com/my-org/my-repo/issues/123", "number": 42 }, "message": "GitHub issue created successfully", "service": "github", "user_id": 12345, "timestamp": "2025-11-01T14:15:22Z" } ``` ### Error Response ```json { "error": "VALIDATION_ERROR", "detail": "Invalid service name provided", "timestamp": "2025-11-01T14:15:22Z" } ``` ## Project Structure ``` src/ ├── main.py # FastAPI application and middleware ├── schemas.py # Pydantic models ├── core/ │ ├── __init__.py │ ├── router.py # API routes │ └── services.py # Service delegation logic └── __init__.py ``` ## Testing Run tests with pytest: ```bash pytest ``` ## Security Features - JWT token authentication - Token blacklist for revoked tokens - Request validation with Pydantic - CORS configuration - Trusted host middleware - Credential encryption - Input sanitization ## Logging The application includes comprehensive logging: - Request/response logging - Authentication events - Service delegation tracking - Error monitoring - Performance metrics ## Database Schema The application uses the following main tables: - `user_credentials` - Encrypted service credentials - `token_blacklist` - Revoked JWT tokens - `service_logs` - Operation audit trail ## Contributing 1. Fork the repository 2. Create a feature branch 3. Make your changes 4. Add tests 5. Submit a pull request ## License This project is licensed under the MIT License.

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