sarvam-mcp
A type-safe MCP server for the Sarvam AI API that enables chat, translation, transliteration, language detection, speech-to-text, and text-to-speech across 10 Indic languages and English.
README
sarvam-mcp
sarvam-mcp/ v0.1 ──────────────────────────────────────────────────
A focused, type-safe MCP server for the Sarvam AI API. Lets Claude Code (or any MCP-compatible client) speak to Sarvam's models — chat, translation, transliteration, language detection, speech-to-text, and text-to-speech — across 10 Indic languages plus English.
[!IMPORTANT] This project is not affiliated with, endorsed by, or associated with Sarvam AI. It's an unofficial MCP wrapper that calls the public Sarvam API using your own API key. No keys, audio, or text are routed through any third-party server.
[!NOTE] Requires a Sarvam AI API key. Get one at dashboard.sarvam.ai. Free tier is generous enough to test all six tools.
What it does
Wraps Sarvam's public REST surface in a small set of well-defined MCP tools. Tools are typed end-to-end with Zod schemas, validated at the boundary, and surface useful error messages when something goes wrong.
┌───────────────┐
│ Claude Code │
│ (or any MCP │
│ client) │
└───────┬───────┘
│ stdio (MCP)
▼
┌───────────────┐
│ sarvam-mcp │
└───────┬───────┘
│ HTTPS · api.sarvam.ai
▼
┌───────────────┐
│ Sarvam API │
│ (Sarvam-105B │
│ · Mayura │
│ · Saarika │
│ · Bulbul) │
└───────────────┘
Why another wrapper?
Sarvam ships a great official SDK for Python and Node. This is the MCP-shaped surface that lets agentic clients call it directly — no SDK code, no glue layer.
- 6 tools, deliberately scoped. Every tool is documented, typed, and tested.
- Strict TypeScript. No
any, no implicit returns,noUncheckedIndexedAccesson. - Zod-validated boundaries. Every input is parsed before the network call.
- Typed errors.
SarvamApiError,SarvamRateLimitError,SarvamConfigError,SarvamValidationError— never bareError. sarvam-mcp doctor. A diagnostic command that tells you exactly what's wrong with your setup.
Use this if you want a small, predictable surface you can read in an afternoon.
The 6 tools
| Tool | What it does | Sarvam endpoint |
|---|---|---|
sarvam_chat |
Chat completions (Sarvam-30B / Sarvam-105B), JSON mode supported | POST /v1/chat/completions |
sarvam_translate |
Bidirectional EN ↔ Indic and Indic ↔ Indic translation | POST /translate |
sarvam_transliterate |
Script conversion (Roman ↔ Devanagari, etc.) | POST /transliterate |
sarvam_detect_language |
Identify language and script of input text | POST /text-lid |
sarvam_speech_to_text |
Saarika v2.5 / Saaras v3 transcription from local audio file | POST /speech-to-text |
sarvam_text_to_speech |
Bulbul v3 synthesis. Returns base64 audio + optional WAV file | POST /text-to-speech |
Document Intelligence (Sarvam Vision) is on the v0.2 roadmap — it's an async batch flow that deserves its own treatment.
Install
Requires Node.js 20+.
npm install -g sarvam-mcp
# or, in a project:
npm install sarvam-mcp
For development:
git clone https://github.com/harshil1502/sarvam-mcp.git
cd sarvam-mcp
npm install
npm run build
Setup — three steps
1. Get a Sarvam API key
dashboard.sarvam.ai → create key. Free tier is enough to test all six tools.
2. Export it
export SARVAM_API_KEY=<your_key>
(Or put it in a .env file and source it before launching the MCP client — see .env.example.)
3. Verify
sarvam-mcp doctor
You should see something like:
sarvam-mcp · doctor
─────────────────────────────────────────────
[ ok ] SARVAM_API_KEY env var
Set (40 chars).
[ ok ] Language ID endpoint
Detected: hi-IN (expected hi-IN).
[ ok ] Chat completions
Got: ok
─────────────────────────────────────────────
all green — sarvam-mcp is ready.
If something fails, the doctor prints the exact reason.
Use with Claude Code
Add to your ~/.claude.json MCP servers:
{
"mcpServers": {
"sarvam": {
"command": "sarvam-mcp",
"env": { "SARVAM_API_KEY": "your_key_here" }
}
}
}
Then in Claude:
> translate "I'll be there at 9pm" to Tamil
[claude calls sarvam_translate]
→ "நான் இரவு 9 மணிக்கு அங்கு வருவேன்"
Examples
Chat in Hindi
// tool call: sarvam_chat
{
"messages": [
{ "role": "system", "content": "You are a helpful assistant. Reply in Hindi." },
{ "role": "user", "content": "What's the difference between Marathi and Hindi?" }
],
"model": "sarvam-105b",
"temperature": 0.4
}
Translate code-mixed text
// tool call: sarvam_translate
{
"input": "मेरा नाम Harshil है and I work in AI",
"source_language_code": "auto",
"target_language_code": "en-IN",
"mode": "code-mixed"
}
// → { "translated_text": "My name is Harshil and I work in AI" }
Transliterate a Hindi name to Roman script
// tool call: sarvam_transliterate
{
"input": "हर्षिल पटेल",
"source_language_code": "hi-IN",
"target_language_code": "en-IN"
}
// → { "transliterated_text": "Harshil Patel" }
Identify language
// tool call: sarvam_detect_language
{ "input": "வணக்கம் உலகம்" }
// → { "language_code": "ta-IN", "script_code": "Taml" }
Transcribe a voice memo
// tool call: sarvam_speech_to_text
{
"audio_path": "/Users/me/Downloads/voice-memo.m4a",
"language_code": "hi-IN",
"model": "saaras:v3",
"with_diarization": true
}
Generate Tamil speech and save it
// tool call: sarvam_text_to_speech
{
"inputs": ["நான் உங்களுக்கு உதவ முடியும்."],
"target_language_code": "ta-IN",
"speaker": "anushka",
"output_path": "/tmp/reply.wav"
}
// → audio also written to /tmp/reply.wav
Architecture
Four files, four responsibilities:
src/
├── client/sarvam.ts ← single fetch wrapper, both auth schemes
├── tools/
│ ├── chat.ts ← sarvam_chat
│ ├── translate.ts ← translate · transliterate · detect_language
│ └── speech.ts ← speech_to_text · text_to_speech
├── server.ts ← MCP transport + tool registration
├── cli/doctor.ts ← setup diagnostics
└── index.ts ← entry point + argv routing
When the next Sarvam API release breaks something, drift is contained to one file.
Strict TypeScript across the agent boundary
// tsconfig.json (excerpts)
{
"strict": true,
"noImplicitAny": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true
}
Agents will happily call your tool with null and then narrate the resulting error. Don't let them.
Errors
| Class | When it fires |
|---|---|
SarvamConfigError |
Missing SARVAM_API_KEY, unreadable audio file. |
SarvamApiError |
Any 4xx/5xx from Sarvam (other than 429). Includes status, endpoint, and body excerpt. |
SarvamRateLimitError |
429. Includes retryAfterSeconds if Sarvam sets Retry-After. |
SarvamValidationError |
Zod validation failed — the LLM passed bad arguments. |
Retries are intentionally not auto-implemented. The LLM gets the error and decides what to do.
Contributing / roadmap
v0.2 — Document Intelligence (Sarvam Vision):
sarvam_doc_extract_start— kick off async OCR jobsarvam_doc_extract_status— pollsarvam_doc_extract_results— fetch structured output
v0.3 — streaming (WebSocket TTS / STT) for low-latency voice agents.
PRs welcome. Run npm run typecheck && npm test before opening one.
License
MIT © 2026 Harshil Patel
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。