barebones-mcp-server

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

  1. Clone the repository
  2. Copy .env.example to .env and configure
  3. Install dependencies: pip install -r requirements.txt
  4. 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 vs company_name vs vendor_name
    • email vs main_email vs contact_email
    • tax_amount vs gst_amount
    • total vs total_amount vs line_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

  1. Define tool schema in tools/your_tools.py
  2. Implement handler in handlers/your_handlers.py
  3. Register in respective __init__.py files
  4. Restart server

Environment Variables

See .env.example for all required variables:

  • SUPABASE_URL: Your Supabase instance URL
  • SUPABASE_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

  1. Ensure your Supabase tables exist
  2. Enable RLS policies for security
  3. Document your schema in docs/SCHEMA_GUIDE.md

Deployment

See systemd/mcp-server.service for production deployment with systemd.

Common Issues & Solutions

  1. "Column not found" errors: Check actual database schema vs handler fields
  2. Authentication failures: Ensure CORS is configured for Claude.ai
  3. SSE connection drops: Check response headers and keep-alive settings
  4. Token validation fails: May need to handle cached tokens temporarily

License

MIT