MediaWiki-MCP-Server
AGENTS.md153 starsChanged 4 months agoMITView on GitHub
Project context for AI coding agents working on this repo. For human users, start from README.md. Relative imports name the .ts file they actually resolve to — import { foo } from './foo.ts', not './foo.js'. TypeScript rewrites the extension to .js on emit (rewriteRelativeImportExtensions), so dist/ is unchanged. Package specifiers are untouched. import/extensions enforces this, so a stale .js specifier fails the pre-commit hook. Its help text says to remove the extension; ignore that and change it to .ts, since…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 69
Create src/tools/extensions/<id>/<id>-<verb>.ts for each tool, following the conventions in docs/tool-conventions.md.
- Very specific: line 70
Create src/tools/extensions/<id>/index.ts exporting the pack:
- Very specific: line 82
Add the pack to the extensionPacks array in src/tools/extensions/index.ts.
- Very specific: line 105
Never add another copy of the standard configuration block: the point is not chasing a change through one block per client, though the …
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Project context for AI coding agents working on this repo. For human users, start from README.md.
Repo layout
src/tools/— one file per non-extension MCP tool (descriptor + handler + registration).src/tools/extensions/<id>/— extension packs: tools gated on a specific MediaWiki extension (SMW / Bucket / Cargo / …), grouped under a per-pack module.src/runtime/— context, dispatcher, register, reconcile, logger, monotonic clock, constants, request-scoped context, auth-shape classifier.src/wikis/— wiki registry, selection, mwn provider, discovery, error sanitiser.src/transport/— stdio and streamable HTTP entry points.src/outbound/— the HTTP requests the server makes itself: SSRF guard, redirect handling, fetch helpers.src/auth/— OAuth for MediaWiki, in two roles (client to a wiki, and the hosted authorization-server proxy). See src/auth/README.md.src/config/—config.jsonloader and substitution.src/services/— section, edit, revision, response services consumed viaToolContext.src/results/— response shaping (truncation, format, schemas).src/errors/— error classifier + wordings tools declare for some error codes (tailoredErrors).src/resources/— MCP resources exposingmcp://wikis/{wikiKey}.src/server.ts,src/index.ts— server factory and bootstrap.tests/— vitest suites mirroring the source tree; shared helpers intests/helpers/.
Imports
Relative imports name the .ts file they actually resolve to — import { foo } from './foo.ts', not './foo.js'. TypeScript rewrites the extension to .js on emit (rewriteRelativeImportExtensions), so dist/ is unchanged. Package specifiers are untouched.
import/extensions enforces this, so a stale .js specifier fails the pre-commit hook. Its help text says to remove the extension; ignore that and change it to .ts, since NodeNext will not resolve an extensionless relative path.
The module paths passed to vi.mock, vi.doMock, vi.unmock, vi.importActual and vi.importMock take the same .ts extension, but the lint rule does not reach them and the compiler does not rewrite them — they are function arguments, not imports. Keep each one in step with the static import it doubles by hand.
A path handed to a runtime createRequire( import.meta.url ) resolves against the emitted file, not the source, so it keeps the extension and depth dist/ needs. Leave those alone.
Commands
npm run build— compile TypeScript todist/.npm test— run the vitest suite once.npm run lint— oxlint.npm run typecheck—tsc --noEmitoversrcandtests, viatsconfig.lint.json.npm run buildonly typecheckssrc, so this is the check that covers test code.npm run check:mcp— MCPJam doctor + MCP protocol conformance against the built server (build first). CI runs it on every PR and also diffs the tool surface against the PR base, failing on breaking changes.npm run fmt/npm run fmt:check— oxfmt (write / dry-run).npm run preflight— full gate (install, lint, typecheck, fmt check, validateserver.json, test, build, bundle). Run before a release.- Git hooks:
lefthookauto-installs onnpm install. Pre-commit runsoxfmt(auto-fix on staged files) +oxlint. Pre-push runsnpm run typecheck+ the test suite. Bypass with--no-verify. npm run inspector— watch-mode build + MCP Inspector UI for interactive debugging.
Tool conventions
See docs/tool-conventions.md for tool design stance, description voice, parameter docs, annotation hints, sibling disambiguation, canonical MediaWiki terminology, and result-cap behavior. Consult before adding or modifying a tool.
Documentation conventions
See docs/documentation-conventions.md for the reader, register, and length rules for prose documentation. Consult before writing or editing README.md, CHANGELOG.md, or any page under docs/.
Tool handlers
Each tool exports a typed descriptor (name, description, inputSchema, annotations, handle) from src/tools/<name>.ts. Tests import the descriptor and route through dispatch( descriptor, ctx ) — see tests/helpers/fakeContext.ts.
Adding or changing tools
A PR that adds, removes, or renames a tool — or that materially changes a tool's user-visible behaviour — must also update:
README.md— the tool table near the top (name, one-line description, OAuth grant required).CHANGELOG.md— an entry under## [Unreleased](Added / Changed / Removed / Breaking changes as appropriate, per Keep a Changelog).
Pure-internal refactors that don't change tool surface or behaviour don't need either.
Adding an extension pack
A pack is a self-describing module exposing tools that share an extension gate. To add one:
- Create
src/tools/extensions/<id>/<id>-<verb>.tsfor each tool, following the conventions indocs/tool-conventions.md. - Create
src/tools/extensions/<id>/index.tsexporting the pack:import type { ExtensionPack } from '../types.ts'; import { myTool } from './<id>-<verb>.ts'; // Convention: export name folds the id — `smwPack`, `bucketPack`, etc. export const myPack: ExtensionPack = { id: '<id>', extensionNames: ['CanonicalExtensionName' /*, aliases */], tools: [/* tool descriptors */], }; - Add the pack to the
extensionPacksarray insrc/tools/extensions/index.ts.
A pack whose tools need a capability the extension list alone does not reveal — Wikibase's query service, which a repository publishes in its siteinfo — declares an optional wikiGate naming those tools, the predicate over the wiki's probed WikiIdentity, and the message a refused call carries; the rest of the pack is unaffected. Gate and extension are conjoined per wiki, so the gated tools are offered while some one wiki satisfies both, and the ungated tools of the same pack while any wiki has the extension. The gate is enforced centrally by the per-call capability guard, so no handler repeats it, and the tool names it lists are checked against the pack's own tools at startup.
A pack whose extension adds error codes to the action API declares them as errorCodes (and errorCodePrefixes for a family the extension numbers per case), mapped to the category a caller should read them as. A tool that reaches the wiki through mwn never catches its own error — mwn throws and the dispatcher classifies — so the codes have to reach one central classifier; declaring them on the pack keeps the vocabulary with the code that produces it, so removing the pack removes its codes. extensionErrorVocabulary merges them and fails startup on a code two packs both claim or one MediaWiki already defines. A pack with its own transport, such as NeoWiki's REST client or wikibase-query's SPARQL one, classifies its failures itself and throws them as a ClassifiedError, which the dispatcher reports like any other; its handlers do not catch them.
Reconcile picks up the new pack automatically — no edits to src/runtime/reconcile.ts. README.md and CHANGELOG.md still need updating per the policy in "Adding or changing tools".
Adding or changing environment variables
A PR that adds, removes, or renames an env var read by the server — or that changes its default or accepted values — must also update:
- The right env-var table for the variable's tier. Each variable lives in exactly one table:
README.mdfor a core variable that applies to any setup;docs/deployment.md(the HTTP-transport or hosted-OAuth-proxy sub-table) for a variable that only matters when self-hosting the HTTP server or running the proxy;docs/configuration.mdfor a config-file substitution or upload-directory variable. server.json— theenvironmentVariablesarray in both themcpbandnpmpackage blocks, if the variable is one the install-time prompts should surface.CHANGELOG.md— an entry under## [Unreleased]if the change is user-visible.Dockerfile— only if the var needs a default baked into the docker image.
Adding a client
A client that just pastes the standard configuration gets a row in the client table under "Standard configuration" in the README, not a ### section by itself. A client can have both, as Cursor and VS Code do, when it also needs install badges or other prose a row cannot carry. Confirm the configuration file path and root key against the client's own current documentation first: a wrong path costs a user a debugging session.
A client earns its own ### section when its configuration shape differs from the standard mcpServers object, as OpenCode's mcp key does, or when it needs install-flow prose a table row cannot carry: plugin install commands, a bundle download, install badges, or more than one configuration file location. Antigravity is an example of the latter: its configuration shape is the standard one, but it needs two file locations plus a note about importing an existing Gemini CLI setup.
Never add another copy of the standard configuration block: the point is not chasing a change through one block per client, though the badge payloads and the two plugin server declarations (plugins/mediawiki-mcp-server/.mcp.json and .codex-plugin/mcp.json) carry their own copies that must be kept in step.
Retiring or adding a committed install channel needs a ## [Unreleased] entry in CHANGELOG.md; documenting a client that needs no committed file does not.
See "Distribution" below for the channel map and the manifest contracts.
Distribution
See docs/distribution.md for the install channels, the Claude Code and Codex plugin layout, the manifest fields scripts/sync-manifests.cjs owns, and how to test an install before publishing. Consult before adding an install channel or editing a plugin manifest.
Testing
Tool tests build a ToolContext via contextOn( mwn ) from tests/helpers/fakeContext.ts, around a mock wiki (typically createMockMwn() from tests/helpers/mock-mwn.ts), and dispatch through dispatch( descriptor, ctx ). Override only the slices the test exercises. See docs/testing.md for the full pattern, MCP Inspector CLI examples, and the bot-password setup required to exercise authenticated tools against a local wiki.
Releasing
See docs/releasing.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

