A docs site for people and AI agents with Margin, on your own server
Updated 11/29/2026
Product documentation is no longer read only by people. AI agents search it, read it and quote it, and a good docs site has to speak to both. Margin does exactly that: it takes a folder of Markdown or MDX files, loads them into a PostgreSQL database and serves them as a searchable site for people and as llms.txt, an MCP server and a Markdown or PDF version of every page for agents. It is open-source (Apache-2.0) and runs on a 2 GB RAM server.
What the install gives you
The one-click install from the catalog prepares everything: Node 24 for the server, Bun for the build, PostgreSQL in a container, automatic HTTPS on the server address and a systemd service that keeps the site running. As an example, the site starts with Margin's own documentation. The access details, including the database password, are in /root/app-credentials.txt.
- /srv/docs is the folder with your documentation. The application code lives separately in
/opt/margin, so an update never touches your content. - margin-rebuild is the publish command: it runs the migrations, builds the application, ingests the docs into the database and restarts the service.
- /etc/margin.env holds the configuration: the database connection, the public site address and the internal port.
1. Put your own documentation in
Replace the contents of /srv/docs with your files. An index.md becomes the front page and subfolders become sections. An optional docs.json controls the site title, page order and navigation, but without it Margin builds the navigation from the folder structure.
rm -rf /srv/docs/*
# copy your docs, for example from a git repository
git clone https://github.com/example/docs /tmp/docs
cp -r /tmp/docs/. /srv/docs/
margin-rebuild
The command hashes the folder and uses that as the content version, so every change is published even without a git commit. Older versions stay in the database and can be brought back if you need to return to a previous edition.
2. Check what agents see
Open https://your-server-address/llms.txt. This is the index AI agents read, with the list of pages and their descriptions. Every page also has a clean Markdown version, with no menus or scripts, exactly what a language model wants to receive. The included MCP server lets an agent search the documentation directly from Claude, Cursor or any MCP client.
3. Your own domain
For docs.example.com, create an A record pointing at the server's IP, then change two things: the public address in the configuration and the host in Caddy. The public address is baked into the build, so publish again.
sed -i 's|^SITE_ORIGIN=.*|SITE_ORIGIN=https://docs.example.com|' /etc/margin.env
sed -i 's|^[^ ]*\.cloudlinux\.ro {|docs.example.com {|' /etc/caddy/Caddyfile
margin-rebuild
systemctl restart caddy
Caddy issues the HTTPS certificate on its own within minutes of the domain propagating.
4. Updates
Margin updates from its git repository, and your documentation is left alone:
cd /opt/margin && git pull
margin-rebuild
If a build fails, the old service keeps running and the site stays up: publishing stops at the first step that does not succeed.
When it makes sense
Margin is a good fit for product, API or team documentation, especially when you want AI agents to find it and quote it correctly. If you need a wiki with in-browser editing and per-page permissions, look at Docmost or BookStack in the same catalog. All of them bill by the hour, and the server is deleted when you no longer use it.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Error tracking for your applications with GlitchTip
Catch production exceptions with the Sentry SDKs on a small server: the project, the DSN, alerts and uptime.
Updated 11/29/2026Dev environmentsTest your application's email with smtp4dev
Send the email from Laravel, WordPress, Node or Python to a test SMTP server and read it in a web inbox, without it ever reaching real customers.
Updated 11/29/2026Dev environmentsHow to set up a staging environment
Test changes on a copy of production before shipping them, to avoid surprises.
Updated 11/29/2026