Skip to content

Commit e534ef6

Browse files
ikiwqCopilot
andauthored
Streammable HTTP events (#10)
* wip: streammable http server * chore: removed useless file * fix: responses and bind * wip: better code * fix: misc * style: imports * wip: fixes and additions * feat: docker and aliases * fix: final tweaks * fix: node graceful shutown * wip: tweaks * chore: docker * feat: tests * fix: test * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * feat: staging docker compose * feat: review changes * fix: security * feat: removed features and readme * feat: reimplemented tmx import * fix: removed cors origins * fix: allowed headers Co-authored-by: Copilot <[email protected]> * fix: readme typo Co-authored-by: Copilot <[email protected]> * Update README.md * fix: readme * fix: reamde * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: Copilot <[email protected]>
1 parent ab6ddeb commit e534ef6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2078
-1004
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Http
2+
HOST=0.0.0.0
3+
PORT=80
4+
TRANSPORT=http
5+
6+
# Logging
7+
LOGGING_LEVEL=info

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ coverage/*
1818
# IntelliJ
1919
out/
2020

21+
# Env
22+
.env
23+
2124
# mpeltonen/sbt-idea plugin
2225
.idea_modules/
2326

Dockerfile

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,15 @@
1-
FROM node:22.13.1-alpine AS builder
1+
FROM node:22.14.0-alpine
22

3-
WORKDIR /app
3+
ENV CI=true
44

5-
COPY package.json pnpm-lock.yaml ./
6-
RUN npm install -g pnpm@latest-10
7-
RUN pnpm install --frozen-lockfile
5+
RUN apk update && apk upgrade
6+
RUN apk add curl
87

8+
WORKDIR /opt
99
COPY . .
10-
RUN pnpm run test
11-
RUN pnpm run build
12-
13-
14-
FROM node:22.13.1-alpine AS release
15-
16-
WORKDIR /app
17-
18-
COPY --from=builder /app/dist /app/dist
19-
COPY --from=builder /app/package.json /app/package.json
20-
COPY --from=builder /app/pnpm-lock.yaml /app/pnpm-lock.yaml
21-
22-
ENV NODE_ENV=production
2310

2411
RUN npm install -g pnpm@latest-10
25-
RUN pnpm install --frozen-lockfile --prod
12+
RUN pnpm install --frozen-lockfile
13+
RUN pnpm build
2614

27-
ENTRYPOINT ["node", "/app/dist/index.js"]
15+
CMD ["node", "dist/index.js"]

README.md

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ A Model Context Protocol (MCP) Server for [Lara Translate](https://laratranslate
1010
- 📖 [Introduction](#-introduction)
1111
- 🛠 [Available Tools](#-available-tools)
1212
- 🚀 [Getting Started](#-getting-started)
13-
- 📋 [Requirements](#-requirements)
14-
- 🔌 [Installation](#-installation)
15-
- 🧩 [Installation Engines](#-installation-engines)
13+
- 📋 [HTTP Server](#http-server-)
14+
- 🔌 [STDIO Server](#stdio-server-%EF%B8%8F)
15+
- 🧪 [Verify Installation](#-verify-installation)
1616
- 💻 [Popular Clients that supports MCPs](#-popular-clients-that-supports-mcps)
1717
- 🆘 [Support](#-support)
1818

@@ -161,7 +161,7 @@ Lara also lowers the cost of using models like GPT-4 in non-English workflows. S
161161

162162
**Inputs**:
163163
- `id` (string): ID of the memory to update
164-
- `tmx` (file path): The path of the TMX file to upload
164+
- `tmx_content` (string): The content of the tmx file to upload
165165
- `gzip` (boolean): Indicates if the file is compressed (.gz)
166166

167167
**Returns**: Import details
@@ -177,69 +177,87 @@ Lara also lowers the cost of using models like GPT-4 in non-English workflows. S
177177
</details>
178178

179179
## 🚀 Getting Started
180+
Lara supports both the STDIO and streamable HTTP protocols. For a hassle-free setup, we recommend using the HTTP protocol. If you prefer to use STDIO, it must be installed locally on your machine.
180181

181-
### 📋 Requirements
182+
You'll find setup instructions for both protocols in the sections below.
182183

183-
- Lara Translate API Credentials
184-
- To get them you can refer to the [Official Documentation](https://developers.laratranslate.com/docs/getting-started#step-3---configure-your-credentials)
185-
- An LLM client that supports Model Context Protocol (MCP), such as Claude Desktop, Cursors, or GitHub Copilot
186-
- NPX or Docker (depending on your preferred installation method)
184+
### HTTP Server 🌐
185+
<details>
186+
<summary><strong>❌ Clients NOT supporting <code>url</code> configuration (e.g., Claude, OpenAI)</strong></summary>
187187

188-
### 🔌 Installation
188+
This installation guide is intended for clients that do NOT support the url-based configuration. This option requires Node.js to be installed on your system.
189189

190-
#### Introduction
191-
The installation process is standardized across all MCP clients. It involves manually adding a configuration object to your client's MCP configuration JSON file.
192190
> If you're unsure how to configure an MCP with your client, please refer to your MCP client's official documentation.
193191
194-
Lara Translate MCP supports multiple installation methods, including NPX and Docker. \
195-
Below, we'll use NPX as an example.
196-
197192
---
198193

199-
#### Installation & Configuration
200-
201-
**Step 1**: Open your client's MCP configuration JSON file with a text editor, then copy and paste the following snippet:
194+
1. Open your client's MCP configuration JSON file with a text editor, then copy and paste the following snippet:
202195

203196
```json
204197
{
205198
"mcpServers": {
206-
"lara-translate": {
199+
"lara": {
207200
"command": "npx",
208201
"args": [
209-
"-y",
210-
"@translated/lara-mcp@latest"
202+
"mcp-remote",
203+
"https://mcp.laratranslate.it/mcp",
204+
"--header",
205+
"x-lara-access-key-id: ${X_LARA_ACCESS_KEY_ID}",
206+
"--header",
207+
"x-lara-access-key-secret: ${X_LARA_ACCESS_KEY_SECRET}"
211208
],
212209
"env": {
213-
"LARA_ACCESS_KEY_ID": "<YOUR_ACCESS_KEY_ID>",
214-
"LARA_ACCESS_KEY_SECRET": "<YOUR_ACCESS_KEY_SECRET>"
210+
"X_LARA_ACCESS_KEY_ID": "<YOUR_ACCESS_KEY_ID>",
211+
"X_LARA_ACCESS_KEY_SECRET": "<YOUR_ACCESS_KEY_SECRET>"
215212
}
216213
}
217214
}
218215
}
219216
```
220217

221-
**Step 2**: Replace `<YOUR_ACCESS_KEY_ID>` and `<YOUR_ACCESS_KEY_SECRET>` with your Lara Translate API credentials (refer to the [Official Documentation](https://developers.laratranslate.com/docs/getting-started#step-3---configure-your-credentials) for details).
218+
2. Replace `<YOUR_ACCESS_KEY_ID>` and `<YOUR_ACCESS_KEY_SECRET>` with your Lara Translate API credentials. Refer to the [Official Documentation](https://developers.laratranslate.com/docs/getting-started#step-3---configure-your-credentials) for details.
222219

223-
**Step 3**: Restart your MCP client.
220+
3. Restart your MCP client.
224221

225-
---
222+
</details>
226223

227-
#### Verify Installation
224+
<details>
225+
<summary><strong>✅ Clients supporting <code>url</code> configuration (e.g., Cursor, Continue)</strong></summary>
228226

229-
After restarting your MCP client, you should see Lara Translate MCP in the list of available MCPs.
230-
> The method for viewing installed MCPs varies by client. Please consult your MCP client's documentation.
227+
This installation guide is intended for clients that support the url-based configuration. These clients can connect to Lara through a remote HTTP endpoint by specifying a simple configuration object.
231228

232-
To verify that Lara Translate MCP is working correctly, try translating with a simple prompt:
233-
```text
234-
Translate with Lara "Hello world" to Spanish
229+
Some examples of supported clients include Cursor, Continue, OpenDevin, and Aider.
230+
> If you're unsure how to configure an MCP with your client, please refer to your MCP client's official documentation.
231+
232+
---
233+
234+
1. Open your client's MCP configuration JSON file with a text editor, then copy and paste the following snippet:
235+
236+
```json
237+
{
238+
"mcpServers": {
239+
"lara": {
240+
"url": "https://mcp.laratranslate.it/mcp",
241+
"headers": {
242+
"x-lara-access-key-id": "<YOUR_ACCESS_KEY_ID>",
243+
"x-lara-access-key-secret": "<YOUR_ACCESS_KEY_SECRET>"
244+
}
245+
}
246+
}
247+
}
235248
```
236249

237-
Your MCP client will begin generating a response. If Lara Translate MCP is properly installed and configured, your client will either request approval for the action or display a notification that Lara Translate is being used.
250+
2. Replace `<YOUR_ACCESS_KEY_ID>` and `<YOUR_ACCESS_KEY_SECRET>` with your Lara Translate API credentials. Refer to the [Official Documentation](https://developers.laratranslate.com/docs/getting-started#step-3---configure-your-credentials) for details.
238251

239-
## 🧩 Installation Engines
252+
3. Restart your MCP client.
240253

254+
</details>
255+
256+
---
257+
258+
### STDIO Server 🖥️
241259
<details>
242-
<summary><strong>Option 1: Using NPX</strong></summary>
260+
<summary><strong>Using NPX</strong></summary>
243261

244262
This option requires Node.js to be installed on your system.
245263

@@ -263,7 +281,7 @@ This option requires Node.js to be installed on your system.
263281
</details>
264282

265283
<details>
266-
<summary><strong>Option 2: Using Docker</strong></summary>
284+
<summary><strong>Using Docker</strong></summary>
267285

268286
This option requires Docker to be installed on your system.
269287

@@ -296,7 +314,7 @@ This option requires Docker to be installed on your system.
296314
</details>
297315

298316
<details>
299-
<summary><strong>Option 3: Building from Source</strong></summary>
317+
<summary><strong>Building from Source</strong></summary>
300318

301319
#### Using Node.js
302320

@@ -375,6 +393,18 @@ docker build -t lara-mcp .
375393
4. Replace `<YOUR_ACCESS_KEY_ID>` and `<YOUR_ACCESS_KEY_SECRET>` with your actual credentials.
376394
</details>
377395

396+
## 🧪 Verify Installation
397+
398+
After restarting your MCP client, you should see Lara Translate MCP in the list of available MCPs.
399+
> The method for viewing installed MCPs varies by client. Please consult your MCP client's documentation.
400+
401+
To verify that Lara Translate MCP is working correctly, try translating with a simple prompt:
402+
```text
403+
Translate with Lara "Hello world" to Spanish
404+
```
405+
406+
Your MCP client will begin generating a response. If Lara Translate MCP is properly installed and configured, your client will either request approval for the action or display a notification that Lara Translate is being used.
407+
378408
## 💻 Popular Clients that supports MCPs
379409

380410
> For a complete list of MCP clients and their feature support, visit the [official MCP clients page](https://modelcontextprotocol.io/clients).

docker-compose.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
lara-mcp:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
container_name: lara-mcp
7+
restart: unless-stopped
8+
working_dir: /opt
9+
command: ["pnpm", "--reporter=silent", "dev"]
10+
ports:
11+
- ${PORT}:${PORT}
12+
env_file:
13+
- .env
14+
volumes:
15+
- ./src:/opt/src
16+
- ./.env:/opt/.env
17+
- ./package.json:/opt/package.json
18+
- ./pnpm-lock.yaml:/opt/pnpm-lock.yaml
19+
- ./vitest.config.ts:/opt/vitest.config.ts
20+
- ./nodemon.json:/opt/nodemon.json
21+
- ./tsconfig.json:/opt/tsconfig.json

nodemon.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"execMap": {
3+
"ts": "tsx"
4+
}
5+
}

package.json

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@
2424
"files": [
2525
"dist"
2626
],
27+
"imports": {
28+
"#env": "./dist/env.js",
29+
"#exception": "./dist/exception.js",
30+
"#logger": "./dist/logger.js",
31+
"#rest/server": "./dist/rest/server.js",
32+
"#mcp/server": "./dist/mcp/server.js"
33+
},
2734
"scripts": {
28-
"build": "tsc",
35+
"build": "rm -rf dist && tsc",
36+
"dev": "nodemon src/index.ts",
2937
"start": "node dist/index.js",
30-
"dev": "ts-node-esm src/index.ts",
3138
"test": "vitest run",
3239
"test:watch": "vitest",
3340
"test:coverage": "vitest run --coverage"
@@ -44,15 +51,23 @@
4451
"translated"
4552
],
4653
"dependencies": {
47-
"@modelcontextprotocol/sdk": "^1.8.0",
54+
"@modelcontextprotocol/sdk": "^1.12.3",
4855
"@translated/lara": "^1.4.0",
49-
"zod": "^3.24.2",
50-
"zod-to-json-schema": "^3.24.5"
56+
"cors": "^2.8.5",
57+
"express": "^5.1.0",
58+
"helmet": "^8.1.0",
59+
"pino": "^9.7.0",
60+
"zod": "^3.25.0"
5161
},
5262
"devDependencies": {
63+
"@types/cors": "^2.8.19",
64+
"@types/express": "^5.0.3",
5365
"@types/node": "^22.13.14",
66+
"@types/supertest": "^6.0.3",
5467
"@vitest/coverage-v8": "^3.1.1",
55-
"ts-node": "^10.9.2",
68+
"nodemon": "^3.1.10",
69+
"supertest": "^7.1.1",
70+
"tsx": "^4.20.3",
5671
"typescript": "^5.8.2",
5772
"vitest": "^3.1.1"
5873
}

0 commit comments

Comments
 (0)