Metadata-Version: 2.5
Name: xliff-mcp-server
Version: 0.1.3
Summary: MCP server for processing XLIFF translation files
Project-URL: Homepage, https://github.com/langlink-localization/xliff-mcp-server
Project-URL: Repository, https://github.com/langlink-localization/xliff-mcp-server
Project-URL: Issues, https://github.com/langlink-localization/xliff-mcp-server/issues
Author-email: floydy <floydy@langlinking.com>
License: MIT License
        
        Copyright (c) 2024 XLIFF MCP Server Contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: localization,mcp,translation,xliff
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: lxml>=4.9.0
Requires-Dist: mcp<1.29.0,>=1.2.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: translate-toolkit>=3.0.0
Provides-Extra: dev
Requires-Dist: httpx<1.0.0,>=0.28.1; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.15.0; extra == 'dev'
Description-Content-Type: text/markdown

# XLIFF MCP Server

An MCP (Model Context Protocol) server for processing XLIFF and TMX translation files. This server provides tools for parsing, validating, and manipulating translation files commonly used in localization workflows.

## Features

- **XLIFF Processing**: Parse and extract translation units from XLIFF files
- **TMX Processing**: Parse and extract translation units from TMX files  
- **Tag Preservation**: Special processing mode that preserves inline tags for AI translation
- **Validation**: Validate XLIFF and TMX file formats
- **Translation Replacement**: Replace target translations in XLIFF files
- **CSV / JSON Export**: Generate CSV or JSON file content from XLIFF and TMX inputs
- **Agent Skills Module**: Provide a standalone `skills/` module that AI agents can read directly

## Installation

### Automatic Setup (Recommended)

```bash
python setup.py
```

### Manual Installation

#### Using pip

```bash
pip install -e .
```

#### Using the install script

```bash
./install.sh  # Unix/Linux/macOS
install.bat   # Windows
```

## Configuration

### For Claude Desktop

Add the server to your Claude Desktop configuration file:

**macOS/Linux**: `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows**: `%AppData%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "xliff-processor": {
      "command": "python",
      "args": ["-m", "xliff_mcp.server"],
      "cwd": "/absolute/path/to/xliff-mcp-server"
    }
  }
}
```

Or if using uv:

```json
{
  "mcpServers": {
    "xliff-processor": {
      "command": "uv",
      "args": ["run", "python", "-m", "xliff_mcp.server"],
      "cwd": "/absolute/path/to/xliff-mcp-server"
    }
  }
}
```

## Available Tools

### process_xliff
Process XLIFF content and extract translation units.

**Parameters:**
- `file_name` (string): Name of the XLIFF file
- `content` (string): XLIFF file content

**Returns:** JSON with translation units including:
- fileName, segNumber, unitId, percent, source, target, srcLang, tgtLang

### process_xliff_with_tags
Process XLIFF preserving inline tags for AI translation.

**Parameters:**
- `file_name` (string): Name of the XLIFF file
- `content` (string): XLIFF file content

**Returns:** JSON with translation units preserving original formatting tags

### validate_xliff
Validate XLIFF content format.

**Parameters:**
- `content` (string): XLIFF file content to validate

**Returns:** JSON with validation status, message, and unit count

### replace_xliff_targets
Replace target translations in XLIFF file.

**Parameters:**
- `content` (string): Original XLIFF file content
- `translations` (string): JSON array of translations with segNumber/unitId and aiResult/mtResult

**Returns:** JSON with updated XLIFF content and replacement count

### process_tmx
Process TMX content and extract translation units.

**Parameters:**
- `file_name` (string): Name of the TMX file
- `content` (string): TMX file content

**Returns:** JSON with translation units including metadata

### validate_tmx
Validate TMX content format.

**Parameters:**
- `content` (string): TMX file content to validate

**Returns:** JSON with validation status and unit count

### export_xliff_file
Generate CSV or JSON file content from an XLIFF file.

**Parameters:**
- `file_name` (string): Name of the source XLIFF file
- `content` (string): XLIFF file content
- `output_format` (string): `csv` or `json`
- `preserve_tags` (boolean): Whether to preserve inline tags before export

**Returns:** JSON with generated `file_name`, `mime_type`, `content`, and `unit_count`

### export_tmx_file
Generate CSV or JSON file content from a TMX file.

**Parameters:**
- `file_name` (string): Name of the source TMX file
- `content` (string): TMX file content
- `output_format` (string): `csv` or `json`

**Returns:** JSON with generated `file_name`, `mime_type`, `content`, and `unit_count`

## Available Skills

Skills are separate from the MCP runtime and its tools.

- **MCP Runtime**: The `xliff_mcp/` package that exposes tools, prompts, and resources
- **Agent Skills Module**: The top-level `skills/` directory that AI agents can read directly
- **Runtime Workflow Registration**: The `xliff_mcp/workflows/` package that maps workflow guidance into MCP prompts/resources

The runtime still exposes workflow guidance through:

- **Prompts**: Reusable workflow prompts that guide the client through the right tool sequence
- **Resources**: A discoverable skill catalog at `skills://catalog` and per-skill detail resources at `skills://{skill_name}`

For agent usage inside the repository:

- start with [skills/README.md](skills/README.md)
- use [skills/catalog.json](skills/catalog.json) as the machine-readable index
- open the referenced skill markdown file for detailed workflow instructions

### prepare_xliff_for_translation
Validate XLIFF content, extract translation units, and summarize translation readiness.

### translate_xliff_with_tags
Extract tag-preserving XLIFF segments and guide AI translation without breaking inline markup.

### replace_xliff_targets_from_translations
Merge translated segment JSON back into the original XLIFF and verify the replacement count.

### inspect_tmx_translation_memory
Validate TMX content, inspect language pairs, and summarize translation memory entries for reuse.

## Usage Examples

Once configured in Claude Desktop, you can use the tools like this:

1. **Process an XLIFF file:**
   "Please process this XLIFF file and show me the translation units"

2. **Validate XLIFF format:**
   "Can you validate if this XLIFF content is properly formatted?"

3. **Replace translations:**
   "Replace the target translations in this XLIFF file with these new translations"

4. **Process TMX file:**
   "Extract all translation units from this TMX file"

5. **Generate a CSV export:**
   "Export this XLIFF file as CSV and give me the file content"

6. **Generate a JSON export:**
   "Export this TMX file as JSON so I can save it locally"

7. **Use a runtime workflow prompt:**
   "Use the `translate_xliff_with_tags` prompt to help me translate this XLIFF safely"

## Development

### Running lint

```bash
ruff check .
```

### Running tests

```bash
python -m pytest
```

### Running the smoke test script

```bash
python test_server.py
```

### Running the server directly

```bash
python -m xliff_mcp.server
```

## Requirements

- Python 3.10+
- mcp >= 1.2.0
- translate-toolkit >= 3.0.0
- lxml >= 4.9.0
- pydantic >= 2.0.0

## License

MIT

## Support

For issues and questions, please open an issue on the GitHub repository.

Both transports report the package version during MCP initialization. Compare it with `get_server_info.version` after reconnecting. Each tool processes supplied content in memory and returns results to the caller.
