Skip to content

miahcodes/pi-shopgql

Repository files navigation

pi-shopgql

A Pi extension that gives the agent direct access to the Shopify Admin GraphQL API for any store you've authed with shopify store auth.

Built originally for internal teams who needed live-store access from inside Pi sessions — partner solutions engineers, implementation specialists, and anyone who spends time inside real merchant stores while building or demoing. It's been useful enough day-to-day that it seemed worth sharing with anyone else in the Pi + Shopify ecosystem who'd benefit.

What it does

The Shopify AI Toolkit ships first-party plugins for Claude Code, Cursor, Gemini CLI, Codex, and VS Code — each gives the AI direct access to the Shopify Admin GraphQL API so the agent can query stores, create products, publish pages, edit metaobjects, and run mutations against a live store using your existing shopify store auth token.

Pi didn't have an equivalent. This extension closes that gap using the same shopify store execute primitive every first-party AI Toolkit client uses under the hood, so a Pi session against a store behaves the same way a Claude Code or Cursor session would.

Tools

Tool What it does
shopgql_status CLI version, resolved binary path, default store, alias map
shopgql_query Read-only GraphQL query against a store
shopgql_mutate WRITE mutation — requires confirm: true + a description string
shopgql_auth Emits the exact shopify store auth command for a given store

Install

Prerequisites

# Shopify CLI 3.93.0+ — needed for `shopify store execute`
pnpm add -g @shopify/cli@latest

# One-time auth per store (opens a browser)
shopify store auth --store <handle> --scopes read_products,read_content,read_metaobject_definitions,read_metaobjects,read_themes,read_customers,read_orders

For mutations, use the wider scope set the extension suggests (run shopgql_auth with write: true from inside Pi to see the exact command).

Add to Pi

pi install https://github.com/miahcodes/pi-shopgql

That's it. Pi auto-loads the extension on next session start.

To pin a version:

pi install https://github.com/miahcodes/pi-shopgql@v0.1.0

To get updates:

pi update

Why a CLI wrapper instead of a Shopify Admin MCP server

Two reasons:

  1. There's no first-party Shopify Admin MCP server. Shopify ships @shopify/dev-mcp, but it's docs + schema search only — it doesn't connect to live stores or run mutations against merchant data.
  2. Third-party Shopify Admin MCP servers exist but each requires you to create a custom app, generate a per-store access token, and paste it into env vars. They don't integrate with shopify store auth, are unaudited by Shopify, and shift token management onto you.

Wrapping shopify store execute keeps auth entirely inside the CLI. The extension never sees, parses, or caches tokens. Scope upgrades, revocation, and re-auth flows are handled by shopify store auth itself.

A nice side effect: the extension carries no Admin schema bindings, so new Admin API versions require nothing here — upgrade @shopify/cli and everything keeps working.

Safety model

  • Query tool rejects any GraphQL containing the mutation keyword.
  • Mutate tool requires both confirm: true and a human-readable description. The Pi UI renders the call in red with applies to LIVE store — no undo before execution.
  • Auth tool is inert — it prints a shopify store auth command; you run it yourself in your terminal.
  • Auth errors include a hint about the cosmetic-vs-permanent *.myshopify.com domain gotcha.

Configuration

Full reference lives in extensions/shopgql/README.md, including:

  • Env vars: SHOPIFY_DEFAULT_STORE, SHOPIFY_CLI_BIN, SHOPIFY_SHOP_ALIASES, PI_SHOPGQL_DEBUG
  • Shop alias resolution (cosmetic handle → permanent myshopify domain), with merge semantics for combining team-shared and personal alias files
  • Worked examples for each of the four tools

Development

git clone https://github.com/miahcodes/pi-shopgql
cd pi-shopgql
npm install
npm test          # vitest
npm run typecheck # tsc --noEmit

Run the extension locally without installing:

pi -e https://github.com/miahcodes/pi-shopgql

Or from a local checkout:

pi -e ./extensions/shopgql/index.ts

License

MIT © Jeremiah Abalos

Disclaimer

Personal project. Not affiliated with, endorsed by, or supported by Shopify Inc. The Shopify name and the shopify CLI are property of Shopify Inc. Use at your own discretion against your own authorized stores.

About

Pi extension for live Shopify Admin GraphQL access, wrapping the official Shopify CLI.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors