# Workspace & Store Setup

> Initialize session context by resolving workspace identity and connecting to Shopify

Canonical URL: https://fa7e86e3d553:3005/tools/workspace-setup

Use `lexsis_workspace` to resolve workspace identity and connected Shopify
stores. Call action `list` first. Automatic workspace selection is allowed
only when exactly one active workspace is available.

---

## List authorized workspaces

Resolve workspace IDs and names selected in the current OAuth grant. Call this
first when the session does not already have a workspace selection.

### Parameters

No parameters are required. The MCP returns only workspaces authorized during
browser consent and still available to the signed-in user.

### Returns

Array of workspaces:

```json
[
  {
    "id": "uuid",
    "name": "Brand Name",
    "status": "active"
  }
]
```

### Example

**Tool call:**
```json
{
  "name": "lexsis_workspace",
  "arguments": {
    "action": "list",
    "args": {}
  }
}
```

**Response:**
```json
[
  {
    "id": "3c4e5f6a-7b8c-9d0e-1f2a-3b4c5d6e7f8a",
    "name": "Resolv Naturals",
    "status": "active"
  }
]
```

### When to Use

- Call when the session has not already resolved `workspace_id`
- Store the returned `workspace_id` and pass it to subsequent tools
- If multiple workspaces returned, ask the user which one to use

---

## get_workspace_details

Load full workspace context — brand URL, vertical, region, membership info. Use when you need industry context for page generation.

### Parameters

| Param | Type | Required | Description |
|-------|------|----------|-------------|
| `workspace_id` | `string` (UUID) | Yes | Workspace UUID from `lexsis_workspace` action `list` |

### Returns

Full workspace object with brand metadata:

```json
{
  "id": "uuid",
  "name": "Brand Name",
  "brand_url": "https://brand.com",
  "vertical": "skincare",
  "region": "North America",
  "membership": { ... }
}
```

### Example

**Tool call:**
```json
{
  "name": "lexsis_workspace",
  "arguments": {
    "action": "get",
    "args": {
      "workspace_id": "3c4e5f6a-7b8c-9d0e-1f2a-3b4c5d6e7f8a"
    }
  }
}
```

**Response:**
```json
{
  "id": "3c4e5f6a-7b8c-9d0e-1f2a-3b4c5d6e7f8a",
  "name": "Resolv Naturals",
  "brand_url": "https://resolvnaturals.com",
  "vertical": "skincare",
  "region": "North America",
  "created_at": "2025-01-15T10:30:00Z"
}
```

### When to Use

- Before generating pages — understand the brand's vertical for industry-appropriate content
- To fetch the brand URL for design source extraction
- When generating copy that should reference the brand's region or market

---

## get_connected_stores

Fetch connected Shopify stores — returns an array of store objects with store ID, shop domain, and plan. Auto-provisions if none exists.

### Parameters

Pass `workspace_id` when the account has multiple workspaces.

### Returns

Array of store objects with Shopify connection details:

```json
[
  {
    "store_id": "7f8a9b0c-1d2e-3f4a-5b6c-7d8e9f0a1b2c",
    "shop_domain": "resolvnaturals.myshopify.com",
    "plan": "shopify_plus",
    "connected_at": "2025-02-01T14:20:00Z"
  }
]
```

### Example

**Tool call:**
```json
{
  "name": "lexsis_workspace",
  "arguments": {
    "action": "stores",
    "args": {
      "workspace_id": "3c4e5f6a-7b8c-9d0e-1f2a-3b4c5d6e7f8a"
    }
  }
}
```

**Response (single store):**
```json
[
  {
    "store_id": "7f8a9b0c-1d2e-3f4a-5b6c-7d8e9f0a1b2c",
    "shop_domain": "resolvnaturals.myshopify.com",
    "plan": "shopify_plus",
    "connected_at": "2025-02-01T14:20:00Z"
  }
]
```

**Response (multi-store):**
```json
[
  {
    "store_id": "7f8a9b0c-...",
    "shop_domain": "brand-us.myshopify.com",
    "plan": "shopify_plus"
  },
  {
    "store_id": "a2b3c4d5-...",
    "shop_domain": "brand-eu.myshopify.com",
    "plan": "shopify"
  }
]
```

### Multi-Store

When the response contains more than one store, you must select the target store and pass its `store_id` to downstream tools (page management, publish, cart). Single-store accounts can omit `store_id` — it resolves automatically.

### When to Use

- Before publishing pages — confirms a store exists
- To get the `shop_domain` for linking to Shopify admin
- Needed before calling product lookup tools (`list_products`, `get_product`)
- If multiple stores returned, pass `store_id` to page and publish tools to target the correct store

---

## Workflow: Session Initialization

```
1. lexsis_workspace → list
   → Get workspace_id (e.g. "3c4e5f6a-...")

2. lexsis_workspace → get({ workspace_id })
   → Load brand context (vertical, region, URL)

3. lexsis_workspace → stores({ workspace_id })
   → Get store(s); auto-provisions if none exists
   → If multiple: select target store_id

4. Proceed with page generation tools
   → Pass store_id to publish/edit tools if multi-store
```

All subsequent tools need the `workspace_id` from step 1. Store it in your session state.
