NavtejDhillon/barebones-mcp-server
3.2
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 henry@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.example
to.env
and 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:
name
vscompany_name
vsvendor_name
email
vsmain_email
vscontact_email
tax_amount
vsgst_amount
total
vstotal_amount
vsline_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__.py
files - 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