Farm Script Service

Last modified by Vincent Massol on 2026/09/04 19:20

Reference

MCPFarmScriptService is the Script API behind the main wiki's MCP farm dashboard: it reads and writes each wiki's MCP state from wiki pages, with the rights check on every write. It is registered under the hint mcp, so pages reach it as $services.mcp.

#foreach ($wikiId in $services.wiki.getAllIds())
  $wikiId: enabled=$services.mcp.isEnabled($wikiId) reach=$services.mcp.isCrossWikiReach($wikiId)
#end

Reading

Method Returns
isEnabled(wikiId) Whether that wiki's MCP endpoint is enabled
getServerUrl(wikiId) That wiki's externally reachable endpoint URL, ready to paste into an MCP client configuration
getToolStates(wikiId) Every registered tool's state on that wiki, sorted by category then id for a stable tree order
isCrossWikiReach(wikiId) Whether that wiki's endpoint may reach other wikis
canAdmin(wikiId) Whether the current user may administer that wiki
canFarmAdmin() Whether the current user may administer the farm

Reads are not rights-gated, consistently with the configuration they expose. Writes are.

Writing

Method Does Rights checked on
setEnabled(wikiId, enabled) Sets that wiki's MCP enabled flag That wiki
setEnabledTools(wikiId, toolIds) Stores the explicit set of enabled tool ids; a null array stores an explicit empty set That wiki
setCrossWikiReach(wikiId, allowed) Sets that wiki's cross-wiki reach grant The MAIN wiki
applyEnabled(managedWikiIds, enabledWikiIds) Sets each managed wiki enabled if and only if it is also listed as enabled Each wiki
applyReach(managedWikiIds, reachWikiIds) The same for cross-wiki reach The MAIN wiki, once

Cross-wiki reach is a farm-level decision, which is why its rights check is on the main wiki: a subwiki administrator cannot grant reach to their own wiki. The bulk methods only write a wiki whose state actually changes, and report how many they changed.

Returned types

Type Members
MCPToolState getId(), getCategory(), getSummary(), isMandatory(), isWrite(), isEnabled()
BulkResult getChanged(), getSkipped()

FAQ

Why is the hint mcp and not mcpFarm?

The component is named mcp, so the Script API is $services.mcp. The class name says farm because that is the scope it administers, not because it changes the binding.

Does a write take effect without a restart?

Yes. Saving a wiki's MCP configuration invalidates that wiki's cached server, and the next request rebuilds it.

Related

Get Connected