# Orders with the MetaEngine MCP server

Use the Orders OpenAPI spec to generate a TypeScript Fetch client or use the Order model recipe to generate a standalone TypeScript interface. Both inputs are synthetic.

## Install

Download and extract the archive. Run the commands from its root with Node.js 22 or later and npm. `npm ci` installs the pinned `@metaengine/mcp-server` 1.6.1 and MCP client. The replay script starts the installed server over stdio. The hosted service requires no API key.

[Download the Orders MCP examples](https://www.metaengine.eu/examples/in-your-repository/v1/mcp/orders-mcp.zip)

```sh
npm ci
```

## Orders OpenAPI client

Run each revision in its own fresh output directory. The script reads `orders/v1/openapi.json` or `orders/v2/openapi.json` verbatim and calls `generate_openapi` with the contents as `openApiSpec`, `framework: "typescript-fetch"`, and the chosen `outputPath`.

```sh
npm run replay -- openapi-v1 ./generated/orders-v1
npm run replay -- openapi-v2 ./generated/orders-v2
```

Both runs write `models/order.ts` and `services/orders.service.ts`. In v1, the service exports `getOrder(apiClient, id)`. In v2, `getOrder(apiClient, id, region)` requires a `region` query parameter. Use new directories such as `./generated/orders-v1-repeat` and `./generated/orders-v2-repeat` each time you replay the revisions.

## Order model recipe

The `recipeVersion: 1` JSON recipe defines a TypeScript interface named `Order` with an `id: string` field. The script calls `generate_from_recipe` with `recipeFilePath` and `outputPath`. It writes `models/order.ts`. This model is shared by both Orders API revisions. [Download the versioned Order recipe](https://www.metaengine.eu/examples/in-your-repository/v1/mcp/order-model.v1.recipe.json)

```sh
npm run replay -- order-model ./generated/order-model
npm run replay -- order-model ./generated/order-model-repeat
```

Both tools default to `skipExisting: true`. A replay into a previously used directory still calls the API and skips each path that already exists. Use a fresh folder to inspect all of the returned files together.

## Verify the files

```sh
npm run verify -- ./generated/orders-v1 ./generated/orders-v2 ./generated/order-model
```

This local check looks for each generated client, the `getOrder` signature for each revision, v2's query serialization, and the standalone `Order` interface.

## What goes to the hosted API

- `generate_openapi` sends the inline OpenAPI spec and supplied converter settings to `https://api.metaengine.eu/api/openapi/typescript-fetch` for client generation.
- `generate_from_recipe` reads, validates, and expands the recipe on your machine. The resulting TypeScript type graph goes to `https://api.metaengine.eu/api/mcp/generate` for model generation.

The server uses the output directory and recipe path locally. It sends its package version in the `X-MCP-Version` header and writes the returned source files locally. Invalid recipes fail during local validation before any generation request or generated-file write. [MCP privacy policy](https://github.com/meta-engine/mcp-server/blob/main/PRIVACY.md)

## Recorded live replay

On 26 November 2026 from 23:33 to 23:35 UTC, the installed MCP package 1.6.1 ran against the two hosted endpoints above. The public responses exposed no hosted engine build identifier. The npm pin identifies the local MCP server.

Each OpenAPI revision generated four files. The recipe generated one file. Fresh repeats produced identical output trees. Reusing the model output reported zero files written and one skipped. A malformed recipe returned a local `invalid JSON` error, with zero HTTP requests and the earlier model output intact.

The examples are MIT-licensed. See `LICENSE` in the archive.
