GW2 MCP Server
by BaLaurent
README.md
# GW2 MCP Server
A [Model Context Protocol](https://modelcontextprotocol.io/) server that gives Claude access to Guild Wars 2 game data — Trading Post prices, account info, crafting recipes, wiki lookups, and more.
Built with [FastMCP](https://github.com/jlowin/fastmcp) (Python). Runs over **stdio**, designed for Claude Desktop and Claude Code.
## Features
### Trading Post
| Tool | Description |
|------|-------------|
| `search_item` | Fuzzy search items by name (supports `en`, `fr`, `de`, `es`, `zh`) |
| `get_item_price` | Current buy/sell prices for an item |
| `get_item_listings` | Order book depth (top N buy and sell listings) |
| `calculate_flip` | Flip profitability after 15% TP tax (margin, ROI) |
| `get_trading_history` | Your open orders and transaction history |
### Items & Crafting
| Tool | Description |
|------|-------------|
| `get_item_details` | Full item metadata (stats, rarity, type, description) |
| `get_recipe` | Crafting recipe with ingredients and estimated cost |
| `get_item_bulk` | Batch resolve up to 200 item IDs to names and details |
### Wiki
| Tool | Description |
|------|-------------|
| `search_wiki` | Search the GW2 Wiki |
| `get_wiki_page` | Retrieve wiki page content as plain text |
### Account (requires API key)
| Tool | Description |
|------|-------------|
| `get_account_info` | Account name, world, guilds, creation date, expansions |
| `get_bank_contents` | Bank contents with resolved item names |
| `get_material_storage` | Material storage inventory |
| `get_characters` | All characters with details |
| `get_wallet` | Wallet currencies (gold, karma, gems, etc.) |
| `get_achievement_progress` | Progress on a specific achievement |
### Dailies & Events
| Tool | Description |
|------|-------------|
| `get_daily_worldbosses` | Today's world bosses (marks completed ones if API key is set) |
| `get_daily_crafting` | Daily craftable items (marks completed ones if API key is set) |
### Resources
Read-only data the LLM can consult for context:
- `gw2://tp/tax-info` — Trading Post tax structure (5% listing + 10% exchange)
- `gw2://currencies` — All GW2 currencies
- `gw2://worlds` — Server/world list
- `gw2://professions` — Professions with specializations
### Prompt Templates
Pre-built workflows that chain multiple tools:
- **`market_analysis`** — Full market report for an item (price, order book, flip analysis)
- **`crafting_cost`** — Craft vs. buy comparison with ingredient pricing
- **`daily_checklist`** — Daily world boss and crafting activity tracker
## Prerequisites
- **Python 3.11+**
- **[uv](https://docs.astral.sh/uv/)** (recommended) or pip
## Setup
### 1. Clone the repository
```bash
git clone https://github.com/your-username/gw2-mcp-server.git
cd gw2-mcp-server
```
### 2. Create your configuration
```bash
cp .env.example .env
```
### 3. Get a GW2 API key
1. Go to [https://account.arena.net/applications](https://account.arena.net/applications)
2. Create a new API key with these permissions:
- `account`
- `characters`
- `inventories`
- `tradingpost`
- `progression`
- `wallet`
3. Paste the key into your `.env` file:
```env
GW2_API_KEY=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
GW2_LANG=en
LOG_LEVEL=INFO
```
> The API key is optional. Without it, account-related tools are unavailable but everything else works (Trading Post, wiki, items, events).
### 4. Install dependencies
```bash
uv sync
```
### 5. Test locally
```bash
uv run python -m gw2_mcp.server
```
## Usage with Claude Desktop
Add the server to your Claude Desktop configuration (`claude_desktop_config.json`):
```json
{
"mcpServers": {
"gw2": {
"command": "uv",
"args": [
"run",
"--directory", "/absolute/path/to/gw2-mcp-server",
"python", "-m", "gw2_mcp.server"
]
}
}
}
```
## Usage with Claude Code
Add the server to your Claude Code settings (`.claude/settings.json`):
```json
{
"mcpServers": {
"gw2": {
"command": "uv",
"args": [
"run",
"--directory", "/absolute/path/to/gw2-mcp-server",
"python", "-m", "gw2_mcp.server"
]
}
}
}
```
## Configuration
All configuration is done through the `.env` file:
| Variable | Default | Description |
|----------|---------|-------------|
| `GW2_API_KEY` | *(none)* | Your ArenaNet API key. Optional — account tools require it |
| `GW2_LANG` | `en` | Language for item names and descriptions (`en`, `fr`, `de`, `es`, `zh`) |
| `GW2_CACHE_DIR` | `~/.cache/gw2-mcp` | Directory for the persistent item index cache |
| `LOG_LEVEL` | `INFO` | Logging level (`DEBUG`, `INFO`, `WARNING`, `ERROR`) |
## Architecture
```
gw2_mcp/
├── server.py # FastMCP entry point, wires everything together
├── config.py # .env loading and validation
├── cache.py # In-memory TTL cache manager
├── item_index.py # Persistent item name index (~90k items, disk JSON)
├── clients/
│ ├── gw2_api.py # GW2 API v2 async client (rate limiting, retry, caching)
│ └── wiki.py # GW2 Wiki MediaWiki client (wikitext cleanup)
├── tools/
│ ├── commerce.py # Trading Post tools
│ ├── items.py # Item & recipe tools
│ ├── account.py # Account-authenticated tools
│ ├── events.py # World bosses, dailies
│ └── wiki.py # Wiki search & retrieval
├── resources/
│ └── static.py # Read-only data resources
├── prompts/
│ └── templates.py # Prompt templates
└── utils/
├── converters.py # Copper to gold/silver/copper conversion
└── validators.py # Input validation
```
### Key design decisions
- **Async-first**: All API calls use `httpx.AsyncClient` with `asyncio.gather` for batch operations.
- **Dual caching**: In-memory with TTL for API responses (5 min to 24h), persistent JSON on disk for the item index.
- **Rate limiting**: Internal cap at 300 req/min with exponential backoff on 429/5xx errors.
- **Graceful degradation**: Works without an API key (account tools return a descriptive error instead of crashing).
- **Stale-while-revalidate**: On API errors, returns expired cache data with a warning rather than failing.
## Development
```bash
# Install dev dependencies
uv sync
# Run tests
uv run pytest
# Run with debug logging
LOG_LEVEL=DEBUG uv run python -m gw2_mcp.server
```
## License
MIT
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues