Efficiently translate content with AI-powered translation and enhance your interactions with large language models.
Initialize Your Project
@modelcontextprotocol/sdk
: The MCP SDK that allows our server to communicate with MCP clients like Claude Desktopdeepl-node
: Official DeepL API client for Node.js, making it easy to interact with DeepL’s translation serviceszod
: A TypeScript-first schema validation library that we’ll use to define our tool parametersCreate Your Server Implementation
McpServer
class is the core of our implementation. It handles all the protocol-specific details of communicating with MCP clients. The StdioServerTransport
uses standard input/output streams for communication, which works well with Claude Desktop’s execution model where it spawns separate processes for each server.We’re using environment variables to pass the DeepL API key to our server, which is a secure way to handle sensitive credentials. Create a file named src/index.mjs
with the following structure:Implement DeepL API Helper Functions
Define MCP Tools
get-source-languages
, get-target-languages
, and rephrase-text
.get-source-languages
, get-target-languages
, and rephrase-text
, please refer to the GitHub repository.~/Library/Application Support/Claude/claude_desktop_config.json
%AppData%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
/path/to/deepl-mcp-server
with the actual path to your server directoryyour-api-key-here
with your actual DeepL API keyYour MCP should show up in the "Search and Tools" menu.
Using the "DeepL" keyword triggers Claude to use the DeepL MCP tools.
McpServer
class creates an MCP-compatible server that exposes tools to clients:
translate-text
tool:
StdioServerTransport
enables communication between the MCP server and clients: