list_locations
Retrieve all store locations—warehouses, retail stores, or drop-ship partners—with their names, active status, city, country, and GID needed for inventory and fulfillment operations.
Instructions
List the store's locations — physical or virtual places where inventory is stocked or fulfilled from (warehouses, retail stores, drop-ship partners). Returns each location's name, active/inactive flag, city + country, and GID. The location GID is required by set_inventory_quantity and create_fulfillment. Inactive locations still exist but cannot accept new inventory or fulfillments.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| first | No | Page size (1-100). Most stores have under a dozen locations. |
Implementation Reference
- src/tools/inventory.ts:17-25 (helper)GraphQL query that fetches locations (id, name, isActive, address.city, address.countryCode) with pagination via $first
const LIST_LOCATIONS_QUERY = /* GraphQL */ ` query ListLocations($first: Int!) { locations(first: $first) { edges { node { id name isActive address { city countryCode } } } } } `; - src/tools/inventory.ts:53-61 (schema)Zod schema for list_locations input: optional 'first' number (1-100, default 20) for page size
const listLocationsSchema = { first: z .number() .int() .min(1) .max(100) .default(20) .describe("Page size (1-100). Most stores have under a dozen locations."), }; - src/tools/inventory.ts:107-135 (handler)The 'list_locations' tool handler: executes GraphQL query, parses locations, returns formatted list with name, active/inactive status, city, country, and GID
server.tool( "list_locations", "List the store's locations — physical or virtual places where inventory is stocked or fulfilled from (warehouses, retail stores, drop-ship partners). Returns each location's name, active/inactive flag, city + country, and GID. The location GID is required by set_inventory_quantity and create_fulfillment. Inactive locations still exist but cannot accept new inventory or fulfillments.", listLocationsSchema, async (args) => { const data = await client.graphql<{ locations: { edges: Array<{ node: { id: string; name: string; isActive: boolean; address?: { city?: string | null; countryCode?: string | null }; }; }>; }; }>(LIST_LOCATIONS_QUERY, { first: args.first }); const lines = [ `Found ${data.locations.edges.length} location(s):`, ...data.locations.edges.map(({ node }) => { const city = node.address?.city ?? "?"; const country = node.address?.countryCode ?? "?"; const active = node.isActive ? "active" : "inactive"; return ` ${node.name} (${active}) — ${city}, ${country} — ${node.id}`; }), ]; return { content: [{ type: "text" as const, text: lines.join("\n") }] }; }, ); - src/server.ts:15-15 (registration)Import of registerInventoryTools from inventory module (which registers list_locations)
import { registerInventoryTools } from "./tools/inventory.js"; - src/server.ts:59-59 (registration)Registration call: registerInventoryTools(s, shopify) invoked when building the MCP server
registerInventoryTools(s, shopify);