Skip to main content
Glama

agenthand

Reference implementation only. This Python build is the reference implementation of agenthand. It is kept public so the product can be checked against it, and it is not the shipped product. The main product is the Rust implementation: AUsernameForYou/agenthand-rust. Start there for the agenthand MCP server. This repo is for reference only.

An MCP server for AI agents that help people sell things.

The seller never opens agenthand. Their agent calls it. A seller hands their agent a messy product photo; agenthand turns it into listing-ready material through three tools, in the order a listing is produced:

Tool

What it does

draw

Places the real product, pixel-untouched, into a generated scene (a chair in a regal room, a game lot on a clean table) and returns the composite with a fidelity receipt.

cut_out

Segments the product out of its photo and returns a transparent PNG, referenced by an asset handle. The concept is optional; without one, the planning step runs internally.

identify

The planning step inside the chain: reads a photo and plans the cut, returning a structured description plus the segmentation-ready noun-phrase concept (with alternates) that cut_out consumes.

Fidelity Lock

draw never regenerates the product. The invariant, enforced in code:

  1. Segmentation extracts the real product foreground and its mask.

  2. The product layer is stored untouched, with hashes recorded for the source, the foreground, and the mask: both the file-byte hash and the decoded-pixel hash of each.

  3. The image model generates ONLY the background scene plate. Its interface takes a prompt and dimensions, never product pixels.

  4. Deterministic code composites the original product layer onto that plate. The plate is resized and cropped to the product's dimensions; the product layer is never scaled.

  5. draw refuses anything that is not a foreground_png asset chained back to a source photo, and verifies the stored hashes before a single pixel moves.

  6. The result ships with a fidelity receipt: source, foreground, and mask hashes, the delivered file's own hashes, the transformations applied, the measured count of changed opaque foreground pixels, the model calls made, and their cost. The receipt also publishes what the count excluded: the edge-band pixel count and its maximum width, the opaque share of the mask, the exact changed-pixel predicate with tolerance 0, and the colour-profile identity of the source photo and the composite (a dropped or changed ICC profile recolours the product while pixel values stay identical, so it is recorded and counted as a fidelity failure).

The claim is precise: the stored extracted foreground reached the composite unchanged, and its hashes pin exactly which layer that was. Edge-band pixels (partially transparent) blend with the plate during compositing; the receipt counts them separately instead of overclaiming. The receipt's counts are measured on the delivered file, decoded back from the store, and can be re-derived independently: composite.verify_receipt_from_disk recounts from the stored files, checks the receipt's own hashes against the assets it names, and passes only on exactly zero changed pixels with real coverage; the standalone agenthand-verify SOURCE FINAL MASK checker verifies exported files with no store at all and likewise refuses a mask that selects nothing. Ingest accepts the formats phones produce, including HEIC, and preserves each photo's embedded colour profile end to end.

A bounded mask-recovery loop guards cut_out: the mask is quality-checked, and on a poor mask the tool retries once with an alternate concept phrase from the planning step. Every attempt is traced in the receipt.

Related MCP server: SuperCMO Skills

Asset handles

Tools never pass image bytes back and forth. Every image is stored locally (with a per-asset sidecar record, written atomically) and referenced as asset://<id>. Handles chain between tools: identify reads one, cut_out returns a new one, draw consumes it.

Photos get in through ingest: a tool's image argument may be an existing handle, an http(s) URL, or a base64 data URI. Ingest caps the byte and pixel size, applies EXIF orientation, and normalizes to 8-bit RGBA PNG. Images get out two ways: draw returns an image preview with its result, and every asset is readable by the client as the MCP resource at its own asset://<id> URI.

Cost receipts and the spend cap

Every billable call flows through one choke point (src/agenthand/meta_client.py) using reserve-then-settle accounting: under a file lock, the projected worst-case cost is checked against the ledger and reserved as a pending receipt; after the call, a settlement receipt records the actual cost priced from the provider's usage counts. If a call fails after it may have billed, the reservation stays counted. A call whose provider response carries no usable usage settles at its reserved projection rather than $0: missing usage never erases spend. Receipts land in a local JSONL ledger with tool, model, token and image counts, USD estimate, and the pricing-table version used. Prices live in one module (src/agenthand/pricing.py) so a price change is a one-line edit with a version bump; an unpriced model raises rather than estimating as $0. Every spend path shares the one ledger — the dry-run gate included (its asset store is isolated in a temp dir, its ledger is not).

The server is fail-closed on spend. The working cap defaults to $120.00; configuration may move it up or down but never past the hard ceiling of $150.00 (the hackathon credit amount), which no configuration can exceed. Corrupt, negative, or non-finite ledger entries refuse all spend: unknown spend state means no spend.

Status

Hackathon build (Meta Global AI Developer Hackathon, Oct 26 - Nov 4, 2026). All three tools are wired to the real Meta Model API through the spend-cap billing choke point — identify to muse-spark-1.3, cut_out to sam-3.1, draw to muse-image-1.0 — and the full chain has run live end to end. The verified run of 2026-10-26 (identify $0.007544, cut_out $0.0025, draw $0.01; 580,613 opaque pixels checked, 0 changed) is published with its fidelity receipt on the project site, where the same check can be re-run in the browser against the run's own files. The placeholder plate survives only behind an explicit dev flag for offline tests. Today the server runs locally over stdio; a hosted endpoint comes later.

The server also exists as a single-binary Rust build. It passed a parity gate against the frozen files of the verified run above, reproducing the run's counts and its output pixel hash, and a live run from the Rust binary was cross-checked by the Python verifier. The Python implementation remains the reference; the Rust build is a second implementation of the same server, and the two agree.

Run it

Register agenthand with any MCP client. The primary route uses uv: nothing to install ahead of time, uv fetches the published package and runs it.

{
  "mcpServers": {
    "agenthand": {
      "command": "uvx",
      "args": ["agenthand"],
      "env": { "META_API_KEY": "…" }
    }
  }
}

Or install the package with pip and point the client at the installed command:

pip install agenthand
{
  "mcpServers": {
    "agenthand": {
      "command": "agenthand",
      "env": { "META_API_KEY": "…" }
    }
  }
}

The server starts and lists its tools without a key; the key is only needed when a tool makes a model call. Configuration is by environment variable; see .env.example.

From source (dev)

git clone https://github.com/AUsernameForYou/agenthand
cd agenthand
python3.12 -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/agenthand          # stdio transport
.venv/bin/pytest             # unit tests

License

Source-available under the PolyForm Noncommercial License 1.0.0 (polyformproject.org/licenses/noncommercial/1.0.0). © Daniel Wagner. Noncommercial use is permitted under the license terms; commercial use requires a separate license from the copyright holder.

Available Tools

3 tools
cut_outA

Cut the product out of its photo as a transparent PNG.

Args: image: The product photo — an asset handle (asset://), an http(s) URL, or a base64 data URI. It is ingested and normalized first. concept: Optional noun-phrase concept naming what to segment ("brown leather wallet"). When omitted, the identify planning step runs internally to produce the concept and alternates.

Calls SAM 3.1 with the concept phrase and decodes the returned mask (Meta's official parser, behind the sam_masks boundary). The mask is quality-checked — coverage sane (not empty, not ~the whole frame) and dominated by one connected region — and on a zero-match or a poor mask, all fixed identify phrases are evaluated and bounded phrase; every attempt is traced in the result. The foreground is the source pixels through the accepted mask, nothing regenerated. Storage is a lineage chain — mask parented to the source photo, foreground parented to the mask — so draw's fidelity receipt pins the exact mask asset the cut used. The input must be a source photo: handing cut_out a generated asset (a composite, a plate) is refused with NOT_A_SOURCE_PHOTO before any billing, because cutting generated pixels out would launder them into a protected foreground. Because a fidelity receipt can only vouch for the pixels a mask selected, the result also carries the selection's own review surface: mask_overlay_asset (the source photo with the mask's outline drawn on it) and mask_review (the mask's bounding box, fill, frame-edge contact, and any sanity warnings).

Failures return a structured error: NOT_CONFIGURED (no META_API_KEY; checked before billing, so no ledger write), NO_MATCH / POOR_MASK (no usable mask after the bounded attempts; the attempts' spend stays counted), BAD_MODEL_RESPONSE (SAM output unusable; spend counted). A planning failure inside the chain (concept omitted and identify failed) surfaces as that step's error code with plan_error attached.

Inputs: image (required), concept.

drawA

Stage the real product into a generated scene. Fidelity Lock applies.

Args: asset: Asset handle (asset://) of the cut-out product layer produced by cut_out (kind foreground_png, chained to a source photo). Anything else is refused before any billing. scene_prompt: Scene preferences compiled into a versioned StageSpec. Only studio, concrete and warm selections are recognized; unmatched prose is dropped. The result discloses the compiled stage_spec and this limitation. Arbitrary rooms and source-camera matching are not supported by the fixed template. The scene text describes the environment only and must never name the product: before any spend it is screened against the cut concept (the scene guard, recorded on the receipt as scene_guard), and a prompt naming the product is refused with SCENE_NAMES_PRODUCT, because naming it makes the image model paint its own copy of the product into the scene.

The background plate is generated by muse-image-1.0 (billed through the spend-cap choke point at the per-image rate) and stored as a background_plate asset; deterministic code then fits the PLATE to the product's dimensions and composites the stored product layer onto it. The product layer is never regenerated, restyled, scaled, or "improved" by a model, and it is never sent to the image model. Returns the composite's asset handle, its fidelity receipt (source / foreground / mask / plate hashes, transformations, the measured changed-opaque-pixel count), and an image preview. The receipt is also persisted beside the composite in the asset store as <asset_id>.receipt.json, enriched with the billed cost and call attribution, so it survives a client dropping the return value and verify_receipt_from_disk can pick it up from the store alone. If the compositor ever measured changed opaque pixels, the tool returns a FIDELITY_VIOLATION error instead of presenting the composite under a false receipt.

Failures return a structured error: NOT_CONFIGURED (no META_API_KEY; checked before billing, so no ledger write), IMAGE_REFUSED / BAD_IMAGE_RESPONSE / IMAGE_CALL_FAILED (the plate call failed; its reservation stays counted as spend). A failed draw never falls back to regenerating the product, and in live mode it never silently substitutes the placeholder plate. Measurable plate rejection retries once; a horizon-placement mismatch goes straight to a disclosed studio-gray fallback without buying an identical second attempt.

Offline dev mode: with AGENTHAND_DRAW_PLACEHOLDER_PLATE=1 the plate is the deterministic local placeholder and no API call is made. That flag exists for tests and no-key demos only.

Inputs: asset (required), scene_prompt (required). Returns: result

identifyA

Plan the cut for a product photo (step inside the listing chain).

Args: image: The product photo — an asset handle (asset://), an http(s) URL, or a base64 data URI. It is ingested and normalized first.

Reads the photo with the vision model and returns the plan the chain consumes: a structured description, the noun-phrase concept suitable for text-prompted segmentation ("brown leather wallet") with at least two alternate phrasings the mask-recovery loop can retry with, plus listing copy (suggested_title, listing_bullets, condition_notes). When phrase hygiene had to change the model's own concept (a frame/medium phrase rewritten or promoted over), concept_rewritten_from names the phrase the model actually returned; it is None when the concept passed through intact. The call is billed through the spend-cap choke point and the result carries its actual cost and token usage.

Without META_API_KEY configured the tool returns a structured NOT_CONFIGURED error and makes no call (and no ledger entry). This tool exists to serve the chain; the sellable outputs are cut_out's transparent PNG and draw's staged composite with its fidelity receipt.

Inputs: image (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 3 tools

    Disambiguation4/5

    The three tools target distinct stages: identify plans/describes, cut_out segments to a transparent PNG, and draw stages the cut-out into a scene with a fidelity receipt. The main overlap is that cut_out can internally run identify when concept is omitted, so an agent may be unsure whether to call identify first, but the descriptions explicitly frame identify as a chain-serving step and name cut_out/draw as the sellable outputs.

    Naming Consistency4/5

    All names are lowercase imperative verbs (identify, cut_out, draw), which is a coherent verb-led convention. The only deviation is that cut_out is a verb-particle form while the others are single verbs, and 'draw' is a somewhat generic label for scene staging, but the set remains predictable and readable.

    Tool Count4/5

    Three tools map cleanly onto the photo-to-listing pipeline (identify -> cut_out -> draw), so each earns its place and the surface is well-scoped rather than bloated. identify is arguably an internal planning step that could be folded into cut_out, making the exposed surface slightly thinner than ideal.

    Completeness3/5

    The core lifecycle is covered end to end: plan the product, cut it out, and stage it with a fidelity receipt. However, draw references verify_receipt_from_disk as a way to recover receipts from the store, yet no such tool is exposed, and there is no tool for retrieving or listing assets, leaving notable gaps and a dead end for receipt verification.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to produce video commercials from product descriptions via a multi-stage pipeline with human-in-the-loop approval gates and explicit spend authorization.
      6
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Open-source skills that empower any AI agent (Claude, Cursor, Codex, Hermes, etc.) to generate end-to-end marketing campaigns — UGC videos, ad videos, product photography and more. From a product photo and a brief it casts AI actors, picks the best models, and edits finished assets of any length with consistent actor and product. It also researches competitors, publishes, and reviews performance.
      22
      103 npm
      337
      Apache 2.0
    • A
      license
      B
      quality
      C
      maintenance
      Enables AI agents to automatically discover, extract, and retrieve verified high-resolution product images and product links from e-commerce sites via a universal extraction pipeline with pluggable search backends, caching, and CDN-aware upscaling.
      4
      MIT