Skip to main content

MCP server for translating Sinhala/Singlish commands into English technical prompts

Project description

sinhala-mcp ๐Ÿ‡ฑ๐Ÿ‡ฐ

Production-ready MCP server that translates Sinhala/Singlish instructions into English technical prompts using Google Gemini AI.

Python Version License MCP

โœจ Features

  • ๐ŸŒ Sinhala/Singlish Translation: Convert colloquial commands into structured English technical specifications
  • ๐Ÿง  Context-Aware: Automatically infers technical context (e.g., "Login" โ†’ "Authentication flow")
  • ๐Ÿ”’ Environment Variable Auth: Secure API key management via environment variables
  • ๐Ÿš€ Production-Ready:
    • Comprehensive error handling and logging
    • Retry logic for API failures
    • Timeout protection (30s default)
    • Input validation and sanitization
    • Health check endpoint for monitoring
    • Rate limit handling
  • ๐Ÿ“ฆ MCP Compliant: Works with Claude Desktop, VS Code MCP client, and other MCP-compatible tools
  • ๐ŸŽฏ Latest AI: Uses Google GenAI SDK with Gemini 2.0 Flash (GA as of May 2025)

๐Ÿ“ฆ Installation

Prerequisites

This tool requires uv to be installed.

Windows:

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

macOS / Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

Using uvx (Recommended - No installation required)

# Just run it directly!
uvx sinhala-mcp

Using pip

pip install sinhala-mcp

Using uv

uv pip install sinhala-mcp

๐Ÿ”‘ Configuration

Step 1: Get a Google Gemini API Key

  1. Visit Google AI Studio
  2. Create a new API key
  3. Keep it secure - never commit it to version control

Step 2: Configure Your MCP Client

IMPORTANT: The server reads the API key from the GEMINI_API_KEY environment variable. Do not use the old set_gemini_key tool - it has been removed for security and store compatibility.

Claude Desktop Configuration

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Roaming\claude-code\mcp_settings.json or %APPDATA%\claude-code\claude_desktop_config.json

{
  "mcpServers": {
    "sinhala-mcp": {
      "command": "uvx",
      "args": ["sinhala-mcp"],
      "env": {
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

VS Code MCP Extension

{
  "mcp.servers": {
    "sinhala-mcp": {
      "command": "uvx",
      "args": ["sinhala-mcp"],
      "env": {
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

Claude Code CLI

The Claude Code CLI typically reads the configuration from the standard Claude Desktop configuration file.

  1. Follow the Claude Desktop Configuration steps above.
  2. Ensure the GEMINI_API_KEY is set in your environment variables if the CLI doesn't pick it up from the config.
  3. Run claude - it should automatically detect the configured MCP servers.

Command Line / Development

# Linux/macOS
export GEMINI_API_KEY="your-api-key-here"

# Windows CMD
set GEMINI_API_KEY=your-api-key-here

# Windows PowerShell
$env:GEMINI_API_KEY="your-api-key-here"

๐Ÿ› ๏ธ Available Tools

1. translate_sinhala_instruction

Translates Sinhala or Singlish instructions into precise English technical prompts.

Parameters:

  • instruction (string, required): The Sinhala or Singlish instruction to translate (max 5000 characters)

Example:

Translate "mata login page ekak hadanna one" using translate_sinhala_instruction

Output:

Original (Sinhala/Singlish):
mama login ekak hadanna one

Translated (English Technical Prompt):
Implement a user authentication system with login functionality including:
- Username/email and password input fields
- Form validation for credentials
- Authentication endpoint integration
- Session management after successful login
- Error handling for failed authentication attempts

2. health_check

Check if the MCP server and Gemini API connection are working properly.

Parameters: None

Example:

Run health_check

Output:

Health Check: PASSED
Server: sinhala-mcp v0.1.0
API Connection: Active
Timestamp: 2025-01-26T12:00:00.000000

๐Ÿ’ก Usage Examples

Example 1: Web Development

Input (Sinhala):

"Mata dashboard ekak denna user stats display karanna example ekka"

Translated Output:

Create a user analytics dashboard with:
- Real-time user statistics display
- Data visualization charts
- Filtering and search capabilities
- Responsive layout for mobile/desktop
- Authentication-protected access

Example 2: Backend Development

Input (Sinhala):

"Database eka connect karanna API endpoint ekak hadala denna"

Translated Output:

Implement database integration with REST API:
- Set up database connection pool
- Create CRUD endpoints for data access
- Implement proper error handling
- Add data validation and sanitization
- Include authentication/authorization middleware

Example 3: Frontend Features

Input (Sinhala):

"Profile page eke photo upload eka hadanna"

Translated Output:

Implement profile photo upload feature:
- File upload input with image type validation
- Client-side image preview
- Size and format restrictions
- Upload progress indicator
- Server-side file storage integration
- Error handling for upload failures

๐Ÿ—๏ธ Development

Setup Development Environment

# Clone the repository
git clone https://github.com/Thamindu-Dev/sinhala-mcp.git
cd sinhala-mcp

# Install dependencies
pip install -e .

# Or using uv
uv pip install -e .

Running Tests

# Test server import
python test_simple.py

# Run with verbose logging
LOGLEVEL=DEBUG python -m sinhala_mcp.server

Project Structure

sinhala-mcp/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ sinhala_mcp/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ server.py          # Main MCP server implementation
โ”œโ”€โ”€ pyproject.toml              # Package configuration
โ”œโ”€โ”€ smithery.yaml              # Store publishing configuration
โ”œโ”€โ”€ README.md                  # This file
โ””โ”€โ”€ LICENSE                    # MIT License

๐Ÿ”’ Security

  • โœ… API keys stored in environment variables only
  • โœ… No local file storage of credentials
  • โœ… Input validation and sanitization
  • โœ… Protection against injection attacks
  • โœ… Rate limit handling
  • โœ… Open source - fully auditable

๐Ÿ“Š Technical Specifications

  • Build Backend: hatchling
  • Package Layout: Modern src/ layout
  • Python Version: 3.10+ (tested on 3.10-3.13)
  • Dependencies:
    • mcp>=0.9.0 - Model Context Protocol SDK
    • google-genai>=1.0.0 - Official Google GenAI SDK (GA)
  • AI Model: Gemini 2.0 Flash Experimental
  • Max Instruction Length: 5000 characters
  • API Timeout: 30 seconds
  • Retry Logic: 2 retries with exponential backoff

๐Ÿš€ Production Deployment

The server is production-ready with:

  • Structured Logging: Timestamped logs for debugging
  • Error Handling: Graceful failure with user-friendly messages
  • Health Checks: Monitor API connectivity
  • Timeout Protection: Prevents hanging requests
  • Retry Logic: Handles transient API failures
  • Input Validation: Prevents abuse and injection attacks

๐Ÿ“š Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ User (Sinhala)  โ”‚โ”€โ”€โ”€โ”€โ”€>โ”‚  MCP Server      โ”‚โ”€โ”€โ”€โ”€โ”€>โ”‚ Google Gemini   โ”‚
โ”‚ "mama login eka โ”‚      โ”‚  (translate_     โ”‚      โ”‚ AI API          โ”‚
โ”‚  karanna one"   โ”‚      โ”‚   sinhala_       โ”‚      โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                  โ”‚
                                  โ–ผ
                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                         โ”‚ English Output   โ”‚
                         โ”‚ "Implement user  โ”‚
                         โ”‚  authentication โ”‚
                         โ”‚  with login form"โ”‚
                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿค Contributing

Contributions are welcome! Please feel free to:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a Pull Request

๐Ÿ“ License

MIT License - see LICENSE for details.

๐Ÿ”ง Troubleshooting

Common Issues

  1. "GEMINI_API_KEY not found" Error

    • Ensure you have added the key to your configuration file (Claude Desktop or VS Code).
    • If using the terminal, ensure you ran export GEMINI_API_KEY=... (Mac/Linux) or $env:GEMINI_API_KEY=... (Windows).
    • Restart your MCP client after changing the configuration.
  2. Connection Refused / Server Error

    • Check if you have the latest version installed: uv tool upgrade sinhala-mcp
    • Verify your internet connection (Google Gemini API requires internet access).
  3. Translation is empty or incorrect

    • The model might have blocked the content due to safety settings. Try rephrasing the instruction.

๐Ÿ†˜ Support

๐Ÿ™ Acknowledgments

Built with:

๐Ÿ‘จโ€๐Ÿ’ป About the Developer

sinhala-mcp was created by Thamindu Hatharasinghe.


Made with โค๏ธ for Sinhala developers

For more information about MCP, visit modelcontextprotocol.io.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sinhala_mcp-0.1.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sinhala_mcp-0.1.2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file sinhala_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: sinhala_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for sinhala_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b7c1d964a90b8e690b86a7162a43e7a5304dbbe855096fea658a03961125698a
MD5 b9a9bc3930ba4f7169f42c7941e71b3d
BLAKE2b-256 af28bd2bcf8d979e7615cf5c4f48ef00383f33932ba55045a456aaaff7cd88a4

See more details on using hashes here.

File details

Details for the file sinhala_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: sinhala_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for sinhala_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ee1e654cdf1f962f38f1faac38dbdc2576fc6b65b24a5976d397bb668700ff15
MD5 b4e66a0fa2eab9010381c7004f979910
BLAKE2b-256 61a71c5bcd581d7ae6771d7f9c9c6ed6c90735f5ea60f920693c398c1ff22c0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page