uchcharan-mcp 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +64 -2
  2. package/bin.js +4 -0
  3. package/package.json +43 -4
  4. package/server.js +167 -0
package/README.md CHANGED
@@ -1,3 +1,65 @@
1
- # Temporary Holding Version
1
+ # uchcharan-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
+ **Make Indian text speakable inside Claude, Cursor and any MCP app**, before it goes to ElevenLabs or another text-to-speech tool.
4
+
5
+ Voiceover and voice-agent scripts break on Indian text: `₹2.5 crore`, `OTP 4821`, `Policy number 9876543210`, `सुबह 9:30 बजे`. This server gives your AI assistant a tool that rewrites them into the words a voice should say, in Hindi, Marathi or Indian English. It runs on your computer, offline, with no API key.
6
+
7
+ | Input | What the voice says |
8
+ |---|---|
9
+ | आपका OTP 4821 है, ₹500 भरें | आपका ओ टी पी चार आठ दो एक है, पाँच सौ रुपये भरें |
10
+ | ₹2,499 चे पेमेंट 10/12/2026 पर्यंत करा | दोन हजार चारशे नव्व्याण्णव रुपयांचे पेमेंट दहा डिसेंबर दोन हजार सव्वीस पर्यंत करा |
11
+ | Pay ₹1,25,000 by 15/12/2026 | Pay one lakh twenty five thousand rupees by fifteenth December twenty twenty six |
12
+
13
+ ## Install
14
+
15
+ You need [Node.js](https://nodejs.org) 18 or newer.
16
+
17
+ ### Claude Desktop
18
+
19
+ Open **Settings → Developer → Edit Config** and add:
20
+
21
+ ```json
22
+ {
23
+ "mcpServers": {
24
+ "uchcharan": {
25
+ "command": "npx",
26
+ "args": ["-y", "uchcharan-mcp"]
27
+ }
28
+ }
29
+ }
30
+ ```
31
+
32
+ Restart Claude Desktop. On Windows, if `npx` is not found, use `"command": "cmd"` and `"args": ["/c", "npx", "-y", "uchcharan-mcp"]`.
33
+
34
+ ### Claude Code
35
+
36
+ ```bash
37
+ claude mcp add uchcharan -- npx -y uchcharan-mcp
38
+ ```
39
+
40
+ ### Cursor, Windsurf, VS Code and others
41
+
42
+ Use the same command in your app's MCP settings: `npx -y uchcharan-mcp` (stdio).
43
+
44
+ ## Use it with ElevenLabs
45
+
46
+ Connect both this server and the ElevenLabs MCP server, then ask, for example:
47
+
48
+ > Make this script speakable with uchcharan, then create a Hindi voiceover with ElevenLabs:
49
+ > "आपकी EMI ₹12,450 दिनांक 05/12/2026 तक बाकी है।"
50
+
51
+ Your assistant calls `normalize_for_tts` first and sends the converted text to ElevenLabs, so amounts, dates and codes are read correctly.
52
+
53
+ ## Tools
54
+
55
+ | Tool | What it does |
56
+ |---|---|
57
+ | `normalize_for_tts` | Converts one text. `lang`: `auto` (default), `hi`, `mr` or `en`. `explain: true` also lists every change. |
58
+ | `normalize_batch` | Converts a list of lines, for example a whole voiceover script. |
59
+ | `detect_language` | Says whether text should be read as Hindi, Marathi or English. |
60
+
61
+ ## Need it in production?
62
+
63
+ The same engine is available as a hosted API with keys, usage limits and help integrating it into your voice agent: **[uchcharan.dev](https://uchcharan.dev)**. The library itself is [`uchcharan`](https://www.npmjs.com/package/uchcharan) on npm (MIT).
64
+
65
+ If it saves you time, you can [sponsor the project](https://github.com/sponsors/densa850-lab).
package/bin.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { serve } from './server.js';
3
+
4
+ serve();
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "uchcharan-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "MCP server for uchcharan: lets Claude, Cursor and other AI apps make Hindi, Marathi and Indian English text speakable (₹, lakh/crore, dates, OTP, phone and policy numbers) before ElevenLabs or any TTS.",
5
+ "type": "module",
6
+ "main": "server.js",
7
+ "exports": "./server.js",
8
+ "bin": {
9
+ "uchcharan-mcp": "bin.js"
10
+ },
11
+ "files": [
12
+ "server.js",
13
+ "bin.js",
14
+ "README.md"
15
+ ],
16
+ "scripts": {
17
+ "test": "node --test"
18
+ },
19
+ "engines": {
20
+ "node": ">=18"
21
+ },
22
+ "dependencies": {
23
+ "uchcharan": "^0.3.1"
24
+ },
25
+ "mcpName": "io.github.densa850-lab/uchcharan",
26
+ "keywords": [
27
+ "mcp",
28
+ "model-context-protocol",
29
+ "claude",
30
+ "tts",
31
+ "elevenlabs",
32
+ "hindi",
33
+ "marathi",
34
+ "text-normalization",
35
+ "voice-ai"
36
+ ],
37
+ "license": "MIT",
38
+ "homepage": "https://uchcharan.dev",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/densa850-lab/uchcharan.git",
42
+ "directory": "mcp"
43
+ },
44
+ "funding": "https://github.com/sponsors/densa850-lab"
45
+ }
package/server.js ADDED
@@ -0,0 +1,167 @@
1
+ // uchcharan-mcp: a Model Context Protocol server (stdio) that lets Claude, Cursor and other
2
+ // AI apps turn Indian text into speakable words before sending it to a TTS engine.
3
+ // No dependencies besides the uchcharan library; works offline.
4
+ import { createInterface } from 'node:readline';
5
+ import { normalize, detectLang } from 'uchcharan';
6
+
7
+ const VERSION = '0.1.0';
8
+ const LANGS = ['auto', 'hi', 'mr', 'en'];
9
+ const MAX_CHARS = 20000;
10
+ const MAX_ITEMS = 200;
11
+
12
+ const langProp = {
13
+ type: 'string',
14
+ enum: LANGS,
15
+ default: 'auto',
16
+ description: "'hi' Hindi, 'mr' Marathi, 'en' Indian English, or 'auto' to detect from the text.",
17
+ };
18
+
19
+ export const TOOLS = [
20
+ {
21
+ name: 'normalize_for_tts',
22
+ title: 'Make Indian text speakable',
23
+ description:
24
+ 'Rewrite Indian text into the words a voice should say, before sending it to a text-to-speech engine ' +
25
+ '(ElevenLabs, Sarvam, Google, Azure, Polly and others). Handles ₹ amounts with lakh/crore, dates, times, ' +
26
+ 'phone numbers, OTP/PIN/PNR and account or policy numbers (digit by digit), UPI IDs, vehicle and train numbers, ' +
27
+ '%, units and acronyms, in Hindi, Marathi or Indian English. Use it on any script or message that contains ' +
28
+ 'numbers before generating speech or a voiceover.',
29
+ inputSchema: {
30
+ type: 'object',
31
+ properties: {
32
+ text: { type: 'string', description: 'The text to convert, as written.' },
33
+ lang: langProp,
34
+ explain: { type: 'boolean', default: false, description: 'Also list each change that was made.' },
35
+ },
36
+ required: ['text'],
37
+ additionalProperties: false,
38
+ },
39
+ annotations: { readOnlyHint: true, openWorldHint: false, idempotentHint: true },
40
+ },
41
+ {
42
+ name: 'normalize_batch',
43
+ title: 'Make many lines speakable',
44
+ description:
45
+ 'Same as normalize_for_tts for a list of lines (for example every line of a voiceover script or every ' +
46
+ 'message template). Returns the converted lines in the same order.',
47
+ inputSchema: {
48
+ type: 'object',
49
+ properties: {
50
+ items: { type: 'array', items: { type: 'string' }, description: 'Lines to convert.' },
51
+ lang: langProp,
52
+ },
53
+ required: ['items'],
54
+ additionalProperties: false,
55
+ },
56
+ annotations: { readOnlyHint: true, openWorldHint: false, idempotentHint: true },
57
+ },
58
+ {
59
+ name: 'detect_language',
60
+ title: 'Detect Hindi, Marathi or English',
61
+ description: "Tell whether text should be read as Hindi ('hi'), Marathi ('mr') or Indian English ('en').",
62
+ inputSchema: {
63
+ type: 'object',
64
+ properties: { text: { type: 'string', description: 'The text to check.' } },
65
+ required: ['text'],
66
+ additionalProperties: false,
67
+ },
68
+ annotations: { readOnlyHint: true, openWorldHint: false, idempotentHint: true },
69
+ },
70
+ ];
71
+
72
+ const INSTRUCTIONS =
73
+ 'Call normalize_for_tts on any Hindi, Marathi or Indian English text that contains numbers, money, dates, ' +
74
+ 'times, codes or IDs before passing it to a text-to-speech or voiceover tool, and send the converted text ' +
75
+ 'to the speech tool. Hosted API, higher limits and business help: https://uchcharan.dev';
76
+
77
+ class ToolError extends Error {}
78
+
79
+ function pickLang(lang, text) {
80
+ const l = lang ?? 'auto';
81
+ if (!LANGS.includes(l)) throw new ToolError(`lang must be one of: ${LANGS.join(', ')}`);
82
+ return l === 'auto' ? detectLang(text) : l;
83
+ }
84
+
85
+ const textResult = (text, structured) => ({ content: [{ type: 'text', text }], structuredContent: structured });
86
+
87
+ export function callTool(name, args = {}) {
88
+ if (name === 'normalize_for_tts') {
89
+ if (typeof args.text !== 'string') throw new ToolError('"text" (string) is required');
90
+ if (args.text.length > MAX_CHARS) throw new ToolError(`"text" can be at most ${MAX_CHARS} characters`);
91
+ const lang = pickLang(args.lang, args.text);
92
+ if (args.explain) {
93
+ const r = normalize(args.text, { lang, explain: true });
94
+ const list = r.changes.map((c) => `- ${c.from} → ${c.to} (${c.rule})`).join('\n');
95
+ return textResult(`${r.text}\n\nChanges:\n${list || '- none'}`, { text: r.text, lang, changes: r.changes });
96
+ }
97
+ const out = normalize(args.text, { lang });
98
+ return textResult(out, { text: out, lang });
99
+ }
100
+ if (name === 'normalize_batch') {
101
+ const { items } = args;
102
+ if (!Array.isArray(items) || items.some((s) => typeof s !== 'string')) throw new ToolError('"items" must be an array of strings');
103
+ if (items.length > MAX_ITEMS) throw new ToolError(`at most ${MAX_ITEMS} items per call`);
104
+ if (items.some((s) => s.length > MAX_CHARS)) throw new ToolError(`each item can be at most ${MAX_CHARS} characters`);
105
+ const out = items.map((t) => normalize(t, { lang: pickLang(args.lang, t) }));
106
+ return textResult(out.join('\n'), { items: out });
107
+ }
108
+ if (name === 'detect_language') {
109
+ if (typeof args.text !== 'string') throw new ToolError('"text" (string) is required');
110
+ const lang = detectLang(args.text);
111
+ return textResult(lang, { lang });
112
+ }
113
+ throw new ToolError(`Unknown tool: ${name}`);
114
+ }
115
+
116
+ /** Handle one JSON-RPC message; returns the response object, or null for notifications. */
117
+ export function handleMessage(msg) {
118
+ const { id, method, params } = msg ?? {};
119
+ const isRequest = id !== undefined && id !== null;
120
+ const reply = (result) => ({ jsonrpc: '2.0', id, result });
121
+ const error = (code, message) => ({ jsonrpc: '2.0', id: id ?? null, error: { code, message } });
122
+
123
+ if (!method || typeof method !== 'string') return isRequest ? error(-32600, 'Invalid request') : null;
124
+ switch (method) {
125
+ case 'initialize':
126
+ return reply({
127
+ protocolVersion: params?.protocolVersion || '2025-06-18',
128
+ capabilities: { tools: { listChanged: false } },
129
+ serverInfo: { name: 'uchcharan', title: 'uchcharan (उच्चारण)', version: VERSION },
130
+ instructions: INSTRUCTIONS,
131
+ });
132
+ case 'ping':
133
+ return reply({});
134
+ case 'tools/list':
135
+ return reply({ tools: TOOLS });
136
+ case 'tools/call':
137
+ try {
138
+ return reply(callTool(params?.name, params?.arguments));
139
+ } catch (e) {
140
+ if (e instanceof ToolError) return reply({ content: [{ type: 'text', text: e.message }], isError: true });
141
+ return reply({ content: [{ type: 'text', text: 'Internal error' }], isError: true });
142
+ }
143
+ default:
144
+ if (method.startsWith('notifications/')) return null;
145
+ return isRequest ? error(-32601, `Method not found: ${method}`) : null;
146
+ }
147
+ }
148
+
149
+ export function serve() {
150
+ const rl = createInterface({ input: process.stdin, crlfDelay: Infinity });
151
+ const send = (obj) => process.stdout.write(`${JSON.stringify(obj)}\n`);
152
+ rl.on('line', (line) => {
153
+ if (!line.trim()) return;
154
+ let msg;
155
+ try {
156
+ msg = JSON.parse(line);
157
+ } catch {
158
+ send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } });
159
+ return;
160
+ }
161
+ const batch = Array.isArray(msg) ? msg : [msg];
162
+ const out = batch.map(handleMessage).filter(Boolean);
163
+ if (out.length) send(Array.isArray(msg) ? out : out[0]);
164
+ });
165
+ rl.on('close', () => process.exit(0));
166
+ }
167
+