@xiedada/nodemw-mcp-server 0.0.1 → 0.0.3

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 (195) hide show
  1. package/LICENSE +24 -166
  2. package/README.md +124 -145
  3. package/dist/index.js +36 -63
  4. package/dist/index.js.map +7 -1
  5. package/package.json +5 -11
  6. package/dist/common/nodemwBot.d.ts +0 -21
  7. package/dist/common/nodemwBot.d.ts.map +0 -1
  8. package/dist/common/nodemwBot.js +0 -62
  9. package/dist/common/nodemwBot.js.map +0 -1
  10. package/dist/common/utils.d.ts +0 -7
  11. package/dist/common/utils.d.ts.map +0 -1
  12. package/dist/common/utils.js +0 -38
  13. package/dist/common/utils.js.map +0 -1
  14. package/dist/index.d.ts +0 -3
  15. package/dist/index.d.ts.map +0 -1
  16. package/dist/server.d.ts +0 -4
  17. package/dist/server.d.ts.map +0 -1
  18. package/dist/server.js +0 -9
  19. package/dist/server.js.map +0 -1
  20. package/dist/tools/editing/add-flow-topic.d.ts +0 -3
  21. package/dist/tools/editing/add-flow-topic.d.ts.map +0 -1
  22. package/dist/tools/editing/add-flow-topic.js +0 -25
  23. package/dist/tools/editing/add-flow-topic.js.map +0 -1
  24. package/dist/tools/editing/append.d.ts +0 -3
  25. package/dist/tools/editing/append.d.ts.map +0 -1
  26. package/dist/tools/editing/append.js +0 -26
  27. package/dist/tools/editing/append.js.map +0 -1
  28. package/dist/tools/editing/create-account.d.ts +0 -3
  29. package/dist/tools/editing/create-account.d.ts.map +0 -1
  30. package/dist/tools/editing/create-account.js +0 -24
  31. package/dist/tools/editing/create-account.js.map +0 -1
  32. package/dist/tools/editing/delete.d.ts +0 -3
  33. package/dist/tools/editing/delete.d.ts.map +0 -1
  34. package/dist/tools/editing/delete.js +0 -25
  35. package/dist/tools/editing/delete.js.map +0 -1
  36. package/dist/tools/editing/edit.d.ts +0 -3
  37. package/dist/tools/editing/edit.d.ts.map +0 -1
  38. package/dist/tools/editing/edit.js +0 -27
  39. package/dist/tools/editing/edit.js.map +0 -1
  40. package/dist/tools/editing/move.d.ts +0 -3
  41. package/dist/tools/editing/move.d.ts.map +0 -1
  42. package/dist/tools/editing/move.js +0 -26
  43. package/dist/tools/editing/move.js.map +0 -1
  44. package/dist/tools/editing/prepend.d.ts +0 -3
  45. package/dist/tools/editing/prepend.d.ts.map +0 -1
  46. package/dist/tools/editing/prepend.js +0 -26
  47. package/dist/tools/editing/prepend.js.map +0 -1
  48. package/dist/tools/editing/protect.d.ts +0 -3
  49. package/dist/tools/editing/protect.d.ts.map +0 -1
  50. package/dist/tools/editing/protect.js +0 -37
  51. package/dist/tools/editing/protect.js.map +0 -1
  52. package/dist/tools/editing/purge.d.ts +0 -3
  53. package/dist/tools/editing/purge.d.ts.map +0 -1
  54. package/dist/tools/editing/purge.js +0 -23
  55. package/dist/tools/editing/purge.js.map +0 -1
  56. package/dist/tools/editing/send-email.d.ts +0 -3
  57. package/dist/tools/editing/send-email.d.ts.map +0 -1
  58. package/dist/tools/editing/send-email.js +0 -25
  59. package/dist/tools/editing/send-email.js.map +0 -1
  60. package/dist/tools/editing/upload-by-url.d.ts +0 -3
  61. package/dist/tools/editing/upload-by-url.d.ts.map +0 -1
  62. package/dist/tools/editing/upload-by-url.js +0 -26
  63. package/dist/tools/editing/upload-by-url.js.map +0 -1
  64. package/dist/tools/editing/upload.d.ts +0 -3
  65. package/dist/tools/editing/upload.d.ts.map +0 -1
  66. package/dist/tools/editing/upload.js +0 -27
  67. package/dist/tools/editing/upload.js.map +0 -1
  68. package/dist/tools/index.d.ts +0 -3
  69. package/dist/tools/index.d.ts.map +0 -1
  70. package/dist/tools/index.js +0 -105
  71. package/dist/tools/index.js.map +0 -1
  72. package/dist/tools/ro/expand-templates.d.ts +0 -3
  73. package/dist/tools/ro/expand-templates.d.ts.map +0 -1
  74. package/dist/tools/ro/expand-templates.js +0 -28
  75. package/dist/tools/ro/expand-templates.js.map +0 -1
  76. package/dist/tools/ro/get-all-pages.d.ts +0 -3
  77. package/dist/tools/ro/get-all-pages.d.ts.map +0 -1
  78. package/dist/tools/ro/get-all-pages.js +0 -30
  79. package/dist/tools/ro/get-all-pages.js.map +0 -1
  80. package/dist/tools/ro/get-article-categories.d.ts +0 -3
  81. package/dist/tools/ro/get-article-categories.d.ts.map +0 -1
  82. package/dist/tools/ro/get-article-categories.js +0 -27
  83. package/dist/tools/ro/get-article-categories.js.map +0 -1
  84. package/dist/tools/ro/get-article-info.d.ts +0 -3
  85. package/dist/tools/ro/get-article-info.d.ts.map +0 -1
  86. package/dist/tools/ro/get-article-info.js +0 -35
  87. package/dist/tools/ro/get-article-info.js.map +0 -1
  88. package/dist/tools/ro/get-article-properties.d.ts +0 -3
  89. package/dist/tools/ro/get-article-properties.d.ts.map +0 -1
  90. package/dist/tools/ro/get-article-properties.js +0 -26
  91. package/dist/tools/ro/get-article-properties.js.map +0 -1
  92. package/dist/tools/ro/get-article-revisions.d.ts +0 -3
  93. package/dist/tools/ro/get-article-revisions.d.ts.map +0 -1
  94. package/dist/tools/ro/get-article-revisions.js +0 -29
  95. package/dist/tools/ro/get-article-revisions.js.map +0 -1
  96. package/dist/tools/ro/get-article.d.ts +0 -3
  97. package/dist/tools/ro/get-article.d.ts.map +0 -1
  98. package/dist/tools/ro/get-article.js +0 -54
  99. package/dist/tools/ro/get-article.js.map +0 -1
  100. package/dist/tools/ro/get-backlinks.d.ts +0 -3
  101. package/dist/tools/ro/get-backlinks.d.ts.map +0 -1
  102. package/dist/tools/ro/get-backlinks.js +0 -27
  103. package/dist/tools/ro/get-backlinks.js.map +0 -1
  104. package/dist/tools/ro/get-categories.d.ts +0 -3
  105. package/dist/tools/ro/get-categories.d.ts.map +0 -1
  106. package/dist/tools/ro/get-categories.js +0 -27
  107. package/dist/tools/ro/get-categories.js.map +0 -1
  108. package/dist/tools/ro/get-external-links.d.ts +0 -3
  109. package/dist/tools/ro/get-external-links.d.ts.map +0 -1
  110. package/dist/tools/ro/get-external-links.js +0 -27
  111. package/dist/tools/ro/get-external-links.js.map +0 -1
  112. package/dist/tools/ro/get-image-info.d.ts +0 -3
  113. package/dist/tools/ro/get-image-info.d.ts.map +0 -1
  114. package/dist/tools/ro/get-image-info.js +0 -29
  115. package/dist/tools/ro/get-image-info.js.map +0 -1
  116. package/dist/tools/ro/get-image-usage.d.ts +0 -3
  117. package/dist/tools/ro/get-image-usage.d.ts.map +0 -1
  118. package/dist/tools/ro/get-image-usage.js +0 -27
  119. package/dist/tools/ro/get-image-usage.js.map +0 -1
  120. package/dist/tools/ro/get-images-from-article.d.ts +0 -3
  121. package/dist/tools/ro/get-images-from-article.d.ts.map +0 -1
  122. package/dist/tools/ro/get-images-from-article.js +0 -27
  123. package/dist/tools/ro/get-images-from-article.js.map +0 -1
  124. package/dist/tools/ro/get-images.d.ts +0 -3
  125. package/dist/tools/ro/get-images.d.ts.map +0 -1
  126. package/dist/tools/ro/get-images.js +0 -43
  127. package/dist/tools/ro/get-images.js.map +0 -1
  128. package/dist/tools/ro/get-log.d.ts +0 -3
  129. package/dist/tools/ro/get-log.d.ts.map +0 -1
  130. package/dist/tools/ro/get-log.js +0 -46
  131. package/dist/tools/ro/get-log.js.map +0 -1
  132. package/dist/tools/ro/get-mediawiki-version.d.ts +0 -3
  133. package/dist/tools/ro/get-mediawiki-version.d.ts.map +0 -1
  134. package/dist/tools/ro/get-mediawiki-version.js +0 -20
  135. package/dist/tools/ro/get-mediawiki-version.js.map +0 -1
  136. package/dist/tools/ro/get-pages-by-prefix.d.ts +0 -3
  137. package/dist/tools/ro/get-pages-by-prefix.d.ts.map +0 -1
  138. package/dist/tools/ro/get-pages-by-prefix.js +0 -27
  139. package/dist/tools/ro/get-pages-by-prefix.js.map +0 -1
  140. package/dist/tools/ro/get-pages-in-category.d.ts +0 -3
  141. package/dist/tools/ro/get-pages-in-category.d.ts.map +0 -1
  142. package/dist/tools/ro/get-pages-in-category.js +0 -29
  143. package/dist/tools/ro/get-pages-in-category.js.map +0 -1
  144. package/dist/tools/ro/get-pages-in-namespace.d.ts +0 -3
  145. package/dist/tools/ro/get-pages-in-namespace.d.ts.map +0 -1
  146. package/dist/tools/ro/get-pages-in-namespace.js +0 -27
  147. package/dist/tools/ro/get-pages-in-namespace.js.map +0 -1
  148. package/dist/tools/ro/get-pages-transcluding.d.ts +0 -3
  149. package/dist/tools/ro/get-pages-transcluding.d.ts.map +0 -1
  150. package/dist/tools/ro/get-pages-transcluding.js +0 -32
  151. package/dist/tools/ro/get-pages-transcluding.js.map +0 -1
  152. package/dist/tools/ro/get-query-page.d.ts +0 -3
  153. package/dist/tools/ro/get-query-page.d.ts.map +0 -1
  154. package/dist/tools/ro/get-query-page.js +0 -27
  155. package/dist/tools/ro/get-query-page.js.map +0 -1
  156. package/dist/tools/ro/get-recent-changes.d.ts +0 -3
  157. package/dist/tools/ro/get-recent-changes.d.ts.map +0 -1
  158. package/dist/tools/ro/get-recent-changes.js +0 -43
  159. package/dist/tools/ro/get-recent-changes.js.map +0 -1
  160. package/dist/tools/ro/get-site-info.d.ts +0 -3
  161. package/dist/tools/ro/get-site-info.d.ts.map +0 -1
  162. package/dist/tools/ro/get-site-info.js +0 -23
  163. package/dist/tools/ro/get-site-info.js.map +0 -1
  164. package/dist/tools/ro/get-site-stats.d.ts +0 -3
  165. package/dist/tools/ro/get-site-stats.d.ts.map +0 -1
  166. package/dist/tools/ro/get-site-stats.js +0 -20
  167. package/dist/tools/ro/get-site-stats.js.map +0 -1
  168. package/dist/tools/ro/get-user-contribs.d.ts +0 -3
  169. package/dist/tools/ro/get-user-contribs.d.ts.map +0 -1
  170. package/dist/tools/ro/get-user-contribs.js +0 -39
  171. package/dist/tools/ro/get-user-contribs.js.map +0 -1
  172. package/dist/tools/ro/get-users.d.ts +0 -3
  173. package/dist/tools/ro/get-users.d.ts.map +0 -1
  174. package/dist/tools/ro/get-users.js +0 -29
  175. package/dist/tools/ro/get-users.js.map +0 -1
  176. package/dist/tools/ro/parse.d.ts +0 -3
  177. package/dist/tools/ro/parse.d.ts.map +0 -1
  178. package/dist/tools/ro/parse.js +0 -37
  179. package/dist/tools/ro/parse.js.map +0 -1
  180. package/dist/tools/ro/search.d.ts +0 -3
  181. package/dist/tools/ro/search.d.ts.map +0 -1
  182. package/dist/tools/ro/search.js +0 -32
  183. package/dist/tools/ro/search.js.map +0 -1
  184. package/dist/tools/ro/whoami.d.ts +0 -3
  185. package/dist/tools/ro/whoami.d.ts.map +0 -1
  186. package/dist/tools/ro/whoami.js +0 -20
  187. package/dist/tools/ro/whoami.js.map +0 -1
  188. package/dist/tools/ro/whoare.d.ts +0 -3
  189. package/dist/tools/ro/whoare.d.ts.map +0 -1
  190. package/dist/tools/ro/whoare.js +0 -19
  191. package/dist/tools/ro/whoare.js.map +0 -1
  192. package/dist/tools/ro/whois.d.ts +0 -3
  193. package/dist/tools/ro/whois.d.ts.map +0 -1
  194. package/dist/tools/ro/whois.js +0 -26
  195. package/dist/tools/ro/whois.js.map +0 -1
package/LICENSE CHANGED
@@ -1,166 +1,24 @@
1
-
2
- GNU LESSER GENERAL PUBLIC LICENSE
3
- Version 3, 29 June 2007
4
-
5
- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
6
- Everyone is permitted to copy and distribute verbatim copies
7
- of this license document, but changing it is not allowed.
8
-
9
-
10
- This version of the GNU Lesser General Public License incorporates
11
- the terms and conditions of version 3 of the GNU General Public
12
- License, supplemented by the additional permissions listed below.
13
-
14
- 0. Additional Definitions.
15
-
16
- As used herein, "this License" refers to version 3 of the GNU Lesser
17
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
18
- General Public License.
19
-
20
- "The Library" refers to a covered work governed by this License,
21
- other than an Application or a Combined Work as defined below.
22
-
23
- An "Application" is any work that makes use of an interface provided
24
- by the Library, but which is not otherwise based on the Library.
25
- Defining a subclass of a class defined by the Library is deemed a mode
26
- of using an interface provided by the Library.
27
-
28
- A "Combined Work" is a work produced by combining or linking an
29
- Application with the Library. The particular version of the Library
30
- with which the Combined Work was made is also called the "Linked
31
- Version".
32
-
33
- The "Minimal Corresponding Source" for a Combined Work means the
34
- Corresponding Source for the Combined Work, excluding any source code
35
- for portions of the Combined Work that, considered in isolation, are
36
- based on the Application, and not on the Linked Version.
37
-
38
- The "Corresponding Application Code" for a Combined Work means the
39
- object code and/or source code for the Application, including any data
40
- and utility programs needed for reproducing the Combined Work from the
41
- Application, but excluding the System Libraries of the Combined Work.
42
-
43
- 1. Exception to Section 3 of the GNU GPL.
44
-
45
- You may convey a covered work under sections 3 and 4 of this License
46
- without being bound by section 3 of the GNU GPL.
47
-
48
- 2. Conveying Modified Versions.
49
-
50
- If you modify a copy of the Library, and, in your modifications, a
51
- facility refers to a function or data to be supplied by an Application
52
- that uses the facility (other than as an argument passed when the
53
- facility is invoked), then you may convey a copy of the modified
54
- version:
55
-
56
- a) under this License, provided that you make a good faith effort to
57
- ensure that, in the event an Application does not supply the
58
- function or data, the facility still operates, and performs
59
- whatever part of its purpose remains meaningful, or
60
-
61
- b) under the GNU GPL, with none of the additional permissions of
62
- this License applicable to that copy.
63
-
64
- 3. Object Code Incorporating Material from Library Header Files.
65
-
66
- The object code form of an Application may incorporate material from
67
- a header file that is part of the Library. You may convey such object
68
- code under terms of your choice, provided that, if the incorporated
69
- material is not limited to numerical parameters, data structure
70
- layouts and accessors, or small macros, inline functions and templates
71
- (ten or fewer lines in length), you do both of the following:
72
-
73
- a) Give prominent notice with each copy of the object code that the
74
- Library is used in it and that the Library and its use are
75
- covered by this License.
76
-
77
- b) Accompany the object code with a copy of the GNU GPL and this license
78
- document.
79
-
80
- 4. Combined Works.
81
-
82
- You may convey a Combined Work under terms of your choice that,
83
- taken together, effectively do not restrict modification of the
84
- portions of the Library contained in the Combined Work and reverse
85
- engineering for debugging such modifications, if you also do each of
86
- the following:
87
-
88
- a) Give prominent notice with each copy of the Combined Work that
89
- the Library is used in it and that the Library and its use are
90
- covered by this License.
91
-
92
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
93
- document.
94
-
95
- c) For a Combined Work that displays copyright notices during
96
- execution, include the copyright notice for the Library among
97
- these notices, as well as a reference directing the user to the
98
- copies of the GNU GPL and this license document.
99
-
100
- d) Do one of the following:
101
-
102
- 0) Convey the Minimal Corresponding Source under the terms of this
103
- License, and the Corresponding Application Code in a form
104
- suitable for, and under terms that permit, the user to
105
- recombine or relink the Application with a modified version of
106
- the Linked Version to produce a modified Combined Work, in the
107
- manner specified by section 6 of the GNU GPL for conveying
108
- Corresponding Source.
109
-
110
- 1) Use a suitable shared library mechanism for linking with the
111
- Library. A suitable mechanism is one that (a) uses at run time
112
- a copy of the Library already present on the user's computer
113
- system, and (b) will operate properly with a modified version
114
- of the Library that is interface-compatible with the Linked
115
- Version.
116
-
117
- e) Provide Installation Information, but only if you would otherwise
118
- be required to provide such information under section 6 of the
119
- GNU GPL, and only to the extent that such information is
120
- necessary to install and execute a modified version of the
121
- Combined Work produced by recombining or relinking the
122
- Application with a modified version of the Linked Version. (If
123
- you use option 4d0, the Installation Information must accompany
124
- the Minimal Corresponding Source and Corresponding Application
125
- Code. If you use option 4d1, you must provide the Installation
126
- Information in the manner specified by section 6 of the GNU GPL
127
- for conveying Corresponding Source.)
128
-
129
- 5. Combined Libraries.
130
-
131
- You may place library facilities that are a work based on the
132
- Library side by side in a single library together with other library
133
- facilities that are not Applications and are not covered by this
134
- License, and convey such a combined library under terms of your
135
- choice, if you do both of the following:
136
-
137
- a) Accompany the combined library with a copy of the same work based
138
- on the Library, uncombined with any other library facilities,
139
- conveyed under the terms of this License.
140
-
141
- b) Give prominent notice with the combined library that part of it
142
- is a work based on the Library, and explaining where to find the
143
- accompanying uncombined form of the same work.
144
-
145
- 6. Revised Versions of the GNU Lesser General Public License.
146
-
147
- The Free Software Foundation may publish revised and/or new versions
148
- of the GNU Lesser General Public License from time to time. Such new
149
- versions will be similar in spirit to the present version, but may
150
- differ in detail to address new problems or concerns.
151
-
152
- Each version is given a distinguishing version number. If the
153
- Library as you received it specifies that a certain numbered version
154
- of the GNU Lesser General Public License "or any later version"
155
- applies to it, you have the option of following the terms and
156
- conditions either of that published version or of any later version
157
- published by the Free Software Foundation. If the Library as you
158
- received it does not specify a version number of the GNU Lesser
159
- General Public License, you may choose any version of the GNU Lesser
160
- General Public License ever published by the Free Software Foundation.
161
-
162
- If the Library as you received it specifies that a proxy can decide
163
- whether future versions of the GNU Lesser General Public License shall
164
- apply, that proxy's public statement of acceptance of any version is
165
- permanent authorization for you to choose that version for the
166
- Library.
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2026 Xie Youtian
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,145 +1,124 @@
1
- # Nodemw MCP Server
2
-
3
- A Model Context Protocol (MCP) server implementation for [nodemw](https://github.com/macbre/nodemw), a Node.js MediaWiki API client.
4
-
5
- ## Features
6
-
7
- - **Complete API Coverage**: Exposes all nodemw `Bot` class methods as MCP tools
8
- - **Resource Management**: Bot configurations are exposed as MCP resources
9
- - **Automatic Authentication**: Login state is managed internally, no credentials exposed to AI
10
- - **Type Safety**: Written in TypeScript with full type definitions
11
-
12
- ## Installation
13
-
14
- ```bash
15
- npm install
16
- npm run build
17
- ```
18
-
19
- ## Single File Build
20
-
21
- For closed-source distribution, you can build a minified single-file version:
22
-
23
- ```bash
24
- # Build standard version (multiple files)
25
- npm run build
26
-
27
- # Build single-file bundle (includes dependencies)
28
- npm run build:bundle
29
-
30
- # Build standalone single-file version
31
- npm run build:standalone
32
-
33
- # Clean build artifacts
34
- npm run clean
35
- ```
36
-
37
- The single-file build outputs to `dist-bundle/index.js` (approx. 1.3MB). This file contains all dependencies bundled together, excluding Node.js built-in modules.
38
-
39
- Usage with Claude Desktop (single-file version):
40
- ```json
41
- {
42
- "mcpServers": {
43
- "nodemw": {
44
- "command": "node",
45
- "args": ["/path/to/nodemw-mcp/dist-bundle/index.js"],
46
- "env": {
47
- "CONFIG": "/path/to/your/config.json"
48
- }
49
- }
50
- }
51
- }
52
- ```
53
-
54
- ## Configuration
55
-
56
- Create a `config.json` file in the project root (or set `CONFIG` environment variable to point to your config file):
57
-
58
- ```json
59
- {
60
- "defaultBot": "en.wikipedia.org",
61
- "bots": {
62
- "en.wikipedia.org": {
63
- "server": "https://en.wikipedia.org",
64
- "path": "/w",
65
- "debug": false,
66
- "username": null,
67
- "password": null
68
- },
69
- "mywiki": {
70
- "server": "https://mywiki.example.com",
71
- "path": "/w",
72
- "debug": false,
73
- "username": "myuser",
74
- "password": "${MY_PASSWORD}" // Environment variable substitution
75
- }
76
- }
77
- }
78
- ```
79
-
80
- ## Usage with Claude Desktop
81
-
82
- Add to your Claude Desktop configuration (`claude_desktop_config.json`):
83
-
84
- ```json
85
- {
86
- "mcpServers": {
87
- "nodemw": {
88
- "command": "node",
89
- "args": ["/path/to/nodemw-mcp/dist/index.js"],
90
- "env": {
91
- "CONFIG": "/path/to/your/config.json"
92
- }
93
- }
94
- }
95
- }
96
- ```
97
-
98
- ## Available Tools
99
-
100
- ### Resource Management
101
-
102
- - `add-bot`: Add a new bot configuration
103
- - `remove-bot`: Remove a bot configuration
104
- - `set-bot`: Switch to a different bot configuration
105
-
106
- ### Read Operations
107
-
108
- - `get-article`: Get the content of a wiki page
109
- - `search`: Search for pages by keyword
110
- - `get-pages-in-category`: List all pages in a category
111
-
112
- ### Write Operations (Requires Authentication)
113
-
114
- - `edit`: Edit a wiki page
115
- - `append`: Append content to a wiki page
116
-
117
- ## Testing with MCP Inspector
118
-
119
- ```bash
120
- # List all tools
121
- npx @modelcontextprotocol/inspector --cli node dist/index.js \
122
- --method tools/list
123
-
124
- # Get a page
125
- npx @modelcontextprotocol/inspector --cli node dist/index.js \
126
- --method tools/call \
127
- --tool-name get-article \
128
- --tool-arg 'title=Main Page'
129
-
130
- # Search
131
- npx @modelcontextprotocol/inspector --cli node dist/index.js \
132
- --method tools/call \
133
- --tool-name search \
134
- --tool-arg 'keyword=MediaWiki'
135
-
136
- # Read a resource
137
- npx @modelcontextprotocol/inspector --cli node dist/index.js \
138
- --method resources/read \
139
- --uri 'mcp://bots/en.wikipedia.org'
140
- ```
141
-
142
- ## Copyright
143
- © 2025 Xie Youtian. All rights reserved.
144
-
145
- Warning: This computer program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program, or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under the law.
1
+ # Nodemw MCP Server
2
+
3
+ A [Model Context Protocol (MCP)](https://modelcontextprotocol.org) server for [nodemw](https://github.com/macbre/nodemw), the Node.js MediaWiki API client.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Install
9
+ npm install
10
+ npm run build
11
+
12
+ # Connect as guest
13
+ node dist/index.js zh.minecraft.wiki
14
+
15
+ # Connect with credentials
16
+ node dist/index.js -u myuser -p mypass mywiki.example.com
17
+ ```
18
+
19
+ ## CLI Usage
20
+
21
+ ```
22
+ nodemw-mcp-server [options] [server]
23
+ ```
24
+
25
+ **Arguments**:
26
+
27
+ | Option | Short | Description |
28
+ |--------|-------|-------------|
29
+ | `[server]` | (positional) | Target MediaWiki server, e.g. `en.wikipedia.org` |
30
+ | `--server` | `-s` | Same as positional, explicit form |
31
+ | `--path` | | API script path (default: auto-detect; tries `/w` then root) |
32
+ | `--user` | `-u` | Login username |
33
+ | `--pass` | `-p` | Login password |
34
+ | `--dry-run` | | Dry-run mode (no actual edits) |
35
+
36
+ **Examples**:
37
+
38
+ ```bash
39
+ # Guest access, auto-detect API path
40
+ nodemw-mcp-server zh.minecraft.wiki
41
+
42
+ # Authenticated, explicit API path
43
+ nodemw-mcp-server -u editor -p secret --path /w mywiki.example.com
44
+
45
+ # With full URL
46
+ nodemw-mcp-server -s https://en.wikipedia.org
47
+
48
+ # Dry-run mode for safe testing
49
+ nodemw-mcp-server --dry-run -u editor -p secret mywiki.example.com
50
+ ```
51
+
52
+ ## Environment Variables
53
+
54
+ All settings can be configured via environment variables. CLI arguments take precedence.
55
+
56
+ | Variable | Equivalent |
57
+ |----------|------------|
58
+ | `NODEMW_MCP_SERVER` | `--server` / positional |
59
+ | `NODEMW_MCP_ENDPOINT_PATH` | `--path` |
60
+ | `NODEMW_MCP_MW_USER` | `--user` / `-u` |
61
+ | `NODEMW_MCP_MW_PASS` | `--pass` / `-p` |
62
+
63
+ ## Usage with config files
64
+
65
+ ```json
66
+ {
67
+ "mcpServers": {
68
+ "nodemw": {
69
+ "command": "npx",
70
+ "args": ["@xiedada/nodemw-mcp-server"],
71
+ "env": {
72
+ "NODEMW_MCP_SERVER": "mywiki.example.com",
73
+ "NODEMW_MCP_MW_USER": "editor",
74
+ "NODEMW_MCP_MW_PASS": "secret"
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ## Available Tools
82
+
83
+ ### Read Operations (29 tools)
84
+
85
+ `get-article`, `search`, `get-pages-in-category`, `get-categories`, `get-users`, `get-all-pages`, `get-pages-in-namespace`, `get-pages-by-prefix`, `get-pages-transcluding`, `get-article-revisions`, `get-article-categories`, `get-article-properties`, `get-article-info`, `get-user-contribs`, `whoami`, `whois`, `whoare`, `get-images`, `get-images-from-article`, `get-image-usage`, `get-image-info`, `get-log`, `expand-templates`, `parse`, `get-recent-changes`, `get-site-info`, `get-site-stats`, `get-mediawiki-version`, `get-external-links`, `get-backlinks`, `get-query-page`
86
+
87
+ ### Write Operations (12 tools, require authentication)
88
+
89
+ `edit`, `append`, `prepend`, `move`, `delete`, `protect`, `purge`, `send-email`, `upload`, `upload-by-url`, `add-flow-topic`, `create-account`
90
+
91
+ ## Development
92
+
93
+ ```bash
94
+ npm run build # Build dist/index.js
95
+ npm run dev # Watch mode
96
+ npm run clean # Remove dist/
97
+ npm test # Run tests
98
+ ```
99
+
100
+ ## License
101
+
102
+ Copyright (c) 2026 Xie Youtian
103
+
104
+ Redistribution and use in source and binary forms, with or without
105
+ modification, are permitted provided that the following conditions are met:
106
+
107
+ 1. Redistributions of source code must retain the above copyright notice, this
108
+ list of conditions and the following disclaimer.
109
+
110
+ 2. Redistributions in binary form must reproduce the above copyright notice,
111
+ this list of conditions and the following disclaimer in the documentation
112
+ and/or other materials provided with the distribution.
113
+
114
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
115
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
116
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
117
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
118
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
119
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
120
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
121
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
122
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
123
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
124
+
package/dist/index.js CHANGED
@@ -1,64 +1,37 @@
1
1
  #!/usr/bin/env node
2
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
- import { parseArgs } from 'util';
4
- import { createServer } from './server.js';
5
- import { registerAllTools } from './tools/index.js';
6
- import { initServerConfig } from './common/nodemwBot.js';
7
- function parseCliArgs() {
8
- const { values } = parseArgs({
9
- options: {
10
- server: { type: 'string' },
11
- endpoint: { type: 'string' },
12
- user: { type: 'string' },
13
- pass: { type: 'string' },
14
- token: { type: 'string' },
15
- 'dry-run': { type: 'boolean' },
16
- },
17
- strict: false,
18
- allowPositionals: true,
19
- });
20
- if (!values.server) {
21
- console.error('Error: --server is required (e.g., --server en.wikipedia.org or --server https://en.wikipedia.org)');
22
- process.exit(1);
23
- }
24
- const serverUrl = values.server;
25
- let server;
26
- let protocol;
27
- let port;
28
- try {
29
- if (serverUrl.startsWith('http://') || serverUrl.startsWith('https://')) {
30
- const url = new URL(serverUrl);
31
- server = url.hostname;
32
- protocol = url.protocol.replace(':', '');
33
- if (url.port) {
34
- port = parseInt(url.port, 10);
35
- }
36
- }
37
- else {
38
- server = serverUrl;
39
- }
40
- }
41
- catch {
42
- server = serverUrl;
43
- }
44
- return {
45
- server,
46
- protocol,
47
- port,
48
- endpoint: values.endpoint ?? '/w',
49
- username: values.user,
50
- password: values.pass,
51
- token: values.token,
52
- dryRun: values['dry-run'],
53
- };
54
- }
55
- async function main() {
56
- const config = parseCliArgs();
57
- initServerConfig(config);
58
- const server = createServer();
59
- registerAllTools(server);
60
- const transport = new StdioServerTransport();
61
- await server.connect(transport);
62
- }
63
- main().catch(console.error);
64
- //# sourceMappingURL=index.js.map
2
+ /*
3
+ * SPDX-License-Identifier: BSD-2-Clause
4
+ *
5
+ * Copyright (c) 2026 Xie Youtian
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright notice,
11
+ * this list of conditions and the following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ * this list of conditions and the following disclaimer in the documentation
15
+ * and/or other materials provided with the distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
+ * POSSIBILITY OF SUCH DAMAGE.
28
+ */
29
+ import{StdioServerTransport as Ke}from"@modelcontextprotocol/sdk/server/stdio.js";import{parseArgs as Ze}from"util";import{McpServer as _t}from"@modelcontextprotocol/sdk/server/mcp.js";var F="nodemw-mcp-server/1.0";function O(t,e=!1){let o,r=e?" Write operations are available.":" Running in guest mode \u2014 only read operations are available.";return t?o=`Connected to ${t.sitename} (${t.base}). Running ${t.generator}.${r} When connecting for the first time, call the get-site-info tool for full site details.`:o=`When connecting to this server for the first time, call the get-site-info tool to understand the target MediaWiki site (version, namespaces, extensions, etc.) before using other tools.${r}`,new _t({name:"nodemw-mcp-server",version:"1.0.0",description:o},{capabilities:{tools:{}}})}import{z as v}from"zod";import Qt from"nodemw";var T=null,Vt=null,U=!1;function z(t){Vt=t}function W(t){let{server:e,path:o,protocol:r,port:a,proxy:c,userAgent:m,concurrency:p,debug:u,username:g,password:y,domain:R,dryRun:x}=t;return new Qt({server:e,protocol:r||"https",port:a,path:o,proxy:c,userAgent:m||F,concurrency:p,debug:u,username:g||void 0,password:y||void 0,domain:R,dryRun:x})}async function Yt(t){try{return await i(t,"getSiteInfo",["general"]),!0}catch{return!1}}async function $(t){let e=["/w",""];for(let o of e){let r={...t,path:o},a=W(r);if(await Yt(a))return o}throw new Error('Could not auto-detect MediaWiki API path. Tried /w/api.php and /api.php. Please specify --path explicitly (e.g., --path /w or --path "" for root).')}async function N(t){T=W(t);let{username:e,password:o}=t;return e&&o&&await new Promise((r,a)=>{T.logIn(c=>{c?a(new Error(`Login failed for user '${e}': ${c.message}`)):(U=!0,r())})}),T}function n(){if(!T)throw new Error("Bot not initialized. Server must be started first.");return T}function L(){return U}function i(t,e,...o){return new Promise((r,a)=>{let c=(m,p)=>{m?a(m):r(p)};t[e](...o,c)})}function D(t){return t.tool("get-article","Retrieve the content of a wiki article",{title:v.string().describe("Article title"),followRedirect:v.boolean().optional().default(!0).describe("Follow redirects"),redirectInfo:v.boolean().optional().default(!1).describe("Include information about redirects")},{title:"Get article",readOnlyHint:!0,destructiveHint:!1},async({title:e,followRedirect:o,redirectInfo:r})=>Jt(e,o,r))}async function Jt(t,e,o){try{let r=await n();if(o){let a=await new Promise((u,g)=>{let y=(R,x,qt)=>{R?g(R):u([x,qt])};r.getArticle(t,e,y)}),[c,m]=a;return c==null?{content:[{type:"text",text:`Page "${t}" not found or has no content.`}],isError:!0}:{content:[{type:"text",text:m?`Content:
30
+
31
+ ${c}
32
+
33
+ Redirect Information:
34
+
35
+ ${JSON.stringify(m,null,2)}`:c}]}}else{let a=await i(r,"getArticle",t,e);return a==null?{content:[{type:"text",text:`Page "${t}" not found or has no content.`}],isError:!0}:{content:[{type:"text",text:a}]}}}catch(r){return{content:[{type:"text",text:`Error: ${r.message}`}],isError:!0}}}import{z as q}from"zod";function l(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function s(t,e){return{content:[{type:"text",text:JSON.stringify({error:t,details:e?.message},null,2)}],isError:!0}}function _(t){return t.tool("search","Search for wiki pages by keyword",{keyword:q.string().describe("Search keyword"),limit:q.number().optional().default(10).describe("Maximum number of results")},{title:"Search",readOnlyHint:!0,destructiveHint:!1},async({keyword:e,limit:o})=>Xt(e,o))}async function Xt(t,e){try{let o=await n(),r=await i(o,"search",t),a=r.slice(0,e);return l({total:r.length,limit:e,keyword:t,results:a})}catch(o){return s("Failed to search",o)}}import{z as Kt}from"zod";function Q(t){return t.tool("get-pages-in-category","Get all pages in a category",{category:Kt.string().describe("Category name (with or without Category: prefix)")},{title:"Get pages in category",readOnlyHint:!0,destructiveHint:!1},async({category:e})=>Zt(e))}async function Zt(t){try{let e=await n(),o=t.replace(/^Category:/i,""),r=await i(e,"getPagesInCategory",o);return l({category:o,pages:r,count:r.length})}catch(e){return s("Failed to get pages in category",e)}}import{z as te}from"zod";function V(t){return t.tool("get-categories","Get all categories matching a prefix",{prefix:te.string().optional().default("").describe("Prefix to filter categories")},{title:"Get categories",readOnlyHint:!0,destructiveHint:!1},async({prefix:e})=>ee(e))}async function ee(t){try{let e=await n(),o=await i(e,"getCategories",t);return l({prefix:t,categories:o,count:o.length})}catch(e){return s("Failed to get categories",e)}}import{z as Y}from"zod";function J(t){return t.tool("get-users","Get all users matching a prefix",{prefix:Y.string().optional().default("").describe("Prefix to filter usernames"),onlyWithEdits:Y.boolean().optional().default(!1).describe("Only include users with at least one edit")},{title:"Get users",readOnlyHint:!0,destructiveHint:!1},async({prefix:e,onlyWithEdits:o})=>oe(e,o))}async function oe(t,e){try{let o=await n(),r=await i(o,"getUsers",{prefix:t,witheditsonly:e});return l({prefix:t,onlyWithEdits:e,users:r,count:r.length})}catch(o){return s("Failed to get users",o)}}import{z as re}from"zod";function X(t){return t.tool("get-all-pages","Get all non-redirect pages from the wiki",{limit:re.number().optional().default(500).describe("Maximum number of pages to return")},{title:"Get all pages",readOnlyHint:!0,destructiveHint:!1},async({limit:e})=>ne(e))}async function ne(t){try{let e=await n(),o=await i(e,"getAllPages"),r=o.slice(0,t);return l({total:o.length,displayed:r.length,pages:r,limit:t})}catch(e){return s("Failed to get all pages",e)}}import{z as ie}from"zod";function K(t){return t.tool("get-pages-in-namespace","Get all non-redirect pages in a specific namespace",{namespace:ie.number().describe("Namespace number to filter pages")},{title:"Get pages in namespace",readOnlyHint:!0,destructiveHint:!1},async({namespace:e})=>se(e))}async function se(t){try{let e=await n(),o=await i(e,"getPagesInNamespace",t);return l({namespace:t,pages:o,count:o.length})}catch(e){return s("Failed to get pages in namespace",e)}}import{z as le}from"zod";function Z(t){return t.tool("get-pages-by-prefix","Get pages starting with a specific prefix",{prefix:le.string().describe("Prefix to match page titles")},{title:"Get pages by prefix",readOnlyHint:!0,destructiveHint:!1},async({prefix:e})=>ae(e))}async function ae(t){try{let e=await n(),o=await i(e,"getPagesByPrefix",t);return l({prefix:t,pages:o,count:o.length})}catch(e){return s("Failed to get pages by prefix",e)}}import{z as ce}from"zod";function tt(t){return t.tool("get-pages-transcluding","Get all pages that transclude (include) a specific template",{template:ce.string().describe("Template title to find transclusions")},{title:"Get pages transcluding template",readOnlyHint:!0,destructiveHint:!1},async({template:e})=>me(e))}async function me(t){try{let e=await n(),r=(await i(e,"getPagesTranscluding",t))[1],a=Array.isArray(r)?r.filter(c=>c!=null&&typeof c=="object"&&"title"in c):[];return l({template:t,pages:a,count:a.length})}catch(e){return s("Failed to get pages transcluding template",e)}}import{z as w}from"zod";function et(t){return t.tool("get-article-revisions","Get all revisions of a wiki article",{title:w.union([w.string(),w.number()]).describe("Article title or page ID")},{title:"Get article revisions",readOnlyHint:!0,destructiveHint:!1},async({title:e})=>pe(e))}async function pe(t){try{let e=await n(),r=(await i(e,"getArticleRevisions",t)).flat();return l({title:t,revisions:r,count:r.length})}catch(e){return s("Failed to get article revisions",e)}}import{z as k}from"zod";function ot(t){return t.tool("get-article-categories","Get all categories that an article belongs to",{title:k.union([k.string(),k.number()]).describe("Article title or page ID")},{title:"Get article categories",readOnlyHint:!0,destructiveHint:!1},async({title:e})=>ue(e))}async function ue(t){try{let e=await n(),o=await i(e,"getArticleCategories",t);return l({title:t,categories:o,count:o.length})}catch(e){return s("Failed to get article categories",e)}}import{z as ge}from"zod";function rt(t){return t.tool("get-article-properties","Get page properties for a wiki article",{title:ge.string().describe("Article title")},{title:"Get article properties",readOnlyHint:!0,destructiveHint:!1},async({title:e})=>de(e))}async function de(t){try{let e=await n(),o=await i(e,"getArticleProperties",t);return l({title:t,properties:o})}catch(e){return s("Failed to get article properties",e)}}import{z as d}from"zod";function nt(t){return t.tool("get-article-info","Get detailed information about one or more articles",{title:d.union([d.string(),d.number(),d.array(d.union([d.string(),d.number()]))]).describe("Article title, page ID, or array of titles/IDs"),properties:d.array(d.string()).optional().describe("Specific properties to retrieve")},{title:"Get article info",readOnlyHint:!0,destructiveHint:!1},async({title:e,properties:o})=>fe(e,o))}async function fe(t,e){try{let o=await n(),a=await i(o,"getArticleInfo",t,e?{inprop:e}:{}),c=Array.isArray(a)?a:[a];return l({title:t,results:c,count:c.length})}catch(o){return s("Failed to get article info",o)}}import{z as A}from"zod";function it(t){return t.tool("get-user-contribs","Get contributions made by a specific user",{username:A.string().describe("Username to get contributions for"),namespace:A.number().optional().describe("Filter contributions by namespace"),limit:A.number().optional().default(50).describe("Maximum number of contributions to return")},{title:"Get user contributions",readOnlyHint:!0,destructiveHint:!1},async({username:e,namespace:o,limit:r})=>ye(e,o,r))}async function ye(t,e,o=50){try{let r=await n(),a={user:t,...e!==void 0&&{namespace:e}},c=await i(r,"getUserContribs",a),m=Array.isArray(c[1])?c[1]:[],p=m.slice(0,o);return l({username:t,namespace:e,limit:o,total:m.length,displayed:p.length,contributions:p})}catch(r){return s("Failed to get user contributions",r)}}function st(t){return t.tool("whoami","Get information about the currently logged in user",{},{title:"Who am I",readOnlyHint:!0,destructiveHint:!1},async()=>Te())}async function Te(){try{let t=await n(),e=await i(t,"whoami");return l(e)}catch(t){return s("Failed to get current user info",t)}}import{z as Re}from"zod";function lt(t){return t.tool("whois","Get information about a specific user",{username:Re.string().describe("Username to look up")},{title:"Whois",readOnlyHint:!0,destructiveHint:!1},async({username:e})=>he(e))}async function he(t){try{let e=await n(),o=await i(e,"whois",t);return o.missing?s(`User "${t}" not found.`):l(o)}catch(e){return s("Failed to get user info",e)}}import{z as at}from"zod";function ct(t){return t.tool("whoare","Get information about multiple wiki users",{usernames:at.array(at.string()).describe("Array of usernames to query")},{title:"Who are",readOnlyHint:!0,destructiveHint:!1},async e=>be(e))}async function be(t){try{let e=await n(),o=await i(e,"whoare",t.usernames);return l(o)}catch(e){return s("Failed to get user information",e)}}import{z as mt}from"zod";function pt(t){return t.tool("get-images","Get list of images starting from a specific name",{startFrom:mt.string().optional().default("").describe("Start from this image name"),limit:mt.number().optional().default(50).describe("Maximum number of images to return")},{title:"Get images",readOnlyHint:!0,destructiveHint:!1},async({startFrom:e,limit:o})=>xe(e,o))}async function xe(t,e){try{let o=await n(),r=await new Promise((c,m)=>{o.getImages(t,(p,...u)=>{if(p)m(p);else{let g=u[0];c(Array.isArray(g)?g:[])}})}),a=r.slice(0,e);return l({total:r.length,limit:e,startFrom:t,images:a})}catch(o){return s("Failed to get images",o)}}import{z as M}from"zod";function ut(t){return t.tool("get-images-from-article","Get all images embedded in a specific article",{title:M.union([M.string(),M.number()]).describe("Article title or page ID")},{title:"Get images from article",readOnlyHint:!0,destructiveHint:!1},async({title:e})=>ve(e))}async function ve(t){try{let e=await n(),o=await i(e,"getImagesFromArticle",t);return l({title:t,images:o,count:o.length})}catch(e){return s("Failed to get images from article",e)}}import{z as we}from"zod";function gt(t){return t.tool("get-image-usage","Get all pages that use a specific image",{filename:we.string().describe("Image filename with File: prefix")},{title:"Get image usage",readOnlyHint:!0,destructiveHint:!1},async({filename:e})=>ke(e))}async function ke(t){try{let e=await n(),o=await i(e,"getImageUsage",t);return l({filename:t,pages:o,count:o.length})}catch(e){return s("Failed to get image usage",e)}}import{z as Ae}from"zod";function dt(t){return t.tool("get-image-info","Get detailed information about an image file",{filename:Ae.string().describe("Image filename with File: prefix")},{title:"Get image info",readOnlyHint:!0,destructiveHint:!1},async({filename:e})=>Me(e))}async function Me(t){try{let e=await n(),o=await i(e,"getImageInfo",t);return o?l({filename:t,info:o}):s(`Image "${t}" not found.`)}catch(e){return s("Failed to get image info",e)}}import{z as S}from"zod";function ft(t){return t.tool("get-log","Get log entries of a specific type",{type:S.string().describe("Log type (e.g. delete, block, move)"),start:S.string().optional().default("").describe("Start timestamp (YYYYMMDDHHMMSS format)"),limit:S.number().optional().default(50).describe("Maximum number of entries to return")},{title:"Get log entries",readOnlyHint:!0,destructiveHint:!1},async({type:e,start:o,limit:r})=>Se(e,o,r))}async function Se(t,e,o){try{let r=await n(),a=await new Promise((m,p)=>{r.getLog(t,e,(u,...g)=>{if(u)p(u);else{let y=g[0];m(Array.isArray(y)?y:[])}})}),c=a.slice(0,o);return l({type:t,start:e,limit:o,total:a.length,displayed:c.length,entries:c})}catch(r){return s("Failed to get log entries",r)}}import{z as yt}from"zod";function Tt(t){return t.tool("expand-templates","Expand templates in wikitext",{text:yt.string().describe("Wikitext with templates to expand"),title:yt.string().optional().describe("Context page title")},{title:"Expand templates",readOnlyHint:!0,destructiveHint:!1},async({text:e,title:o})=>Ce(e,o))}async function Ce(t,e){try{let o=await n(),r=await i(o,"expandTemplates",t,e||"");return r==null?{content:[{type:"text",text:`Failed to expand templates for "${t}".`}],isError:!0}:{content:[{type:"text",text:r}]}}catch(o){return{content:[{type:"text",text:`Error: ${o.message}`}],isError:!0}}}import{z as Rt}from"zod";function ht(t){return t.tool("parse","Parse wikitext to HTML",{text:Rt.string().describe("Wikitext to parse"),title:Rt.string().optional().describe("Context page title")},{title:"Parse wikitext",readOnlyHint:!0,destructiveHint:!1},async({text:e,title:o})=>Pe(e,o))}async function Pe(t,e){try{let o=await n(),r=await i(o,"parse",t,e||""),a=r[1]||"",c=Array.isArray(r[2])?r[2]:[];return{content:[{type:"text",text:["Parsed XML structure:","",a,"",`Images found: ${c.length>0?c.join(", "):"none"}`].join(`
36
+ `)}]}}catch(o){return{content:[{type:"text",text:`Error: ${o.message}`}],isError:!0}}}import{z as bt}from"zod";function xt(t){return t.tool("get-recent-changes","Get recent changes on the wiki",{start:bt.string().optional().describe("Start timestamp"),limit:bt.number().optional().default(50).describe("Maximum number of changes to return")},{title:"Get recent changes",readOnlyHint:!0,destructiveHint:!1},async({start:e,limit:o})=>je(e,o))}async function je(t,e=50){try{let o=await n(),r=await new Promise((c,m)=>{o.getRecentChanges(t,(p,...u)=>{if(p)m(p);else{let g=u[0];c(Array.isArray(g)?g:[])}})}),a=r.slice(0,e);return l({total:r.length,limit:e,start:t,changes:a})}catch(o){return s("Failed to get recent changes",o)}}import{z as vt}from"zod";function wt(t){return t.tool("get-site-info","Get site information from MediaWiki",{properties:vt.array(vt.string()).describe("List of site information properties to retrieve")},{title:"Get site info",readOnlyHint:!0,destructiveHint:!1},async({properties:e})=>Be(e))}async function Be(t){try{let e=await n(),o=await i(e,"getSiteInfo",t);return l(o||{})}catch(e){return s("Failed to get site info",e)}}function kt(t){return t.tool("get-site-stats","Get site statistics",{},{title:"Get site stats",readOnlyHint:!0,destructiveHint:!1},async()=>Ee())}async function Ee(){try{let t=await n(),e=await i(t,"getSiteStats");return l(e)}catch(t){return s("Failed to get site stats",t)}}function At(t){return t.tool("get-mediawiki-version","Get MediaWiki version running on the server",{},{title:"Get MediaWiki version",readOnlyHint:!0,destructiveHint:!1},async()=>He())}async function He(){try{let t=await n(),e=await i(t,"getMediaWikiVersion");return l({version:e})}catch(t){return s("Failed to get MediaWiki version",t)}}import{z as Ie}from"zod";function Mt(t){return t.tool("get-query-page","Get results from a query page (special page)",{name:Ie.string().describe("Name of the query page")},{title:"Get query page results",readOnlyHint:!0,destructiveHint:!1},async({name:e})=>Ge(e))}async function Ge(t){try{let e=await n(),o=await i(e,"getQueryPage",t);return l({name:t,results:o,count:o.length})}catch(e){return s("Failed to get query page results",e)}}import{z as C}from"zod";function St(t){return t.tool("get-external-links","Get all external links from an article",{title:C.union([C.string(),C.number()]).describe("Article title or page ID")},{title:"Get external links",readOnlyHint:!0,destructiveHint:!1},async({title:e})=>Fe(e))}async function Fe(t){try{let e=await n(),o=await i(e,"getExternalLinks",t);return l({title:t,links:o.map(r=>r["*"]),count:o.length})}catch(e){return s("Failed to get external links",e)}}import{z as Oe}from"zod";function Ct(t){return t.tool("get-backlinks","Get all backlinks to a specific page",{title:Oe.string().describe("Target page title to find backlinks for")},{title:"Get backlinks",readOnlyHint:!0,destructiveHint:!1},async({title:e})=>Ue(e))}async function Ue(t){try{let e=await n(),o=await i(e,"getBacklinks",t);return l({target:t,backlinks:o,count:o.length})}catch(e){return s("Failed to get backlinks",e)}}import{z as h}from"zod";function Pt(t){return t.tool("edit","Edit a wiki page (requires authentication)",{title:h.string().describe("Page title to edit"),content:h.string().describe("New content for the page"),summary:h.string().describe("Edit summary"),minor:h.boolean().optional().default(!1).describe("Mark as minor edit")},{title:"Edit page",readOnlyHint:!1,destructiveHint:!0},async e=>ze(e))}async function ze(t){try{let e=await n(),o=`[nodemw-mcp] ${t.summary}`,r=await i(e,"edit",t.title,t.content,o,t.minor||!1);return l(r)}catch(e){return s("Failed to edit page",e)}}import{z as P}from"zod";function jt(t){return t.tool("append","Append content to a wiki page (requires authentication)",{title:P.string().describe("Page title"),content:P.string().describe("Content to append"),summary:P.string().describe("Edit summary")},{title:"Append to page",readOnlyHint:!1,destructiveHint:!0},async e=>We(e))}async function We(t){try{let e=await n(),o=`[nodemw-mcp] ${t.summary}`;return await i(e,"append",t.title,t.content,o),l({success:!0,title:t.title})}catch(e){return s("Failed to append to page",e)}}import{z as j}from"zod";function Bt(t){return t.tool("prepend","Prepend content to a wiki page (requires authentication)",{title:j.string().describe("Page title to prepend to"),content:j.string().describe("Content to prepend"),summary:j.string().describe("Edit summary")},{title:"Prepend to page",readOnlyHint:!1,destructiveHint:!0},async e=>$e(e))}async function $e(t){try{let e=await n(),o=`[nodemw-mcp] ${t.summary}`,r=await i(e,"prepend",t.title,t.content,o);return l(r)}catch(e){return s("Failed to prepend to page",e)}}import{z as B}from"zod";function Et(t){return t.tool("move","Move (rename) a wiki page (requires authentication)",{from:B.string().describe("Current page title"),to:B.string().describe("New page title"),summary:B.string().describe("Move summary")},{title:"Move page",readOnlyHint:!1,destructiveHint:!0},async e=>Ne(e))}async function Ne(t){try{let e=await n(),o=`[nodemw-mcp] ${t.summary}`,r=await i(e,"move",t.from,t.to,o);return l(r)}catch(e){return s("Failed to move page",e)}}import{z as Ht}from"zod";function It(t){return t.tool("delete","Delete a wiki page (requires authentication)",{title:Ht.string().describe("Page title to delete"),reason:Ht.string().describe("Reason for deletion")},{title:"Delete page",readOnlyHint:!1,destructiveHint:!0},async e=>Le(e))}async function Le(t){try{let e=await n(),o=`[nodemw-mcp] ${t.reason}`,r=await i(e,"delete",t.title,o);return l(r)}catch(e){return s("Failed to delete page",e)}}import{z as f}from"zod";function Gt(t){return t.tool("protect","Protect a wiki page (requires authentication)",{title:f.string().describe("Page title to protect"),protections:f.array(f.object({type:f.string().describe("Action type (e.g., edit, move)"),level:f.string().optional().default("all").describe("Protection level (e.g., sysop, autoconfirmed)"),expiry:f.string().optional().describe("Expiry time (e.g., 1 week, never)")})).describe("Protection settings"),reason:f.string().optional().describe("Reason for protection"),cascade:f.boolean().optional().default(!1).describe("Apply cascade protection")},{title:"Protect page",readOnlyHint:!1,destructiveHint:!0},async e=>De(e))}async function De(t){try{let e=await n(),o={};t.reason&&(o.reason=`[nodemw-mcp] ${t.reason}`),t.cascade&&(o.cascade=t.cascade);let r=await i(e,"protect",t.title,t.protections,o);return l(r)}catch(e){return s("Failed to protect page",e)}}import{z as b}from"zod";function Ft(t){return t.tool("purge","Purge cache for wiki pages",{titles:b.union([b.string(),b.array(b.string())]).describe("Page title(s) or category to purge")},{title:"Purge pages",readOnlyHint:!1,destructiveHint:!1},async e=>qe(e))}async function qe(t){try{let e=await n(),o=await i(e,"purge",t.titles);return l(o)}catch(e){return s("Failed to purge pages",e)}}import{z as E}from"zod";function Ot(t){return t.tool("send-email","Send email to a wiki user (requires authentication)",{username:E.string().describe("Username to email"),subject:E.string().describe("Email subject"),text:E.string().describe("Email content")},{title:"Send email",readOnlyHint:!1,destructiveHint:!1},async e=>_e(e))}async function _e(t){try{let e=await n(),o=await i(e,"sendEmail",t.username,t.subject,t.text);return l(o)}catch(e){return s("Failed to send email",e)}}import{z as H}from"zod";function Ut(t){return t.tool("upload","Upload a file to wiki (requires authentication)",{filename:H.string().describe("Destination filename on wiki"),content:H.string().describe("File content as base64 string"),comment:H.string().optional().describe("Upload comment")},{title:"Upload file",readOnlyHint:!1,destructiveHint:!1},async e=>Qe(e))}async function Qe(t){try{let e=await n(),o=Buffer.from(t.content,"base64"),r=t.comment?`[nodemw-mcp] ${t.comment}`:"[nodemw-mcp] File upload",a=await i(e,"upload",t.filename,o,r);return l(a)}catch(e){return s("Failed to upload file",e)}}import{z as I}from"zod";function zt(t){return t.tool("upload-by-url","Upload a file to wiki from URL (requires authentication)",{filename:I.string().describe("Destination filename on wiki"),url:I.string().url().describe("Source URL to download file from"),summary:I.string().optional().describe("Upload summary")},{title:"Upload file by URL",readOnlyHint:!1,destructiveHint:!1},async e=>Ve(e))}async function Ve(t){try{let e=await n(),o=t.summary?`[nodemw-mcp] ${t.summary}`:"[nodemw-mcp] File upload from URL",r=await i(e,"uploadByUrl",t.filename,t.url,o);return l(r)}catch(e){return s("Failed to upload file by URL",e)}}import{z as G}from"zod";function Wt(t){return t.tool("add-flow-topic","Add a new Flow topic to a wiki page (requires authentication)",{title:G.string().describe("Page title to add topic to"),subject:G.string().describe("Topic subject"),content:G.string().describe("Topic content in wikitext")},{title:"Add Flow topic",readOnlyHint:!1,destructiveHint:!1},async e=>Ye(e))}async function Ye(t){try{let e=await n(),o=await i(e,"addFlowTopic",t.title,t.subject,t.content);return l(o)}catch(e){return s("Failed to add Flow topic",e)}}import{z as $t}from"zod";function Nt(t){return t.tool("create-account","Create a new MediaWiki user account (requires authentication)",{username:$t.string().describe("New account username"),password:$t.string().describe("New account password")},{title:"Create user account",readOnlyHint:!1,destructiveHint:!1},async e=>Je(e))}async function Je(t){try{let e=await n(),o=await i(e,"createAccount",t.username,t.password);return l(o)}catch(e){return s("Failed to create account",e)}}var Lt=[D,_,Q,V,J,X,K,Z,tt,et,ot,rt,nt,it,st,lt,ct,pt,ut,gt,dt,ft,Tt,ht,xt,wt,kt,At,Mt,St,Ct],Xe=[Pt,jt,Bt,Et,It,Gt,Ft,Ot,Ut,zt,Wt,Nt];function Dt(t,e=!0){let o=e?[...Lt,...Xe]:Lt,r=[];for(let a of o)try{r.push(a(t))}catch(c){console.error(`Error registering tool: ${c.message}`)}return r}function to(){let{values:t,positionals:e}=Ze({options:{server:{type:"string",short:"s"},path:{type:"string"},endpoint:{type:"string"},user:{type:"string",short:"u"},pass:{type:"string",short:"p"},token:{type:"string"},"dry-run":{type:"boolean"}},strict:!1,allowPositionals:!0}),o=t.server??e[0]??process.env.NODEMW_MCP_SERVER;o||(console.error("Error: target server is required (-s, positional arg, or NODEMW_MCP_SERVER env)"),process.exit(1));let r,a,c;try{if(o.startsWith("http://")||o.startsWith("https://")){let u=new URL(o);r=u.hostname,a=u.protocol.replace(":",""),u.port&&(c=parseInt(u.port,10))}else r=o}catch{r=o}let m=process.env.NODEMW_MCP_ENDPOINT_PATH,p=!!(t.path??t.endpoint??m);return{config:{server:r,protocol:a,port:c,path:t.path??t.endpoint??m??"/w",username:t.user??process.env.NODEMW_MCP_MW_USER,password:t.pass??process.env.NODEMW_MCP_MW_PASS,token:t.token,dryRun:t["dry-run"]},pathExplicit:p}}async function eo(){let{config:t,pathExplicit:e}=to();if(!e)try{t.path=await $(t),console.error(`Auto-detected API path: ${t.path}`)}catch(p){console.error("Error:",p.message),process.exit(1)}z(t);try{await N(t)}catch(p){console.error("Error:",p.message),process.exit(1)}let o=n(),r;try{let u=(await i(o,"getSiteInfo",["general"]))?.general;u&&(r={sitename:u.sitename||"Unknown",base:u.base||"",generator:u.generator||"MediaWiki"})}catch{console.error("Warning: Could not fetch site info for server description.")}let a=L(),c=O(r,a);Dt(c,a);let m=new Ke;await c.connect(m)}eo().catch(console.error);
37
+ //# sourceMappingURL=index.js.map