touhou-wiki
# Touhou Wiki Plugin (`touhou-wiki`)
Zero-dependency **Antigravity Plugin**, **Model Context Protocol (MCP) server**, **Antigravity Skill**, and **CLI** for live HTTP/2 queries against [Touhou Wiki](https://en.touhouwiki.net).
Built on native Node.js (`node:http2`, `node >= 18`) with zero `npm` dependencies, balanced-brace MediaWiki Infobox extraction, Touhou Wiki template unwrapping (`{{ruby-ja}}`, `{{lang}}`, `{{H:title}}`, `{{nihongo}}`), and TTL caching.
---
## Features
- **7 Live MCP Tools** (`touhou_wiki_*`) covering full-text & title search, structured Infobox + article fetching, TOC inspection, section-level extraction, category browsing, subpage discovery, and image URL/dimension resolution.
- **1 MCP Resource** (`touhou-wiki://guide/categories`) exposing canonical Touhou Wiki categories and official game (`TH01`–`TH20`) / print-work abbreviations.
- **Antigravity Skill** (`skills/touhou-wiki/SKILL.md`) guiding agents to inspect Table of Contents first, fetch targeted sections, verify canon vs. doujin categories, and cite `en.touhouwiki.net` URLs.
- **Standalone CLI** (`scripts/touhou-wiki-cli.mjs`) for terminal scripts or non-MCP environments.
---
## Installation
### 1. Antigravity CLI (Recommended)
Install directly from GitHub:
```bash
agy plugin install https://github.com/Remilya/Touhou-mcp
```
Or validate and install from a local clone:
```bash
git clone https://github.com/Remilya/Touhou-mcp.git
agy plugin validate --strict ./Touhou-mcp
agy plugin install ./Touhou-mcp
```
### 2. Manual Global Plugin Install (Antigravity App / IDE)
Clone or copy this repository into your global Antigravity plugins directory:
- **macOS / Linux:** `~/.gemini/config/plugins/touhou-wiki`
- **Windows:** `%USERPROFILE%\.gemini\config\plugins\touhou-wiki`
Then open **Customizations** in Antigravity to verify `Touhou Wiki` appears with its bundled MCP server and `touhou-wiki` skill.
### 3. Standalone MCP Server Only (Claude Desktop / Cursor / Windsurf / Custom `mcp_config.json`)
Point any MCP client at `scripts/touhou-wiki-mcp.mjs` using Node.js 18+:
```json
{
"mcpServers": {
"touhou-wiki": {
"command": "node",
"args": ["/path/to/Touhou-mcp/scripts/touhou-wiki-mcp.mjs"]
}
}
}
```
---
## Exposed MCP Tools
| Tool Name | Purpose | Key Arguments |
| :--- | :--- | :--- |
| **`touhou_wiki_search`** | Combined title (`opensearch`) and full-text MediaWiki search (`ns=0`). | `query`, `limit`, `include_subpages` |
| **`touhou_wiki_get_page`** | Fetch structured Infobox, kanji/romaji metadata, primary image URL, categories, TOC, and cleaned text. | `title`, `max_chars`, `include_raw_wikitext`, `resolve_image` |
| **`touhou_wiki_get_sections`** | Retrieve article Table of Contents (section indices, levels, titles, anchors). | `title` |
| **`touhou_wiki_get_section`** | Fetch a single section by numeric index (`"0"` for Lead) or heading name (`"Personality"`). | `title`, `section`, `max_chars`, `include_raw_wikitext` |
| **`touhou_wiki_list_category`** | Browse pages or subcategories in a `Category:...` with `continue_token` pagination. | `category`, `type`, `limit`, `continue_token` |
| **`touhou_wiki_list_subpages`** | List `<Title>/...` subpages (e.g., `Perfect Memento in Strict Sense`). | `title`, `limit` |
| **`touhou_wiki_get_image_info`** | Resolve direct image URLs, dimensions, and MIME types for `File:...` names or an article's images. | `files`, `page`, `limit` |
### Exposed MCP Resource
| URI | MIME Type | Contents |
| :--- | :--- | :--- |
| `touhou-wiki://guide/categories` | `application/json` | Canonical Touhou Wiki categories plus `TH01`–`TH20` and print-work abbreviations. |
---
## Standalone CLI Usage
```bash
node scripts/touhou-wiki-cli.mjs --help
node scripts/touhou-wiki-cli.mjs search "Hakurei Shrine" --limit 5
node scripts/touhou-wiki-cli.mjs page "Reimu Hakurei" --max-chars 3000
node scripts/touhou-wiki-cli.mjs sections "Embodiment of Scarlet Devil"
node scripts/touhou-wiki-cli.mjs section "Reimu Hakurei" "Personality"
node scripts/touhou-wiki-cli.mjs category "Locations" --type articles --limit 25
node scripts/touhou-wiki-cli.mjs subpages "Perfect Memento in Strict Sense" --limit 15
node scripts/touhou-wiki-cli.mjs images --files "File:Th20Reimu.png"
```
---
## Local Verification & Testing
Run the offline unit tests (wikitext unwrapping, infobox extraction, tool schemas, resource checks):
```bash
npm test
```
Run the full live HTTP/2 integration suite against `https://en.touhouwiki.net`:
```bash
npm run test:live
```
---
## License & Attribution
- Plugin code, MCP server, CLI, and skill documentation are licensed under the [MIT License](./LICENSE).
- Article text and media retrieved at runtime originate from [Touhou Wiki (`en.touhouwiki.net`)](https://en.touhouwiki.net) and remain subject to its respective content licenses (including CC BY-SA where applicable). *Touhou Project* is created by ZUN / Team Shanghai Alice.
TDQS
Scored across 7 tools
Each tool has a distinct scope: search vs. full-page fetch vs. TOC-only vs. single-section vs. category listing vs. subpage listing vs. image metadata. The only mild overlap is between get_page (which includes the TOC and full text) and get_sections/get_section, but the descriptions make the cost/granularity tradeoff explicit enough that an agent can choose correctly.
All seven tools use the same touhou_wiki_ prefix followed by a consistent verb_noun pattern (search, get_page, get_sections, get_section, list_category, list_subpages, get_image_info) in snake_case. The singular/plural get_section vs get_sections pair is a deliberate and readable distinction rather than an inconsistency.
Seven tools is a well-scoped surface for a wiki server: retrieval, navigation, and media resolution each get focused, non-redundant tools. No tool feels like filler and none of the obvious access patterns is split into unnecessary variants.
The surface covers search, page retrieval, section navigation, category browsing, subpage enumeration, and image resolution — the core read-only workflows for a MediaWiki domain. Minor gaps remain for link graph operations (what-links-here, external links) and site-wide listings like recent changes, which agents would have to work around.