fmg-mcp

fmg-mcp

MCP server that drives Azgaar's Fantasy Map Generator in a real browser via Playwright, letting users generate maps, inspect them, and export screenshots/SVG/JSON through natural language.

Category
访问服务器

README

fmg-mcp

An MCP (Model Context Protocol) server that drives Azgaar's Fantasy Map Generator in a real browser via Playwright, so Claude (or any MCP client) can generate maps, inspect them, and export screenshots / SVG / JSON.

FMG is a client-side web app with no public API, so this server works by puppeting an actual instance of the page — clicking buttons, filling inputs, and reading its in-memory JS state — rather than reimplementing its generation algorithms.

There are two ways to run this: locally over stdio (for Claude Desktop/Code) or remotely over HTTP (to use as a "custom connector" URL in claude.ai). Pick one.

Option A: Local, stdio (Claude Desktop / Claude Code)

cd fmg-mcp
npm install
npx playwright install chromium   # downloads a headless Chromium build
npm run build

Register it:

{
  "mcpServers": {
    "fmg": {
      "command": "node",
      "args": ["/absolute/path/to/fmg-mcp/dist/stdio.js"],
      "env": {
        "FMG_HEADLESS": "true",
        "FMG_OUTPUT_DIR": "/absolute/path/to/fmg-output"
      }
    }
  }
}

Environment variables (all optional):

  • FMG_URL — override the FMG URL (defaults to the GitHub Pages instance).
  • FMG_HEADLESS"false" to watch the browser while it works. Defaults to headless.
  • FMG_OUTPUT_DIR — where screenshots/exports are written. Defaults to ./fmg-output.

Option B: Remote, HTTP (claude.ai "Add custom connector")

This runs the same tools over Streamable HTTP at /mcp, so you can host it somewhere and give claude.ai the URL. It needs a real browser, so it must run on a container/VM host, not a serverless/edge platform.

Deploy on Render.com (free/starter tier, easiest)

  1. Push this folder to a GitHub repo.
  2. In Render: New > Blueprint, point it at the repo — it will pick up render.yaml and Dockerfile automatically and build the image.
  3. Render auto-generates an AUTH_TOKEN env var for you (see the service's Environment tab) — copy it.
  4. Once deployed, your MCP URL is https://<your-service>.onrender.com/mcp.

Deploy anywhere else that runs Docker (Fly.io, Railway, a VPS, etc.)

docker build -t fmg-mcp .
docker run -p 8787:8787 -e AUTH_TOKEN=$(openssl rand -hex 24) fmg-mcp

Put whatever host/domain that ends up behind at https://your-host/mcp.

Add it to claude.ai

Settings → Connectors → Add custom connector, then:

  • URL: https://your-host/mcp
  • If you set AUTH_TOKEN, choose the auth option that lets you supply a bearer token, and paste the token value in.

⚠️ Security note: anyone with the URL and token can drive a real browser through your server. Always set AUTH_TOKEN on anything reachable from the public internet — don't leave it unset outside of local testing.

Notes on the HTTP deployment

  • Playwright's official Docker base image (mcr.microsoft.com/playwright) is used so Chromium and its OS dependencies are already present — no extra apt-get/playwright install step needed in the container.
  • The server keeps one browser page per MCP session (keyed by the Mcp-Session-Id header the SDK manages automatically), so map state persists across tool calls within a conversation, same as the stdio version.
  • Free hosting tiers that spin containers down when idle will lose in-memory map state between calls — fine for occasional use, but if you want state to reliably survive idle periods, use a plan that keeps the container warm.

Tools

Tool What it does
open_map Launches/reuses the browser session and waits for FMG to load. Call first.
new_map Generates a new map, optionally with a specific seed and/or heightmap template.
get_map_info Reads seed, dimensions, and counts of cultures/states/burgs/religions from the page state.
screenshot Saves a PNG of the map (or full page) to the output directory.
export_svg Saves the live map SVG to a .svg file.
export_json Best-effort dump of FMG's internal pack/grid/notes data to JSON.
click Clicks any element by CSS selector — for UI FMG doesn't have a dedicated tool for.
inspect_globals Lists map-related window globals FMG currently exposes, to help you write run_js calls.
run_js Evaluates arbitrary JS in the page (e.g. calling FMG's own save/generate functions directly).
close_browser Closes the browser session.

A note on fragility

FMG doesn't publish a stable API, and its internal function/variable names and UI selectors have changed across versions over the project's history. The tools above use the most common/longstanding selectors and globals (#regenerateMap, window.pack, window.seed, etc.), but if the deployed version has drifted:

  1. Use inspect_globals and run_js to poke around and find the current equivalents (e.g. run_js with "Object.keys(window).filter(k => /gener/i.test(k))").
  2. Use click with browser devtools-inspected selectors as a fallback for any UI action not covered by a dedicated tool.

Example session

open_map
new_map { "seed": "123456789", "template": "Continents" }
get_map_info
screenshot { "fileName": "continents.png" }
export_svg { "fileName": "continents.svg" }

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选