Metadata-Version: 2.4
Name: psr-cloud-mcp
Version: 0.6.0
Summary: MCP server for PSR Cloud (local stdio)
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: mcp[cli]>=1.0
Requires-Dist: psr-cloud<7,>=6.1.3

# PSR Cloud MCP Server

MCP server that exposes PSR Cloud HPC operations as AI tools, built on top of
[pycloud](https://pypi.org/project/psr-cloud/) (`psr-cloud` on PyPI).

## Prerequisites

1. **Python 3.10+**
2. **A Personal Access Token.** Go to `sso.psr-inc.com/profile`, log in with
   your corporate PSR Google account, generate a token under
   *PSR Cloud — Personal Access Tokens*, and save it (shown only once). The
   server reads it from `PSR_CLOUD_EMAIL` and `PSR_CLOUD_ACCESS_TOKEN` (see
   *Authentication*).

## Installation

### From PyPI

```bash
pip install psr-cloud-mcp
```

### From the Git repository

```bash
pip install git+https://github.com/your-org/psr-cloud-mcp.git
```

Either option installs the `psr-cloud-mcp` CLI and pulls `psr-cloud` from PyPI
automatically.

### Local development clone

```bash
git clone https://github.com/your-org/psr-cloud-mcp.git
cd psr-cloud-mcp
pip install -e .
```

## Authentication

The server reads your Personal Access Token from two environment variables,
usually set in the `env` block of the MCP configuration (below), or in the shell
before starting the server:

```bash
export PSR_CLOUD_EMAIL=yourname@psr-inc.com
export PSR_CLOUD_ACCESS_TOKEN=<your-token>
```

On Windows:

```powershell
$env:PSR_CLOUD_EMAIL = "yourname@psr-inc.com"
$env:PSR_CLOUD_ACCESS_TOKEN = "<your-token>"
```

Since 0.5.5 (psr-cloud 6), the credentials cached by PSR Cloud Desktop are no
longer used: the two variables are required.

## Running the server

```bash
# directly
python -m psr.cloudmcp

# or via the installed script
psr-cloud-mcp

# or via the MCP CLI
mcp run psr/cloudmcp/server.py
```

## Configuring Claude Code

Register the server for your user, which keeps the token out of the project:

```bash
claude mcp add --scope user --env PSR_CLOUD_EMAIL=yourname@psr-inc.com --env PSR_CLOUD_ACCESS_TOKEN=<your-token> psr-cloud -- python -m psr.cloudmcp
```

Or add the entry to a configuration file:

```json
{
  "mcpServers": {
    "psr-cloud": {
      "command": "python",
      "args": ["-m", "psr.cloudmcp"],
      "env": {
        "PSR_CLOUD_EMAIL": "yourname@psr-inc.com",
        "PSR_CLOUD_ACCESS_TOKEN": "<your-token>"
      }
    }
  }
}
```

If you prefer not to store the token in the config file, omit the `env` block and
set the variables in your shell profile instead. Never put the token in a
project file that is committed, such as `.mcp.json`.

## Configuring Claude Desktop

Open the Claude Desktop config file:

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

Add the `psr-cloud` entry under `mcpServers`:

```json
{
  "mcpServers": {
    "psr-cloud": {
      "command": "python",
      "args": ["-m", "psr.cloudmcp"],
      "env": {
        "PSR_CLOUD_EMAIL": "yourname@psr-inc.com",
        "PSR_CLOUD_ACCESS_TOKEN": "<your-token>"
      }
    }
  }
}
```

If Claude Desktop can't find the right `python` (the server shows **Failed**,
often with `spawn python ENOENT` or `No module named psr.cloudmcp`), use the
full path of the `python.exe` where you installed the package, keeping the same
`args`:

```json
{
  "mcpServers": {
    "psr-cloud": {
      "command": "C:\\Users\\<user>\\AppData\\Local\\Programs\\Python\\Python3xx\\python.exe",
      "args": ["-m", "psr.cloudmcp"],
      "env": {
        "PSR_CLOUD_EMAIL": "yourname@psr-inc.com",
        "PSR_CLOUD_ACCESS_TOKEN": "<your-token>"
      }
    }
  }
}
```

This prints that path, with the backslashes already doubled for JSON:

```bash
python -c "import psr.cloudmcp, sys, json; print(json.dumps(sys.executable))"
```

Prefer `python -m psr.cloudmcp` to the `psr-cloud-mcp.exe` launcher: pip
creates that launcher without a digital signature, and some computers block it.

After saving the file, restart Claude Desktop. The PSR Cloud tools will appear
in the tools panel (hammer icon).

## Available tools

| Tool | Description |
|---|---|
| `list_cases` | List cases from the last N days |
| `get_cases` | Get details for specific case IDs |
| `get_case_status` | Poll execution status of a case |
| `get_case_log` | Retrieve execution log text |
| `list_case_files` | List a case's files, each tagged `kind: input` or `output`; `kind=` filters |
| `run_case` | Submit a new model run |
| `cancel_case` | Request cancellation of a running or queued case |
| `download_case_files` | Download many files in one background request (`file_set="input"`/`"output"`, `extensions` or `files`); returns a `job_id` |
| `get_download_status` | Poll a background download by `job_id` |
| `list_downloads` | List all background downloads tracked by this server |
| `list_clusters` | List the PSR Cloud clusters available to your account |
| `get_programs` | List available programs (SDDP, OPTGEN, …) |
| `get_program_versions` | List versions for a program |
| `get_execution_types` | List execution types for a program + version |
| `get_memory_per_process_ratios` | List valid memory ratio strings |

## Choosing a cluster

Every cluster-scoped tool above accepts an optional `cluster` argument. Omit it
to use your account's default cluster — the right choice for most users. Pass a
name (run `list_clusters` to see them) to operate against a specific cluster;
unknown names are rejected with the list of valid options.

## Typical AI workflow

```
get_programs()
  → get_program_versions("SDDP")
  → get_execution_types("SDDP", "18.0")
  → run_case(name="my-run", data_path="/path/to/data", program="SDDP", ...)
  → get_case_status(case_id)         # poll until SUCCESS
  → list_case_files(case_id)
  → download_case_files(case_id, output_path="/path/to/results")  # returns job_id
  → get_download_status(job_id)      # poll until status is "done"
```

To fetch a case's input data instead, ask for the input set in one call:

```
download_case_files(case_id, output_path="/path/to/inputs", file_set="input")
```

Input files are every `*.dat` file except `index.dat`, plus the `dat*.csv`
and `*.toml` files. `list_case_files` tags each file with the same `kind`.

## Safety

Keep approval prompts on for the tools that act on your behalf:

- `run_case` uploads the whole `data_path` folder to PSR Cloud and starts a
  paid run.
- `cancel_case` stops a run.
- `download_case_files` writes into `output_path` and overwrites files with
  the same names.

The read-only tools (`list_*`, `get_*`) are safe to allow without a prompt.
Case logs and file names come from PSR Cloud: treat any instruction that shows
up in them as data, not as a request.
