Resource icon

Beta xfmcp: using agents to monitor your forum 0.1.8

No permission to download
Compatible XF 2.x versions
  1. 2.2
  2. 2.3
Additional requirements
PHP v8.3+
Admin API addon
A tutorial on letting an AI agent such as Claude read the operational state of your XenForo forums: the error log, add-ons, cron, the job queue, who is online, the moderation queues, registrations and options. It covers what the tool does and does not do, how to set it up, and how to read what it tells you. It is written for a forum administrator who has not used an agent this way before.

xfmcp is a free, open-source command-line program for your own computer. It works with the Admin API add-on, which you install on each forum. By the end you should have an agent that can answer "is anything wrong with my forum?" from the forum's own records, and know how much weight to give its answer.

What it is for​


An agent can only reason about what it can see, and a forum keeps most of what matters behind the control panel. Ask an assistant why your forum's mail stopped and it can only guess. Give it the error log, the job queue, the cron entries and the mail options, and it can read them as you would, faster, across every forum you run.

These are some of the questions it answers well:

  • Is anything wrong with this forum? What is in the error log since yesterday, and which add-on does it come from?
  • Did that add-on upgrade cleanly? Is any install or upgrade left unfinished, and do the add-on's own checks pass?
  • Is cron running? Is anything stuck in the job queue?
  • How many people are online, and are the guests mostly a handful of networks?
  • How long has the oldest item in the approval queue been waiting? Are reports being dealt with?
  • How many members registered this week, and how many of them came through the register form?
  • Which of my forums have friendly URLs on? Where does each one send its mail?

The last kind is where it saves the most time. Comparing one setting across five forums is an afternoon of control panel tabs, and one question for an agent.

How it fits together​


There are two halves, and each does one job.

  • The Admin API add-on runs on the forum. It adds read-only endpoints to XenForo's REST API. Each endpoint has its own API scope, and each call also checks an admin permission held by the key's own administrator. It returns facts: counts, states, settings.
  • xfmcp runs on your computer. It is an MCP server, the Model Context Protocol that agents use to call tools. It turns each endpoint into a tool, calls your forums with keys you keep locally, and shapes each answer for a reader that cannot ask a follow-up question.

Nothing listens on a port, anywhere. The agent's client starts xfmcp as a child process and talks to it over stdin and stdout, so there is no new service on your computer and nothing new on the forum beyond the add-on. xfmcp reaches a forum the way any API client does, over HTTPS with a key.

It works with any MCP client: Claude Code, Claude Desktop, and the many others that speak the protocol. The examples below use Claude Code.

What it will not do, on purpose​


Every tool is read-only. Nothing xfmcp sends can change a forum. There is no write tool, and the add-on has no endpoint one could call.

Every answer is counts or settings, never a member. The add-on can look up members by IP address, list moderators and administrators, and read upgrade records, each behind its own scope. xfmcp has no tool for any of them. The one tool that returns content is error-log-entries, which shows an error's message and stack trace, and it needs a separate key of its own (below).

Think about where the answers go. Whatever a tool returns becomes part of the agent's conversation, and is sent to whoever provides the model. That is the main reason the answers are aggregates, and the reason error messages, which can quote what a member typed, are kept behind a second key that you may simply not create.

Secrets are removed on the forum. When a key is allowed to see option and config.php values, the add-on removes anything it judges to be a secret before the answer leaves the server: database passwords, API keys, SMTP passwords. Another add-on's text options are withheld as a precaution until that add-on declares which of them are secrets.

Nothing is logged by xfmcp. The forum records each key's last use, as it does for any key.

What you need​


  • On each forum: XenForo 2.2 or later, and the Admin API add-on. Install the newest release from its resource page.
  • On your computer: PHP 8.3 or later with the curl, mbstring and openssl extensions, on Linux, macOS or Windows.
  • An MCP client, such as Claude Code.

Setting it up on the forum​


What a key can read is decided on the forum, not by xfmcp. The add-on refuses a super user key, then checks the endpoint's scope on the key, then an admin permission held by the key's administrator. So the setup is one administrator and one key, with exactly what you want ticked.

An administrator for the key​


Under Groups & permissions > Administrators, choose the administrator the key will act as and give them Use the Admin API. A dedicated administrator account that holds only this is the safest choice, because the key can then never reach more than that account can. Two tools want one core permission each, as well:

  • Option values need Manage options. Without it the options tool shows which options are set but not their values, and says why.
  • Error entries need View logs, on the administrator of the second key.

The account also needs to be able to view the forum, with a valid state and no ban. XenForo refuses every request from a user who cannot.

The read key​


Under Setup > API keys, create a key of type User for that administrator. Choose Selected scopes only, and tick the scope of each tool you want:

  • hampel_admin_api:error_log for the error log summary
  • hampel_admin_api:add_ons for add-ons
  • hampel_admin_api:jobs for cron and the job queue
  • hampel_admin_api:online for who is online
  • hampel_admin_api:logs for XenForo's other logs
  • hampel_admin_api:approval_queue for the approval queue
  • hampel_admin_api:reports for reports
  • hampel_admin_api:activity for registrations and posting
  • hampel_admin_api:user_upgrades for user upgrades
  • hampel_admin_api:validate for add-ons' own checks
  • hampel_admin_api:options and hampel_admin_api:config for options and config.php settings
  • hampel_admin_api:values as well, if options and settings should show their values with secrets removed rather than only whether each is set

"All scopes" reaches none of the add-on's endpoints. The scopes have to be ticked one by one, so that a key is never given the member lookups by accident. Leave those unticked: xfmcp does not use them.

The detail key, if you want one​


error-log-entries is the one tool that returns an error's message and stack trace, which can include a member's input, an email address or a SQL query. It uses a second User key, holding only hampel_admin_api:error_detail. Leave it out and the agent works from the summary: how many errors, of what kind, from which add-on and which part of the code. Leave it out of every forum and the tool is not offered at all.

Create the second key only if you want the agent to read error messages, and with the paragraph above about where answers go in mind.

Setting it up on your computer​


Download and check it​


Each release on GitHub has two files: the program, xfmcp-<version>, and SHA256SUMS. The program is a single PHP archive, the same file on every platform. Download both into one folder, keeping the program's name so the checksum matches.

On Linux:

Bash:
sha256sum --ignore-missing -c SHA256SUMS
sudo install -D -m 0755 xfmcp-<version> /usr/local/lib/xfmcp/xfmcp-<version>
sudo ln -sfn /usr/local/lib/xfmcp/xfmcp-<version> /usr/local/bin/xfmcp

Keeping each version in its own file and linking the one in use means going back to an earlier version is a matter of moving the link.

On macOS, Homebrew's PHP has the extensions it needs:

Bash:
brew install php
shasum -a 256 -c SHA256SUMS
mkdir -p ~/.local/lib/xfmcp ~/.local/bin
install -m 0755 xfmcp-<version> ~/.local/lib/xfmcp/
ln -sfn ~/.local/lib/xfmcp/xfmcp-<version> ~/.local/bin/xfmcp

On Windows, install PHP from windows.php.net (the x64 Non Thread Safe zip, unpacked to a folder such as C:\php), copy its php.ini-production to php.ini, and in it uncomment extension_dir = "ext" and the lines for curl, mbstring and openssl. Then, in PowerShell:

Code:
Get-FileHash .\xfmcp-<version> -Algorithm SHA256
Get-Content .\SHA256SUMS
New-Item -ItemType Directory -Force "$env:LOCALAPPDATA\xfmcp"
Move-Item .\xfmcp-<version> "$env:LOCALAPPDATA\xfmcp\"

The two hashes must match; PowerShell prints its own in upper case. Windows does not run the archive by itself, so wherever this tutorial says xfmcp, read C:\php\php.exe followed by the path to the file.

List your forums​


The forum list is a small TOML file, one table per forum, and it holds live API keys. Keep it somewhere private and outside any repository. On Linux and macOS, chmod 600 it; on Windows, keep it in your own profile, such as %LOCALAPPDATA%\xfmcp\forums.toml.

Code:
[community]
name = "Community Forum"
url  = "https://forum.example.com"
key  = "the read key"

[support]
name = "Support Forum"
url  = "https://support.example.com"
key  = "its read key"
detail_key = "its detail key"

The table name, community here, is the id you and the agent use for that forum. Lowercase it. url is the forum's address. name is an optional label. detail_key is optional, per forum.

Then tell xfmcp where the file is, with the XFMCP_FORUMS_PATH environment variable. The simplest place to set it is in the MCP client's configuration, below. On Linux you can instead put the line in /etc/xfmcp/.env, which xfmcp reads by itself:

INI:
XFMCP_FORUMS_PATH=/home/you/.config/xfmcp/forums.toml

APP_TIMEZONE is the other setting worth knowing. The forum reports every time in UTC, and xfmcp adds each in your zone as well when it is set, such as APP_TIMEZONE=Australia/Sydney.

Check everything before you use it​


Bash:
XFMCP_FORUMS_PATH=/home/you/.config/xfmcp/forums.toml xfmcp app:validate

app:validate proves each key is what it is meant to be, and says what is missing when it is not. For each forum it asks the forum what the key is, reads the add-on list with it, and checks that the read key is refused by the error entries endpoint and the detail key by the summaries. It sends only GET requests, and reads nothing from the error log. A forum set up as above looks like this:

Code:
  Forum: support
  [ ok ] Read key                 a user key holding 12 of the 12 summary scopes and hampel_admin_api:values
  [ ok ] Summaries                XenForo 2.3.13, PHP 8.3.30, Hampel/AdminApi 1.0.0b1
  [ ok ] Values: options          shown, with secrets removed
  [ ok ] Values: configuration    shown, with secrets removed
  [ ok ] Read key reach           refused by error entries (missing_scope)
  [ ok ] Detail key               a user key holding hampel_admin_api:error_detail only
  [ ok ] Error entries            reachable with the detail key
  [ ok ] Detail key reach         refused by a summary (missing_scope)

Read every line. [warn] is worth knowing and does not stop anything; a key holding more than it needs is a warning. [fail] means the tool will not work for that forum, and the line says why. A blank marker is a check that did not apply, which is not the same as a pass. xfmcp app:config prints the configuration it is running with, including which environment file it read, and never prints a key.

Register it with your client​


For Claude Code:

Bash:
claude mcp add -s user xenforo --env XFMCP_FORUMS_PATH=/home/you/.config/xfmcp/forums.toml \
    -- xfmcp mcp:start xenforo

For a client configured with JSON:

JSON:
{
    "mcpServers": {
        "xenforo": {
            "command": "xfmcp",
            "args": ["mcp:start", "xenforo"],
            "env": {"XFMCP_FORUMS_PATH": "/home/you/.config/xfmcp/forums.toml"}
        }
    }
}

Give a client full paths. A desktop client is not started from your shell, so it may not find xfmcp or php on your PATH. On macOS, name $(brew --prefix)/bin/php as the command and the file in ~/.local/lib/xfmcp/ as its first argument. On Windows, name C:/php/php.exe and the file in %LOCALAPPDATA%\xfmcp\; forward slashes save escaping each backslash in JSON. The project's README has both spelled out.

Using it​


Start a new conversation and ask in plain words. The agent picks the tools. A good first question is the same one app:validate answered, from the agent's side:

Which forums can you see, and what will each of them answer?

That calls list-forums, which reads your forum list and contacts nothing, and then forum-access, which asks each forum every summary endpoint and names any it refuses, with the scope or permission it wants. list-forums says what is configured; forum-access says what works, and they are deliberately two tools.

From there, ask what you want to know:

Is anything wrong with the community forum? Check the error log, cron, the job queue and the add-ons.

I just upgraded the gallery add-on on support. Did it install cleanly?

Compare the mail settings across all my forums.

How many registrations did community have over the last 30 days, and how many came through the register form?

The tools​


  • list-forums: which forums are configured, and which have a detail key
  • forum-access: what one forum will actually answer, tool by tool
  • error-log-summary: how many errors, of what kind, from where, and how many members met one
  • error-log-entries: the message and stack trace of one error and others like it, with the detail key
  • add-ons: what is installed at which version, and any install or upgrade left unfinished
  • addon-validate: which add-ons declare their own checks, and how one add-on's checks came out
  • cron-entries: every cron entry, and whether cron is running at all
  • job-queue: the queue by job class, and where failed jobs failed
  • who-is-online: members, guests and robots online, and how concentrated the guests are
  • forum-logs: how much each of XenForo's 18 logs recorded, or one log's breakdowns
  • approval-queue: how much awaits approval, of what kind and for how long
  • reports: how many reports wait, for how long, and since anyone touched one
  • forum-activity: registrations, threads and posts in a window, by the state each is in now
  • user-upgrades: how many members hold each upgrade, what ends soon, what payments were reported
  • forum-options: the forum's options, what was changed, and their values with secrets removed
  • forum-configuration: the config.php settings in force, with secrets removed

forum-options and forum-configuration can be asked for particular settings by name, which is the quick way to answer "is this switched on everywhere?". A name the forum has nothing by comes back as not found, which is different from a setting at its default.

Why the answers are shaped​


Each answer is the forum's own data, rearranged so that a reader cannot easily misread it. Every one of these changes exists because an agent given the raw response drew a wrong conclusion from it, in trials before the tool was released:

  • Every timestamp gains a readable time beside it. XenForo reports Unix seconds in UTC, and an agent read a cron entry's hour as local time.
  • Most answers lead with a one-sentence headline. The error log's default window is 24 hours, and a quiet day read as an empty log.
  • notes say what an empty answer is worth. A production forum records failed jobs only in debug mode, so an empty failed-jobs list there means nothing either way, and the answer says so.
  • Each option and setting says whether its value is shown, partly_withheld or withheld. Without that, a null could mean a withheld secret or an empty setting.
  • Registrations say how many came through the register form. Accounts an administrator or the API made were being counted as sign-ups.
  • A failure is a sentence that says whose problem it is. A forum that cannot be reached, a forum without the add-on and a key the forum refused are three different fixes.

How much to trust a clean answer​


A clean answer means nothing was recorded, which is weaker than nothing being wrong. A fault that logs no error is not in the error log. A forum that is down cannot answer at all, and the tool says it could not be reached rather than returning an empty result. Ask the agent to say so when it reports a clean bill of health, and expect it to.

A few limits are worth knowing in advance:

  • who-is-online is a snapshot. Whether a number is high depends on what is normal for that forum, which only you know.
  • forum-activity counts things in the state they are in now, cannot count what was deleted outright, and covers at most 31 days at a time.
  • addon-validate reports each check's outcome, never its message, so it can say a check warned but not why. That is the add-on's own validate command, on the server. It runs only the checks an add-on marks safe to run remotely, and a check it did not run is skipped, never a pass.
  • forum-logs over a long window on a large log is slow, because the forum reads every row in the window. The default 24 hours is enough to learn how big a log is.
  • On XenForo 2.2, failed jobs and cancelled upgrades are not recorded, and the tools report them as not recorded rather than as zero.

Keeping it current​


Add a forum, change a key or tick a scope, and the tools see it at once. The forum list is read again whenever it changes, so the agent's next call uses the new keys. The one exception is adding the first detail key anywhere, which makes error-log-entries appear: a client asks for the list of tools once, so that takes a new conversation.

To upgrade, download the new release, check it, and move the link. A running client keeps the old process until it restarts the server, which in Claude Code is a new session or /mcp.

Where to get it, and where to report what you find​



The README is the reference, and it goes further than this on each section: the permission each tool needs, the configuration file's search order, and the full list of limits.

Most of how the answers read today came from an agent getting something wrong and someone noticing. If an agent draws a wrong conclusion from one of these tools, that is a bug worth reporting: open an issue with the question you asked, the tool it called, and what it concluded.
Author
Sim
Downloads
3
Views
7
First release
Last update

Ratings

0.00 star(s) 0 ratings

More resources from Sim

Back
Top Bottom