russian-word-mcp 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,442 @@
1
+ # Data license
2
+
3
+ `data/dictionary.json.gz` is built from the OpenRussian.org dictionary export
4
+ (https://github.com/Badestrand/russian-dictionary) by `scripts/build-dict.ts`.
5
+ Changes made: notation converted (apostrophe to combining acute accent), secondary
6
+ stress marks removed, multi-form cells split, malformed cells dropped.
7
+
8
+ The data is licensed under **Creative Commons Attribution-ShareAlike 4.0
9
+ International (CC BY-SA 4.0)**. If you redistribute it or data derived from it,
10
+ give credit to OpenRussian.org and share it under the same license.
11
+
12
+ The code in this repository is MIT licensed (see `LICENSE`).
13
+
14
+ ---
15
+
16
+ Attribution-ShareAlike 4.0 International
17
+
18
+ =======================================================================
19
+
20
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
21
+ does not provide legal services or legal advice. Distribution of
22
+ Creative Commons public licenses does not create a lawyer-client or
23
+ other relationship. Creative Commons makes its licenses and related
24
+ information available on an "as-is" basis. Creative Commons gives no
25
+ warranties regarding its licenses, any material licensed under their
26
+ terms and conditions, or any related information. Creative Commons
27
+ disclaims all liability for damages resulting from their use to the
28
+ fullest extent possible.
29
+
30
+ Using Creative Commons Public Licenses
31
+
32
+ Creative Commons public licenses provide a standard set of terms and
33
+ conditions that creators and other rights holders may use to share
34
+ original works of authorship and other material subject to copyright
35
+ and certain other rights specified in the public license below. The
36
+ following considerations are for informational purposes only, are not
37
+ exhaustive, and do not form part of our licenses.
38
+
39
+ Considerations for licensors: Our public licenses are
40
+ intended for use by those authorized to give the public
41
+ permission to use material in ways otherwise restricted by
42
+ copyright and certain other rights. Our licenses are
43
+ irrevocable. Licensors should read and understand the terms
44
+ and conditions of the license they choose before applying it.
45
+ Licensors should also secure all rights necessary before
46
+ applying our licenses so that the public can reuse the
47
+ material as expected. Licensors should clearly mark any
48
+ material not subject to the license. This includes other CC-
49
+ licensed material, or material used under an exception or
50
+ limitation to copyright. More considerations for licensors:
51
+ wiki.creativecommons.org/Considerations_for_licensors
52
+
53
+ Considerations for the public: By using one of our public
54
+ licenses, a licensor grants the public permission to use the
55
+ licensed material under specified terms and conditions. If
56
+ the licensor's permission is not necessary for any reason--for
57
+ example, because of any applicable exception or limitation to
58
+ copyright--then that use is not regulated by the license. Our
59
+ licenses grant only permissions under copyright and certain
60
+ other rights that a licensor has authority to grant. Use of
61
+ the licensed material may still be restricted for other
62
+ reasons, including because others have copyright or other
63
+ rights in the material. A licensor may make special requests,
64
+ such as asking that all changes be marked or described.
65
+ Although not required by our licenses, you are encouraged to
66
+ respect those requests where reasonable. More_considerations
67
+ for the public:
68
+ wiki.creativecommons.org/Considerations_for_licensees
69
+
70
+ =======================================================================
71
+
72
+ Creative Commons Attribution-ShareAlike 4.0 International Public
73
+ License
74
+
75
+ By exercising the Licensed Rights (defined below), You accept and agree
76
+ to be bound by the terms and conditions of this Creative Commons
77
+ Attribution-ShareAlike 4.0 International Public License ("Public
78
+ License"). To the extent this Public License may be interpreted as a
79
+ contract, You are granted the Licensed Rights in consideration of Your
80
+ acceptance of these terms and conditions, and the Licensor grants You
81
+ such rights in consideration of benefits the Licensor receives from
82
+ making the Licensed Material available under these terms and
83
+ conditions.
84
+
85
+
86
+ Section 1 -- Definitions.
87
+
88
+ a. Adapted Material means material subject to Copyright and Similar
89
+ Rights that is derived from or based upon the Licensed Material
90
+ and in which the Licensed Material is translated, altered,
91
+ arranged, transformed, or otherwise modified in a manner requiring
92
+ permission under the Copyright and Similar Rights held by the
93
+ Licensor. For purposes of this Public License, where the Licensed
94
+ Material is a musical work, performance, or sound recording,
95
+ Adapted Material is always produced where the Licensed Material is
96
+ synched in timed relation with a moving image.
97
+
98
+ b. Adapter's License means the license You apply to Your Copyright
99
+ and Similar Rights in Your contributions to Adapted Material in
100
+ accordance with the terms and conditions of this Public License.
101
+
102
+ c. BY-SA Compatible License means a license listed at
103
+ creativecommons.org/compatiblelicenses, approved by Creative
104
+ Commons as essentially the equivalent of this Public License.
105
+
106
+ d. Copyright and Similar Rights means copyright and/or similar rights
107
+ closely related to copyright including, without limitation,
108
+ performance, broadcast, sound recording, and Sui Generis Database
109
+ Rights, without regard to how the rights are labeled or
110
+ categorized. For purposes of this Public License, the rights
111
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
112
+ Rights.
113
+
114
+ e. Effective Technological Measures means those measures that, in the
115
+ absence of proper authority, may not be circumvented under laws
116
+ fulfilling obligations under Article 11 of the WIPO Copyright
117
+ Treaty adopted on December 20, 1996, and/or similar international
118
+ agreements.
119
+
120
+ f. Exceptions and Limitations means fair use, fair dealing, and/or
121
+ any other exception or limitation to Copyright and Similar Rights
122
+ that applies to Your use of the Licensed Material.
123
+
124
+ g. License Elements means the license attributes listed in the name
125
+ of a Creative Commons Public License. The License Elements of this
126
+ Public License are Attribution and ShareAlike.
127
+
128
+ h. Licensed Material means the artistic or literary work, database,
129
+ or other material to which the Licensor applied this Public
130
+ License.
131
+
132
+ i. Licensed Rights means the rights granted to You subject to the
133
+ terms and conditions of this Public License, which are limited to
134
+ all Copyright and Similar Rights that apply to Your use of the
135
+ Licensed Material and that the Licensor has authority to license.
136
+
137
+ j. Licensor means the individual(s) or entity(ies) granting rights
138
+ under this Public License.
139
+
140
+ k. Share means to provide material to the public by any means or
141
+ process that requires permission under the Licensed Rights, such
142
+ as reproduction, public display, public performance, distribution,
143
+ dissemination, communication, or importation, and to make material
144
+ available to the public including in ways that members of the
145
+ public may access the material from a place and at a time
146
+ individually chosen by them.
147
+
148
+ l. Sui Generis Database Rights means rights other than copyright
149
+ resulting from Directive 96/9/EC of the European Parliament and of
150
+ the Council of 11 March 1996 on the legal protection of databases,
151
+ as amended and/or succeeded, as well as other essentially
152
+ equivalent rights anywhere in the world.
153
+
154
+ m. You means the individual or entity exercising the Licensed Rights
155
+ under this Public License. Your has a corresponding meaning.
156
+
157
+
158
+ Section 2 -- Scope.
159
+
160
+ a. License grant.
161
+
162
+ 1. Subject to the terms and conditions of this Public License,
163
+ the Licensor hereby grants You a worldwide, royalty-free,
164
+ non-sublicensable, non-exclusive, irrevocable license to
165
+ exercise the Licensed Rights in the Licensed Material to:
166
+
167
+ a. reproduce and Share the Licensed Material, in whole or
168
+ in part; and
169
+
170
+ b. produce, reproduce, and Share Adapted Material.
171
+
172
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
173
+ Exceptions and Limitations apply to Your use, this Public
174
+ License does not apply, and You do not need to comply with
175
+ its terms and conditions.
176
+
177
+ 3. Term. The term of this Public License is specified in Section
178
+ 6(a).
179
+
180
+ 4. Media and formats; technical modifications allowed. The
181
+ Licensor authorizes You to exercise the Licensed Rights in
182
+ all media and formats whether now known or hereafter created,
183
+ and to make technical modifications necessary to do so. The
184
+ Licensor waives and/or agrees not to assert any right or
185
+ authority to forbid You from making technical modifications
186
+ necessary to exercise the Licensed Rights, including
187
+ technical modifications necessary to circumvent Effective
188
+ Technological Measures. For purposes of this Public License,
189
+ simply making modifications authorized by this Section 2(a)
190
+ (4) never produces Adapted Material.
191
+
192
+ 5. Downstream recipients.
193
+
194
+ a. Offer from the Licensor -- Licensed Material. Every
195
+ recipient of the Licensed Material automatically
196
+ receives an offer from the Licensor to exercise the
197
+ Licensed Rights under the terms and conditions of this
198
+ Public License.
199
+
200
+ b. Additional offer from the Licensor -- Adapted Material.
201
+ Every recipient of Adapted Material from You
202
+ automatically receives an offer from the Licensor to
203
+ exercise the Licensed Rights in the Adapted Material
204
+ under the conditions of the Adapter's License You apply.
205
+
206
+ c. No downstream restrictions. You may not offer or impose
207
+ any additional or different terms or conditions on, or
208
+ apply any Effective Technological Measures to, the
209
+ Licensed Material if doing so restricts exercise of the
210
+ Licensed Rights by any recipient of the Licensed
211
+ Material.
212
+
213
+ 6. No endorsement. Nothing in this Public License constitutes or
214
+ may be construed as permission to assert or imply that You
215
+ are, or that Your use of the Licensed Material is, connected
216
+ with, or sponsored, endorsed, or granted official status by,
217
+ the Licensor or others designated to receive attribution as
218
+ provided in Section 3(a)(1)(A)(i).
219
+
220
+ b. Other rights.
221
+
222
+ 1. Moral rights, such as the right of integrity, are not
223
+ licensed under this Public License, nor are publicity,
224
+ privacy, and/or other similar personality rights; however, to
225
+ the extent possible, the Licensor waives and/or agrees not to
226
+ assert any such rights held by the Licensor to the limited
227
+ extent necessary to allow You to exercise the Licensed
228
+ Rights, but not otherwise.
229
+
230
+ 2. Patent and trademark rights are not licensed under this
231
+ Public License.
232
+
233
+ 3. To the extent possible, the Licensor waives any right to
234
+ collect royalties from You for the exercise of the Licensed
235
+ Rights, whether directly or through a collecting society
236
+ under any voluntary or waivable statutory or compulsory
237
+ licensing scheme. In all other cases the Licensor expressly
238
+ reserves any right to collect such royalties.
239
+
240
+
241
+ Section 3 -- License Conditions.
242
+
243
+ Your exercise of the Licensed Rights is expressly made subject to the
244
+ following conditions.
245
+
246
+ a. Attribution.
247
+
248
+ 1. If You Share the Licensed Material (including in modified
249
+ form), You must:
250
+
251
+ a. retain the following if it is supplied by the Licensor
252
+ with the Licensed Material:
253
+
254
+ i. identification of the creator(s) of the Licensed
255
+ Material and any others designated to receive
256
+ attribution, in any reasonable manner requested by
257
+ the Licensor (including by pseudonym if
258
+ designated);
259
+
260
+ ii. a copyright notice;
261
+
262
+ iii. a notice that refers to this Public License;
263
+
264
+ iv. a notice that refers to the disclaimer of
265
+ warranties;
266
+
267
+ v. a URI or hyperlink to the Licensed Material to the
268
+ extent reasonably practicable;
269
+
270
+ b. indicate if You modified the Licensed Material and
271
+ retain an indication of any previous modifications; and
272
+
273
+ c. indicate the Licensed Material is licensed under this
274
+ Public License, and include the text of, or the URI or
275
+ hyperlink to, this Public License.
276
+
277
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
278
+ reasonable manner based on the medium, means, and context in
279
+ which You Share the Licensed Material. For example, it may be
280
+ reasonable to satisfy the conditions by providing a URI or
281
+ hyperlink to a resource that includes the required
282
+ information.
283
+
284
+ 3. If requested by the Licensor, You must remove any of the
285
+ information required by Section 3(a)(1)(A) to the extent
286
+ reasonably practicable.
287
+
288
+ b. ShareAlike.
289
+
290
+ In addition to the conditions in Section 3(a), if You Share
291
+ Adapted Material You produce, the following conditions also apply.
292
+
293
+ 1. The Adapter's License You apply must be a Creative Commons
294
+ license with the same License Elements, this version or
295
+ later, or a BY-SA Compatible License.
296
+
297
+ 2. You must include the text of, or the URI or hyperlink to, the
298
+ Adapter's License You apply. You may satisfy this condition
299
+ in any reasonable manner based on the medium, means, and
300
+ context in which You Share Adapted Material.
301
+
302
+ 3. You may not offer or impose any additional or different terms
303
+ or conditions on, or apply any Effective Technological
304
+ Measures to, Adapted Material that restrict exercise of the
305
+ rights granted under the Adapter's License You apply.
306
+
307
+
308
+ Section 4 -- Sui Generis Database Rights.
309
+
310
+ Where the Licensed Rights include Sui Generis Database Rights that
311
+ apply to Your use of the Licensed Material:
312
+
313
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
314
+ to extract, reuse, reproduce, and Share all or a substantial
315
+ portion of the contents of the database;
316
+
317
+ b. if You include all or a substantial portion of the database
318
+ contents in a database in which You have Sui Generis Database
319
+ Rights, then the database in which You have Sui Generis Database
320
+ Rights (but not its individual contents) is Adapted Material,
321
+
322
+ including for purposes of Section 3(b); and
323
+ c. You must comply with the conditions in Section 3(a) if You Share
324
+ all or a substantial portion of the contents of the database.
325
+
326
+ For the avoidance of doubt, this Section 4 supplements and does not
327
+ replace Your obligations under this Public License where the Licensed
328
+ Rights include other Copyright and Similar Rights.
329
+
330
+
331
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
332
+
333
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
334
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
335
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
336
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
337
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
338
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
339
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
340
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
341
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
342
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
343
+
344
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
345
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
346
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
347
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
348
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
349
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
350
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
351
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
352
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
353
+
354
+ c. The disclaimer of warranties and limitation of liability provided
355
+ above shall be interpreted in a manner that, to the extent
356
+ possible, most closely approximates an absolute disclaimer and
357
+ waiver of all liability.
358
+
359
+
360
+ Section 6 -- Term and Termination.
361
+
362
+ a. This Public License applies for the term of the Copyright and
363
+ Similar Rights licensed here. However, if You fail to comply with
364
+ this Public License, then Your rights under this Public License
365
+ terminate automatically.
366
+
367
+ b. Where Your right to use the Licensed Material has terminated under
368
+ Section 6(a), it reinstates:
369
+
370
+ 1. automatically as of the date the violation is cured, provided
371
+ it is cured within 30 days of Your discovery of the
372
+ violation; or
373
+
374
+ 2. upon express reinstatement by the Licensor.
375
+
376
+ For the avoidance of doubt, this Section 6(b) does not affect any
377
+ right the Licensor may have to seek remedies for Your violations
378
+ of this Public License.
379
+
380
+ c. For the avoidance of doubt, the Licensor may also offer the
381
+ Licensed Material under separate terms or conditions or stop
382
+ distributing the Licensed Material at any time; however, doing so
383
+ will not terminate this Public License.
384
+
385
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
386
+ License.
387
+
388
+
389
+ Section 7 -- Other Terms and Conditions.
390
+
391
+ a. The Licensor shall not be bound by any additional or different
392
+ terms or conditions communicated by You unless expressly agreed.
393
+
394
+ b. Any arrangements, understandings, or agreements regarding the
395
+ Licensed Material not stated herein are separate from and
396
+ independent of the terms and conditions of this Public License.
397
+
398
+
399
+ Section 8 -- Interpretation.
400
+
401
+ a. For the avoidance of doubt, this Public License does not, and
402
+ shall not be interpreted to, reduce, limit, restrict, or impose
403
+ conditions on any use of the Licensed Material that could lawfully
404
+ be made without permission under this Public License.
405
+
406
+ b. To the extent possible, if any provision of this Public License is
407
+ deemed unenforceable, it shall be automatically reformed to the
408
+ minimum extent necessary to make it enforceable. If the provision
409
+ cannot be reformed, it shall be severed from this Public License
410
+ without affecting the enforceability of the remaining terms and
411
+ conditions.
412
+
413
+ c. No term or condition of this Public License will be waived and no
414
+ failure to comply consented to unless expressly agreed to by the
415
+ Licensor.
416
+
417
+ d. Nothing in this Public License constitutes or may be interpreted
418
+ as a limitation upon, or waiver of, any privileges and immunities
419
+ that apply to the Licensor or You, including from the legal
420
+ processes of any jurisdiction or authority.
421
+
422
+
423
+ =======================================================================
424
+
425
+ Creative Commons is not a party to its public
426
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
427
+ its public licenses to material it publishes and in those instances
428
+ will be considered the “Licensor.” The text of the Creative Commons
429
+ public licenses is dedicated to the public domain under the CC0 Public
430
+ Domain Dedication. Except for the limited purpose of indicating that
431
+ material is shared under a Creative Commons public license or as
432
+ otherwise permitted by the Creative Commons policies published at
433
+ creativecommons.org/policies, Creative Commons does not authorize the
434
+ use of the trademark "Creative Commons" or any other trademark or logo
435
+ of Creative Commons without its prior written consent including,
436
+ without limitation, in connection with any unauthorized modifications
437
+ to any of its public licenses or any other arrangements,
438
+ understandings, or agreements concerning use of licensed material. For
439
+ the avoidance of doubt, this paragraph does not form part of the
440
+ public licenses.
441
+
442
+ Creative Commons may be contacted at creativecommons.org.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 akinakkus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,93 @@
1
- # Temporary Holding Version
1
+ # russian-word-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![russian-word-mcp MCP server](https://glama.ai/mcp/servers/akinakkusru-max/russian-word-mcp/badges/score.svg)](https://glama.ai/mcp/servers/akinakkusru-max/russian-word-mcp)
4
+
5
+ **Give your AI assistant reliable Russian word stress, inflection tables and dictionary lookup.**
6
+
7
+ Language models often put the stress on the wrong syllable in Russian, and they rarely say when a word's stress depends on its meaning. This [MCP](https://modelcontextprotocol.io) server answers from a dictionary of about 59,000 words and 567,000 inflected forms instead of from the model's memory.
8
+
9
+ | Tool | What it does |
10
+ |---|---|
11
+ | `stress_text` | Adds stress marks and restores ё in any Russian text. Words whose stress depends on meaning or case are **left unmarked and listed with every option**, most common first, so the assistant picks by context instead of guessing. |
12
+ | `word_info` | Looks up a word in any form (`людьми` finds `челове́к`, plural instrumental) and returns part of speech, English translation, gender or aspect and aspect partner, and the full stressed inflection table. |
13
+ | `inflect` | Declines or conjugates a word given in any form. Without `form` it returns readable tables (nouns by case and number, verbs by person with past and imperative, adjectives by case and gender with short forms). With `form` it returns just that form: `inflect("книгами", form: "pl_gen")` gives `кни́г`. |
14
+
15
+ ```
16
+ stress_text("Это старый замок. Я думаю, что он хороший человек.")
17
+
18
+ Э́то ста́рый замок. Я ду́маю, что он хоро́ший челове́к.
19
+
20
+ Ambiguous (choose by context; options listed most common word first):
21
+ - замок: за́мок [за́мок (noun: sg_nom, sg_acc): castle] | замо́к [замо́к (noun: sg_nom, sg_acc): lock]
22
+ ```
23
+
24
+ ```
25
+ inflect("людей")
26
+
27
+ **челове́к** (noun, masculine, animate): person, people; man
28
+
29
+ | Case | Singular | Plural |
30
+ | --- | --- | --- |
31
+ | nominative | челове́к | лю́ди |
32
+ | genitive | челове́ка | люде́й |
33
+ | dative | челове́ку | лю́дям |
34
+ | accusative | челове́ка | люде́й |
35
+ | instrumental | челове́ком | людьми́ |
36
+ | prepositional | челове́ке | лю́дях |
37
+ ```
38
+
39
+ Verb tables say **Present** for imperfective verbs and **Future** for perfective ones, since the same personal forms mean the future for perfective verbs (`прочита́ю` = I will read).
40
+
41
+ ## Use it
42
+
43
+ Try it first on [Glama](https://glama.ai/mcp/servers/akinakkusru-max/russian-word-mcp): browse the server's tools, check its quality score, or test it online with the [MCP Inspector](https://glama.ai/mcp/inspector).
44
+
45
+ Claude Code:
46
+
47
+ ```bash
48
+ claude mcp add russian-word -- npx -y github:akinakkusru-max/russian-word-mcp
49
+ ```
50
+
51
+ Claude Desktop or any MCP client (add to its config file):
52
+
53
+ ```json
54
+ {
55
+ "mcpServers": {
56
+ "russian-word": { "command": "npx", "args": ["-y", "github:akinakkusru-max/russian-word-mcp"] }
57
+ }
58
+ }
59
+ ```
60
+
61
+ Runs locally, offline, no API key. First start downloads the package; the dictionary loads in about half a second.
62
+
63
+ ## How good is it?
64
+
65
+ - **Coverage:** on a plain A2-level paragraph (59 words), 56 were stressed or needed no mark, 2 were listed as ambiguous (`недалеко` has two accepted stresses; `парке` has a rare homograph), and 1 was unknown (the name `Анна`; personal names are not in the dictionary). This number is locked by a test.
66
+ - **Homographs are never guessed:** `замок` (castle / lock), `руки` (genitive singular / nominative plural), `стоит` (stands / costs), `писала` and others come back as options.
67
+ - **Accuracy is the dictionary's accuracy.** OpenRussian is built from Wiktionary plus user corrections; its authors note it is not free of flaws. The build drops cells it cannot parse (65 of several hundred thousand) rather than repair them by guesswork.
68
+ - Tests start the real server over stdio and call it like an AI app does. Disabling the homograph rule on purpose makes 5 tests fail; swapping the present/future rule or dropping the form check in `inflect` makes the inflection tests fail too.
69
+
70
+ ## Develop
71
+
72
+ ```bash
73
+ npm install
74
+ npm test # 42 tests
75
+ npm start # run the server on stdio
76
+ ```
77
+
78
+ Rebuild the dictionary from source:
79
+
80
+ ```bash
81
+ sh scripts/fetch-raw.sh && npm run build:dict
82
+ ```
83
+
84
+ ## Licenses
85
+
86
+ - Code: MIT (`LICENSE`).
87
+ - Dictionary data (`data/dictionary.json.gz`): **CC BY-SA 4.0**, from [OpenRussian.org](https://en.openrussian.org) via [github.com/Badestrand/russian-dictionary](https://github.com/Badestrand/russian-dictionary). See `DATA_LICENSE.md`.
88
+
89
+ ---
90
+
91
+ ### Türkçe özet
92
+
93
+ Yapay zekâ asistanlarına Rusça kelime vurgusu, okunur çekim tabloları (`inflect`: isim hâlleri, fiil çekimi, sıfat çekimi) ve sözlük bilgisi veren bir MCP sunucusu. Açık lisanslı OpenRussian sözlüğünü (yaklaşık 59.000 kelime) kullanır, bilgisayarında internetsiz ve ücretsiz çalışır. Anlamına göre vurgusu değişen kelimeleri (замок: kale / kilit) tahmin etmez; seçenekleri en yaygın olandan başlayarak listeler.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ // Runs the TypeScript server through tsx, so no build step is needed.
3
+ import { register } from 'tsx/esm/api';
4
+ register();
5
+ await import('../src/server.ts');
Binary file
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "russian-word-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "MCP server that gives AI assistants reliable Russian word stress, inflection tables and lemma lookup, built on the open OpenRussian dictionary.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/akinakkusru-max/russian-word-mcp.git"
10
+ },
11
+ "homepage": "https://github.com/akinakkusru-max/russian-word-mcp#readme",
12
+ "bugs": "https://github.com/akinakkusru-max/russian-word-mcp/issues",
13
+ "keywords": [
14
+ "mcp",
15
+ "model-context-protocol",
16
+ "russian",
17
+ "stress",
18
+ "dictionary",
19
+ "inflection"
20
+ ],
21
+ "engines": {
22
+ "node": ">=20"
23
+ },
24
+ "bin": {
25
+ "russian-word-mcp": "bin/russian-word-mcp.mjs"
26
+ },
27
+ "files": [
28
+ "bin",
29
+ "src",
30
+ "data",
31
+ "README.md",
32
+ "LICENSE",
33
+ "DATA_LICENSE.md"
34
+ ],
35
+ "scripts": {
36
+ "build:dict": "tsx scripts/build-dict.ts",
37
+ "start": "tsx src/server.ts",
38
+ "test": "vitest run",
39
+ "typecheck": "tsc --noEmit"
40
+ },
41
+ "dependencies": {
42
+ "@modelcontextprotocol/sdk": "^1.32.2",
43
+ "tsx": "^4.23.15",
44
+ "zod": "^4.6.7"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^26.6.11",
48
+ "typescript": "^7.0.2",
49
+ "vitest": "^5.1.2"
50
+ }
51
+ }
@@ -0,0 +1,168 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { gunzipSync } from 'node:zlib';
5
+ import { applyStress, hasKnownStress, keyOf, stressPositions, vowelCount } from './normalize.js';
6
+ import type { DictFile, Lemma } from './types.js';
7
+
8
+ export interface FormHit {
9
+ lemma: number;
10
+ /** "lemma" for the dictionary form, otherwise the source tag (sg_gen, past_f...). */
11
+ tag: string;
12
+ form: string;
13
+ }
14
+
15
+ export class Dictionary {
16
+ readonly lemmas: Lemma[];
17
+ readonly source: string;
18
+ /** Frequency rank within the entry's part of speech (the source lists words most common first). */
19
+ readonly rank: number[];
20
+ private readonly index = new Map<string, FormHit[]>();
21
+
22
+ constructor(file: DictFile) {
23
+ this.lemmas = file.lemmas;
24
+ this.source = file.source;
25
+ const seen: Record<string, number> = {};
26
+ this.rank = file.lemmas.map((l) => (seen[l.pos] = (seen[l.pos] ?? 0) + 1));
27
+ file.lemmas.forEach((lemma, id) => {
28
+ for (const w of lemma.w) this.add(w, { lemma: id, tag: 'lemma', form: w });
29
+ for (const [tag, forms] of Object.entries(lemma.f)) for (const form of forms) this.add(form, { lemma: id, tag, form });
30
+ });
31
+ }
32
+
33
+ static load(path = join(dirname(fileURLToPath(import.meta.url)), '..', 'data', 'dictionary.json.gz')): Dictionary {
34
+ return new Dictionary(JSON.parse(gunzipSync(readFileSync(path)).toString('utf8')));
35
+ }
36
+
37
+ private add(form: string, hit: FormHit): void {
38
+ const k = keyOf(form);
39
+ const list = this.index.get(k);
40
+ if (list) list.push(hit); else this.index.set(k, [hit]);
41
+ }
42
+
43
+ /** Every dictionary form that spells `word` (stress and ё ignored). */
44
+ find(word: string): FormHit[] {
45
+ return this.index.get(keyOf(word)) ?? [];
46
+ }
47
+
48
+ get formCount(): number {
49
+ return this.index.size;
50
+ }
51
+ }
52
+
53
+ export type StressStatus = 'stressed' | 'single-syllable' | 'ambiguous' | 'unknown';
54
+
55
+ export interface StressOption {
56
+ stressed: string;
57
+ /** Best frequency rank among the entries behind this option (1 = most common). */
58
+ rank: number;
59
+ /** Which dictionary entries give this stress, e.g. "замок (noun, sg_nom): lock". */
60
+ sources: string[];
61
+ }
62
+
63
+ export interface WordStress {
64
+ word: string;
65
+ status: StressStatus;
66
+ /** The word with stress, when there is exactly one answer. */
67
+ result: string;
68
+ options: StressOption[];
69
+ }
70
+
71
+ const describe = (d: Dictionary, lemmaId: number, tags: string[]) => {
72
+ const l = d.lemmas[lemmaId]!;
73
+ const gloss = l.en.split(/[,;]/)[0]?.trim();
74
+ return `${l.w[0]} (${l.pos}${tags.length ? `: ${tags.join(', ')}` : ''})${gloss ? `: ${gloss}` : ''}`;
75
+ };
76
+
77
+ /**
78
+ * Stress one word. Homographs with different stress (за́мок / замо́к, ру́ки / руки́)
79
+ * are reported as ambiguous with every option; the word is never guessed.
80
+ */
81
+ export function stressWord(d: Dictionary, word: string): WordStress {
82
+ if (vowelCount(word) <= 1) {
83
+ return { word, status: 'single-syllable', result: applyStress(word, word), options: [] };
84
+ }
85
+ const byPattern = new Map<string, { opt: StressOption; tags: Map<number, string[]> }>();
86
+ for (const h of d.find(word)) {
87
+ if (!hasKnownStress(h.form)) continue;
88
+ const pattern = stressPositions(h.form).join(',') + '|' + /[ёЁ]/.test(h.form);
89
+ const entry = byPattern.get(pattern)
90
+ ?? { opt: { stressed: applyStress(word, h.form), rank: Infinity, sources: [] }, tags: new Map() };
91
+ const tags = entry.tags.get(h.lemma) ?? [];
92
+ if (h.tag !== 'lemma' && !tags.includes(h.tag)) tags.push(h.tag);
93
+ entry.tags.set(h.lemma, tags);
94
+ entry.opt.rank = Math.min(entry.opt.rank, d.rank[h.lemma]!);
95
+ byPattern.set(pattern, entry);
96
+ }
97
+ // One source line per dictionary entry: "за́мок (noun: sg_nom, sg_acc): castle".
98
+ for (const { opt, tags } of byPattern.values()) {
99
+ opt.sources = [...tags.entries()].map(([id, t]) => describe(d, id, t));
100
+ }
101
+ // Most common meaning first. Ordering only: an ambiguous word is never auto-resolved.
102
+ const options = [...byPattern.values()].map((e) => e.opt).sort((a, b) => a.rank - b.rank);
103
+ if (options.length === 0) return { word, status: 'unknown', result: word, options };
104
+ if (options.length > 1) return { word, status: 'ambiguous', result: word, options };
105
+ return { word, status: 'stressed', result: options[0]!.stressed, options };
106
+ }
107
+
108
+ export interface TextStress {
109
+ text: string;
110
+ ambiguous: WordStress[];
111
+ unknown: string[];
112
+ counts: Record<StressStatus, number>;
113
+ }
114
+
115
+ const WORD = /[А-Яа-яЁё́]+(?:-[А-Яа-яЁё́]+)*/g;
116
+
117
+ /** Stress every word of a text. Ambiguous and unknown words are left as written and listed. */
118
+ export function stressText(d: Dictionary, text: string): TextStress {
119
+ const ambiguous: WordStress[] = [];
120
+ const unknown: string[] = [];
121
+ const counts: Record<StressStatus, number> = { stressed: 0, 'single-syllable': 0, ambiguous: 0, unknown: 0 };
122
+ const out = text.replace(WORD, (w) => {
123
+ let r = stressWord(d, w);
124
+ // Hyphenated words missing from the dictionary: stress each part on its own.
125
+ if (r.status === 'unknown' && w.includes('-')) {
126
+ const parts = w.split('-').map((p) => stressWord(d, p));
127
+ if (parts.every((p) => p.status === 'stressed' || p.status === 'single-syllable')) {
128
+ r = { word: w, status: 'stressed', result: parts.map((p) => p.result).join('-'), options: [] };
129
+ }
130
+ }
131
+ counts[r.status]++;
132
+ if (r.status === 'ambiguous' && !ambiguous.some((a) => keyOf(a.word) === keyOf(w))) ambiguous.push(r);
133
+ if (r.status === 'unknown' && !unknown.includes(w)) unknown.push(w);
134
+ return r.result;
135
+ });
136
+ return { text: out, ambiguous, unknown, counts };
137
+ }
138
+
139
+ export interface WordInfo {
140
+ query: string;
141
+ matches: {
142
+ lemma: string;
143
+ pos: string;
144
+ translation: string;
145
+ info: Record<string, string>;
146
+ /** How the query relates to this entry: "dictionary form" or the tags it matches. */
147
+ queryIs: string[];
148
+ forms: Record<string, string[]>;
149
+ }[];
150
+ }
151
+
152
+ /** Dictionary entries for a word in any form: "людьми" finds человек (pl_inst). */
153
+ export function wordInfo(d: Dictionary, word: string): WordInfo {
154
+ const byLemma = new Map<number, string[]>();
155
+ for (const h of d.find(word)) {
156
+ const tags = byLemma.get(h.lemma) ?? [];
157
+ const label = h.tag === 'lemma' ? 'dictionary form' : h.tag;
158
+ if (!tags.includes(label)) tags.push(label);
159
+ byLemma.set(h.lemma, tags);
160
+ }
161
+ return {
162
+ query: word,
163
+ matches: [...byLemma.entries()].map(([id, tags]) => {
164
+ const l = d.lemmas[id]!;
165
+ return { lemma: l.w.join(' / '), pos: l.pos, translation: l.en, info: l.i ?? {}, queryIs: tags, forms: l.f };
166
+ }),
167
+ };
168
+ }
package/src/inflect.ts ADDED
@@ -0,0 +1,108 @@
1
+ import type { Dictionary } from './dictionary.js';
2
+ import type { Lemma } from './types.js';
3
+
4
+ const CASES = ['nom', 'gen', 'dat', 'acc', 'inst', 'prep'] as const;
5
+ const CASE_NAMES: Record<string, string> = {
6
+ nom: 'nominative', gen: 'genitive', dat: 'dative', acc: 'accusative', inst: 'instrumental', prep: 'prepositional',
7
+ };
8
+ const PERSONS: [string, string][] = [
9
+ ['я', 'sg1'], ['ты', 'sg2'], ['он / она / оно', 'sg3'], ['мы', 'pl1'], ['вы', 'pl2'], ['они', 'pl3'],
10
+ ];
11
+ const GENDERS: Record<string, string> = { m: 'masculine', f: 'feminine', n: 'neuter', both: 'common gender', pl: 'plural only' };
12
+ const list = (v: string) => v.split(/[;,]/).map((x) => x.trim()).filter(Boolean).join(', ');
13
+
14
+ /** Every form tag the dictionary uses, for the tool's input schema. */
15
+ export const FORM_TAGS = [
16
+ ...CASES.flatMap((c) => [`sg_${c}`, `pl_${c}`]),
17
+ ...PERSONS.map(([, p]) => `presfut_${p}`),
18
+ 'past_m', 'past_f', 'past_n', 'past_pl', 'imperative_sg', 'imperative_pl',
19
+ ...['m', 'f', 'n', 'pl'].flatMap((g) => CASES.map((c) => `decl_${g}_${c}`)),
20
+ 'short_m', 'short_f', 'short_n', 'short_pl', 'comparative', 'superlative',
21
+ ] as const;
22
+
23
+ /** Entries for a word in any form, most common first. */
24
+ function entries(d: Dictionary, word: string): number[] {
25
+ const ids = [...new Set(d.find(word).map((h) => h.lemma))];
26
+ return ids.sort((a, b) => d.rank[a]! - d.rank[b]!);
27
+ }
28
+
29
+ export interface InflectResult {
30
+ lemma: string;
31
+ pos: string;
32
+ form: string;
33
+ forms: string[];
34
+ }
35
+
36
+ /** One form of a word given in any form: ("книгами", "pl_gen") → кни́г. */
37
+ export function inflect(d: Dictionary, word: string, form: string): InflectResult[] {
38
+ return entries(d, word)
39
+ .map((id) => d.lemmas[id]!)
40
+ .filter((l) => l.f[form]?.length)
41
+ .map((l) => ({ lemma: l.w[0]!, pos: l.pos, form, forms: l.f[form]! }));
42
+ }
43
+
44
+ const cell = (l: Lemma, tag: string) => l.f[tag]?.join(', ') || '—';
45
+ const row = (cells: string[]) => `| ${cells.join(' | ')} |`;
46
+
47
+ function nounTable(l: Lemma): string[] {
48
+ const info = [l.i?.gender && GENDERS[l.i.gender], l.i?.animate === 'yes' && 'animate', l.i?.indeclinable === 'yes' && 'indeclinable', l.i?.partner && `pair: ${list(l.i.partner)}`]
49
+ .filter(Boolean).join(', ');
50
+ return [
51
+ `**${l.w[0]}** (noun${info ? `, ${info}` : ''}): ${l.en}`,
52
+ '',
53
+ row(['Case', 'Singular', 'Plural']),
54
+ row(['---', '---', '---']),
55
+ ...CASES.map((c) => row([CASE_NAMES[c]!, cell(l, `sg_${c}`), cell(l, `pl_${c}`)])),
56
+ ];
57
+ }
58
+
59
+ function verbTable(l: Lemma): string[] {
60
+ const perfective = l.i?.aspect === 'perfective';
61
+ const partner = l.i?.partner ? `; aspect partner: ${list(l.i.partner)}` : '';
62
+ return [
63
+ `**${l.w[0]}** (verb${l.i?.aspect ? `, ${l.i.aspect}` : ''}${partner}): ${l.en}`,
64
+ '',
65
+ row(['Person', perfective ? 'Future' : l.i?.aspect === 'both' ? 'Present / Future' : 'Present']),
66
+ row(['---', '---']),
67
+ ...PERSONS.map(([who, p]) => row([who, cell(l, `presfut_${p}`)])),
68
+ '',
69
+ `Past: ${['m', 'f', 'n', 'pl'].map((g) => `${g} ${cell(l, `past_${g}`)}`).join(', ')}`,
70
+ `Imperative: ${cell(l, 'imperative_sg')}, ${cell(l, 'imperative_pl')}`,
71
+ ...(l.i?.aspect === 'imperfective' ? ['Future: буду / будешь … + infinitive'] : []),
72
+ ];
73
+ }
74
+
75
+ function adjectiveTable(l: Lemma): string[] {
76
+ const variants = (tag: string) => l.f[tag]?.join(' / ');
77
+ const short = ['short_m', 'short_f', 'short_n', 'short_pl'].map(variants).filter(Boolean);
78
+ const extra = [
79
+ short.length ? `Short forms: ${short.join(', ')}` : '',
80
+ variants('comparative') ? `Comparative: ${variants('comparative')}` : '',
81
+ variants('superlative') ? `Superlative: ${variants('superlative')}` : '',
82
+ ].filter(Boolean);
83
+ return [
84
+ `**${l.w[0]}** (adjective): ${l.en}`,
85
+ '',
86
+ row(['Case', 'Masculine', 'Feminine', 'Neuter', 'Plural']),
87
+ row(['---', '---', '---', '---', '---']),
88
+ ...CASES.map((c) => row([CASE_NAMES[c]!, ...['m', 'f', 'n', 'pl'].map((g) => cell(l, `decl_${g}_${c}`))])),
89
+ ...(extra.length ? ['', ...extra] : []),
90
+ ];
91
+ }
92
+
93
+ function table(l: Lemma): string[] {
94
+ if (Object.keys(l.f).length === 0) return [`**${l.w[0]}** (${l.pos}): ${l.en}`, '', 'This word does not inflect.'];
95
+ if (l.pos === 'noun') return nounTable(l);
96
+ if (l.pos === 'verb') return verbTable(l);
97
+ if (l.pos === 'adjective') return adjectiveTable(l);
98
+ return [`**${l.w[0]}** (${l.pos}): ${l.en}`, '', ...Object.entries(l.f).map(([t, f]) => `${t}: ${f.join(', ')}`)];
99
+ }
100
+
101
+ /** Readable inflection tables (Markdown) for a word in any form; null when unknown. */
102
+ export function inflectionTable(d: Dictionary, word: string, limit = 3): string | null {
103
+ const ids = entries(d, word);
104
+ if (ids.length === 0) return null;
105
+ const parts = ids.slice(0, limit).map((id) => table(d.lemmas[id]!).join('\n'));
106
+ if (ids.length > limit) parts.push(`(${ids.length - limit} more entries share this spelling)`);
107
+ return parts.join('\n\n');
108
+ }
@@ -0,0 +1,102 @@
1
+ /** Combining acute accent: the stress mark used in Russian learning materials. */
2
+ export const STRESS = '́';
3
+ const GRAVE = '̀';
4
+ const VOWELS = 'аеёиоуыэюяАЕЁИОУЫЭЮЯ';
5
+
6
+ /**
7
+ * Remove stress marks without breaking letters. NFD splits й and ё into base +
8
+ * combining mark, so we drop only the accents and recompose with NFC; otherwise
9
+ * й would turn into и and lookups would silently fail.
10
+ */
11
+ export function stripStress(s: string): string {
12
+ return s.normalize('NFD').replace(/[̀́]/g, '').normalize('NFC');
13
+ }
14
+
15
+ /** Lookup key: no stress, lower case, ё folded to е (most texts write е for ё). */
16
+ export function keyOf(s: string): string {
17
+ return stripStress(s).toLowerCase().replace(/ё/g, 'е');
18
+ }
19
+
20
+ export function vowelCount(word: string): number {
21
+ return [...stripStress(word)].filter((c) => VOWELS.includes(c)).length;
22
+ }
23
+
24
+ /** Index (in characters of the unstressed word) of each stressed vowel. */
25
+ export function stressPositions(accented: string): number[] {
26
+ const out: number[] = [];
27
+ const chars = [...accented.normalize('NFC')];
28
+ let plain = 0;
29
+ for (let i = 0; i < chars.length; i++) {
30
+ const c = chars[i]!;
31
+ if (c === STRESS) { out.push(plain - 1); continue; }
32
+ if (c === 'ё' || c === 'Ё') out.push(plain);
33
+ plain++;
34
+ }
35
+ return [...new Set(out)].sort((a, b) => a - b);
36
+ }
37
+
38
+ /**
39
+ * A word's stress is known if it carries a mark or ё, or has one vowel per part
40
+ * (a one-syllable word needs no mark).
41
+ */
42
+ export function hasKnownStress(accented: string): boolean {
43
+ if (accented.includes(STRESS) || /[ёЁ]/.test(accented)) return true;
44
+ return accented.split(/[- ]/).every((part) => vowelCount(part) <= 1);
45
+ }
46
+
47
+ /** Convert one OpenRussian notation ("сказа'ть") to Unicode ("сказа́ть"). */
48
+ export function fromApostrophe(raw: string): string {
49
+ return raw
50
+ .replace(/`/g, '') // secondary stress: dropped
51
+ .replace(/ѐ/g, 'е').replace(/ѝ/g, 'и').replace(new RegExp(GRAVE, 'g'), '')
52
+ .replace(/á/g, 'а' + STRESS) // stray Latin á in a few verb cells
53
+ .replace(/'/g, STRESS)
54
+ .normalize('NFC');
55
+ }
56
+
57
+ const VALID = /^[а-яё́]+(?:[- ][а-яё́]+)*$/i;
58
+
59
+ /**
60
+ * Split one dictionary cell into clean variants. Cells may hold several forms
61
+ * ("ра'за, ра'зу", "уда'лось//удало'сь", "до'лжной,(до'лжною)"), a leading "*"
62
+ * marking a rare form, or junk; junk is dropped rather than guessed at.
63
+ * A single word with two marks ("фро'нта'") means either stress is used, so it
64
+ * becomes two variants.
65
+ */
66
+ export function cellVariants(cell: string): string[] {
67
+ const out: string[] = [];
68
+ for (let part of cell.split(/\/\/|[,;/]/)) {
69
+ part = part.replace(/[()*]/g, '').trim();
70
+ if (!part || part === '—') continue;
71
+ const word = fromApostrophe(part);
72
+ if (!VALID.test(word)) continue;
73
+ const marks = [...word].filter((c) => c === STRESS).length;
74
+ if (marks > 1 && !/[- ]/.test(word)) {
75
+ const plain = [...word];
76
+ plain.forEach((c, i) => {
77
+ if (c !== STRESS) return;
78
+ out.push(plain.filter((ch, j) => ch !== STRESS || j === i).join(''));
79
+ });
80
+ } else out.push(word);
81
+ }
82
+ return [...new Set(out)];
83
+ }
84
+
85
+ /**
86
+ * Put the stress of `accented` onto `original`, keeping the user's capital
87
+ * letters, and restore ё where the dictionary has it.
88
+ */
89
+ export function applyStress(original: string, accented: string): string {
90
+ const src = [...stripStress(original)];
91
+ const acc = [...stripStress(accented)];
92
+ if (keyOf(original) !== keyOf(accented)) return original;
93
+ const positions = new Set(stressPositions(accented));
94
+ let out = '';
95
+ src.forEach((c, i) => {
96
+ let ch = c;
97
+ if ((acc[i] === 'ё' || acc[i] === 'Ё') && (c === 'е' || c === 'Е')) ch = c === 'е' ? 'ё' : 'Ё';
98
+ out += ch;
99
+ if (positions.has(i) && ch !== 'ё' && ch !== 'Ё' && vowelCount(original) > 1) out += STRESS;
100
+ });
101
+ return out.normalize('NFC');
102
+ }
package/src/server.ts ADDED
@@ -0,0 +1,85 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { z } from 'zod';
4
+ import { Dictionary, stressText, wordInfo } from './dictionary.js';
5
+ import { FORM_TAGS, inflect, inflectionTable } from './inflect.js';
6
+
7
+ const dict = Dictionary.load();
8
+
9
+ const server = new McpServer({ name: 'russian-word-mcp', version: '0.2.0' });
10
+
11
+ server.registerTool(
12
+ 'stress_text',
13
+ {
14
+ title: 'Add stress marks to Russian text',
15
+ description:
16
+ 'Adds stress marks (combining acute accent) to every Russian word found in the OpenRussian dictionary, ' +
17
+ 'and restores ё. Words whose stress depends on meaning or case (замок, руки) are left unmarked and listed ' +
18
+ 'with every option, so you can pick by context instead of guessing. Unknown words are listed too.',
19
+ inputSchema: { text: z.string().min(1).max(20000).describe('Russian text, with or without stress marks') },
20
+ annotations: { readOnlyHint: true, openWorldHint: false },
21
+ },
22
+ async ({ text }) => {
23
+ const r = stressText(dict, text);
24
+ const lines = [r.text];
25
+ if (r.ambiguous.length) {
26
+ lines.push('', 'Ambiguous (choose by context; options listed most common word first):');
27
+ for (const a of r.ambiguous) {
28
+ lines.push(`- ${a.word}: ` + a.options.map((o) => `${o.stressed} [${o.sources.slice(0, 3).join('; ')}]`).join(' | '));
29
+ }
30
+ }
31
+ if (r.unknown.length) lines.push('', `Not in dictionary (left as written): ${r.unknown.join(', ')}`);
32
+ return { content: [{ type: 'text', text: lines.join('\n') }] };
33
+ },
34
+ );
35
+
36
+ server.registerTool(
37
+ 'word_info',
38
+ {
39
+ title: 'Look up a Russian word in any form',
40
+ description:
41
+ 'Finds the dictionary entry for a Russian word in any inflected form (людьми → человек, plural instrumental) ' +
42
+ 'and returns part of speech, English translation, gender or aspect and aspect partner, and the full ' +
43
+ 'stressed inflection table. Several entries are returned when the spelling is shared.',
44
+ inputSchema: { word: z.string().min(1).max(100).describe('One Russian word, any form') },
45
+ annotations: { readOnlyHint: true, openWorldHint: false },
46
+ },
47
+ async ({ word }) => {
48
+ const r = wordInfo(dict, word.trim());
49
+ if (r.matches.length === 0) {
50
+ return { content: [{ type: 'text', text: `"${word}" is not in the dictionary.` }] };
51
+ }
52
+ return { content: [{ type: 'text', text: JSON.stringify(r, null, 2) }] };
53
+ },
54
+ );
55
+
56
+ server.registerTool(
57
+ 'inflect',
58
+ {
59
+ title: 'Decline or conjugate a Russian word',
60
+ description:
61
+ 'Takes a Russian word in any form. Without `form`, returns readable stressed tables: nouns by case and number, ' +
62
+ 'verbs by person (present for imperfective, future for perfective) with past and imperative, adjectives by case ' +
63
+ 'and gender with short forms. With `form`, returns just that form, for example word "книгами" + form "pl_gen" ' +
64
+ 'gives кни́г. Tags: sg_/pl_ + nom|gen|dat|acc|inst|prep (nouns); presfut_sg1..pl3, past_m|f|n|pl, ' +
65
+ 'imperative_sg|pl (verbs); decl_m|f|n|pl_ + case, short_m|f|n|pl, comparative, superlative (adjectives).',
66
+ inputSchema: {
67
+ word: z.string().min(1).max(100).describe('One Russian word, any form'),
68
+ form: z.enum(FORM_TAGS).optional().describe('Return only this form, e.g. pl_gen, past_f, decl_f_acc'),
69
+ },
70
+ annotations: { readOnlyHint: true, openWorldHint: false },
71
+ },
72
+ async ({ word, form }) => {
73
+ const w = word.trim();
74
+ if (form) {
75
+ const r = inflect(dict, w, form);
76
+ const text = r.length
77
+ ? r.map((x) => `${x.lemma} (${x.pos}), ${form}: ${x.forms.join(', ')}`).join('\n')
78
+ : `No ${form} form found for "${w}" (unknown word, or the form does not fit its part of speech).`;
79
+ return { content: [{ type: 'text', text }] };
80
+ }
81
+ return { content: [{ type: 'text', text: inflectionTable(dict, w) ?? `"${w}" is not in the dictionary.` }] };
82
+ },
83
+ );
84
+
85
+ await server.connect(new StdioServerTransport());
package/src/types.ts ADDED
@@ -0,0 +1,20 @@
1
+ export type Pos = 'noun' | 'verb' | 'adjective' | 'other';
2
+
3
+ /** One dictionary entry. Strings carry stress as U+0301. */
4
+ export interface Lemma {
5
+ /** Dictionary form(s). */
6
+ w: string[];
7
+ pos: Pos;
8
+ /** English translations, as in the source. */
9
+ en: string;
10
+ /** gender, aspect, aspect partner, animate, indeclinable. */
11
+ i?: Record<string, string>;
12
+ /** Inflected forms by tag (e.g. sg_gen, past_f, decl_m_nom). */
13
+ f: Record<string, string[]>;
14
+ }
15
+
16
+ export interface DictFile {
17
+ version: 1;
18
+ source: string;
19
+ lemmas: Lemma[];
20
+ }