Skip to main content
Glama
scicompute

scicompute

README.md
# scicompute

scicompute is a scientific-computation server built around one
idea: a named, in-process tensor store. You create tensors under
names, then run matrix algebra and vector operations by referring
to those names. Everything is computed locally in pure TypeScript —
no network, no external math library. One binary serves a
command-line interface and a stdio MCP server.

This build is a labelled core subset of the documented tool set:
tensor storage, linear algebra, and vector operations (14 tools).
Eigen/SVD/QR decompositions, the vector-calculus tools, basis
changes, and plotting from the wider documented set are not
included; see the build report for the full omission list.

## Install

```bash
npx @reneturcios/scicompute create-tensor T 2,2 1,2,3,4
```

Or run the container image:

```bash
docker run -i ghcr.io/cloudcorprecords/scicompute
```

The container defaults to the MCP server (see below). Pass CLI
arguments to use it as a CLI instead.

## CLI

```bash
scicompute create-tensor A 2,2 4,7,2,6
scicompute view-tensor A
scicompute determinant A
scicompute --version
```

The store is in-process, so a single CLI invocation holds its
tensors only for its own lifetime; chained operations over several
tensors belong to one MCP session, where the store persists across
tool calls. Exit codes: `0` on success, `1` for a computation error
(such as a shape mismatch or a singular matrix), `2` for usage
errors.

Subcommands: `create-tensor`, `view-tensor`, `delete-tensor`,
`add`, `subtract`, `multiply`, `scale` (`--no-in-place` to leave
the stored matrix untouched), `transpose`, `determinant`, `rank`,
`inverse`, `dot`, `cross`, `project`, and `mcp`.

## MCP server

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

MCP client configuration:

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

### Tools

| Tool | Input | What it returns |
| --- | --- | --- |
| `create_tensor` | `name`, `shape`, `values` (all required) | The stored tensor: name, shape, flat values, and nested data. `values` length must equal the shape product. |
| `view_tensor` | `name` (required) | The stored tensor under that name. |
| `delete_tensor` | `name` (required) | Confirmation that the tensor was deleted. |
| `add_matrices` | `a`, `b` (required), `result` (optional) | The element-wise sum matrix; stored under `result` when given. |
| `subtract_matrices` | `a`, `b` (required), `result` (optional) | The element-wise difference matrix. |
| `multiply_matrices` | `a`, `b` (required), `result` (optional) | The matrix product. |
| `scale_matrix` | `name`, `factor` (required), `in_place` (optional) | The scaled matrix. In place by default; stored matrix is untouched when `in_place` is false. |
| `transpose` | `name` (required), `result` (optional) | The transposed matrix. |
| `determinant` | `name` (required) | The determinant of a square matrix. |
| `rank` | `name` (required) | The matrix rank, from row-echelon reduction. |
| `matrix_inverse` | `name` (required), `result` (optional) | The inverse of a square, non-singular matrix. |
| `vector_dot_product` | `a`, `b` (required) | The dot product of two stored vectors. |
| `vector_cross_product` | `a`, `b` (required) | The cross product of two stored 3-vectors. |
| `vector_project` | `a`, `b` (required) | The projection of vector `a` onto vector `b`. |

Algebra and vector operands are tensor names, not raw data.
Matrices are 2-entry shapes and vectors are 1-entry shapes; shape
mismatches, missing tensors, non-square determinant/inverse
requests, singular inverses, and projections onto the zero vector
are all errors rather than silent zeros.

## Development

```bash
npm install
npm run build   # tsc -> dist/
npm test        # node test runner over test/*.test.ts, no network
npm run dev     # run the CLI from source via tsx
```

## License

MIT — see `LICENSE`.