LightCMS
A lightweight, AI-native content management system for building and managing websites. Built with Go and MongoDB Atlas.
Why LightCMS?
Lightweight
A clean, focused codebase (~5K lines of Go) that's easy to understand, modify, and extend. No bloated frameworks or complex abstractions.
AI-Native
Built from the ground up for the AI era:
- MCP Integration: Full Model Context Protocol server with 38 tools for website management. Control your entire site through Claude Code or other agentic workflows.
- Fork-Friendly: Designed to be forked and customized by Claude Code. Ask Claude to add new content types, modify templates, or build custom features—the codebase is structured for AI-assisted development.
- Natural Language Website Management: Skip the admin UI entirely. Create pages, manage assets, customize themes, and publish content through conversation.
Features
MCP server for agentic control of your site
Define reusable content structures with custom fields
Fast page loads from pre-rendered HTML
Group and display content by category
Full HTML control for special pages
Modern, sleek design with customizable colors, fonts, and styles
TinyMCE integration for visual content editing
Secure content management at
/cmFull version history with diff comparison and revert capability
Recover deleted content with undelete functionality
Prerequisites
- Go 1.21 or later
- MongoDB Atlas account (free tier works great)
Quick Start
- Clone the repository:
git clone https://github.com/jonradoff/lightcms.git cd lightcms - Copy
config.dev.json.exampletoconfig.dev.json - Edit
config.dev.jsonwith your MongoDB connection string - Run
go run cmd/server/main.go - Visit http://localhost:8082/cm and login with
admin123 - Change your password immediately via Security settings
MongoDB Atlas Setup
Step 1: Create an Atlas Account
- Go to MongoDB Atlas
- Sign up for a free account (no credit card required)
Step 2: Create a Cluster
- Click "Build a Database"
- Select "M0 FREE" (Shared) tier
- Choose your preferred cloud provider and region (closest to you)
- Click "Create Deployment"
Step 3: Set Up Database Access
- Create a database user:
- Username:
lightcms(or your choice) - Password: Generate a secure password (save this!)
- Click "Create User"
- Username:
- Add your IP address:
- Click "Add My Current IP Address"
- Or add
0.0.0.0/0to allow access from anywhere (less secure, but convenient for development) - Click "Finish and Close"
Step 4: Get Your Connection String
- Click "Connect" on your cluster
- Select "Drivers"
- Copy the connection string, it looks like:
mongodb+srv://lightcms:<password>@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority - Replace
<password>with your actual password
Step 5: Create Your Config File
For development, copy the example and fill in your values:
cp config.dev.json.example config.dev.json
Edit config.dev.json:
{
"port": "8082",
"mongo_uri": "mongodb+srv://lightcms:YOUR_PASSWORD@cluster0.xxxxx.mongodb.net/lightcms",
"env": "development",
"session_secret": "any-random-string-for-dev"
}
For production, use config.prod.json:
cp config.prod.json.example config.prod.json
Edit with production values (use openssl rand -hex 32 for session_secret).
Installation
# Clone the repository
git clone https://github.com/jonradoff/lightcms.git
cd lightcms
# Install dependencies
go mod tidy
# Run the server
go run cmd/server/main.go
Or use the run script:
./run.sh
Configuration
LightCMS uses JSON config files. Create either:
config.dev.json- for developmentconfig.prod.json- for production (takes precedence if both exist)
| Field | Description |
|---|---|
port | Server port (e.g., "8082" for dev, "80" for prod) |
mongo_uri | MongoDB Atlas connection string |
env | Environment: "development" or "production" |
session_secret | Random string for session encryption |
Note: Config files contain secrets and are excluded from git via .gitignore.
Usage
Accessing the Site
- Public site: http://localhost:8082
- Admin panel: http://localhost:8082/cm
Default Admin Password
The default password is admin123. On first login, you'll be prompted to change it.
The admin password is stored securely in MongoDB using bcrypt hashing.
Creating Content
- Log in to the admin panel at
/cm - Go to Content → New Content
- Select a template (Blog Post, Press Release, or Explanatory Page)
- Fill in the fields
- Check "Published" and save
Creating Custom Templates
- Go to Templates → New Template
- Define your fields (text, textarea, richtext, date, image, select)
- Create an HTML layout using
{{.field_name}}placeholders - Save the template
Available placeholders:
{{.title}}- Content title{{.slug}}- URL slug{{.published_at}}- Publication date{{.your_field_name}}- Any custom field you define
Creating Collections
Collections display grouped content (like a blog listing page).
- Go to Collections → New Collection
- Set the category filter to match your content's category
- Define item and page templates
- The collection will be available at
/collection-slug
Customizing the Theme
- Go to Theme in the admin panel
- Adjust colors, fonts, and border radius
- Add custom CSS if needed
- Save to apply changes site-wide
Project Structure
lightcms/
├── cmd/
│ └── server/
│ └── main.go # Application entry point
├── config/
│ └── config.go # Configuration loading
├── internal/
│ ├── auth/
│ │ └── auth.go # Authentication logic
│ ├── database/
│ │ └── mongo.go # MongoDB connection & operations
│ ├── handlers/
│ │ ├── handlers.go # HTTP handlers
│ │ └── admin_templates.go # Admin UI templates
│ └── models/
│ └── models.go # Data models & default templates
├── static/
│ ├── css/
│ │ ├── main.css # Public site styles
│ │ └── theme-vars.css # Theme CSS variables
│ └── uploads/ # Uploaded files
├── content/
│ ├── pages/ # Custom page files
│ └── generated/ # Generated static HTML
├── config.dev.json.example # Development config template
├── config.prod.json.example # Production config template
└── README.md
Default Templates
Blog Post
Fields: title, excerpt, featured_image, content, author, tags
Press Release
Fields: headline, subheadline, dateline, release_date, body, boilerplate, contact_info
Explanatory Page
Fields: title, subtitle, hero_image, intro, main_content, sidebar, cta_text, cta_link
Using with Claude Code (AI-Powered Content Management)
LightCMS includes an MCP (Model Context Protocol) server that allows you to manage your website content using Claude Code. Instead of navigating the admin UI, you can simply ask Claude to create pages, update content, manage assets, and more.
Setup
- Build the MCP server:
go build -o bin/lightcms-mcp ./cmd/mcp - Register the MCP server with Claude Code using the wrapper script:
claude mcp add --transport stdio lightcms-mcp -- /path/to/lightcms/lightcms-mcp-wrapper.shThe wrapper script automatically sets
LIGHTCMS_CONFIG_DIRso the MCP server can find your config files regardless of where Claude Code runs from. - Restart Claude Code (or start a new session)
- Verify the connection by running
/mcpin Claude Code
Alternative: Environment Variables
Instead of using config files, you can configure via environment variables:
claude mcp add --transport stdio lightcms-mcp \
-e MONGO_URI="mongodb+srv://..." \
-e SESSION_SECRET="your-secret" \
-- /path/to/lightcms/bin/lightcms-mcp
Configuration Options
The MCP server supports these environment variables:
LIGHTCMS_CONFIG_DIR- Directory containing config.dev.json or config.prod.jsonMONGO_URI- MongoDB connection string (bypasses config files)SESSION_SECRET- Session encryption key (required with MONGO_URI)BASE_URL- Public site URL (optional)
Example Commands
Once connected, you can manage your site with natural language:
- "Create a new blog post about machine learning"
- "List all my draft content"
- "Update the homepage title to 'Welcome to My Site'"
- "Delete the /old-page content"
- "Show me all templates"
- "Upload an image for my latest blog post"
- "Change the site's primary color to blue"
Available Tools
The MCP server provides 38 tools for complete content management:
- Content: Create, read, update, delete, publish, unpublish, versioning
- Templates: Manage content templates and their fields
- Assets: Upload and manage images, documents, and other files
- Settings: Theme customization, redirects, folders, collections
For detailed API documentation, see MCP API Reference.
Development
# Run with hot reload (using air)
go install github.com/cosmtrek/air@latest
air
# Build for production
go build -o lightcms cmd/server/main.go
# Run production build
./lightcms
Security Notes
For production:
- Use a strong
session_secret(generate withopenssl rand -hex 32) - Change the default admin password immediately after first login
- Use HTTPS (put behind a reverse proxy like nginx or caddy)
- Restrict MongoDB Atlas IP whitelist to your server IPs
- Regularly backup your MongoDB database
License
MIT License - View on GitHub