@cyanheads/wikipedia-mcp-server 0.1.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.
- package/AGENTS.md +394 -0
- package/CLAUDE.md +394 -0
- package/Dockerfile +99 -0
- package/LICENSE +201 -0
- package/README.md +294 -0
- package/changelog/0.1.x/0.1.0.md +18 -0
- package/changelog/0.1.x/0.1.1.md +22 -0
- package/changelog/0.1.x/0.1.2.md +13 -0
- package/changelog/0.1.x/0.1.3.md +31 -0
- package/changelog/template.md +119 -0
- package/dist/config/server-config.d.ts +13 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +25 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/index.d.ts +168 -0
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/index.js +19 -0
- package/dist/mcp-server/tools/definitions/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-article.tool.d.ts +34 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-article.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-article.tool.js +153 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-article.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-languages.tool.d.ts +35 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-languages.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-languages.tool.js +105 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-languages.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-sections.tool.d.ts +37 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-sections.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-sections.tool.js +109 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-sections.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-summary.tool.d.ts +30 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-summary.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-summary.tool.js +107 -0
- package/dist/mcp-server/tools/definitions/wikipedia-get-summary.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-search-nearby.tool.d.ts +42 -0
- package/dist/mcp-server/tools/definitions/wikipedia-search-nearby.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-search-nearby.tool.js +127 -0
- package/dist/mcp-server/tools/definitions/wikipedia-search-nearby.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-search.tool.d.ts +32 -0
- package/dist/mcp-server/tools/definitions/wikipedia-search.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/wikipedia-search.tool.js +91 -0
- package/dist/mcp-server/tools/definitions/wikipedia-search.tool.js.map +1 -0
- package/dist/services/wikipedia/types.d.ts +110 -0
- package/dist/services/wikipedia/types.d.ts.map +1 -0
- package/dist/services/wikipedia/types.js +6 -0
- package/dist/services/wikipedia/types.js.map +1 -0
- package/dist/services/wikipedia/wikipedia-service.d.ts +81 -0
- package/dist/services/wikipedia/wikipedia-service.d.ts.map +1 -0
- package/dist/services/wikipedia/wikipedia-service.js +577 -0
- package/dist/services/wikipedia/wikipedia-service.js.map +1 -0
- package/package.json +86 -0
- package/server.json +99 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Casey Hand @cyanheads
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>@cyanheads/wikipedia-mcp-server</h1>
|
|
3
|
+
<p><b>Search Wikipedia articles, read summaries and full text, target sections, find nearby pages, and list language editions via MCP. STDIO or Streamable HTTP.</b>
|
|
4
|
+
<div>6 Tools</div>
|
|
5
|
+
</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<div align="center">
|
|
9
|
+
|
|
10
|
+
[](./CHANGELOG.md) [](./LICENSE) [](https://github.com/users/cyanheads/packages/container/package/wikipedia-mcp-server) [](https://modelcontextprotocol.io/) [](https://www.npmjs.com/package/@cyanheads/wikipedia-mcp-server) [](https://www.typescriptlang.org/) [](https://bun.sh/)
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<div align="center">
|
|
15
|
+
|
|
16
|
+
[](https://github.com/cyanheads/wikipedia-mcp-server/releases/latest/download/wikipedia-mcp-server.mcpb) [](https://cursor.com/en/install-mcp?name=wikipedia-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvd2lraXBlZGlhLW1jcC1zZXJ2ZXIiXX0=) [](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22wikipedia-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fwikipedia-mcp-server%22%5D%7D)
|
|
17
|
+
|
|
18
|
+
[](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Tools
|
|
25
|
+
|
|
26
|
+
Six tools for working with Wikipedia across all language editions:
|
|
27
|
+
|
|
28
|
+
| Tool | Description |
|
|
29
|
+
|:---|:---|
|
|
30
|
+
| `wikipedia_search` | Full-text search across Wikipedia, returning ranked results with plain-text snippets and page IDs. |
|
|
31
|
+
| `wikipedia_get_summary` | Lead-section summary for any article — plain text, Wikidata QID, description, thumbnail URL, and page type. |
|
|
32
|
+
| `wikipedia_get_article` | Full article or a targeted section as clean plain text, with section markers preserved. |
|
|
33
|
+
| `wikipedia_get_sections` | Table of contents with `section_index` values for targeted section reads. |
|
|
34
|
+
| `wikipedia_search_nearby` | Geotagged Wikipedia articles within a radius of a WGS 84 coordinate, sorted by distance. |
|
|
35
|
+
| `wikipedia_get_languages` | All language editions available for an article, with titles and URLs. |
|
|
36
|
+
|
|
37
|
+
### `wikipedia_search`
|
|
38
|
+
|
|
39
|
+
Search Wikipedia articles by full-text query.
|
|
40
|
+
|
|
41
|
+
- Returns ranked results with plain-text snippets (HTML stripped), page IDs, and word counts
|
|
42
|
+
- Use when the exact article title is unknown or to discover multiple articles on a topic
|
|
43
|
+
- Supports all Wikipedia language editions via the `language` parameter
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### `wikipedia_get_summary`
|
|
48
|
+
|
|
49
|
+
Fetch the lead-section summary for a Wikipedia article.
|
|
50
|
+
|
|
51
|
+
- Returns the 2–4 paragraph intro, Wikidata QID for cross-referencing, short description, and thumbnail URL
|
|
52
|
+
- Surfaces `page_type: "disambiguation"` — a signal to follow up with `wikipedia_search` using a more specific query
|
|
53
|
+
- Redirect pages followed automatically
|
|
54
|
+
- Right tool for 90% of encyclopedic lookups
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
### `wikipedia_get_article`
|
|
59
|
+
|
|
60
|
+
Fetch article content as clean plain text.
|
|
61
|
+
|
|
62
|
+
- Without `section_index`: returns the full article (40–100 KB for major articles) with `== Section ==` markers
|
|
63
|
+
- With `section_index` (from `wikipedia_get_sections`): returns just that section (1–10 KB)
|
|
64
|
+
- Section path uses wikitext stripping via `wtf_wikipedia`
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### `wikipedia_get_sections`
|
|
69
|
+
|
|
70
|
+
Fetch the table of contents for a Wikipedia article.
|
|
71
|
+
|
|
72
|
+
- Returns section titles, heading levels, section numbering (e.g. "2.1"), and `section_index` values
|
|
73
|
+
- `section_index` is the integer to pass to `wikipedia_get_article` for targeted reads
|
|
74
|
+
- Call this before `wikipedia_get_article` when only a specific section is needed
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### `wikipedia_search_nearby`
|
|
79
|
+
|
|
80
|
+
Find Wikipedia articles about places near a geographic coordinate.
|
|
81
|
+
|
|
82
|
+
- Results sorted ascending by distance in meters
|
|
83
|
+
- Only articles with geographic coordinates in their Wikidata record are returned
|
|
84
|
+
- Radius capped at 10,000 meters; up to 50 results per call
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### `wikipedia_get_languages`
|
|
89
|
+
|
|
90
|
+
List language editions available for a Wikipedia article.
|
|
91
|
+
|
|
92
|
+
- Returns language codes, article titles in each language, and full URLs
|
|
93
|
+
- Use for cross-language research or to discover a non-English title before switching editions
|
|
94
|
+
|
|
95
|
+
## Features
|
|
96
|
+
|
|
97
|
+
Built on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):
|
|
98
|
+
|
|
99
|
+
- Declarative tool definitions — single file per tool, framework handles registration and validation
|
|
100
|
+
- Unified error handling — handlers throw, framework catches, classifies, and formats
|
|
101
|
+
- Pluggable auth: `none`, `jwt`, `oauth`
|
|
102
|
+
- Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`
|
|
103
|
+
- Structured logging with optional OpenTelemetry tracing
|
|
104
|
+
- STDIO and Streamable HTTP transports
|
|
105
|
+
|
|
106
|
+
Wikipedia-specific:
|
|
107
|
+
|
|
108
|
+
- Dual API integration — MediaWiki REST API (`/api/rest_v1/`) for summaries, Action API (`/w/api.php`) for search, full text, sections, geo search, and language links
|
|
109
|
+
- Retry and backoff on all requests; `User-Agent` header per Wikimedia API policy
|
|
110
|
+
- Wikitext stripping pipeline via `wtf_wikipedia` — handles links, templates, refs, bold/italic; re-injects section headings for structure
|
|
111
|
+
- Per-call `language` parameter on every tool — all Wikipedia language editions accessible in a single session
|
|
112
|
+
- Language validation against ~250 known Wikipedia edition codes — catches structurally valid but nonexistent editions before they cause timeouts
|
|
113
|
+
|
|
114
|
+
Agent-friendly output:
|
|
115
|
+
|
|
116
|
+
- `page_type` field on summaries discriminates article / disambiguation / redirect — no string parsing needed
|
|
117
|
+
- `wikibase_item` (Wikidata QID) on summaries enables direct cross-referencing with wikidata-mcp-server
|
|
118
|
+
- `section_index` on table-of-contents entries links directly to the targeted-read parameter on `wikipedia_get_article`
|
|
119
|
+
- Recovery hints on every error type — callers get actionable next steps (e.g., "use `wikipedia_search` to find the correct title")
|
|
120
|
+
|
|
121
|
+
## Getting started
|
|
122
|
+
|
|
123
|
+
Add the following to your MCP client configuration file.
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"mcpServers": {
|
|
128
|
+
"wikipedia": {
|
|
129
|
+
"type": "stdio",
|
|
130
|
+
"command": "bunx",
|
|
131
|
+
"args": ["wikipedia-mcp-server@latest"],
|
|
132
|
+
"env": {
|
|
133
|
+
"MCP_TRANSPORT_TYPE": "stdio",
|
|
134
|
+
"MCP_LOG_LEVEL": "info"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Or with npx (no Bun required):
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"mcpServers": {
|
|
146
|
+
"wikipedia": {
|
|
147
|
+
"type": "stdio",
|
|
148
|
+
"command": "npx",
|
|
149
|
+
"args": ["-y", "wikipedia-mcp-server@latest"],
|
|
150
|
+
"env": {
|
|
151
|
+
"MCP_TRANSPORT_TYPE": "stdio",
|
|
152
|
+
"MCP_LOG_LEVEL": "info"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Or with Docker:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"mcpServers": {
|
|
164
|
+
"wikipedia": {
|
|
165
|
+
"type": "stdio",
|
|
166
|
+
"command": "docker",
|
|
167
|
+
"args": [
|
|
168
|
+
"run", "-i", "--rm",
|
|
169
|
+
"-e", "MCP_TRANSPORT_TYPE=stdio",
|
|
170
|
+
"ghcr.io/cyanheads/wikipedia-mcp-server:latest"
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
For Streamable HTTP, set the transport and start the server:
|
|
178
|
+
|
|
179
|
+
```sh
|
|
180
|
+
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
|
|
181
|
+
# Server listens at http://localhost:3010/mcp
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Prerequisites
|
|
185
|
+
|
|
186
|
+
- [Bun v1.3.0](https://bun.sh/) or higher (or Node.js v24+).
|
|
187
|
+
- No API keys required — Wikipedia's API is public.
|
|
188
|
+
|
|
189
|
+
### Installation
|
|
190
|
+
|
|
191
|
+
1. **Clone the repository:**
|
|
192
|
+
|
|
193
|
+
```sh
|
|
194
|
+
git clone https://github.com/cyanheads/wikipedia-mcp-server.git
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
2. **Navigate into the directory:**
|
|
198
|
+
|
|
199
|
+
```sh
|
|
200
|
+
cd wikipedia-mcp-server
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
3. **Install dependencies:**
|
|
204
|
+
|
|
205
|
+
```sh
|
|
206
|
+
bun install
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
4. **Configure environment (optional):**
|
|
210
|
+
|
|
211
|
+
```sh
|
|
212
|
+
cp .env.example .env
|
|
213
|
+
# edit .env if you want to customize WIKIPEDIA_USER_AGENT or logging
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Configuration
|
|
217
|
+
|
|
218
|
+
| Variable | Description | Default |
|
|
219
|
+
|:---------|:------------|:--------|
|
|
220
|
+
| `WIKIPEDIA_USER_AGENT` | User-Agent header sent with every Wikimedia API request. Customize for your deployment. | `wikipedia-mcp-server/0.1.3 (https://github.com/cyanheads/wikipedia-mcp-server)` |
|
|
221
|
+
| `WIKIPEDIA_BASE_URL` | Base Wikipedia URL. Language selection is per-call — not a global language setting. | `https://en.wikipedia.org` |
|
|
222
|
+
| `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
|
|
223
|
+
| `MCP_HTTP_PORT` | Port for HTTP server. | `3010` |
|
|
224
|
+
| `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |
|
|
225
|
+
| `MCP_LOG_LEVEL` | Log level (RFC 5424). | `info` |
|
|
226
|
+
| `LOGS_DIR` | Directory for log files (Node.js only). | `<project-root>/logs` |
|
|
227
|
+
| `OTEL_ENABLED` | Enable OpenTelemetry instrumentation (spans, metrics, completion logs). | `false` |
|
|
228
|
+
|
|
229
|
+
See [`.env.example`](./.env.example) for the full list of optional overrides.
|
|
230
|
+
|
|
231
|
+
## Running the server
|
|
232
|
+
|
|
233
|
+
### Local development
|
|
234
|
+
|
|
235
|
+
- **Build and run:**
|
|
236
|
+
|
|
237
|
+
```sh
|
|
238
|
+
# One-time build
|
|
239
|
+
bun run rebuild
|
|
240
|
+
|
|
241
|
+
# Run the built server
|
|
242
|
+
bun run start:stdio
|
|
243
|
+
# or
|
|
244
|
+
bun run start:http
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
- **Run checks and tests:**
|
|
248
|
+
|
|
249
|
+
```sh
|
|
250
|
+
bun run devcheck # Lint, format, typecheck, security
|
|
251
|
+
bun run test # Vitest test suite
|
|
252
|
+
bun run lint:mcp # Validate MCP definitions against spec
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Docker
|
|
256
|
+
|
|
257
|
+
```sh
|
|
258
|
+
docker build -t wikipedia-mcp-server .
|
|
259
|
+
docker run --rm -p 3010:3010 wikipedia-mcp-server
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The Dockerfile defaults to HTTP transport, stateless session mode, and logs to `/var/log/wikipedia-mcp-server`. OpenTelemetry peer dependencies are installed by default — build with `--build-arg OTEL_ENABLED=false` to omit them.
|
|
263
|
+
|
|
264
|
+
## Project structure
|
|
265
|
+
|
|
266
|
+
| Directory | Purpose |
|
|
267
|
+
|:----------|:--------|
|
|
268
|
+
| `src/index.ts` | `createApp()` entry point — registers tools and inits the Wikipedia service. |
|
|
269
|
+
| `src/config` | Server-specific environment variable parsing and validation with Zod. |
|
|
270
|
+
| `src/mcp-server/tools` | Tool definitions (`*.tool.ts`) — one file per tool. |
|
|
271
|
+
| `src/services/wikipedia` | WikipediaService — REST API + Action API client with retry/backoff and language validation. |
|
|
272
|
+
| `tests/` | Unit and integration tests mirroring `src/`. |
|
|
273
|
+
|
|
274
|
+
## Development guide
|
|
275
|
+
|
|
276
|
+
See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:
|
|
277
|
+
|
|
278
|
+
- Handlers throw, framework catches — no `try/catch` in tool logic
|
|
279
|
+
- Use `ctx.log` for request-scoped logging, `ctx.state` for tenant-scoped storage
|
|
280
|
+
- Register new tools in `src/mcp-server/tools/definitions/index.ts`
|
|
281
|
+
- Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
|
|
282
|
+
|
|
283
|
+
## Contributing
|
|
284
|
+
|
|
285
|
+
Issues and pull requests are welcome. Run checks and tests before submitting:
|
|
286
|
+
|
|
287
|
+
```sh
|
|
288
|
+
bun run devcheck
|
|
289
|
+
bun run test
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## License
|
|
293
|
+
|
|
294
|
+
Apache-2.0 — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "Initial release — 6 tools for Wikipedia search, summaries, article reading, section targeting, geo search, and language links."
|
|
3
|
+
breaking: false
|
|
4
|
+
security: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.1.0 — 2026-05-24
|
|
8
|
+
|
|
9
|
+
## Added
|
|
10
|
+
|
|
11
|
+
- **`wikipedia_search`** — full-text search across Wikipedia, returning ranked results with plain-text snippets and page IDs.
|
|
12
|
+
- **`wikipedia_get_summary`** — lead-section summary for any article, with Wikidata QID, description, and thumbnail URL; surfaces `page_type: "disambiguation"` for disambiguation pages.
|
|
13
|
+
- **`wikipedia_get_article`** — full article or targeted section as clean plain text; section path uses wikitext stripping via `wtf_wikipedia`.
|
|
14
|
+
- **`wikipedia_get_sections`** — table of contents with `section_index` values for use with `wikipedia_get_article`; fallback to header parsing when `prop=sections` returns empty.
|
|
15
|
+
- **`wikipedia_search_nearby`** — geo search for geotagged Wikipedia articles within a radius of a WGS 84 coordinate.
|
|
16
|
+
- **`wikipedia_get_languages`** — list all language editions available for an article with titles and URLs.
|
|
17
|
+
- **`WikipediaService`** — wraps the MediaWiki REST API (`/api/rest_v1/`) and Action API (`/w/api.php`) with retry/backoff and User-Agent header per Wikimedia policy.
|
|
18
|
+
- Language selection as a per-call parameter (`language`, default `"en"`) on every tool — supports all Wikipedia language editions in a single session.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "Launch release — full implementation of 6 Wikipedia tools, 41 tests, field-test fixes, and pre-launch polish."
|
|
3
|
+
breaking: false
|
|
4
|
+
security: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.1.1 — 2026-05-24
|
|
8
|
+
|
|
9
|
+
## Added
|
|
10
|
+
|
|
11
|
+
- **`WikipediaService`** — REST + Action API client with retry/backoff, `wtf_wikipedia` for wikitext stripping, and User-Agent header per Wikimedia policy.
|
|
12
|
+
- **6 tools** — `wikipedia_search`, `wikipedia_get_summary`, `wikipedia_get_article`, `wikipedia_get_sections`, `wikipedia_search_nearby`, `wikipedia_get_languages`.
|
|
13
|
+
- **`wtf_wikipedia` ^10.4.1** — wikitext stripping used by `wikipedia_get_article` section content.
|
|
14
|
+
- **41 tests** across 7 test files covering all tools and `WikipediaService`.
|
|
15
|
+
- **README**, `docs/tree.md`, one-click install badges (Claude Desktop, Cursor, VS Code).
|
|
16
|
+
|
|
17
|
+
## Fixed
|
|
18
|
+
|
|
19
|
+
- **`formatversion=2` mismatch** — `wikitext` and `title` were accessed as `{ '*': string }` objects from `formatversion=1`; corrected to plain string keys.
|
|
20
|
+
- **Language validation** — added eager validation against known Wikipedia edition codes; invalid codes previously caused 4 retries × 15 s timeout and leaked the full API URL in the error message.
|
|
21
|
+
- **HTML entity decoding** — snippet HTML from the Action API left encoded entities (`&`, `<`, etc.) after tag stripping; now decoded before returning.
|
|
22
|
+
- **Expanded test coverage** — sparse payload cases, invalid language codes, HTML entity handling, and edge cases added across all tool test files.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "Fix npm package scope to @cyanheads/wikipedia-mcp-server."
|
|
3
|
+
breaking: false
|
|
4
|
+
security: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.1.2 — 2026-05-24
|
|
8
|
+
|
|
9
|
+
## Fixed
|
|
10
|
+
|
|
11
|
+
- **npm package scope** — `name` corrected from `wikipedia-mcp-server` to `@cyanheads/wikipedia-mcp-server` in `package.json`, `server.json` registry identifiers, README npm badge, and install badge configs (Cursor, VS Code).
|
|
12
|
+
- **`bundle` script** — replaced `npm run build` with `bun run build` to match project tooling.
|
|
13
|
+
- **`author` field** — normalized to `cyanheads <casey@caseyjhand.com>` format.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "Field-test fixes: not_found propagation, invalid section_index guard, negative/float input validation, tool-description improvements, service simplification."
|
|
3
|
+
breaking: false
|
|
4
|
+
security: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.1.3 — 2026-05-24
|
|
8
|
+
|
|
9
|
+
## Changed
|
|
10
|
+
|
|
11
|
+
- **`wikipedia_get_summary` description** — clearer prose; documents `page_type: "no-extract"` alongside `"standard"` and `"disambiguation"`.
|
|
12
|
+
- **`wikipedia_get_article` description** — removed KB size estimates (stale); tightened wording.
|
|
13
|
+
- **`wikipedia_get_sections` description** — condensed; removed redundant instruction to call this before `wikipedia_get_article`.
|
|
14
|
+
- **`wikipedia_get_languages` description** — condensed; clarified that `language` specifies which edition to query from.
|
|
15
|
+
- **`wikipedia_search` description** — tightened wording; `pageid` field description clarifies it can be passed to other tools.
|
|
16
|
+
- **`wikipedia_search_nearby` description** — condensed.
|
|
17
|
+
- **`title` field descriptions** — added concrete examples (`"Python (programming language)"`) to `wikipedia_get_article`, `wikipedia_get_sections`, `wikipedia_search`, and `wikipedia_search_nearby` output schemas.
|
|
18
|
+
- **`pageid` output descriptions** — updated in `wikipedia_search` and `wikipedia_search_nearby` to note the value is usable as input to other tools.
|
|
19
|
+
- **`page_type` output description** (`wikipedia_get_summary`) — documents actual values returned by the Wikipedia REST API (`"standard"`, `"disambiguation"`, `"no-extract"`).
|
|
20
|
+
- **`pageid` output description** (`wikipedia_get_summary`) — documents that the field may be absent when the API omits it.
|
|
21
|
+
- **Server instructions** — converted string concatenation to template literal (`src/index.ts`).
|
|
22
|
+
- **`WikipediaService`** — simplified heading extraction loops to filter+map chains; dropped redundant `await` on `withRetry` calls; `...(signal && { signal })` replaces ternary spread.
|
|
23
|
+
|
|
24
|
+
## Fixed
|
|
25
|
+
|
|
26
|
+
- **`not_found` propagation** — `wikipedia_get_article`, `wikipedia_get_sections`, `wikipedia_get_summary`, and `wikipedia_get_languages` now catch `McpError` with `NotFound` from the service layer and re-throw via `ctx.fail('not_found', …)`, so `data.reason` is set consistently for callers (issues #8, #11, #12).
|
|
27
|
+
- **`invalid_section` guard** — `wikipedia_get_article` previously only rejected `section_index === 0`; now rejects any value `< 1` (including negatives) with a typed `invalid_section` error and a message that includes the offending value (issue #9).
|
|
28
|
+
- **`serviceUnavailable` on empty `pages`** — `WikipediaService.getSummary` previously threw `serviceUnavailable` when the Wikipedia extracts API returned no `pages` key; now throws `notFound` with an actionable message (issue #8).
|
|
29
|
+
- **`language` destructuring** — all tool handlers now use `const { language } = input` instead of `input.language || 'en'`; Zod default handles the fallback at parse time.
|
|
30
|
+
- **`radius_meters` and `limit` validation** (`wikipedia_search_nearby`) — schemas now include `.int().min(1)`, rejecting negative and float values at parse time (issues #10, #14).
|
|
31
|
+
- **`limit` validation** (`wikipedia_search`) — schema now includes `.int().min(1)`, rejecting negative, zero, and float values at parse time (issues #10, #14).
|