@langapi/mcp-server
MCP server for AI-powered translation management in i18n projects, enabling automated locale detection, translation status checks, and sync via LangAPI.
README
@langapi/mcp-server
MCP (Model Context Protocol) server for LangAPI - AI-powered translation management for i18n projects.
This package enables AI assistants like Claude, Cursor, and VS Code extensions to manage translations in your project programmatically.
Quick Start
# 1. Get your API key at https://langapi.io (1,000 free credits)
# 2. Add to your AI tool (example for Claude Desktop on macOS):
# Edit ~/Library/Application Support/Claude/claude_desktop_config.json
# 3. Start chatting:
# "Scan my project for translations"
# "What keys are missing in German?"
# "Sync all translations"
Features
- Locale Detection: Automatically detect i18n framework (next-intl, i18next, react-intl, iOS/macOS) and locale files
- Translation Status: Compare source and target locales to find missing translations
- Sync Translations: Translate missing keys via LangAPI with credit-based billing
- Dry Run Mode: Preview changes and costs before syncing (enabled by default)
- Format Preservation: Maintains JSON formatting when writing translated files
- Delta Detection: Only translate new/changed keys, saving up to 90% on costs
- Apple Localization: Support for iOS/macOS
.strings,.xcstrings, and.stringsdictfiles
Installation
npm install @langapi/mcp-server
Or use directly with npx (recommended):
npx @langapi/mcp-server
Setup by Tool
Claude Desktop
Config file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Configuration:
{
"mcpServers": {
"langapi": {
"command": "npx",
"args": ["@langapi/mcp-server"],
"env": {
"LANGAPI_API_KEY": "your-api-key-here"
}
}
}
}
After editing, restart Claude Desktop for changes to take effect.
Claude Code (CLI)
Option 1: CLI command (quickest)
# Add to current project (stored in .mcp.json)
claude mcp add langapi \
--env LANGAPI_API_KEY=your-api-key-here \
-- npx -y @langapi/mcp-server
Option 2: Project-level config (recommended for teams)
Create .mcp.json in your project root:
{
"mcpServers": {
"langapi": {
"command": "npx",
"args": ["@langapi/mcp-server"],
"env": {
"LANGAPI_API_KEY": "your-api-key-here"
}
}
}
}
Option 3: User-level config
Add to ~/.claude.json:
{
"mcpServers": {
"langapi": {
"command": "npx",
"args": ["@langapi/mcp-server"],
"env": {
"LANGAPI_API_KEY": "your-api-key-here"
}
}
}
}
Option 4: Environment variable
export LANGAPI_API_KEY="your-api-key-here"
Then the MCP server will pick it up automatically.
Verify connection:
# List configured servers
claude mcp list
# Check server status inside Claude Code
/mcp
Remove server:
claude mcp remove langapi
Cursor
Config file locations:
- Project-level:
.cursor/mcp.jsonin your project root - Global:
~/.cursor/mcp.json
Configuration:
{
"mcpServers": {
"langapi": {
"command": "npx",
"args": ["@langapi/mcp-server"],
"env": {
"LANGAPI_API_KEY": "your-api-key-here"
}
}
}
}
Alternative: Via UI
- Open Cursor Settings (Cmd/Ctrl + ,)
- Search for "MCP"
- Click "Edit in settings.json"
- Add the configuration above
VS Code with Cline
- Install the Cline extension
- Create
.vscode/cline_mcp_settings.jsonin your project:
{
"mcpServers": {
"langapi": {
"command": "npx",
"args": ["@langapi/mcp-server"],
"env": {
"LANGAPI_API_KEY": "your-api-key-here"
}
}
}
}
- Reload VS Code window (Cmd/Ctrl + Shift + P > "Reload Window")
VS Code with Roo Code
- Install the Roo Code extension
- Create
.vscode/mcp.jsonin your project:
{
"mcpServers": {
"langapi": {
"command": "npx",
"args": ["@langapi/mcp-server"],
"env": {
"LANGAPI_API_KEY": "your-api-key-here"
}
}
}
}
- Reload VS Code window
Windsurf
Config file: ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"langapi": {
"command": "npx",
"args": ["@langapi/mcp-server"],
"env": {
"LANGAPI_API_KEY": "your-api-key-here"
}
}
}
}
Restart Windsurf after editing.
Environment Variables
| Variable | Required | Description |
|---|---|---|
LANGAPI_API_KEY |
Yes | Your LangAPI API key (get one at langapi.io) |
LANGAPI_API_URL |
No | Custom API URL (default: https://api.langapi.io) |
MCP Tools
list_local_locales
Scan your project for locale JSON files and detect the i18n framework.
Input:
{
"project_path": "/path/to/project", // optional, defaults to cwd
"include_key_count": true // optional, default: true
}
Output:
{
"framework": "next-intl",
"confidence": "high",
"source_lang": "en",
"locales_path": "messages",
"locales": [
{
"lang": "en",
"files": [{ "path": "messages/en.json", "namespace": null, "key_count": 150 }],
"total_keys": 150
},
{
"lang": "de",
"files": [{ "path": "messages/de.json", "namespace": null, "key_count": 120 }],
"total_keys": 120
}
],
"config_file": "i18n.ts"
}
get_translation_status
Compare source locale against targets to identify missing keys and estimate costs.
Input:
{
"source_lang": "en",
"target_langs": ["de", "fr"], // optional, all non-source by default
"project_path": "/path/to/project" // optional
}
Output:
{
"source_lang": "en",
"source_keys": 150,
"targets": [
{
"lang": "de",
"status": "outdated",
"keys": { "total": 120, "missing": ["new.key1", "new.key2"], "extra": [] }
}
],
"cost_estimate": {
"words_to_translate": 45,
"credits_required": 90,
"current_balance": 1000,
"balance_after_sync": 910
}
}
sync_translations
Sync translations via the LangAPI API. Default is dry_run=true for safety.
Input:
{
"source_lang": "en",
"target_langs": ["de", "fr"],
"dry_run": true, // default: true (preview mode)
"project_path": "/path/to/project", // optional
"write_to_files": true, // optional, default: true
"skip_keys": ["key.to.skip"] // optional, keys to exclude
}
Output (dry_run=true):
{
"success": true,
"dry_run": true,
"delta": {
"new_keys": ["new.key1", "new.key2"],
"changed_keys": [],
"total_keys_to_sync": 2
},
"cost": {
"words_to_translate": 45,
"credits_required": 90,
"current_balance": 1000,
"balance_after_sync": 910
},
"message": "Preview: 2 keys to sync, 90 credits required. Run with dry_run=false to execute."
}
Output (dry_run=false):
{
"success": true,
"dry_run": false,
"results": [
{ "language": "de", "translated_count": 2, "file_written": "messages/de.json" },
{ "language": "fr", "translated_count": 2, "file_written": "messages/fr.json" }
],
"cost": {
"credits_used": 90,
"balance_after_sync": 1910
},
"message": "Sync complete. 4 keys translated across 2 languages. 90 credits used."
}
Prompt Examples
Scanning Your Project
"Scan my project for translations"
"What i18n framework am I using?"
"List all my locale files"
"How many translation keys do I have?"
"What languages are configured in my project?"
Checking Translation Status
"What translations are missing?"
"Compare English to all other languages"
"How many keys need to be translated for French?"
"Which languages are out of sync?"
"Show me the missing keys for German"
"How much will it cost to sync all languages?"
Preview Changes (Dry Run)
"Preview what would happen if I sync all languages"
"Do a dry run for French translations"
"Show me what keys will be translated"
"What's the cost estimate for syncing German?"
"Preview the sync without making changes"
Syncing Translations
"Sync all missing translations"
"Translate to German and French"
"Update all locale files with missing keys"
"Sync translations and write to files"
"Execute the translation sync"
Advanced Operations
"Are there any extra keys in German that aren't in English?"
"Skip the settings.* keys when syncing"
"Only sync the home.* and nav.* keys"
"Sync to Japanese but skip experimental features"
Complete Workflow Example
You: List the translations in my project
Claude: [Calls list_local_locales]
I found a next-intl project with English (150 keys) and German (120 keys) translations.
You: What translations are missing for German?
Claude: [Calls get_translation_status]
German is missing 30 keys. The sync would cost 85 credits (you have 1000 credits).
You: Sync the German translations
Claude: [Calls sync_translations with dry_run=true]
Preview: 30 keys will be translated, costing 85 credits. Should I proceed?
You: Yes, go ahead
Claude: [Calls sync_translations with dry_run=false]
Done! 30 keys translated. German file updated at messages/de.json.
Supported Frameworks
The server automatically detects these i18n frameworks:
| Framework | Locale Patterns | Config Files |
|---|---|---|
| next-intl | messages/*.json, locales/*.json |
i18n.ts, next.config.js |
| i18next | public/locales/*/*.json, locales/*/*.json |
i18next.config.js, i18n.js |
| react-intl | src/lang/*.json, lang/*.json |
src/i18n.ts |
| iOS/macOS | .strings, .xcstrings, .stringsdict |
Info.plist |
| generic | Various common patterns | - |
Troubleshooting
"MCP server not found"
- Ensure
npxis in your PATH - Try running
npx @langapi/mcp-servermanually to test - On Windows, you may need to use the full path to npx
"API key invalid" or "Unauthorized"
- Verify your API key at langapi.io/dashboard
- Check for extra spaces or quotes in your config
- Ensure the key is set in the
envsection, notargs
"No locale files found"
- Check that your locale files match supported patterns (see Frameworks above)
- Verify files are valid JSON
- Try specifying
project_pathexplicitly
"Permission denied" when writing files
- Check file/directory write permissions
- On macOS, ensure your terminal has disk access
Server not connecting
- Restart your IDE/tool completely (not just reload)
- Check the config file syntax (valid JSON?)
- Look for error messages in your tool's developer console
Dry run works but execute fails
- Check your credit balance at langapi.io
- Verify network connectivity to api.langapi.io
Advanced Configuration
Multiple Projects
Use project-level config files (.mcp.json, .cursor/mcp.json) with different API keys per project.
Custom API URL
For self-hosted or enterprise deployments:
{
"mcpServers": {
"langapi": {
"command": "npx",
"args": ["@langapi/mcp-server"],
"env": {
"LANGAPI_API_KEY": "your-api-key",
"LANGAPI_API_URL": "https://your-api-server.com"
}
}
}
}
Credits & Billing
LangAPI uses a credit-based billing system:
- 1 credit = 1 word to translate
- New users get 1,000 free credits
- Top up with 100,000 credits for $15 (no subscription, no expiry)
Get your API key at langapi.io.
License
MIT
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。