# Connecting Claude / AI Agent to Fandom via MediaWiki MCP

When you are ready to publish the wiki to production on Fandom.com, you can connect me (or Claude Code / Antigravity / Cursor) directly to your wiki using the **MediaWiki MCP Server**. This allows an agent to read, write, update, and upload pages automatically.

---

## 1. What You Need
* **Target Wiki API URL**:  
  `https://beach-detector.fandom.com/api.php`
* **Bot Username**:  
  `BeachDetector-Bot@mcp-publisher` (generated in `Special:BotPasswords`)
* **Bot Password**:  
  `<YOUR_GENERATED_BOT_PASSWORD>`

---

## 2. Setting Up the MediaWiki MCP Server

The open-source MediaWiki MCP server (`@modelcontextprotocol/server-mediawiki` or `mediawiki-mcp-server`) connects standard LLMs to any MediaWiki instance via standard JSON-RPC.

### Claude Desktop / Claude Code Config
Add the server entry to your Claude configuration file (e.g. `claude_desktop_config.json` or `~/.claude.json`):

```json
{
  "mcpServers": {
    "fandom-beach-detector": {
      "command": "npx",
      "args": ["-y", "mediawiki-mcp-server"],
      "env": {
        "MEDIAWIKI_API_URL": "https://beach-detector.fandom.com/api.php",
        "MEDIAWIKI_USERNAME": "BeachDetector-Bot@mcp-publisher",
        "MEDIAWIKI_PASSWORD": "YOUR_BOT_PASSWORD_HERE"
      }
    }
  }
}
```

### Alternatively via Python MCP / Pip
If running a python-based server:
```bash
pip install mediawiki-mcp-server
```
And point the environment variables to the same credentials.

---

## 3. What the AI Agent Can Do Through MCP
Once connected, you can ask the agent with simple prompts:
* *"Upload the Sand King article from `docs/fandom/articles/Sand_King.wiki` to the wiki"*
* *"Upload all images from `docs/fandom/assets/` to Fandom with proper image descriptions"*
* *"Synchronize all weapon and monster stats with `src/loot/catalogue.rs`"*
* *"Create the Navigation Bar template for all beach locations"*

---

## 4. Rate Limiting Safeguards
To comply with Fandom's platform rules:
1. Ensure the agent or script pauses **1 second** between page edits (`time.sleep(1.0)`).
2. For initial bulk imports, push the **Templates** and **CSS** first (`Template:Infobox_Monster`, `MediaWiki:Common.css`), followed by category hubs, then individual article pages.
3. Keep the "Human-in-the-Loop" workflow active by letting the agent show you page diffs before committing mass changes.
