@piekasz/wow-mcp 0.0.0-stage → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE +674 -0
  2. package/NOTICE +37 -0
  3. package/README.md +41 -2
  4. package/addon/WowMcp/AuctionTooltip.lua +106 -0
  5. package/addon/WowMcp/Commands.lua +259 -0
  6. package/addon/WowMcp/Compat.lua +167 -0
  7. package/addon/WowMcp/Core.lua +50 -0
  8. package/addon/WowMcp/Events.lua +62 -0
  9. package/addon/WowMcp/Items.lua +314 -0
  10. package/addon/WowMcp/Maps.lua +66 -0
  11. package/addon/WowMcp/MinimapButton.lua +114 -0
  12. package/addon/WowMcp/Options.lua +208 -0
  13. package/addon/WowMcp/Panel.lua +294 -0
  14. package/addon/WowMcp/QuestDb.lua +303 -0
  15. package/addon/WowMcp/QuestRewards.lua +137 -0
  16. package/addon/WowMcp/Sections/ActionBars.lua +54 -0
  17. package/addon/WowMcp/Sections/Auctions.lua +305 -0
  18. package/addon/WowMcp/Sections/Bank.lua +48 -0
  19. package/addon/WowMcp/Sections/Buyback.lua +47 -0
  20. package/addon/WowMcp/Sections/Character.lua +177 -0
  21. package/addon/WowMcp/Sections/Cooldowns.lua +76 -0
  22. package/addon/WowMcp/Sections/Currencies.lua +47 -0
  23. package/addon/WowMcp/Sections/Deaths.lua +43 -0
  24. package/addon/WowMcp/Sections/Dungeons.lua +117 -0
  25. package/addon/WowMcp/Sections/EquipmentSets.lua +83 -0
  26. package/addon/WowMcp/Sections/FlightPaths.lua +145 -0
  27. package/addon/WowMcp/Sections/Friends.lua +70 -0
  28. package/addon/WowMcp/Sections/Group.lua +101 -0
  29. package/addon/WowMcp/Sections/Guide.lua +317 -0
  30. package/addon/WowMcp/Sections/Guild.lua +131 -0
  31. package/addon/WowMcp/Sections/Inspect.lua +100 -0
  32. package/addon/WowMcp/Sections/Inventory.lua +64 -0
  33. package/addon/WowMcp/Sections/Legacy.lua +375 -0
  34. package/addon/WowMcp/Sections/Loot.lua +170 -0
  35. package/addon/WowMcp/Sections/Macros.lua +26 -0
  36. package/addon/WowMcp/Sections/Mail.lua +70 -0
  37. package/addon/WowMcp/Sections/Note.lua +38 -0
  38. package/addon/WowMcp/Sections/Pet.lua +127 -0
  39. package/addon/WowMcp/Sections/Played.lua +52 -0
  40. package/addon/WowMcp/Sections/Probe.lua +79 -0
  41. package/addon/WowMcp/Sections/Professions.lua +129 -0
  42. package/addon/WowMcp/Sections/Pvp.lua +45 -0
  43. package/addon/WowMcp/Sections/QuestDb.lua +106 -0
  44. package/addon/WowMcp/Sections/QuestGiver.lua +45 -0
  45. package/addon/WowMcp/Sections/Quests.lua +146 -0
  46. package/addon/WowMcp/Sections/Recipes.lua +195 -0
  47. package/addon/WowMcp/Sections/Reputation.lua +56 -0
  48. package/addon/WowMcp/Sections/Spells.lua +87 -0
  49. package/addon/WowMcp/Sections/Stable.lua +90 -0
  50. package/addon/WowMcp/Sections/Talents.lua +137 -0
  51. package/addon/WowMcp/Sections/Trainer.lua +58 -0
  52. package/addon/WowMcp/Sections/Vendor.lua +72 -0
  53. package/addon/WowMcp/Sections/XpGains.lua +258 -0
  54. package/addon/WowMcp/Snapshot.lua +412 -0
  55. package/addon/WowMcp/Store.lua +142 -0
  56. package/addon/WowMcp/TalentGrid.lua +171 -0
  57. package/addon/WowMcp/Timing.lua +61 -0
  58. package/addon/WowMcp/TraitTree.lua +158 -0
  59. package/addon/WowMcp/WowMcp.lua +24 -0
  60. package/addon/WowMcp/WowMcp.toc +72 -0
  61. package/bin/wow-mcp.js +248 -0
  62. package/package.json +41 -4
package/NOTICE ADDED
@@ -0,0 +1,37 @@
1
+ wow-mcp and the WowMcp addon
2
+ Copyright (C) 2026 Piekasz (GitHub: Piekario)
3
+
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU General Public License as published by the Free Software
6
+ Foundation, either version 3 of the License, or (at your option) any later
7
+ version.
8
+
9
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY
10
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11
+ PARTICULAR PURPOSE. See the GNU General Public License in the LICENSE file for
12
+ more details.
13
+
14
+ Additional term under section 7(b) of the GNU General Public License version 3
15
+ -------------------------------------------------------------------------------
16
+
17
+ The author attribution of this work must be preserved. Every copy of this
18
+ program, and every work based on it, in source or object form, must keep:
19
+
20
+ 1. this NOTICE file, unchanged, next to the LICENSE file;
21
+ 2. the line "Original author: Piekasz (GitHub: Piekario)" in the README, or
22
+ in the equivalent main documentation of the work;
23
+ 3. the "## Author:" line naming Piekasz in the addon file
24
+ addon/WowMcp/WowMcp.toc, or in the equivalent metadata of a
25
+ work based on the addon;
26
+ 4. the copyright and author lines in source files that carry them.
27
+
28
+ Modified versions may add their own copyright lines and must be marked as
29
+ changed (section 5 of the License), but they may not remove or obscure the
30
+ attribution above, and must not present the original author as the author of
31
+ the modifications.
32
+
33
+ Third-party components keep their own licenses; see server/go.mod for the Go
34
+ modules the server depends on.
35
+
36
+ World of Warcraft is a trademark of Blizzard Entertainment, Inc. This project
37
+ is not affiliated with or endorsed by Blizzard Entertainment.
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # wow-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An [MCP](https://modelcontextprotocol.io) server that lets an AI assistant in any MCP client read the state of
4
+ your World of Warcraft character: quests, bags, gear, talents, professions, reputation, auctions, progress over time and
5
+ more. Everything is read-only: the in-game addon saves the state with the official addon API, and the server reads that
6
+ one file. Full documentation: <https://github.com/Piekario/wow-mcp>.
7
+
8
+ Original author: Piekasz (GitHub: Piekario). License: GPL-3.0-or-later with an author attribution term (see `NOTICE`).
9
+
10
+ ## 1. Install the in-game addon
11
+
12
+ ```sh
13
+ npx -y @piekasz/wow-mcp install-addon
14
+ ```
15
+
16
+ It finds the game the way Battle.net recorded it (Windows registry), or in the usual install folders (on Windows on
17
+ every drive, also one folder deep such as `D:\Games\World of Warcraft`), and picks the
18
+ client folder when there is only one (`_retail_`, `_classic_era_`, `_forever_`, ...). Otherwise tell it:
19
+ `npx -y @piekasz/wow-mcp install-addon --wow-dir "D:\Games\World of Warcraft" --client _classic_era_`. It copies the bundled
20
+ addon into `<game>/<client>/Interface/AddOns`, moves an older copy aside as a backup and writes nothing else in the game
21
+ directory. Restart the game completely, then type `/reload` once in game to write the first dump.
22
+
23
+ ## 2. Add the server to your MCP client
24
+
25
+ ```json
26
+ {
27
+ "mcpServers": {
28
+ "wow": {
29
+ "command": "npx",
30
+ "args": ["-y", "@piekasz/wow-mcp"],
31
+ "env": { "WOW_DIR": "C:\\Program Files (x86)\\World of Warcraft" }
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ Run `npx -y @piekasz/wow-mcp --check` to see what the server finds, and `npx -y @piekasz/wow-mcp --help` for every option.
38
+
39
+ npm installs only the prebuilt server for your platform (Windows, macOS and Linux on x64 and arm64), so you need
40
+ neither Go nor a separate download. The dump history is kept in your user data directory
41
+ (`%LOCALAPPDATA%\wow-mcp`, `~/Library/Application Support/wow-mcp` or `~/.local/share/wow-mcp`), so it survives updates;
42
+ pass `--history-dir` to choose another place.
@@ -0,0 +1,106 @@
1
+ -- SPDX-License-Identifier: GPL-3.0-or-later
2
+ -- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
3
+
4
+ -- Auction house price in the item tooltip: one line "AH: <price> (<age>)" when the addon
5
+ -- has a saved price for that item (auctions section). Only displays text in the tooltip,
6
+ -- no action in the game. Disabled by /mcp ahtip off.
7
+
8
+ local _, ns = ...
9
+ local plain, firstValue = ns.Compat.plain, ns.Compat.firstValue
10
+
11
+ local AuctionTooltip = {}
12
+ ns.AuctionTooltip = AuctionTooltip
13
+
14
+ local COPPER_PER_SILVER, COPPER_PER_GOLD = 100, 10000
15
+ local MINUTE, HOUR, DAY = 60, 3600, 86400
16
+ local LINE_COLOR = { 0.4, 0.8, 1 }
17
+
18
+ ---------------------------------------------------------------------------
19
+ -- Line text (pure functions)
20
+ ---------------------------------------------------------------------------
21
+
22
+ -- 12345 -> "1g 23s 45c"; skips zero parts (but 0 -> "0c").
23
+ function AuctionTooltip.formatMoney(copper)
24
+ local gold = math.floor(copper / COPPER_PER_GOLD)
25
+ local silver = math.floor(copper % COPPER_PER_GOLD / COPPER_PER_SILVER)
26
+ local rest = copper % COPPER_PER_SILVER
27
+ local parts = {}
28
+ if gold > 0 then parts[#parts + 1] = gold .. "g" end
29
+ if silver > 0 then parts[#parts + 1] = silver .. "s" end
30
+ if rest > 0 or #parts == 0 then parts[#parts + 1] = rest .. "c" end
31
+ return table.concat(parts, " ")
32
+ end
33
+
34
+ -- Price age in English: "just now", "15 min ago", "3 h ago", "2 days ago".
35
+ function AuctionTooltip.formatAge(seconds)
36
+ if type(seconds) ~= "number" or seconds < MINUTE then return "just now" end
37
+ if seconds < HOUR then return math.floor(seconds / MINUTE) .. " min ago" end
38
+ if seconds < DAY then return math.floor(seconds / HOUR) .. " h ago" end
39
+ local days = math.floor(seconds / DAY)
40
+ return days .. (days == 1 and " day ago" or " days ago")
41
+ end
42
+
43
+ -- Tooltip line for a saved price, or nil when there is no price.
44
+ function AuctionTooltip.lineFor(price, now)
45
+ if type(price) ~= "table" then return nil end
46
+ local copper = price.minBuyout or price.minBid
47
+ if type(copper) ~= "number" then return nil end
48
+ return "AH: " .. AuctionTooltip.formatMoney(copper) .. " (" .. AuctionTooltip.formatAge(now - (price.seenAt or now)) .. ")"
49
+ end
50
+
51
+ ---------------------------------------------------------------------------
52
+ -- Setting and tooltip
53
+ ---------------------------------------------------------------------------
54
+
55
+ function AuctionTooltip.isEnabled()
56
+ return ns.Store.settings().ahTooltip ~= false
57
+ end
58
+
59
+ function AuctionTooltip.setEnabled(enabled)
60
+ -- On by default, so only disabling is saved.
61
+ ns.Store.settings().ahTooltip = ns.Compat.pick(enabled, nil, false)
62
+ end
63
+
64
+ local function storedPrice(name)
65
+ local saved = ns.Store.savedCurrentCharacter()
66
+ local auctions = saved and saved.auctions
67
+ if type(auctions) ~= "table" or type(auctions.prices) ~= "table" then return nil end
68
+ return auctions.prices[name]
69
+ end
70
+
71
+ -- Item name in the tooltip: from the tooltip itself or from the ID in the tooltip data.
72
+ local function tooltipItemName(tooltip, data)
73
+ if tooltip and type(tooltip.GetItem) == "function" then
74
+ local ok, name = pcall(tooltip.GetItem, tooltip)
75
+ if ok and plain(name) and name ~= "" then return name end
76
+ end
77
+ if type(data) == "table" and plain(data.id) then
78
+ return firstValue({ "C_Item.GetItemNameByID", "GetItemInfo" }, data.id)
79
+ end
80
+ return nil
81
+ end
82
+
83
+ local function addPriceLine(tooltip, data)
84
+ if not AuctionTooltip.isEnabled() or ns.Snapshot.isDisabled("auctions") then return end
85
+ local name = tooltipItemName(tooltip, data)
86
+ local line = name and AuctionTooltip.lineFor(storedPrice(name), time())
87
+ if line then tooltip:AddLine(line, LINE_COLOR[1], LINE_COLOR[2], LINE_COLOR[3]) end
88
+ end
89
+
90
+ local function onItemTooltip(tooltip, data)
91
+ pcall(addPriceLine, tooltip, data)
92
+ end
93
+
94
+ -- New clients: TooltipDataProcessor; older ones: the game tooltip's OnTooltipSetItem script.
95
+ function AuctionTooltip.install()
96
+ if TooltipDataProcessor and TooltipDataProcessor.AddTooltipPostCall
97
+ and Enum and Enum.TooltipDataType and Enum.TooltipDataType.Item ~= nil then
98
+ return pcall(TooltipDataProcessor.AddTooltipPostCall, Enum.TooltipDataType.Item, onItemTooltip)
99
+ end
100
+ if GameTooltip and GameTooltip.HookScript then
101
+ return pcall(GameTooltip.HookScript, GameTooltip, "OnTooltipSetItem", onItemTooltip)
102
+ end
103
+ return false
104
+ end
105
+
106
+ pcall(AuctionTooltip.install)
@@ -0,0 +1,259 @@
1
+ -- SPDX-License-Identifier: GPL-3.0-or-later
2
+ -- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
3
+
4
+ -- Slash commands /mcp and /wmcp. Each command is an entry in the COMMANDS table;
5
+ -- an unknown command (and bare /mcp) takes a dump without /reload.
6
+
7
+ local _, ns = ...
8
+ local Store, Snapshot, Panel, Played, chat = ns.Store, ns.Snapshot, ns.Panel, ns.Played, ns.chat
9
+
10
+ local HELP = {
11
+ "/mcp reload - dump and save to disk (reloads the UI)",
12
+ "/mcp - dump only; it reaches the disk on the next /reload or logout",
13
+ "/mcp status - this character's last dump, dump time, disabled sections and errors",
14
+ "/mcp panel - show or hide the panel with the Save button",
15
+ "/mcp played on|off - whether to request played time after login (for progress statistics)",
16
+ "/mcp note <text> - note for the assistant in the dump (e.g. what you plan today); bare /mcp note removes it",
17
+ "/mcp quest <id or name> - where a quest starts and ends, from the Questie database you have installed; the answer also goes into the dump",
18
+ "/mcp off <section> - stop collecting this section; bare /mcp off lists disabled sections and all section names",
19
+ "/mcp on <section> - collect the section again",
20
+ "/mcp minimap on|off - minimap button (left click: panel; on by default)",
21
+ "/mcp compact on|off - one-line panel: dump age and Save button (off by default)",
22
+ "/mcp ahtip on|off - auction house price in the item tooltip (on by default)",
23
+ "/mcp options - open the WowMcp page in the game's options (the same switches as the commands above)",
24
+ "/mcp probe - diagnostics: list of client API functions (spells, items, maps, achievements...) and the events the client accepted",
25
+ "Windows saved automatically when opened: trainer and vendor (last 10), bank, flights, professions, mail,"
26
+ .. " auction house (search results), Inspect, stable, NPC quest (offer and turn-in),"
27
+ .. " buyback list (at the vendor), friends and guild (from client memory once the window is open; the addon requests nothing from the server)",
28
+ "Deaths, your own loot and experience (kills, quests) since the last save are recorded automatically."
29
+ .. " The panel highlights Save after new window data, but never saves by itself.",
30
+ }
31
+
32
+ local function reportErrors(errors)
33
+ for _, err in ipairs(errors) do
34
+ chat("|cffff5555error|r " .. err)
35
+ end
36
+ end
37
+
38
+ local function showHelp()
39
+ for _, line in ipairs(HELP) do chat(line) end
40
+ end
41
+
42
+ -- Settings take the first word, case-insensitive.
43
+ local function firstWord(rest)
44
+ return (rest or ""):lower():match("^(%S*)")
45
+ end
46
+
47
+ local function setPlayedTracking(rest)
48
+ if firstWord(rest) == "off" then
49
+ Played.setTracking(false)
50
+ chat("Played time will no longer be requested. Progress statistics will be computed from dump times.")
51
+ else
52
+ Played.setTracking(true)
53
+ chat("Played time enabled: the addon requests it after login.")
54
+ end
55
+ end
56
+
57
+ local function setAuctionTooltip(rest)
58
+ local enabled = firstWord(rest) ~= "off"
59
+ ns.AuctionTooltip.setEnabled(enabled)
60
+ if enabled then
61
+ chat("The auction house price will show in the item tooltip (when the addon knows it). Turn off: /mcp ahtip off")
62
+ else
63
+ chat("The auction house price will no longer show in the item tooltip. Turn on: /mcp ahtip on")
64
+ end
65
+ end
66
+
67
+ local function setMinimapButton(rest)
68
+ local enabled = firstWord(rest) ~= "off"
69
+ local ok = ns.MinimapButton.setEnabled(enabled)
70
+ if not enabled then
71
+ chat("Minimap button hidden. Turn on: /mcp minimap on")
72
+ elseif ok then
73
+ chat("Minimap button enabled (left click: panel). Turn off: /mcp minimap off")
74
+ else
75
+ chat("Could not create the minimap button. The panel still works: /mcp panel")
76
+ end
77
+ end
78
+
79
+ local function setCompactPanel(rest)
80
+ local enabled = firstWord(rest) ~= "off"
81
+ Panel.setCompact(enabled)
82
+ if enabled then
83
+ chat("Panel in compact mode (one line). Normal look: /mcp compact off")
84
+ else
85
+ chat("Panel in normal look. Compact mode: /mcp compact on")
86
+ end
87
+ end
88
+
89
+ local function setNote(rest)
90
+ if Snapshot.isDisabled("note") then
91
+ chat("The note section is disabled. Enable it: /mcp on note")
92
+ return
93
+ end
94
+ local note = ns.Note.set(rest)
95
+ if note then
96
+ chat("Note saved: " .. note.text)
97
+ else
98
+ chat("Note removed.")
99
+ end
100
+ end
101
+
102
+ local function lookUpQuest(rest)
103
+ if (rest or "") == "" then
104
+ chat("Usage: /mcp quest <quest ID, exact quest name or NPC name>")
105
+ return
106
+ end
107
+ local entry = ns.QuestLookup.run(rest)
108
+ if not entry then
109
+ chat("No quest database found. Install Questie (with QuestieDB) to use /mcp quest.")
110
+ return
111
+ end
112
+ for _, line in ipairs(ns.QuestLookup.lines(entry)) do chat(line) end
113
+ Panel.refresh()
114
+ end
115
+
116
+ local function listSections()
117
+ local disabled = Snapshot.disabledNames()
118
+ chat("Disabled sections: " .. (#disabled > 0 and table.concat(disabled, ", ") or "none"))
119
+ chat("All sections: " .. table.concat(Snapshot.sectionNames(), ", "))
120
+ end
121
+
122
+ -- Section name from the player's input, or nil (with a message saying why not).
123
+ local function sectionFromInput(rest)
124
+ local name = Snapshot.resolveName(firstWord(rest))
125
+ if not name then
126
+ chat("Unknown section: " .. firstWord(rest) .. ". Type /mcp off to see the names.")
127
+ return nil
128
+ end
129
+ return name
130
+ end
131
+
132
+ local function disableSection(rest)
133
+ if firstWord(rest) == "" then
134
+ listSections()
135
+ return
136
+ end
137
+ local name = sectionFromInput(rest)
138
+ if not name then return end
139
+ if not Snapshot.canDisable(name) then
140
+ chat("Section " .. name .. " cannot be disabled.")
141
+ return
142
+ end
143
+ Snapshot.setEnabled(name, false)
144
+ Panel.refresh()
145
+ chat("Section " .. name .. " disabled: it disappears from the dump (including this section's saved data). Enable it: /mcp on " .. name)
146
+ end
147
+
148
+ local function enableSection(rest)
149
+ if firstWord(rest) == "" then
150
+ chat("Usage: /mcp on <section>. Section list: /mcp off")
151
+ return
152
+ end
153
+ local name = sectionFromInput(rest)
154
+ if not name then return end
155
+ Snapshot.setEnabled(name, true)
156
+ chat("Section " .. name .. " enabled. It will appear in the next dump.")
157
+ end
158
+
159
+ local function auctionPriceCount(snapshot)
160
+ local prices = 0
161
+ if type(snapshot.auctions) == "table" and type(snapshot.auctions.prices) == "table" then
162
+ for _ in pairs(snapshot.auctions.prices) do prices = prices + 1 end
163
+ end
164
+ return prices
165
+ end
166
+
167
+ local function reportTimings(timings)
168
+ if type(timings) ~= "table" or type(timings.totalMs) ~= "number" then return end
169
+ local slow = {}
170
+ for _, entry in ipairs(timings.slowest or {}) do
171
+ slow[#slow + 1] = entry.name .. " " .. entry.ms .. " ms"
172
+ end
173
+ local line = "Dump collected in " .. timings.totalMs .. " ms"
174
+ if #slow > 0 then line = line .. ". Slowest: " .. table.concat(slow, ", ") end
175
+ if timings.totalMs > ns.Timing.WARNING_TOTAL_MS then
176
+ chat("|cffffcc00Warning:|r " .. line .. ". The dump is heavy (over " .. ns.Timing.WARNING_TOTAL_MS
177
+ .. " ms); disable unneeded sections with /mcp off.")
178
+ else
179
+ chat(line)
180
+ end
181
+ end
182
+
183
+ -- Dump state of the character being played (not the account's last one).
184
+ local function showStatus()
185
+ local snapshot = Store.savedCurrentCharacter()
186
+ if not snapshot or not snapshot.dumpedAtText then
187
+ local lastKey = Store.lastSaved()
188
+ chat("No dump for character " .. Store.characterKey() .. ". Type /mcp reload."
189
+ .. (lastKey and (" Last dump on the account: " .. lastKey .. ".") or ""))
190
+ return
191
+ end
192
+ chat("Version " .. ns.ADDON_VERSION .. ". Last dump: " .. Store.characterKey() .. ", " .. snapshot.dumpedAtText
193
+ .. (Snapshot.isUnsaved() and " (not on disk yet)" or ""))
194
+ if Snapshot.continuesPeriod(snapshot) then
195
+ chat("At the last logout the client no longer had character data, so the dump from "
196
+ .. snapshot.dumpedAtText .. " was kept. Fresh save: /mcp reload")
197
+ end
198
+ local prices = auctionPriceCount(snapshot)
199
+ if prices > 0 then chat("Auction house prices: " .. prices .. " items.") end
200
+ if type(snapshot.disabledSections) == "table" and #snapshot.disabledSections > 0 then
201
+ chat("Disabled sections: " .. table.concat(snapshot.disabledSections, ", "))
202
+ end
203
+ reportTimings(snapshot.timings)
204
+ reportErrors(snapshot.errors or {})
205
+ end
206
+
207
+ -- Manual dump. With reload it is saved to disk immediately via /reload.
208
+ local function dumpManually(reload)
209
+ local snapshot = Snapshot.dump("manual")
210
+ local questCount = snapshot.quests and #snapshot.quests or 0
211
+ local errorCount = #snapshot.errors
212
+ chat(("Dump ready: %d quests, section errors: %d."):format(questCount, errorCount))
213
+ reportErrors(snapshot.errors)
214
+
215
+ if reload then
216
+ ReloadUI()
217
+ else
218
+ Snapshot.markUnsaved()
219
+ Panel.refresh()
220
+ chat("Data reaches the disk on /reload or logout. Shortcut: /mcp reload or the Save button on the panel")
221
+ end
222
+ end
223
+
224
+ local function probeAndReload()
225
+ Snapshot.capture("probe")
226
+ dumpManually(true)
227
+ end
228
+
229
+ local COMMANDS = {
230
+ help = showHelp,
231
+ ["?"] = showHelp,
232
+ panel = Panel.toggle,
233
+ played = setPlayedTracking,
234
+ ahtip = setAuctionTooltip,
235
+ minimap = setMinimapButton,
236
+ compact = setCompactPanel,
237
+ note = setNote,
238
+ quest = lookUpQuest,
239
+ off = disableSection,
240
+ on = enableSection,
241
+ status = showStatus,
242
+ options = function() ns.Options.open() end,
243
+ probe = probeAndReload,
244
+ reload = function() dumpManually(true) end,
245
+ }
246
+
247
+ SLASH_WOWMCP1 = "/mcp"
248
+ SLASH_WOWMCP2 = "/wmcp"
249
+
250
+ SlashCmdList["WOWMCP"] = function(input)
251
+ -- The command is case-insensitive; the rest (e.g. note text) stays as typed.
252
+ local command, rest = (input or ""):match("^%s*(%S*)%s*(.-)%s*$")
253
+ local run = COMMANDS[command:lower()]
254
+ if run then
255
+ run(rest)
256
+ else
257
+ dumpManually(false)
258
+ end
259
+ end
@@ -0,0 +1,167 @@
1
+ -- SPDX-License-Identifier: GPL-3.0-or-later
2
+ -- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
3
+
4
+ -- Client API compatibility layer: the only place that knows that functions
5
+ -- have different names in different clients and that Forever has "secrets".
6
+ -- Sections get plain values from here.
7
+
8
+ local _, ns = ...
9
+
10
+ local Compat = {}
11
+ ns.Compat = Compat
12
+
13
+ -- Only plain values go into SavedVariables. The Forever client has "secrets"
14
+ -- (values the addon cannot read in combat); we do not save those.
15
+ function Compat.plain(value)
16
+ local t = type(value)
17
+ if t ~= "string" and t ~= "number" and t ~= "boolean" then return nil end
18
+ if issecretvalue and issecretvalue(value) then return nil end
19
+ return value
20
+ end
21
+
22
+ local plain = Compat.plain
23
+
24
+ -- Deepest table nesting written to SavedVariables; a deeper table is dropped (real dumps have under ten levels).
25
+ Compat.MAX_SAVED_DEPTH = 20
26
+
27
+ local function isPlainKey(key)
28
+ local t = type(key)
29
+ if t ~= "string" and t ~= "number" then return false end
30
+ return not (issecretvalue and issecretvalue(key))
31
+ end
32
+
33
+ -- Length of a table that is a list 1..n (no other keys, no holes); nil for any other table.
34
+ local function listLength(tbl)
35
+ local count = 0
36
+ for key in pairs(tbl) do
37
+ if not isPlainKey(key) or type(key) ~= "number" or key < 1 or key % 1 ~= 0 then return nil end
38
+ count = count + 1
39
+ end
40
+ for i = 1, count do
41
+ if tbl[i] == nil then return nil end
42
+ end
43
+ return count
44
+ end
45
+
46
+ -- Removes, in place and at any depth, everything that must not reach SavedVariables: secret values and keys,
47
+ -- functions, userdata and tables nested deeper than MAX_SAVED_DEPTH. A list stays a list (gaps are closed), so the
48
+ -- server never sees a list turn into a map. Every write to SavedVariables ends with this pass (Snapshot.sanitizeCurrent),
49
+ -- so a value a section forgot to pass through plain() cannot be written. Returns how many entries were removed.
50
+ function Compat.sanitizeTree(tbl, depth)
51
+ depth = depth or 1
52
+ local length = listLength(tbl)
53
+ local removedHere, removed = 0, 0
54
+ for key, value in pairs(tbl) do
55
+ local keep
56
+ if not isPlainKey(key) then
57
+ keep = false
58
+ elseif type(value) == "table" then
59
+ keep = depth < Compat.MAX_SAVED_DEPTH
60
+ if keep then removed = removed + Compat.sanitizeTree(value, depth + 1) end
61
+ else
62
+ keep = plain(value) ~= nil
63
+ end
64
+ if not keep then
65
+ tbl[key] = nil -- assigning nil to an existing field is allowed during pairs
66
+ removedHere = removedHere + 1
67
+ end
68
+ end
69
+ if length and removedHere > 0 then
70
+ local j = 0
71
+ for i = 1, length do
72
+ if tbl[i] ~= nil then
73
+ j = j + 1
74
+ tbl[j] = tbl[i]
75
+ end
76
+ end
77
+ for i = j + 1, length do tbl[i] = nil end
78
+ end
79
+ return removed + removedHere
80
+ end
81
+
82
+ function Compat.plainFields(source)
83
+ local out = {}
84
+ for key, value in pairs(source) do
85
+ if type(key) == "string" and plain(value) ~= nil then
86
+ out[key] = value
87
+ end
88
+ end
89
+ return out
90
+ end
91
+
92
+ -- Picks one of two values by a condition. Instead of `cond and a or b`, which
93
+ -- substitutes `b` when `a` is nil (the neighbouring field), i.e. returns the wrong value.
94
+ function Compat.pick(condition, whenTrue, whenFalse)
95
+ if condition then return whenTrue end
96
+ return whenFalse
97
+ end
98
+
99
+ -- Returns the function at a path like "C_PetInfo.GetPetHappiness", or nil.
100
+ function Compat.resolve(path)
101
+ local object = _G
102
+ for part in path:gmatch("[^.]+") do
103
+ if type(object) ~= "table" then return nil end
104
+ object = object[part]
105
+ end
106
+ return type(object) == "function" and object or nil
107
+ end
108
+
109
+ -- Calls the first existing function from a list of paths. Returns the result table
110
+ -- and the path that worked, or nil if none exists or every one raises an error.
111
+ function Compat.callFirst(paths, ...)
112
+ for _, path in ipairs(paths) do
113
+ local fn = Compat.resolve(path)
114
+ if fn then
115
+ local results = { pcall(fn, ...) }
116
+ if results[1] then
117
+ table.remove(results, 1)
118
+ return results, path
119
+ end
120
+ end
121
+ end
122
+ return nil
123
+ end
124
+
125
+ -- First value returned by the first working function, already filtered. A boolean false stays false
126
+ -- (`results and plain(x) or nil` would turn it into nil, e.g. UnitIsConnected for an offline group member).
127
+ function Compat.firstValue(paths, ...)
128
+ local results = Compat.callFirst(paths, ...)
129
+ if not results then return nil end
130
+ return plain(results[1])
131
+ end
132
+
133
+ -- Strips color and icon codes used in item descriptions from the text.
134
+ function Compat.stripMarkup(text)
135
+ text = text:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "")
136
+ text = text:gsub("|T.-|t", ""):gsub("|A.-|a", "")
137
+ return text
138
+ end
139
+
140
+ -- Converts tooltip data (C_TooltipInfo) into a list of text lines.
141
+ local function tooltipLines(data)
142
+ if type(data) ~= "table" or type(data.lines) ~= "table" then return nil end
143
+ local out = {}
144
+ for _, line in ipairs(data.lines) do
145
+ local left, right = plain(line.leftText), plain(line.rightText)
146
+ if type(left) == "string" then
147
+ left = Compat.stripMarkup(left)
148
+ if left:find("%S") then
149
+ if type(right) == "string" and right:find("%S") then
150
+ out[#out + 1] = left .. " | " .. Compat.stripMarkup(right)
151
+ else
152
+ out[#out + 1] = left
153
+ end
154
+ end
155
+ end
156
+ end
157
+ if #out == 0 then return nil end
158
+ return out
159
+ end
160
+
161
+ -- Tooltip lines from C_TooltipInfo[method](...), or nil if the client lacks that function.
162
+ function Compat.tooltipFor(method, ...)
163
+ if not (C_TooltipInfo and type(C_TooltipInfo[method]) == "function") then return nil end
164
+ local ok, data = pcall(C_TooltipInfo[method], ...)
165
+ if ok then return tooltipLines(data) end
166
+ return nil
167
+ end
@@ -0,0 +1,50 @@
1
+ -- SPDX-License-Identifier: GPL-3.0-or-later
2
+ -- Copyright (C) 2026 Piekasz (GitHub: Piekario). Author attribution must be kept: see NOTICE.
3
+
4
+ -- WowMcp: dumps character state to SavedVariables.
5
+ --
6
+ -- The addon ONLY reads data through the official API and writes it to the file
7
+ -- WTF/Account/<account>/SavedVariables/WowMcp.lua. It clicks nothing,
8
+ -- sends nothing and automates nothing. The game writes SavedVariables to disk on
9
+ -- /reload and on logout, so the data is as fresh as the last /reload.
10
+ --
11
+ -- Commands (Commands.lua):
12
+ -- /mcp dump state (saved on the next /reload or logout)
13
+ -- /mcp reload dump state and /reload immediately
14
+ -- /mcp status when the last dump was taken and whether there were errors
15
+ -- /mcp probe like /mcp reload, but adds a list of client API functions (diagnostics)
16
+ -- /mcp panel shows or hides the panel with the dump age and a "Save" button
17
+ -- /mcp note note for the assistant in the dump (without text: removes the note)
18
+ -- /mcp quest <id or name>: where a quest starts and ends (from the installed Questie database)
19
+ -- /mcp ahtip on|off: auction house price in the item tooltip
20
+ -- /mcp minimap on|off: minimap button (left click shows the panel)
21
+ -- /mcp compact on|off: one-line panel
22
+ -- /mcp off|on disables or enables a dump section
23
+ --
24
+ -- The panel and the "Save" button do exactly the same as /mcp reload and work
25
+ -- only when the player clicks. The addon never saves anything on its own.
26
+ --
27
+ -- File layout (load order in WowMcp.toc, dependencies only point down the list):
28
+ -- Core, Compat, Maps, QuestDb, Items, QuestRewards, TalentGrid, Store, Events, Timing, Snapshot - shared foundations
29
+ -- Sections/* - one file per dump section;
30
+ -- each registers itself in Snapshot
31
+ -- Panel, AuctionTooltip, WowMcp (lifecycle), Commands - player UI
32
+ --
33
+ -- The Forever client (Interface 16001) uses the new API (C_QuestLog, C_Container,
34
+ -- C_SpellBook, C_Traits). Each section also tries the older function names and
35
+ -- is wrapped in pcall: an error in one section does not break the rest, and its
36
+ -- text goes to the "errors" field of the dump.
37
+
38
+ local _, ns = ...
39
+
40
+ ns.ADDON_VERSION = "0.16.0"
41
+ ns.SCHEMA_VERSION = 2
42
+
43
+ function ns.chat(text)
44
+ DEFAULT_CHAT_FRAME:AddMessage("|cff66ccff[WowMcp]|r " .. tostring(text))
45
+ end
46
+
47
+ function ns.round1(number)
48
+ if type(number) ~= "number" then return nil end
49
+ return math.floor(number * 10 + 0.5) / 10
50
+ end