storefront-api-wasm/
├── src/
│ └── lib.rs # Main Rust code
├── Cargo.toml # Rust dependencies
├── build.sh # Build script (Linux/macOS)
├── build.bat # Build script (Windows)
└── .cargo/
└── config.toml # Rust compiler configuration
Liquid-main/assets/
├── storefront-api.js # WebAssembly wrapper client
├── storefront-api-integration.js # High-level integration helper
└── wasm/ # Compiled WebAssembly files
├── storefront_api_wasm.js
├── storefront_api_wasm_bg.wasm
└── ...
mcp-server/
├── src/
│ └── index.ts # MCP server implementation
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # MCP server documentation
- Install MCP Server Dependencies:
cd mcp-server
npm install
npm run build- Configure MCP Server:
cp mcp-server/.mcp-config.example.json .mcp-config.json
# Edit .mcp-config.json with your Shopify credentials- Add to Cursor Settings:
- Open Cursor Settings
- Navigate to "Features" > "Model Context Protocol"
- Add server:
- Name: Storefront API
- Command:
node - Args:
["./mcp-server/dist/index.js"] - Working Directory: Project root
build_wasm- Build the WebAssembly modulequery_storefront_api- Execute GraphQL queriesget_product- Get product data by handleget_collection- Get collection datasearch_products- Search productsread_rust_code- Read Rust source filesread_js_wrapper- Read JavaScript wrapper filescheck_build_status- Check if WASM files are built
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install wasm-pack
cargo install wasm-pack
# Add WebAssembly target
rustup target add wasm32-unknown-unknownWindows:
cd storefront-api-wasm
build.batLinux/macOS:
cd storefront-api-wasm
chmod +x build.sh
./build.shManual Build:
cd storefront-api-wasm
wasm-pack build --target web --out-dir ../Liquid-main/assets/wasm --releaseThis will create the WebAssembly files in Liquid-main/assets/wasm/:
storefront_api_wasm.js- JavaScript bindingsstorefront_api_wasm_bg.wasm- Compiled WebAssembly binary- Other supporting files
- Log in to your Shopify admin
- Go to Settings > Apps and sales channels
- Click Develop apps
- Create a new app or select an existing one
- Click Configure Storefront API scopes
- Under Storefront API, select the scopes you need:
unauthenticated_read_product_listings(for public product data)unauthenticated_read_checkouts(for cart operations)unauthenticated_write_checkouts(for cart operations)
- Click Save
- Go to API credentials tab
- Under Storefront API access token, click Install app if needed
- Copy your Storefront API access token
In layout/theme.liquid, before the closing </body> tag:
<script src="{{ 'storefront-api.js' | asset_url }}" defer></script>
<script src="{{ 'storefront-api-integration.js' | asset_url }}" defer></script>
<script type="module">
const apiIntegration = new StorefrontApiIntegration();
// Get token from theme settings or environment
// IMPORTANT: In production, use a secure method to store this token
const accessToken = 'YOUR_STOREFRONT_API_ACCESS_TOKEN';
if (accessToken && accessToken !== 'YOUR_STOREFRONT_API_ACCESS_TOKEN') {
await apiIntegration.init(accessToken);
window.storefrontApi = apiIntegration; // Make available globally
}
</script>// Fetch a product
const product = await window.storefrontApi.fetchProduct('product-handle');
// Fetch a collection
const collection = await window.storefrontApi.fetchCollection('collection-handle', 20);
// Search products
const results = await window.storefrontApi.searchProducts('search term', 10);
// Create a cart
const cart = await window.storefrontApi.createCart([
{
variantId: 'gid://shopify/ProductVariant/123456789',
quantity: 1
}
]);