tdk-api-wrapper 1.6.0 → 1.7.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.
package/dist/cli.mjs CHANGED
@@ -48,7 +48,8 @@ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
48
48
  "repl",
49
49
  "kubbealti",
50
50
  "nisanyan",
51
- "viki"
51
+ "viki",
52
+ "mcp"
52
53
  ]);
53
54
  var command = args[0];
54
55
  var word = args.slice(1).join(" ");
@@ -135,6 +136,12 @@ async function startRepl() {
135
136
  });
136
137
  }
137
138
  async function run() {
139
+ const binaryName = (process.argv[1] || "").toLowerCase();
140
+ if (command === "mcp" || rawArgs.includes("--mcp") || binaryName.includes("tdk-mcp")) {
141
+ const { runMcpServer } = await import("./mcp-NAXIX4TQ.mjs");
142
+ await runMcpServer();
143
+ return;
144
+ }
138
145
  if (!command) {
139
146
  if (process.stdin.isTTY) {
140
147
  await startRepl();
@@ -142,19 +149,19 @@ async function run() {
142
149
  }
143
150
  console.log("Kullan\u0131m: tdk [komut] <kelime> [--json]");
144
151
  console.log(
145
- "Komutlar: ara, anlam, koken, ornek, hece, uyum, kucukuyum, yazim, kok, deyim, gunun, rastgele, esanlam, karsit, yabanci, kurallar, kural, karsilastir, analiz, oneri, bulmaca, anagram, kafiye, denetle, repl, kubbealti, nisanyan, viki"
152
+ "Komutlar: ara, anlam, koken, ornek, hece, uyum, kucukuyum, yazim, kok, deyim, gunun, rastgele, esanlam, karsit, yabanci, kurallar, kural, karsilastir, analiz, oneri, bulmaca, anagram, kafiye, denetle, repl, kubbealti, nisanyan, viki, mcp"
146
153
  );
147
154
  console.log("Not: Komut belirtilmezse do\u011Frudan kelime anlam\u0131 aran\u0131r (\xF6rn: tdk selam)");
148
155
  process.exit(1);
149
156
  }
150
157
  if (command === "--version" || command === "-v") {
151
- console.log("tdk-api-wrapper v1.5.1");
158
+ console.log("tdk-api-wrapper v1.7.0");
152
159
  process.exit(0);
153
160
  }
154
161
  if (command === "--help" || command === "-h") {
155
162
  console.log("Kullan\u0131m: tdk [komut] <kelime> [--json]");
156
163
  console.log(
157
- "Komutlar: ara, anlam, koken, ornek, hece, uyum, kucukuyum, yazim, kok, deyim, gunun, rastgele, esanlam, karsit, yabanci, kurallar, kural, karsilastir, analiz, oneri, bulmaca, anagram, kafiye, denetle, repl, kubbealti, nisanyan, viki"
164
+ "Komutlar: ara, anlam, koken, ornek, hece, uyum, kucukuyum, yazim, kok, deyim, gunun, rastgele, esanlam, karsit, yabanci, kurallar, kural, karsilastir, analiz, oneri, bulmaca, anagram, kafiye, denetle, repl, kubbealti, nisanyan, viki, mcp"
158
165
  );
159
166
  console.log("Not: Komut belirtilmezse do\u011Frudan kelime anlam\u0131 aran\u0131r (\xF6rn: tdk selam)");
160
167
  process.exit(0);
package/dist/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+
1
3
  interface Author {
2
4
  yazar_id: string;
3
5
  tam_adi: string;
@@ -685,4 +687,16 @@ declare function restoreInfinitive(stem: string): string[];
685
687
  */
686
688
  declare function getStemCandidates(word: string, minStemLength?: number, maxDepth?: number): string[];
687
689
 
688
- export { type AnagramOptions, type Author, type DailyContent, type DailyPick, type Example, type Feature, type KubbealtiEntry, type Meaning, type PatternSearchOptions, type ProofreadIssue, type ProofreadResult, type Proverb, type RhymeOptions, type SpellCheckResult, type StemResult, TDK, TDKClient, type TDKConfig, TDKError, TDKNetworkError, type TDKResponse, type TDKRule, TDKValidationError, TURKISH_SUFFIXES, TURKISH_VOWELS, type WiktionaryEntry, type WordAnalysis, type WordComparison, type WordComparisonSide, type WordInfo, type WordOfTheDay, getStemCandidates, isVowel, restoreConsonantSoftening, restoreGemination, restoreInfinitive, restoreVowelDrop, restoreVowelNarrowing };
690
+ /**
691
+ * Builds the TDK MCP server: every meaningful `TDK` static method is surfaced
692
+ * as a Model Context Protocol tool so an LLM client (Claude Desktop, Cursor,
693
+ * Antigravity, …) can query Turkish dictionary, morphology, spelling and
694
+ * etymology data directly. All tools return JSON text; network/scraping
695
+ * failures come back as `{ "error": ... }` with `isError: true` rather than
696
+ * throwing.
697
+ */
698
+ declare function createMcpServer(): McpServer;
699
+ /** Starts the TDK MCP server over stdio (used by the `tdk mcp` CLI command). */
700
+ declare function runMcpServer(): Promise<void>;
701
+
702
+ export { type AnagramOptions, type Author, type DailyContent, type DailyPick, type Example, type Feature, type KubbealtiEntry, type Meaning, type PatternSearchOptions, type ProofreadIssue, type ProofreadResult, type Proverb, type RhymeOptions, type SpellCheckResult, type StemResult, TDK, TDKClient, type TDKConfig, TDKError, TDKNetworkError, type TDKResponse, type TDKRule, TDKValidationError, TURKISH_SUFFIXES, TURKISH_VOWELS, type WiktionaryEntry, type WordAnalysis, type WordComparison, type WordComparisonSide, type WordInfo, type WordOfTheDay, createMcpServer, getStemCandidates, isVowel, restoreConsonantSoftening, restoreGemination, restoreInfinitive, restoreVowelDrop, restoreVowelNarrowing, runMcpServer };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+
1
3
  interface Author {
2
4
  yazar_id: string;
3
5
  tam_adi: string;
@@ -685,4 +687,16 @@ declare function restoreInfinitive(stem: string): string[];
685
687
  */
686
688
  declare function getStemCandidates(word: string, minStemLength?: number, maxDepth?: number): string[];
687
689
 
688
- export { type AnagramOptions, type Author, type DailyContent, type DailyPick, type Example, type Feature, type KubbealtiEntry, type Meaning, type PatternSearchOptions, type ProofreadIssue, type ProofreadResult, type Proverb, type RhymeOptions, type SpellCheckResult, type StemResult, TDK, TDKClient, type TDKConfig, TDKError, TDKNetworkError, type TDKResponse, type TDKRule, TDKValidationError, TURKISH_SUFFIXES, TURKISH_VOWELS, type WiktionaryEntry, type WordAnalysis, type WordComparison, type WordComparisonSide, type WordInfo, type WordOfTheDay, getStemCandidates, isVowel, restoreConsonantSoftening, restoreGemination, restoreInfinitive, restoreVowelDrop, restoreVowelNarrowing };
690
+ /**
691
+ * Builds the TDK MCP server: every meaningful `TDK` static method is surfaced
692
+ * as a Model Context Protocol tool so an LLM client (Claude Desktop, Cursor,
693
+ * Antigravity, …) can query Turkish dictionary, morphology, spelling and
694
+ * etymology data directly. All tools return JSON text; network/scraping
695
+ * failures come back as `{ "error": ... }` with `isError: true` rather than
696
+ * throwing.
697
+ */
698
+ declare function createMcpServer(): McpServer;
699
+ /** Starts the TDK MCP server over stdio (used by the `tdk mcp` CLI command). */
700
+ declare function runMcpServer(): Promise<void>;
701
+
702
+ export { type AnagramOptions, type Author, type DailyContent, type DailyPick, type Example, type Feature, type KubbealtiEntry, type Meaning, type PatternSearchOptions, type ProofreadIssue, type ProofreadResult, type Proverb, type RhymeOptions, type SpellCheckResult, type StemResult, TDK, TDKClient, type TDKConfig, TDKError, TDKNetworkError, type TDKResponse, type TDKRule, TDKValidationError, TURKISH_SUFFIXES, TURKISH_VOWELS, type WiktionaryEntry, type WordAnalysis, type WordComparison, type WordComparisonSide, type WordInfo, type WordOfTheDay, createMcpServer, getStemCandidates, isVowel, restoreConsonantSoftening, restoreGemination, restoreInfinitive, restoreVowelDrop, restoreVowelNarrowing, runMcpServer };
package/dist/index.js CHANGED
@@ -37,13 +37,15 @@ __export(src_exports, {
37
37
  TDKValidationError: () => TDKValidationError,
38
38
  TURKISH_SUFFIXES: () => TURKISH_SUFFIXES,
39
39
  TURKISH_VOWELS: () => TURKISH_VOWELS,
40
+ createMcpServer: () => createMcpServer,
40
41
  getStemCandidates: () => getStemCandidates,
41
42
  isVowel: () => isVowel,
42
43
  restoreConsonantSoftening: () => restoreConsonantSoftening,
43
44
  restoreGemination: () => restoreGemination,
44
45
  restoreInfinitive: () => restoreInfinitive,
45
46
  restoreVowelDrop: () => restoreVowelDrop,
46
- restoreVowelNarrowing: () => restoreVowelNarrowing
47
+ restoreVowelNarrowing: () => restoreVowelNarrowing,
48
+ runMcpServer: () => runMcpServer
47
49
  });
48
50
  module.exports = __toCommonJS(src_exports);
49
51
 
@@ -2504,6 +2506,277 @@ var TDKClient = class {
2504
2506
  return TDK.checkLabialHarmony(word);
2505
2507
  }
2506
2508
  };
2509
+
2510
+ // src/mcp.ts
2511
+ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
2512
+ var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
2513
+ var import_zod = require("zod");
2514
+ var VERSION = "1.7.0";
2515
+ function ok(data) {
2516
+ return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
2517
+ }
2518
+ function fail(message) {
2519
+ return {
2520
+ content: [{ type: "text", text: JSON.stringify({ error: message }, null, 2) }],
2521
+ isError: true
2522
+ };
2523
+ }
2524
+ function guard(fn) {
2525
+ return async (args) => {
2526
+ try {
2527
+ return await fn(args);
2528
+ } catch (error) {
2529
+ return fail(error instanceof Error ? error.message : String(error));
2530
+ }
2531
+ };
2532
+ }
2533
+ function createMcpServer() {
2534
+ const server = new import_mcp.McpServer({
2535
+ name: "TDK API Server",
2536
+ version: VERSION
2537
+ });
2538
+ server.tool(
2539
+ "tdk_lookup",
2540
+ "Bir kelimenin TDK G\xFCncel T\xFCrk\xE7e S\xF6zl\xFCk'teki ham kayd\u0131n\u0131 (t\xFCm anlamlar, \xF6rnekler, birle\u015Fikler, k\xF6ken, atas\xF6zleri) d\xF6nd\xFCr\xFCr.",
2541
+ { word: import_zod.z.string().describe("Aranacak T\xFCrk\xE7e kelime (\xF6rn: 'kalem').") },
2542
+ guard(async ({ word }) => {
2543
+ const results = await TDK.getWord(word);
2544
+ if (results.length === 0)
2545
+ return fail(`"${word}" TDK s\xF6zl\xFC\u011F\xFCnde bulunamad\u0131.`);
2546
+ return ok(results);
2547
+ })
2548
+ );
2549
+ server.tool(
2550
+ "tdk_meanings",
2551
+ "Bir kelimenin sadele\u015Ftirilmi\u015F anlam listesini (madde madde tan\u0131mlar) d\xF6nd\xFCr\xFCr.",
2552
+ { word: import_zod.z.string().describe("Aranacak T\xFCrk\xE7e kelime.") },
2553
+ guard(async ({ word }) => ok({ word, meanings: await TDK.getMeanings(word) }))
2554
+ );
2555
+ server.tool(
2556
+ "tdk_examples",
2557
+ "Bir kelimenin s\xF6zl\xFCkteki \xF6rnek c\xFCmlelerini (varsa yazar\u0131yla) d\xF6nd\xFCr\xFCr.",
2558
+ { word: import_zod.z.string().describe("Aranacak T\xFCrk\xE7e kelime.") },
2559
+ guard(async ({ word }) => ok({ word, examples: await TDK.getExamples(word) }))
2560
+ );
2561
+ server.tool(
2562
+ "tdk_proverbs",
2563
+ "Bir kelime ile kurulan atas\xF6z\xFC ve deyimleri listeler.",
2564
+ { word: import_zod.z.string().describe("Aranacak T\xFCrk\xE7e kelime (\xF6rn: 'g\xF6z').") },
2565
+ guard(async ({ word }) => ok({ word, proverbs: await TDK.getProverbs(word) }))
2566
+ );
2567
+ server.tool(
2568
+ "tdk_compound_words",
2569
+ "Bir kelime ile olu\u015Fturulmu\u015F birle\u015Fik kelimeleri listeler (\xF6rn: 'kalem' -> 'dolma kalem').",
2570
+ { word: import_zod.z.string().describe("Aranacak T\xFCrk\xE7e kelime.") },
2571
+ guard(async ({ word }) => ok({ word, compounds: await TDK.getCompoundWords(word) }))
2572
+ );
2573
+ server.tool(
2574
+ "tdk_part_of_speech",
2575
+ "Bir kelimenin s\xF6zc\xFCk t\xFCrlerini (isim, s\u0131fat, zarf, fiil vb.) d\xF6nd\xFCr\xFCr.",
2576
+ { word: import_zod.z.string().describe("Aranacak T\xFCrk\xE7e kelime.") },
2577
+ guard(async ({ word }) => ok({ word, partsOfSpeech: await TDK.getPartOfSpeech(word) }))
2578
+ );
2579
+ server.tool(
2580
+ "tdk_synonyms",
2581
+ "Bir kelimenin e\u015F anlaml\u0131lar\u0131n\u0131 (yak\u0131n anlaml\u0131 kelimeler) d\xF6nd\xFCr\xFCr.",
2582
+ { word: import_zod.z.string().describe("Aranacak T\xFCrk\xE7e kelime.") },
2583
+ guard(async ({ word }) => ok({ word, synonyms: await TDK.getSynonyms(word) }))
2584
+ );
2585
+ server.tool(
2586
+ "tdk_antonyms",
2587
+ "Bir kelimenin z\u0131t (kar\u015F\u0131t) anlaml\u0131lar\u0131n\u0131 d\xF6nd\xFCr\xFCr.",
2588
+ { word: import_zod.z.string().describe("Aranacak T\xFCrk\xE7e kelime.") },
2589
+ guard(async ({ word }) => ok({ word, antonyms: await TDK.getAntonyms(word) }))
2590
+ );
2591
+ server.tool(
2592
+ "tdk_origin",
2593
+ "Bir kelimenin TDK'deki k\xF6ken bilgisini ve yabanc\u0131 k\xF6kenli olup olmad\u0131\u011F\u0131n\u0131 d\xF6nd\xFCr\xFCr.",
2594
+ { word: import_zod.z.string().describe("Aranacak T\xFCrk\xE7e kelime.") },
2595
+ guard(async ({ word }) => {
2596
+ const [origin, foreign] = await Promise.all([TDK.getOrigin(word), TDK.isForeignWord(word)]);
2597
+ return ok({ word, origin, isForeign: foreign });
2598
+ })
2599
+ );
2600
+ server.tool(
2601
+ "tdk_nisanyan",
2602
+ "Ni\u015Fanyan S\xF6zl\xFCk'ten bir kelimenin ayr\u0131nt\u0131l\u0131 etimolojisini (server-rendered meta a\xE7\u0131klamas\u0131) \xE7eker.",
2603
+ { word: import_zod.z.string().describe("Etimolojisi aranacak kelime.") },
2604
+ guard(async ({ word }) => {
2605
+ const etymology = await TDK.getNisanyan(word);
2606
+ return etymology ? ok({ word, etymology }) : fail(`Ni\u015Fanyan S\xF6zl\xFCk'te "${word}" bulunamad\u0131.`);
2607
+ })
2608
+ );
2609
+ server.tool(
2610
+ "tdk_kubbealti",
2611
+ "Kubbealt\u0131 Lugat\u0131'ndan (ticari s\xF6zl\xFCk) bir kelimenin anlamlar\u0131n\u0131 \xE7eker.",
2612
+ { word: import_zod.z.string().describe("Aranacak kelime.") },
2613
+ guard(async ({ word }) => {
2614
+ const meanings = await TDK.getKubbealtiMeanings(word);
2615
+ if (meanings === null)
2616
+ return fail("Kubbealt\u0131 Lugat\u0131'na ula\u015F\u0131lamad\u0131.");
2617
+ return ok({ word, meanings });
2618
+ })
2619
+ );
2620
+ server.tool(
2621
+ "tdk_wiktionary",
2622
+ "T\xFCrk\xE7e Wiktionary'den (tr.wiktionary.org, resmi MediaWiki API) bir maddenin b\xF6l\xFCmlere ayr\u0131lm\u0131\u015F i\xE7eri\u011Fini \xE7eker.",
2623
+ {
2624
+ word: import_zod.z.string().describe("Aranacak madde ba\u015Fl\u0131\u011F\u0131."),
2625
+ section: import_zod.z.string().optional().describe("Sadece belirli bir b\xF6l\xFCm istenirse ba\u015Fl\u0131k ad\u0131 (\xF6rn: 'K\xF6ken', '\xC7eviriler').")
2626
+ },
2627
+ guard(async ({ word, section }) => {
2628
+ if (section) {
2629
+ const text = await TDK.getWiktionarySection(word, section);
2630
+ return text ? ok({ word, section, text }) : fail(`Wiktionary'de "${word}" i\xE7in "${section}" b\xF6l\xFCm\xFC bulunamad\u0131.`);
2631
+ }
2632
+ const entry = await TDK.getWiktionary(word);
2633
+ return entry ? ok(entry) : fail(`Wiktionary'de "${word}" bulunamad\u0131.`);
2634
+ })
2635
+ );
2636
+ server.tool(
2637
+ "tdk_spell_check",
2638
+ "Bir kelimenin do\u011Fru yaz\u0131l\u0131p yaz\u0131lmad\u0131\u011F\u0131n\u0131 denetler; yanl\u0131\u015Fsa klavye/diakritik fark\u0131ndal\u0131kl\u0131 en yak\u0131n madde \xF6nerisi verir, \xE7ekimli bi\xE7imse k\xF6k\xFCn\xFC d\xF6nd\xFCr\xFCr.",
2639
+ { word: import_zod.z.string().describe("Yaz\u0131m\u0131 denetlenecek kelime (\xF6rn: 'yanl\u0131z', 'arabs').") },
2640
+ guard(async ({ word }) => ok(await TDK.checkSpelling(word)))
2641
+ );
2642
+ server.tool(
2643
+ "tdk_proofread",
2644
+ "Bir T\xFCrk\xE7e metni imla, ayr\u0131/biti\u015Fik yaz\u0131m ve 'da/de', 'ki', 'mi' ba\u011Fla\xE7/ek hatalar\u0131 a\xE7\u0131s\u0131ndan denetler.",
2645
+ { text: import_zod.z.string().describe("Denetlenecek T\xFCrk\xE7e metin.") },
2646
+ guard(async ({ text }) => ok(await TDK.proofread(text)))
2647
+ );
2648
+ server.tool(
2649
+ "tdk_stem",
2650
+ "Bir kelimenin morfolojik k\xF6k\xFCn\xFC (ek s\u0131y\u0131rma / stemming) bulur ve \xE7ekimli olup olmad\u0131\u011F\u0131n\u0131 belirtir (\xF6rn: 'kitab\u0131m\u0131z\u0131n' -> 'kitap').",
2651
+ { word: import_zod.z.string().describe("K\xF6k\xFC aranacak kelime.") },
2652
+ guard(async ({ word }) => {
2653
+ const result = await TDK.stem(word);
2654
+ return result ? ok(result) : fail(`"${word}" i\xE7in k\xF6k tespit edilemedi.`);
2655
+ })
2656
+ );
2657
+ server.tool(
2658
+ "tdk_analyze_text",
2659
+ "Bir metindeki her kelime i\xE7in k\xF6k, anlam ve k\xF6ken bilgisini toplu olarak \xE7\u0131kar\u0131r.",
2660
+ { text: import_zod.z.string().describe("Analiz edilecek T\xFCrk\xE7e metin.") },
2661
+ guard(async ({ text }) => ok(await TDK.analyzeText(text)))
2662
+ );
2663
+ server.tool(
2664
+ "tdk_syllables",
2665
+ "Bir kelimeyi T\xFCrk\xE7e hece kurallar\u0131na g\xF6re hecelere ay\u0131r\u0131r (tamamen yerel, a\u011F iste\u011Fi yok).",
2666
+ { word: import_zod.z.string().describe("Hecelenecek kelime.") },
2667
+ guard(async ({ word }) => ok({ word, syllables: TDK.syllabicate(word) }))
2668
+ );
2669
+ server.tool(
2670
+ "tdk_vowel_harmony",
2671
+ "Bir kelimenin b\xFCy\xFCk \xFCnl\xFC uyumuna ve k\xFC\xE7\xFCk \xFCnl\xFC uyumuna (d\xFCzl\xFCk-yuvarlakl\u0131k) uyup uymad\u0131\u011F\u0131n\u0131 kontrol eder.",
2672
+ { word: import_zod.z.string().describe("Kontrol edilecek kelime.") },
2673
+ guard(
2674
+ async ({ word }) => ok({
2675
+ word,
2676
+ vowelHarmony: TDK.checkVowelHarmony(word),
2677
+ labialHarmony: TDK.checkLabialHarmony(word)
2678
+ })
2679
+ )
2680
+ );
2681
+ server.tool(
2682
+ "tdk_autocomplete",
2683
+ "Bir \xF6nek ile ba\u015Flayan s\xF6zl\xFCk maddelerini (autocomplete) d\xF6nd\xFCr\xFCr.",
2684
+ { prefix: import_zod.z.string().describe("Aranacak \xF6nek (\xF6rn: 'kalem').") },
2685
+ guard(async ({ prefix }) => ok({ prefix, suggestions: await TDK.getSuggestions(prefix) }))
2686
+ );
2687
+ server.tool(
2688
+ "tdk_pattern_search",
2689
+ "Bulmaca deseni ile e\u015Fle\u015Fen s\xF6zl\xFCk maddelerini bulur: '_' veya '?' tek harf, '*' s\u0131f\u0131r ya da daha fazla harf yerine ge\xE7er (\xF6rn: 'k_l_m').",
2690
+ {
2691
+ pattern: import_zod.z.string().describe("Desen. '_'/'?' = tek harf, '*' = s\u0131f\u0131r ya da daha fazla harf."),
2692
+ max_results: import_zod.z.number().int().min(1).max(500).default(50).describe("En fazla sonu\xE7 say\u0131s\u0131.")
2693
+ },
2694
+ guard(async ({ pattern, max_results }) => {
2695
+ const matches = await TDK.patternSearch(pattern, { maxResults: max_results });
2696
+ return ok({ pattern, count: matches.length, matches });
2697
+ })
2698
+ );
2699
+ server.tool(
2700
+ "tdk_anagram",
2701
+ "Verilen harflerle kurulabilecek T\xFCrk\xE7e s\xF6zl\xFCk maddelerini bulur. Birebir anagram varsa onlar, yoksa harflerin bir alt k\xFCmesiyle kurulan kelimeler d\xF6ner.",
2702
+ {
2703
+ letters: import_zod.z.string().describe("Kullan\u0131lacak harfler (\xF6rn: 'kalem')."),
2704
+ exact_length: import_zod.z.boolean().default(false).describe("Sadece harflerin tamam\u0131n\u0131 kullanan birebir anagramlar\u0131 d\xF6nd\xFCr."),
2705
+ max_results: import_zod.z.number().int().min(1).max(500).default(50).describe("En fazla sonu\xE7 say\u0131s\u0131.")
2706
+ },
2707
+ guard(async ({ letters, exact_length, max_results }) => {
2708
+ const words = await TDK.findAnagrams(letters, { exactLength: exact_length, maxResults: max_results });
2709
+ return ok({ letters, count: words.length, words });
2710
+ })
2711
+ );
2712
+ server.tool(
2713
+ "tdk_rhymes",
2714
+ "Bir kelime ile kafiyeli (son harfleri uyu\u015Fan) s\xF6zl\xFCk maddelerini bulur.",
2715
+ {
2716
+ word: import_zod.z.string().describe("Kafiyesi aranacak kelime."),
2717
+ min_letters: import_zod.z.number().int().min(1).default(3).describe("Uyu\u015Fmas\u0131 gereken en az son harf say\u0131s\u0131."),
2718
+ max_results: import_zod.z.number().int().min(1).max(500).default(50).describe("En fazla sonu\xE7 say\u0131s\u0131.")
2719
+ },
2720
+ guard(async ({ word, min_letters, max_results }) => {
2721
+ const rhymes = await TDK.findRhymes(word, { minLetters: min_letters, maxResults: max_results });
2722
+ return ok({ word, count: rhymes.length, rhymes });
2723
+ })
2724
+ );
2725
+ server.tool(
2726
+ "tdk_compare",
2727
+ "\u0130ki kelimeyi anlam say\u0131s\u0131, k\xF6ken, hece b\xF6l\xFCn\xFC\u015F\xFC ve \xFCnl\xFC uyumu a\xE7\u0131s\u0131ndan kar\u015F\u0131la\u015Ft\u0131r\u0131r.",
2728
+ {
2729
+ a: import_zod.z.string().describe("Birinci kelime."),
2730
+ b: import_zod.z.string().describe("\u0130kinci kelime.")
2731
+ },
2732
+ guard(async ({ a, b }) => ok(await TDK.compareWords(a, b)))
2733
+ );
2734
+ server.tool(
2735
+ "tdk_audio_url",
2736
+ "Bir kelimenin TDK seslendirme (.wav) URL'sini d\xF6nd\xFCr\xFCr (bulunamazsa null).",
2737
+ { word: import_zod.z.string().describe("Seslendirmesi aranacak kelime.") },
2738
+ guard(async ({ word }) => ok({ word, audioUrl: await TDK.getAudioUrl(word) }))
2739
+ );
2740
+ server.tool(
2741
+ "tdk_word_of_the_day",
2742
+ "TDK'nin 'g\xFCn\xFCn kelimesi'ni anlamlar\u0131yla d\xF6nd\xFCr\xFCr.",
2743
+ {},
2744
+ guard(async () => {
2745
+ const wotd = await TDK.getWordOfTheDay();
2746
+ return wotd ? ok(wotd) : fail("G\xFCn\xFCn kelimesi al\u0131namad\u0131.");
2747
+ })
2748
+ );
2749
+ server.tool(
2750
+ "tdk_random_word",
2751
+ "TDK i\xE7eri\u011Finden rastgele bir kelime ya da atas\xF6z\xFC d\xF6nd\xFCr\xFCr.",
2752
+ {},
2753
+ guard(async () => {
2754
+ const pick = await TDK.getRandomWord();
2755
+ return pick ? ok(pick) : fail("Rastgele i\xE7erik al\u0131namad\u0131.");
2756
+ })
2757
+ );
2758
+ server.tool(
2759
+ "tdk_rules",
2760
+ "TDK Yaz\u0131m K\u0131lavuzu kurallar\u0131n\u0131 listeler; 'name' verilirse o kural\u0131n tam metnini d\xF6nd\xFCr\xFCr.",
2761
+ {
2762
+ name: import_zod.z.string().optional().describe("\u0130stenirse tek bir kural\u0131n ad\u0131 (\xF6rn: 'Ba\u011Fla\xE7 Olan da, de'nin Yaz\u0131l\u0131\u015F\u0131').")
2763
+ },
2764
+ guard(async ({ name }) => {
2765
+ if (name) {
2766
+ const rule = await TDK.getRule(name);
2767
+ return rule ? ok({ name, rule }) : fail(`"${name}" kural\u0131 bulunamad\u0131.`);
2768
+ }
2769
+ const rules = await TDK.getKurallar();
2770
+ return ok({ count: rules.length, rules });
2771
+ })
2772
+ );
2773
+ return server;
2774
+ }
2775
+ async function runMcpServer() {
2776
+ const server = createMcpServer();
2777
+ const transport = new import_stdio.StdioServerTransport();
2778
+ await server.connect(transport);
2779
+ }
2507
2780
  // Annotate the CommonJS export names for ESM import in node:
2508
2781
  0 && (module.exports = {
2509
2782
  TDK,
@@ -2513,11 +2786,13 @@ var TDKClient = class {
2513
2786
  TDKValidationError,
2514
2787
  TURKISH_SUFFIXES,
2515
2788
  TURKISH_VOWELS,
2789
+ createMcpServer,
2516
2790
  getStemCandidates,
2517
2791
  isVowel,
2518
2792
  restoreConsonantSoftening,
2519
2793
  restoreGemination,
2520
2794
  restoreInfinitive,
2521
2795
  restoreVowelDrop,
2522
- restoreVowelNarrowing
2796
+ restoreVowelNarrowing,
2797
+ runMcpServer
2523
2798
  });
package/dist/index.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ import {
2
+ createMcpServer,
3
+ runMcpServer
4
+ } from "./chunk-MELLECWT.mjs";
1
5
  import {
2
6
  TDK,
3
7
  TDKClient,
@@ -22,11 +26,13 @@ export {
22
26
  TDKValidationError,
23
27
  TURKISH_SUFFIXES,
24
28
  TURKISH_VOWELS,
29
+ createMcpServer,
25
30
  getStemCandidates,
26
31
  isVowel,
27
32
  restoreConsonantSoftening,
28
33
  restoreGemination,
29
34
  restoreInfinitive,
30
35
  restoreVowelDrop,
31
- restoreVowelNarrowing
36
+ restoreVowelNarrowing,
37
+ runMcpServer
32
38
  };
@@ -0,0 +1,9 @@
1
+ import {
2
+ createMcpServer,
3
+ runMcpServer
4
+ } from "./chunk-MELLECWT.mjs";
5
+ import "./chunk-ZFWZXNGY.mjs";
6
+ export {
7
+ createMcpServer,
8
+ runMcpServer
9
+ };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "tdk-api-wrapper",
3
- "version": "1.6.0",
4
- "description": "TDK (Türk Dil Kurumu) unofficial live data API wrapper for Node.js",
3
+ "version": "1.7.0",
4
+ "description": "TDK (Türk Dil Kurumu) unofficial live data API wrapper and MCP server for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "bin": {
9
- "tdk": "dist/cli.js"
9
+ "tdk": "dist/cli.js",
10
+ "tdk-mcp": "dist/cli.js"
10
11
  },
11
12
  "exports": {
12
13
  ".": {
@@ -25,13 +26,40 @@
25
26
  "api",
26
27
  "turkish",
27
28
  "dictionary",
28
- "turkce"
29
+ "turkce",
30
+ "sozluk.gov.tr",
31
+ "spell-check",
32
+ "morphology",
33
+ "kubbealti",
34
+ "nisanyan",
35
+ "wiktionary",
36
+ "mcp",
37
+ "mcp-server",
38
+ "model-context-protocol"
29
39
  ],
30
- "author": "",
40
+ "author": "cemyilmazzzz122 <cemyleo12@icloud.com> (https://github.com/cemyilmazzzz122)",
31
41
  "license": "MIT",
42
+ "homepage": "https://github.com/cemyilmazzzz122/tdk-api#readme",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/cemyilmazzzz122/tdk-api.git"
46
+ },
47
+ "bugs": {
48
+ "url": "https://github.com/cemyilmazzzz122/tdk-api/issues"
49
+ },
50
+ "engines": {
51
+ "node": ">=18"
52
+ },
53
+ "files": [
54
+ "dist"
55
+ ],
32
56
  "devDependencies": {
33
57
  "@types/node": "^22.0.0",
34
58
  "tsup": "^8.0.2",
35
59
  "typescript": "^5.4.5"
60
+ },
61
+ "dependencies": {
62
+ "@modelcontextprotocol/sdk": "^1.30.0",
63
+ "zod": "^3.25.0 || ^4.0.0"
36
64
  }
37
65
  }
@@ -1,41 +0,0 @@
1
- name: Publish to npm
2
-
3
- on:
4
- push:
5
- branches: [main]
6
-
7
- jobs:
8
- publish:
9
- runs-on: ubuntu-latest
10
- steps:
11
- - uses: actions/checkout@v4
12
-
13
- - uses: actions/setup-node@v4
14
- with:
15
- node-version: '20'
16
- registry-url: 'https://registry.npmjs.org'
17
-
18
- - run: npm ci
19
-
20
- - name: Check if version changed
21
- id: version-check
22
- run: |
23
- LOCAL_VERSION=$(node -p "require('./package.json').version")
24
- PKG_NAME=$(node -p "require('./package.json').name")
25
- PUBLISHED_VERSION=$(npm view "$PKG_NAME" version 2>/dev/null || echo "0.0.0")
26
- echo "Local: $LOCAL_VERSION / Published: $PUBLISHED_VERSION"
27
- if [ "$LOCAL_VERSION" != "$PUBLISHED_VERSION" ]; then
28
- echo "changed=true" >> "$GITHUB_OUTPUT"
29
- else
30
- echo "changed=false" >> "$GITHUB_OUTPUT"
31
- fi
32
-
33
- - name: Build
34
- if: steps.version-check.outputs.changed == 'true'
35
- run: npm run build
36
-
37
- - name: Publish
38
- if: steps.version-check.outputs.changed == 'true'
39
- run: npm publish
40
- env:
41
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}