An MCP server lets an AI assistant such as Claude call your tools: "list the last ten articles", "save a draft", "fix this meta description". For Joomla there's no official MCP server, and you don't need one. Joomla has had a REST API in core since 4.0, and a small MCP server that wraps the parts you want to expose is about 150 lines.
This post builds one, with the current SDK (v2, @modelcontextprotocol/server) and the Joomla API as it actually behaves in Joomla 6.2. We also cover the security decisions, which matter more than the code.
The shape of it
Claude (Desktop / Code) ──stdio──▶ your MCP server (Node) ──HTTPS + token──▶ Joomla /api/index.php/v1/…
The MCP server runs on your machine or a server you control. It holds one Joomla API token and exposes a short list of tools. The AI never sees the token and can only do what the tools allow. That is the whole security model, so choose the tools carefully.
1. Prepare Joomla: a user just for the AI
- Create a dedicated user, for example in a new group "API – Content" with permission to create and edit articles in the categories it should touch, and nothing else. Never use a Super User token for an AI.
- Allow that group to have tokens. By default only Super Users can. Open Plugins → User – Joomla API Token and add the group under "Allowed User Groups".
- Make sure API Authentication – Web Services Joomla Token is enabled, and the Web Services – Content plugin.
- Disable API Authentication – Basic if nothing uses it. It accepts a username and password on every API request.
- Log in as the new user (or edit it), open the Joomla API Token tab, and copy the token.
Test the token before writing any code:
# terminal
curl -s -H "Authorization: Bearer $JOOMLA_TOKEN" -H "Accept: application/vnd.api+json" \
"https://example.com/api/index.php/v1/content/articles?page[limit]=2" | python3 -m json.tool | head -30
A 401 with {"errors":[{"title":"Forbidden"}]} means the token, the plugin or the group setting is wrong. The response format is JSON:API: each item is { "type": "articles", "id": "12", "attributes": { … } }.
2. The project
# terminal
mkdir joomla-mcp && cd joomla-mcp
npm init -y
npm pkg set type=module
npm install @modelcontextprotocol/server zod tsx
type=module is required, because the SDK ships ES modules only. tsx runs TypeScript directly, so there's no build step.
3. A small Joomla client
// src/joomla.ts
const BASE = process.env.JOOMLA_URL?.replace(/\/$/, ''); // https://example.com
const TOKEN = process.env.JOOMLA_TOKEN;
if (!BASE || !TOKEN) {
throw new Error('Set JOOMLA_URL and JOOMLA_TOKEN');
}
export async function joomla(path: string, init: RequestInit = {}): Promise<any> {
const res = await fetch(`${BASE}/api/index.php/v1/${path}`, {
...init,
headers: {
Authorization: `Bearer ${TOKEN}`,
Accept: 'application/vnd.api+json',
'Content-Type': 'application/json',
...init.headers,
},
signal: AbortSignal.timeout(20_000),
});
const body = await res.text();
if (!res.ok) {
throw new Error(`Joomla API ${res.status}: ${body.slice(0, 300)}`);
}
return body ? JSON.parse(body) : null;
}
// JSON:API item → plain object
export const flat = (item: any) => ({ id: Number(item.id), ...item.attributes });
4. The server and its tools
Four tools: two that read, two that write, and the writes can't publish. New articles are saved unpublished (state: 0), and a person publishes them in the back end. That one rule removes most of the risk of letting an AI write to a live site.
// src/index.ts
import { McpServer } from '@modelcontextprotocol/server';
import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
import * as z from 'zod/v4';
import { joomla, flat } from './joomla.js';
const server = new McpServer({ name: 'joomla-content', version: '1.0.0' });
const text = (data: unknown) => ({ content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }] });
server.registerTool(
'list_articles',
{
description: 'List articles, newest first. Optional search text and category id.',
inputSchema: z.object({
search: z.string().optional(),
category: z.number().int().optional(),
limit: z.number().int().min(1).max(50).default(10),
}),
annotations: { readOnlyHint: true },
},
async ({ search, category, limit }) => {
const q = new URLSearchParams({ 'page[limit]': String(limit), 'list[ordering]': 'a.id', 'list[direction]': 'DESC' });
if (search) q.set('filter[search]', search);
if (category) q.set('filter[category]', String(category));
const res = await joomla(`content/articles?${q}`);
return text(res.data.map(flat).map(({ id, title, state, metadesc }: any) => ({ id, title, state, metadesc })));
}
);
server.registerTool(
'get_article',
{
description: 'Get one article with its full text and metadata.',
inputSchema: z.object({ id: z.number().int() }),
annotations: { readOnlyHint: true },
},
async ({ id }) => text(flat((await joomla(`content/articles/${id}`)).data))
);
server.registerTool(
'create_draft',
{
description: 'Create an UNPUBLISHED article for human review. HTML body; use <hr id="system-readmore"> for the intro break.',
inputSchema: z.object({
title: z.string().min(5).max(150),
catid: z.number().int(),
html: z.string().min(50),
metadesc: z.string().max(160).optional(),
}),
},
async ({ title, catid, html, metadesc }) => {
const res = await joomla('content/articles', {
method: 'POST',
body: JSON.stringify({ title, catid, articletext: html, metadesc, language: '*', state: 0 }),
});
return text({ created: flat(res.data).id, state: 'unpublished – publish it in the back end after review' });
}
);
server.registerTool(
'update_meta_description',
{
description: 'Set the meta description of an article (max 160 characters).',
inputSchema: z.object({ id: z.number().int(), metadesc: z.string().min(50).max(160) }),
},
async ({ id, metadesc }) => {
await joomla(`content/articles/${id}`, { method: 'PATCH', body: JSON.stringify({ metadesc }) });
return text({ updated: id });
}
);
await server.connect(new StdioServerTransport());
Three details from testing against Joomla 6.2:
- The article body field for writing is
articletext. Joomla's content table splits it into intro and full text at the read-more marker, the same as the editor does. - Custom fields are sent by field name at the top level of the JSON (
"price": "19"). The API controller moves them intocom_fieldsfor you. - List filters use
filter[search],filter[category],filter[state]andfilter[language], and paging usespage[limit]andpage[offset].
5. Try it, then connect Claude
# terminal – the MCP Inspector lets you call each tool by hand
JOOMLA_URL=https://staging.example.com JOOMLA_TOKEN=… npx @modelcontextprotocol/inspector npx tsx src/index.ts
Claude Desktop reads servers from its config file (Settings → Developer → Edit Config):
// claude_desktop_config.json
{
"mcpServers": {
"joomla": {
"command": "npx",
"args": ["tsx", "/Users/you/joomla-mcp/src/index.ts"],
"env": {
"JOOMLA_URL": "https://staging.example.com",
"JOOMLA_TOKEN": "…"
}
}
}
}
Point it at a staging site first. Ask for something read-only ("which articles have no meta description?"), then for a draft, and check what lands in the back end.
Security decisions that matter more than the code
- Least privilege in Joomla, not in the prompt. The AI's user can only touch what its group allows. A prompt that says "don't delete anything" is not a control. A missing delete permission is.
- No publish, no delete tools. If a tool doesn't exist, the AI can't call it. Add them only with a confirmation step you control.
- The token stays in the server's environment. Never in a prompt, a repository or the tool output. Rotate it like a password: change the token in the user's profile and update the config.
- Treat article content as untrusted input. Text read from the site can contain instructions aimed at the model ("ignore previous instructions…"). Read tools should return data, and nothing in that data should be able to trigger a write without a person seeing it.
- Log what happens. Joomla's User Actions Log records API changes under the AI's user, which is one more reason to give it its own account.
Where to go from here
The same pattern extends to anything the Web Services API exposes: categories, tags, menus, modules, users (careful), redirects, and your own components if they have web services plugins. When not to use MCP, and when a plain script against the API is the better tool, is in MCP vs traditional APIs. The API itself is covered in Joomla REST API for beginners.
