pagliacci-mcp
by sslivins
README.md
# pagliacci
A Python client and [MCP](https://modelcontextprotocol.io) server for the
Pagliacci Pizza ordering API. As of v0.8.0 the MCP server can place real
orders end-to-end via `place_order(confirm=True)` — the cart is verified,
priced, and submitted using a saved card. The default (`confirm=False`)
remains quote-only. See [`docs/api-recon.md`](docs/api-recon.md) for the
API surface this package exposes.
## Install
Wheels are attached to each [GitHub release](https://github.com/sslivins/pagliacci-mcp/releases):
```sh
# library only (pin a release)
pip install https://github.com/sslivins/pagliacci-mcp/releases/download/v0.8.1/pagliacci-0.8.1-py3-none-any.whl
# or from git, library + MCP server
pip install "pagliacci[mcp] @ git+https://github.com/sslivins/pagliacci-mcp.git"
```
Requires Python ≥ 3.11.
## Quickstart (library)
```python
from pagliacci.client import Client
from pagliacci.menu import get_menu
from pagliacci.models import OrderLine, Side
from pagliacci.pricing import price_order
with Client.login("you@example.com", "...", store_id=381) as client:
menu = get_menu(client)
# Find the Pizza category and grab the first 8" item.
pizza = next(c for c in menu.Categories if c.Name == "Pizza")
item = pizza.Items[0]
size = pizza.Sizes[0]
# Quote a single-item carryout cart. Empty Toppings = recipe defaults.
line = OrderLine(
Pos=0, Qty=1, Cat=pizza.ID, Size=size.ID,
Side1=Side(MenuItem=item.ID, Toppings=[]),
)
quote = price_order(client, [line])
print(quote.Total)
```
Quoting never places an order. Submitting is a separate, explicit step — see
`pagliacci.submit` (`verify_order` / `submit_order`) and the MCP `place_order` tool.
For human-friendly construction (resolve names → IDs, add/extra/remove toppings),
use `pagliacci.builder.build_pizza()`:
```python
from pagliacci.builder import build_pizza
from pagliacci.menu import get_menu
from pagliacci.pricing import price_order
with Client.login("you@example.com", "...", store_id=381) as client:
menu = get_menu(client)
line = build_pizza(menu, item="Original Cheese", size='13"',
add=["Mushrooms"], extra=["Pepperoni"])
print(price_order(client, [line]).Total)
```
For half-and-half pizzas, use `build_half_and_half()` — both sides must be from a
`TwoSides=True` category (currently only Pizza qualifies):
```python
from pagliacci.builder import build_half_and_half
with Client.login("you@example.com", "...", store_id=381) as client:
menu = get_menu(client)
line = build_half_and_half(
menu,
side1_item="Original Cheese", side1_add=["Pepperoni"],
side2_item="Brooklyn Bridge",
size='17"',
)
print(price_order(client, [line]).Total)
```
## Quickstart (MCP server)
The MCP server is the intended consumer. Read/price-only tools:
| Tool | What it does |
| --- | --- |
| `get_my_account` | Sanity check — returns your customer/store/base-url. |
| `list_categories` | Top-level menu sections. |
| `list_items` | Directory of all categories (no arg) or items in one category with prices. |
| `find_pizzas` | Filter pizza-shaped items by `seasonal` / `vegan` / `vegetarian`. |
| `get_pizza_details` | Sizes, default recipe, available toppings, prices. |
| `get_item_details` | Generic version of `get_pizza_details` — works for cookies, gelato, beverages, etc. |
| `build_pizza` | Assemble one whole-pizza cart line from human-friendly names. |
| `build_half_and_half` | Assemble one two-half pizza cart line. |
| `price_cart` | Quote a pre-built cart (carryout or delivery). For delivery, pass a `delivery_building` ID from `list_my_buildings`. Pass `scheduled_for="YYYY-MM-DDTHH:MM:00"` (a slot string from `list_time_windows`) for a future-time order; omit for ASAP. |
| `place_order` | Verify-then-submit a real order. With default `confirm=False` it validates the payment method, prices the cart, runs server-side verify, and returns a quote + payment summary — **no charge**. With `confirm=True` it re-verifies and submits via `POST /api/OrderSend`. Defaults to the customer's primary card; pass `payment_method_id` from `list_my_payment_methods` to choose a specific card. Cards with `needs_ccv=true` are refused. Accepts `scheduled_for`, `tip`, `delivery_instructions`, `alt_phone`. |
| `list_my_payment_methods` | Saved credit cards (read-only). Returns `payment_method_id`, brand, last-four, eligibility flags, and a `usable_via_mcp` flag (false when CVV re-entry is required). PAN/token never exposed. |
| `get_my_profile` | Customer profile: name, email, phone, last-used building/store, lifetime order count. Used by `place_order` to default the contact phone. |
| `list_stores` | All Pagliacci locations. |
| `find_stores` | Filter the store directory by zip / city / state / name. |
| `list_orders` | Past orders for the signed-in customer (1-indexed pagination). |
| `list_my_buildings` | Saved delivery addresses for the signed-in customer (with the `building_id` for `price_cart`). |
| `check_delivery_address` | Geocode a street address; returns the `building_id` Pagliacci would assign. No side effects. |
| `add_building` | Save a new delivery address to the address book. Geocodes + names in one call. |
| `update_building` | Rename a saved address, change its delivery instructions, or set/unset its `primary` flag. (Street/city/zip are not editable — delete and re-add to fix those.) |
| `delete_building` | Remove a saved address by `building_id`. |
| `list_time_windows` | Open delivery / pickup slots for a given store (or building) on a given date (defaults to today). Returns `windows[]` of `{slot, label}`; pass the `slot` string back as `scheduled_for`. When the day is closed, returns `windows: []` plus a `next_available_date` hint. |
There is **no** `add_payment_method` / `add_card` / `set_billing_*`
tool, and there never will be: adding a card requires the raw PAN +
CVV to flow through the conversation, which would persist them in
chat logs forever. Add cards on pagliacci.com instead.
`place_order(confirm=True)` is the only mutating, money-moving tool.
The two-call quote-then-confirm flow is a convention enforced via the
docstring + system prompt, not a server-side interlock — a misbehaving
LLM could bypass it in one shot. Treat `confirm=True` as a forcing
function for explicit user consent.
### Configuring the GitHub Copilot CLI
Add a minimal entry to `~/.copilot/mcp-config.json` (no env block needed if
credentials are in the OS keyring):
```json
{
"mcpServers": {
"pagliacci": {
"command": "pagliacci-mcp"
}
}
}
```
### Credentials
As of v0.3.2, the server resolves email and password through the
`pagliacci.mcp.credentials.get_credential` helper, which checks the env var
first and falls back to the OS keyring (`keyring` package). The store_id is
auto-detected from the most-frequent store in your order history on first use,
so `PAGLIACCI_STORE_ID` is no longer needed (and is ignored).
**Desktop / Windows / macOS / Linux GUI session** — use the keyring:
```sh
python -m keyring set pagliacci-mcp email
python -m keyring set pagliacci-mcp password
```
The service name is `pagliacci-mcp` and the username is the literal string
`email` or `password` (the helper stores both under that single service).
**Headless / Raspberry Pi / systemd** — there's no keyring daemon, so use env
vars via a systemd `EnvironmentFile=` (mode `0600`, owned by the service user):
```ini
# /etc/pagliacci-mcp.env (chmod 0600)
PAGLIACCI_EMAIL=you@example.com
PAGLIACCI_PASSWORD=your-password
```
```ini
# /etc/systemd/system/pagliacci-mcp.service
[Service]
EnvironmentFile=/etc/pagliacci-mcp.env
ExecStart=/usr/local/bin/pagliacci-mcp
```
The library never logs credentials and never writes them to disk on its own.
### Optional environment variables
| Variable | Default | Notes |
| --- | --- | --- |
| `PAGLIACCI_EMAIL` | *(keyring)* | Account email. Env wins over keyring. |
| `PAGLIACCI_PASSWORD` | *(keyring)* | Account password. Env wins over keyring. |
| `PAGLIACCI_RATE_LIMIT_HZ` | `1.0` | Soft cap on outbound requests per second. |
| `PAGLIACCI_LOG_LEVEL` | `INFO` | Standard `logging` level name. |
## Live smoke test
A read-only end-to-end smoke test lives at `scripts/smoke_live.py`. It is gated
behind `PAGLIACCI_LIVE=1` so it cannot run by accident or in CI. It hits
`MenuCache` and a single `OrderPrice` quote — nothing is submitted, no card is
charged, your existing PAGCART is not touched.
```powershell
$env:PAGLIACCI_LIVE = "1"
$env:PAGLIACCI_EMAIL = "you@example.com"
$env:PAGLIACCI_PASSWORD = "..."
python scripts\smoke_live.py
```
## Development
```sh
git clone https://github.com/sslivins/pagliacci-mcp.git
cd pagliacci-mcp
python -m venv .venv
.\.venv\Scripts\pip install -e .[mcp,dev]
.\.venv\Scripts\pytest
```
## Status
**v0.8** — full quote → verify → submit flow exposed via
`place_order`. Adds `list_my_payment_methods` and `get_my_profile` MCP
tools. Idempotency guard via cart fingerprint + `OrderListPending`
dedup (60s window). See [`docs/api-recon.md`](docs/api-recon.md) for
the live wire format.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues