Skip to main content
Glama
README.md
# alephtext

Hebrew text is where translation tools usually stumble: vowel points, right-to-left layout mixed with Latin terms and prices, and clinical wording where a dropped negation changes the meaning. alephtext is a small local bridge to the hosted HebrewCore MCP service, covering translation between Hebrew, English, Russian and other languages, protected terms that must survive translation exactly, nikud, transliteration, direction analysis, and clinical translation, querying and verification.

Nothing is translated on your own machine. This package answers `tools/list` locally from the captured tool definitions and forwards every `tools/call` to the hosted service over a streamable-HTTP JSON-RPC session, returning whatever the service sends back unchanged.

## The tools

All sixteen tools work on text or terms you supply.

Translation:

- **`translate`** — Translates one text (up to 20,000 characters) into a target language, with optional protected translation, domain registers (`general`, `clinical`, `finance`, `legal`), glossaries, gender controls, ICU MessageFormat handling, and quality tiers.
- **`translate_batch`** — Translates 1 to 50 short strings into one target language in a single call, in input order, with the same options as `translate`.
- **`clinical_translate`** — Translates a complete English clinical text into Israeli medical Hebrew, keeping drugs, doses, lab values and codes exact and checking every sentence.
- **`clinical_query`** — Turns a Hebrew clinical question into an English query for a record search or an English model.
- **`clinical_verify`** — Checks Hebrew produced elsewhere against its English clinical source for exact values, negation and laterality.

Language and layout helpers:

- **`detect_language`** — Detects the dominant language, script and direction of a string, with one segment per language.
- **`analyze_direction`** — Resolves the RTL/LTR structure of mixed Hebrew text, for one string or a map of fields.
- **`wrap_for_display`** — Makes one mixed Hebrew/English display line render correctly, in HTML, isolate or marks format.
- **`transliterate`** — Romanizes Hebrew into Latin letters, or writes Latin spelling in Hebrew letters.
- **`add_nikud`** — Adds full nikud (vowel points) to Hebrew text.
- **`strip_nikud`** — Removes nikud, dagesh and cantillation marks from Hebrew text.
- **`list_languages`** — Lists every language the service translates to and from, with codes, names and direction.

Your own account glossary and service status:

- **`list_terms`** — Lists the account's protected terms, with the ids `delete_term` needs.
- **`add_terms`** — Adds protected terms to your own account, or updates existing ones, optionally with per-language renderings.
- **`delete_term`** — Permanently deletes one of your own account terms by its id.
- **`health`** — Checks that the upstream API is up and its database reachable; needs no key and uses no quota.

Per the captured descriptions, several tools draw on the caller's own monthly character quota on their pre-existing account. No tool in this surface buys anything, tops up credit, checks out, or creates an API key.

## Install and run

As an MCP server via npm:

```bash
npx -y @reneturcios/alephtext mcp
```

MCP client configuration:

```json
{
  "mcpServers": {
    "alephtext": {
      "command": "npx",
      "args": ["-y", "@reneturcios/alephtext", "mcp"]
    }
  }
}
```

As a container:

```bash
docker run -i ghcr.io/cloudcorprecords/alephtext
docker run --rm ghcr.io/cloudcorprecords/alephtext health '{}'
```

## CLI

One binary serves both the command line and the MCP server. Each tool is a subcommand taking a single JSON string with that tool's arguments:

```bash
alephtext translate '{"text":"Welcome to your account","target_lang":"he"}'
alephtext translate_batch '{"items":["Checkout","Last updated %s ago"],"target_lang":"he"}'
alephtext detect_language '{"text":"שלום world"}'
alephtext strip_nikud '{"text":"שָׁלוֹם"}'
alephtext list_languages '{}'
alephtext health '{}'
alephtext --version
```

Exit codes: `0` when the forwarded call succeeds, `1` when the upstream result is an error, and `2` for usage problems such as an unknown subcommand or a malformed JSON argument.

## Configuration

- `HEBREWCORE_MCP_URL` — Overrides the upstream endpoint. The default is the pinned hosted endpoint, `https://hc.itsbaba.com/mcp`. (The override variable is a reconstruction added by this rebuild.)
- `HEBREWCORE_API_KEY` — When set, its value is sent to the upstream on every request as an `Authorization: Bearer <value>` header. When it is not set, no key header is sent at all, matching the keyless behaviour the tool surface was captured with. (The Bearer form and forwarding the key from this variable are reconstructions; the hosted service's registry record declares an `Authorization` header as a required secret, and the capture itself was taken without a key.)

Upstream failures — a JSON-RPC error from the service, a non-2xx response, an unreadable body, or a request that fails outright — are reported to the caller as an error result whose text starts with `alephtext error:`.

## How forwarding works

The first forwarded call opens a session: an `initialize` request (protocol version `2025-03-26`), followed by a `notifications/initialized` notification, then the `tools/call` itself. If the service answers the initialize request with an `Mcp-Session-Id` header, that value is carried on every later request, and the open session is reused for the rest of the process. Replies are accepted either as plain JSON or as server-sent events. Successful results pass through verbatim, including any `isError` flag and any extra fields the service includes.

## Development

```bash
npm install
npm run build   # tsc -> dist/ (dist/cli.js is the bin)
npm test        # tsx --test test/*.test.ts — stubbed upstream, no network
npm run dev     # run the CLI from source
```

The test suite checks the served tool list against the captured surface tool by tool, exercises the session handshake and its reuse, covers both key-header branches, and verifies that arguments go upstream untouched and results come back untouched.

## License

MIT — see `LICENSE`. Copyright (c) 2026 Rene Turcios.