Skip to main content
Glama
MyArchitectAI MCP server

MyArchitectAI MCP server

Official
README.md
# MyArchitectAI MCP server

[![npm](https://img.shields.io/npm/v/@myarchitectai/mcp)](https://www.npmjs.com/package/@myarchitectai/mcp)
[![license: MIT](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)

A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server for the
[MyArchitectAI](https://www.myarchitectai.com) rendering API. It gives MCP-compatible assistants
(Claude Code, Claude Desktop, Cursor, …) tools to generate photorealistic architectural renders,
edit images, change textures and atmosphere, animate renders, generate prompts, transfer styles, create images from text, and upscale to 4K/8K — plus tools to preview, save, and track results.

## Features

**API tools** (charged in USD, except `balance`):

| Tool | What it does | Required | Optional |
| --- | --- | --- | --- |
| `render_exterior` | Photorealistic **exterior** render from a sketch, drawing, 3D screenshot, or photo | `image`, `outputFormat` | `prompt` |
| `render_interior` | Photorealistic **interior** render | `image`, `outputFormat` | `prompt` |
| `style_transfer` | Apply a reference image's style to a source image | `image`, `referenceImage`, `outputFormat` | `prompt`, `negativePrompt`, `styleTransferStrength` |
| `text_to_image` | Generate an architectural image from text | `prompt`, `outputFormat`, `outputWidth`, `outputHeight` | `negativePrompt` |
| `auto_prompt` | Describe an image as a render prompt (plain text) | `image` | — |
| `edit_by_prompt` | Apply an edit instruction | `image`, `prompt` | `referenceImage` |
| `change_textures` | Retexture masked surfaces | `image`, `mask`, exactly one of `prompt` / `referenceImage` | `outputFormat` |
| `set_atmosphere` | Change interior lighting or exterior atmosphere | `image`, `sceneType`; interior: `lighting`; exterior: at least one of `timeOfDay` / `season` / `weather` | Additional exterior controls, `outputFormat` |
| `animate` | Animate a frame or transition between frames (video URL) | `startFrameUrl`, `prompt` | `endFrameUrl`, `speed` |
| `upscale` | Upscale to 4K or 8K | `image` | `targetResolution`, `outputFormat` |
| `upscale_4k` | Legacy 4K endpoint; prefer `upscale` | `image` | `outputFormat` |
| `balance` | Read the current account balance without a charge | — | — |

**Stdio quality-of-life tools** (no API charge):

| Tool | What it does |
| --- | --- |
| `preview_image` | Fetch a URL and return the image **inline**, so the assistant (and GUI clients) can see it |
| `save_image` | Download an image URL to disk |
| `validate_image_url` | Check an input URL is a reachable image *before* a paid generation |
| `usage_summary` | Session totals: requests, USD spent, last-known balance |
| `list_recent_generations` | Recent image/video/text results, cost, balance and request IDs |

Image inputs accept a public HTTPS URL reachable by MyArchitectAI or an inline `data:image/<mime>;base64,<payload>` URI. Output formats are endpoint-specific: upscale accepts `jpg`/`webp`/`png`, but PNG is unavailable at 8K and AVIF is unsupported. Text-to-image dimensions are 128–2048px. Requests have a 10 MB body limit; prefer URLs for large inputs.

The API responds synchronously, streaming while it works. Animation typically takes 60–90 seconds, or 20–30 seconds with `speed: "fast"`; configure your MCP host's tool timeout to accommodate it. Image utilities do not preview or download videos; open the returned animation URL in a video-capable client.

The stdio server exposes **17 tools**, covering all **12 API operations** in the [published API reference](https://portal.myarchitectai.com/docs). The hosted connector exposes those **12 API operations**. [API contract maintenance](docs/API-CONTRACT.md) describes the snapshot and automated drift checks.

## Install

Local stdio installations require **Node.js 24 or newer**. Use a current patch release of a supported LTS version; CI covers Node 24 and 26. Node 18, 20 and 22 are no longer supported. Hosted connector users do not need to install Node.js.

You need a MyArchitectAI API key — create one in the [portal](https://portal.myarchitectai.com). It
is passed via the `MYARCHITECTAI_API_KEY` environment variable and sent as the `x-api-key` header.
Requests also include `x-myarchitectai-source: mcp` for reported usage attribution; this marker grants no permissions.

### Claude Code

```bash
claude mcp add myarchitectai \
  --env MYARCHITECTAI_API_KEY=your-api-key \
  -- npx -y @myarchitectai/mcp
```

### Claude Desktop

Add to `claude_desktop_config.json` (Settings → Developer → Edit Config):

```json
{
  "mcpServers": {
    "myarchitectai": {
      "command": "npx",
      "args": ["-y", "@myarchitectai/mcp"],
      "env": { "MYARCHITECTAI_API_KEY": "your-api-key" }
    }
  }
}
```

### Cursor, Windsurf, VS Code, and other MCP hosts

Use the same stdio launch — command `npx`, args `["-y", "@myarchitectai/mcp"]`, with
`MYARCHITECTAI_API_KEY` in `env` — in that host's MCP config. (Note: VS Code's config uses the key
`servers`, not `mcpServers`.)

### Claude Code plugin

For one-command setup with a bundled image-compare skill and a `/render` workflow, install the
companion plugin: **[myarchitectai-claude-plugin](https://github.com/MyArchitectAI/myarchitectai-claude-plugin)**.

```
/plugin marketplace add MyArchitectAI/myarchitectai-claude-plugin
/plugin install myarchitectai@myarchitectai
```

### Docker

A `Dockerfile` is included. Build and run the stdio server (keep stdin attached with `-i`; no port
is exposed):

```bash
docker build -t myarchitectai-mcp .
docker run -i -e MYARCHITECTAI_API_KEY=your-api-key myarchitectai-mcp
```

## Configuration

| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| `MYARCHITECTAI_API_KEY` | **yes** | — | Your API key (sent as `x-api-key`). |
| `MYARCHITECTAI_BASE_URL` | no | `https://api.myarchitectai.com/v1` | Override the API base URL. |
| `MYARCHITECTAI_TIMEOUT_MS` | no | `120000` | Total call timeout including retries, backoff and body in ms (1000–600000). |
| `MYARCHITECTAI_MAX_RETRIES` | no | `2` | Safe retries inside the total timeout, 0 disables (0–10). |
| `MYARCHITECTAI_DOWNLOAD_DIR` | no | `renders` | Directory `save_image` writes to. |
| `MYARCHITECTAI_MAX_PREVIEW_BYTES` | no | `5000000` | Max bytes `preview_image` embeds inline before falling back to a URL. |
| `MYARCHITECTAI_STATE_FILE` | no | — | Optional path to persist generation history across restarts. |

Stdio requests have a 64 MiB buffer limit, enough for the base64 representation of the largest supported inline preview (50,000,000 image bytes). For larger source images, `preview_image` and `save_image` accept a local file path or HTTPS URL. Clients requesting large inline previews must also allow the corresponding response size; otherwise keep `MYARCHITECTAI_MAX_PREVIEW_BYTES` within the client's response limit. Tool arguments are limited to 10,000 object members and array elements before schema validation. Hosted requests retain their separate 1,000,000-byte default body limit.

## Behavior

- **Success** → a text summary listing the generated image URL(s), cost, and balance, plus
  `structuredContent` of the shape `{ output: string[], balance: number, cost: number, requestId?: number }`. `auto_prompt` returns `output: string` containing text; `balance` returns only `{ balance }`. Amounts are USD. Request IDs are preserved for support.
- **API/validation errors** (bad input, invalid key, rate limits, server errors) are returned as tool results with `isError: true` and a clear message. Public safety errors include `structuredContent` with `{ error, code, balance?, cost?, requestId? }`; absent fields remain absent. API output schemas declare separate strict success and public safety alternatives, so clients can validate errors after discovering tools. Other hosted errors keep upstream details masked.
- **Content safety**: `CONTENT_POLICY_VIOLATION` returns `Request blocked by content policy`; its positive `cost` remains charged even though there is no usable output. `SAFETY_CHECK_UNAVAILABLE` returns `Content safety check unavailable` and follows the automatic refund path; `cost` becomes `0` once the refund succeeds. If the refund fails, `cost` may remain positive; trust the returned final `cost` and `balance`. Both preserve the API's `code`, `balance`, `cost` and `requestId` when provided, including streamed HTTP 200 failures. Neither triggers an automatic retry or provider fallback, even at HTTP 429/502. An unavailable check may be retried later only by an explicit caller decision.
- **Session usage**: `usage_summary.totalCost` and per-tool costs include retained positive policy charges. Successful generation totals, per-tool counts and `list_recent_generations` still include successful outputs only; rejected requests increment `failedGenerations`. With `MYARCHITECTAI_STATE_FILE`, successful history, failure count, retained charges and the last-known balance are saved together. Existing history-only files remain readable.
- **Safe retries**: direct paid operations retry ordinary HTTP 429 and 502 responses, which the API guarantees were not charged; safety codes always take precedence. Hosted paid operations are never retried automatically. Unknown outcomes (network errors, timeouts and other 5xx responses) are never automatically replayed. Read-only balance lookups can retry transient failures. Backoff, every attempt and response-body consumption share one `MYARCHITECTAI_TIMEOUT_MS` budget. Inspect the API request log before manually retrying an uncertain paid call.

API diagnostics are JSON lines on stderr; stdout remains the MCP protocol channel. Logs include endpoint, status, outcome, duration and request ID without prompts, media, keys or response bodies. No production analytics or error telemetry is sent.

## Keeping the API current

```bash
npm run build
npm run api:check        # registered tools against the reviewed snapshot
npm run api:check:live   # also compare with the current published OpenAPI
npm run api:update      # refresh snapshot; then align code and tests
```

CI checks the live contract on PRs, main pushes and manual dispatch. A spec change fails the check and requires review; runtime capabilities never change silently.

## Authentication

The stdio server authenticates to the MyArchitectAI API with an **API key** (`x-api-key`) from your environment. It also sends `x-myarchitectai-source: mcp` as a client-reported analytics marker, separate from authentication. Credential handling is isolated in `src/config.ts` and the client's header injection. The executable is `myarchitectai-mcp`; the generic `mcp` alias has been removed. Existing `npx -y @myarchitectai/mcp` configurations still select the package's single executable.

The repository also prepares an OAuth-protected stateless Streamable HTTP connector for the company's Vercel account. It verifies an audience-bound OAuth token and delegates the 12 existing API operations to the API Portal backend with a separate signed internal request. The hosted runtime uses API Portal accounts and API balance. Portal retains customer keys, ownership checks and billing. Hosted MCP has no history store, Redis, or local media utilities; stdio retains its existing tools and local history. The connector is live at `https://mcp.myarchitectai.com/mcp` (OAuth 2.0 with dynamic client registration via `portal.myarchitectai.com`). See the [integration contract](docs/REMOTE-CONNECTOR.md), [hosted runtime configuration](docs/HOSTED-RUNTIME.md), and [production deployment setup](docs/DEPLOYMENT.md). The deployment workflow is production-only; there are no preview deployments. Hosted paid calls through Portal are never automatically retried, because an intermediary error cannot prove that generation was uncharged.

## Contributing

Contributions are welcome — please open an issue or PR. The published npm package is built from this
repository.

Use the latest Node 24 LTS patch release and its bundled npm for development and release tooling. The `.nvmrc` file selects this major version for local development and workflow setup; run `nvm install` and `nvm use` after cloning if you use nvm. The container uses Node 24. Vercel currently selects Node 24 for the package's `>=24` engine range, but can select a newer major when it becomes [available on Vercel](https://vercel.com/docs/functions/runtimes/node-js/node-js-versions); this range does not pin the managed runtime. The npm package supports Node 24 or newer; CI builds and tests on Node 24 and 26.

```bash
git clone https://github.com/MyArchitectAI/myarchitectai-api-mcp.git
cd myarchitectai-api-mcp
npm install
npm run build       # compile TypeScript to dist/
npm run typecheck   # strict type-check of src + tests
npm test            # unit + integration tests (node:test)
node scripts/smoke.mjs   # spawn the built server and list its tools over stdio
npm run smoke:remote     # built HTTP server, synthetic accounts only; no API charges
```

Run `npm run build && npm run typecheck && npm test` before submitting a PR.

To point an MCP host at your **local build** instead of the published package, use the command
`node` with args `["/absolute/path/to/dist/index.js"]`.

### Project layout

```
src/
  index.ts     entry point: load config, register tools, serve over stdio
  config.ts    env loading/validation + server identity
  client.ts    HTTP client: auth, timeout, retries, response/error mapping
  errors.ts    typed error hierarchy (retryable vs not)
  schemas.ts   Zod input/output schemas (mirror the API)
  tools.ts     tool registration + result/error formatting
  media.ts     image fetch/save/preview helpers (the QoL tools)
  session.ts   in-memory (optionally persisted) generation history
test/          node:test suites (config, client, media, session, end-to-end MCP)
docs/          DISTRIBUTION.md — per-host coverage & transport notes
```

### Releasing (maintainers)

Published as [`@myarchitectai/mcp`](https://www.npmjs.com/package/@myarchitectai/mcp) via npm
[Trusted Publishing (OIDC)](https://docs.npmjs.com/trusted-publishers) — no token is stored. CI runs
build/typecheck/tests on every push and PR; pushing a `vX.Y.Z` tag triggers
`.github/workflows/release.yml`, which publishes with provenance.

```bash
npm version patch   # or minor / major — bumps package.json and creates the tag
git push --follow-tags
```

One-time setup: publish once manually (`npm publish --access public`) so the package exists, then
attach the GitHub Actions trusted publisher under the npm package's **Settings → Trusted Publisher**
(organization `MyArchitectAI`, repository `myarchitectai-api-mcp`, workflow `release.yml`).

## License

[MIT](./LICENSE) © MyArchitectAI

TDQS

A3.6/5.0

Scored across 17 tools

Disambiguation4/5

Most tools map to clearly distinct operations (interior vs exterior render, texture swap vs atmosphere, preview vs save vs validate). The one real overlap is upscale_4k versus upscale, which is mitigated by an explicit deprecation note but still leaves two tools that do the same job. The editing family (edit_by_prompt, style_transfer, change_textures, set_atmosphere) is distinguishable but requires reading descriptions carefully.

Naming Consistency3/5

All names are snake_case, but the grammatical pattern is mixed: verb_noun (render_exterior, save_image, validate_image_url), bare verbs (animate, upscale), noun_noun (style_transfer, usage_summary, text_to_image), and noun-only (balance). Readable, but there is no single predictable convention an agent can rely on to guess a tool name.

Tool Count3/5

17 tools for a broad image-generation-plus-utility surface is on the heavy side, and one of them (upscale_4k) is a deprecated duplicate of upscale that earns no place. The rest of the surface is reasonably justified by the split between paid generation tools and free inspection/cost tools.

Completeness4/5

Coverage is strong: generation (text, exterior, interior), editing (prompt, style, texture, atmosphere), upscaling, animation, plus asset inspection/saving and cost tracking. Minor gaps remain — no explicit job status/cancel for long-running animate calls, no mask-authoring helper for change_textures, and no batch operations.

Maintenance

ActivityActive
ResponsivenessNo recent community issues