NavtejDhillon/barebones-mcp-server
3.1
If you are the rightful owner of barebones-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A production-ready skeleton for building MCP (Model Context Protocol) servers with Supabase integration, proper authentication, and modular architecture.
Skeleton MCP Server
A production-ready skeleton for building MCP (Model Context Protocol) servers with Supabase integration, proper authentication, and modular architecture.
Features
- ✅ Modular architecture (separate handlers, tools, utils)
- ✅ Supabase authentication with OAuth flow
- ✅ SSE (Server-Sent Events) transport for MCP
- ✅ Proper error handling and logging
- ✅ Database schema validation
- ✅ RLS (Row Level Security) support
- ✅ Systemd service configuration
- ✅ Environment-based configuration
Project Structure
skeleton-mcp-server/
├── server.py # Main server file
├── handlers/ # Tool handlers (business logic)
│ ├── __init__.py
│ └── example_handlers.py
├── tools/ # Tool definitions (MCP interface)
│ ├── __init__.py
│ └── example_tools.py
├── utils/ # Utility functions
│ ├── __init__.py
│ ├── auth.py # Authentication utilities
│ └── database.py # Database utilities
├── tests/ # Test files
├── docs/ # Documentation
│ └── SCHEMA_GUIDE.md
├── .env.example # Environment variables template
├── requirements.txt # Python dependencies
└── systemd/ # Systemd service files
└── mcp-server.service
Quick Start
- Clone the repository
- Copy
.env.exampleto.envand configure - Install dependencies:
pip install -r requirements.txt - Run the server:
python server.py
Key Learnings Incorporated
1. Database Schema Matching
- Always verify database column names match handler field names
- Common gotchas:
namevscompany_namevsvendor_nameemailvsmain_emailvscontact_emailtax_amountvsgst_amounttotalvstotal_amountvsline_total
2. Authentication Flow
- Support both OAuth and direct token validation
- Handle Claude's token caching behavior
- Proper CORS configuration for Claude.ai
3. SSE Implementation
- Correct headers for SSE streaming
- Proper error response formatting
- Handle MCP protocol methods correctly
4. Modular Architecture
- Separate concerns: tools (interface) vs handlers (logic)
- Easy to add new tools without modifying core server
- Centralized error handling
Adding New Tools
- Define tool schema in
tools/your_tools.py - Implement handler in
handlers/your_handlers.py - Register in respective
__init__.pyfiles - Restart server
Environment Variables
See .env.example for all required variables:
SUPABASE_URL: Your Supabase instance URLSUPABASE_SERVICE_KEY: Service role key (full access)SUPABASE_ANON_KEY: Anonymous key (public access)DATABASE_URL: Direct database connection (if needed)SERVER_PORT: Port to run server on (default: 8080)
Database Setup
- Ensure your Supabase tables exist
- Enable RLS policies for security
- Document your schema in
docs/SCHEMA_GUIDE.md
Deployment
See systemd/mcp-server.service for production deployment with systemd.
Common Issues & Solutions
- "Column not found" errors: Check actual database schema vs handler fields
- Authentication failures: Ensure CORS is configured for Claude.ai
- SSE connection drops: Check response headers and keep-alive settings
- Token validation fails: May need to handle cached tokens temporarily
License
MIT