@atlas-kitchen/atlas-mcp 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example CHANGED
@@ -1,8 +1,12 @@
1
+ # Atlas API key (required for automatic authentication)
2
+ ATLAS_API_KEY=your-api-key-here
3
+
1
4
  # Atlas GraphQL base URL (production by default)
2
- ATLAS_GRAPHQL_ENDPOINT=https://atlas-api.food.wearelion.com
5
+ ATLAS_GRAPHQL_ENDPOINT=https://api.atlas.kitchen
3
6
 
4
7
  # Client identification headers
5
8
  ATLAS_CLIENT_NAME=atlas-mcp-1.0.0
6
9
 
7
- # Optional: Override default Atlas endpoint for development
8
- # ATLAS_GRAPHQL_ENDPOINT=http://localhost:3000
10
+ # Optional: Set default merchant context on first run
11
+ # ATLAS_MERCHANT_ID=1
12
+ # ATLAS_OUTLET_ID=1
package/CLAUDE.md CHANGED
@@ -2,19 +2,19 @@
2
2
 
3
3
  This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
4
 
5
- ## Project Overview
5
+ ## Project overview
6
6
 
7
7
  Atlas MCP Server - A Model Context Protocol (MCP) server that provides integration with the Atlas restaurant management system's GraphQL API. This server enables Claude to interact with restaurant orders, menus, sales reports, and other restaurant management features.
8
8
 
9
- ## Development Commands
9
+ ## Development commands
10
10
 
11
11
  ### Setup
12
12
  ```bash
13
13
  npm install
14
- cp .env.example .env # Configure with your Atlas credentials
14
+ cp .env.example .env # Configure with your Atlas API key
15
15
  ```
16
16
 
17
- ### Build & Run
17
+ ### Build & run
18
18
  ```bash
19
19
  npm run build # Compile TypeScript to dist/
20
20
  npm run dev # Run source directly with tsx (development)
@@ -23,113 +23,122 @@ npm start # Run compiled JavaScript (production)
23
23
 
24
24
  ### Requirements
25
25
  - Node.js >= 18.0.0 (required for native fetch and Headers APIs)
26
- - Environment variables configured in .env file
26
+ - `ATLAS_API_KEY` environment variable (required for authentication)
27
27
 
28
28
  ## Architecture
29
29
 
30
- ### Core Structure
30
+ ### Core structure
31
31
  ```
32
32
  src/
33
- ├── index.ts # MCP server setup and tool registration
34
- ├── auth.ts # Authentication state manager (JWT tokens)
35
- ├── client.ts # GraphQL client wrapper with auth handling
36
- ├── types/ # TypeScript type definitions
37
- └── tools/ # MCP tool implementations by domain
33
+ ├── index.ts # MCP server setup, auto-auth startup, tool registration
34
+ ├── auth.ts # Authentication state manager (JWT tokens, merchant context)
35
+ ├── client.ts # GraphQL client with auth retry and API key login
36
+ ├── token-cache.ts # Token + context persistence to ~/.atlas-mcp/cache.json
37
+ ├── types/ # TypeScript type definitions
38
+ └── tools/ # MCP tool implementations by domain
38
39
  ```
39
40
 
40
- ### Key Components
41
+ ### Key components
41
42
 
42
43
  1. **Authentication Manager** (auth.ts)
43
44
  - Stateful JWT token management
44
- - Automatic token refresh on 401 errors
45
- - Multi-merchant context switching
45
+ - Merchant/outlet context (outlet defaults to "all")
46
46
 
47
- 2. **GraphQL Client** (client.ts)
47
+ 2. **Token Cache** (token-cache.ts)
48
+ - Persists tokens + merchant/outlet context to `~/.atlas-mcp/cache.json`
49
+ - Survives server restarts (like browser localStorage)
50
+
51
+ 3. **GraphQL Client** (client.ts)
48
52
  - Wrapper around graphql-request
49
53
  - Automatic auth header injection
50
- - Error handling with retry on auth failures
54
+ - `onAuthFailure` callback for auto-retry on 401
55
+ - `apiKeyLogin()` and `getMerchants()` methods
51
56
 
52
- 3. **Tool Organization**
53
- - `tools/auth.ts` - Login, logout, token refresh, merchant switching
57
+ 4. **Tool Organization**
58
+ - `tools/auth.ts` - Merchant switching (fuzzy match), auth status
54
59
  - `tools/orders.ts` - Order and cart management
55
60
  - `tools/menu.ts` - Menu and item queries
56
61
  - `tools/reports.ts` - Sales analytics and insights
57
62
 
58
- ### Authentication Flow
59
- 1. Use `atlas_login` tool with email/password
60
- 2. Tokens are stored in AuthManager singleton
61
- 3. All subsequent API calls use stored tokens
62
- 4. On 401, automatically attempts token refresh
63
- 5. Use `atlas_switch_merchant` to change merchant context
64
-
65
- ### IMPORTANT: Outlet Context Requirements
66
- Many API endpoints require an outlet context to be set. Always use `atlas_switch_merchant` with an `outletId` after login:
67
-
68
- ```javascript
69
- // After login, switch to a merchant WITH an outlet ID
70
- atlas_switch_merchant({
71
- merchantId: "1",
72
- outletId: "1" // REQUIRED for many endpoints!
73
- })
74
- ```
75
-
76
- **Endpoints that REQUIRE outlet context:**
77
- - `atlas_get_pos_carts` - Uses `context[:current_outlet].id` in backend
63
+ ### Authentication flow
64
+ 1. Server starts loads cached tokens from `~/.atlas-mcp/cache.json`
65
+ 2. If no cache authenticates with `ATLAS_API_KEY` env var
66
+ 3. Sets merchant context from cache or `ATLAS_MERCHANT_ID` / `ATLAS_OUTLET_ID` env vars
67
+ 4. On 401 during any API call → refresh token → re-auth with API key → retry
68
+ 5. No manual login needed - fully automatic
69
+
70
+ ### Merchant context persistence
71
+ - Merchant and outlet IDs persist to `~/.atlas-mcp/cache.json`
72
+ - Switching merchant via `atlas_switch_merchant` updates the cache
73
+ - On restart, cached context is restored automatically
74
+ - `X-Outlet-ID` defaults to "all" unless explicitly set
75
+
76
+ ### Outlet context requirements
77
+ Some endpoints require a specific outlet (not "all"):
78
+ - `atlas_get_pos_carts` - Requires specific outlet ID
78
79
  - `atlas_get_product_insights` - Needs outlet context for data filtering
79
- - Most POS-related operations
80
80
 
81
- **Common error if outlet not set:**
82
- - 500 server error
83
- - GraphQL execution errors
81
+ Use `atlas_switch_merchant` with an `outletId` parameter for these operations.
84
82
 
85
- Always check if an endpoint is returning 500 errors - it likely needs outlet context!
86
-
87
- ### GraphQL Endpoint
83
+ ### GraphQL endpoint
88
84
  Default: `https://api.atlas.kitchen`
89
85
  Configurable via `ATLAS_GRAPHQL_ENDPOINT` environment variable (base URL only, paths are appended automatically)
90
86
 
91
- ## Type Safety
87
+ ## Type safety
92
88
 
93
89
  All GraphQL operations use TypeScript types defined in `src/types/atlas.ts`. When adding new queries/mutations:
94
90
  1. Define input/output types in atlas.ts
95
91
  2. Use Zod schemas for runtime validation of tool inputs
96
92
  3. Ensure GraphQL fragments match expected response types
97
93
 
98
- ## Common Development Tasks
94
+ ## Common development tasks
99
95
 
100
- ### Adding a New Tool
96
+ ### Adding a new tool
101
97
  1. Create tool definition in appropriate file under `src/tools/`
102
98
  2. Define Zod schema for input validation
103
99
  3. Implement GraphQL query/mutation
104
100
  4. Add corresponding TypeScript types in `src/types/atlas.ts`
105
101
  5. Register tool in `src/index.ts`
106
102
 
107
- ### Debugging GraphQL Requests
103
+ ### Debugging GraphQL requests
108
104
  The GraphQL client logs errors to console. Check for:
109
105
  - Authentication failures (401)
110
106
  - GraphQL validation errors
111
107
  - Network connectivity issues
112
108
 
113
- ### Testing Authentication
114
- ```bash
115
- # Start in dev mode
116
- npm run dev
109
+ ## Environment variables
110
+
111
+ | Variable | Required | Description |
112
+ |---|---|---|
113
+ | `ATLAS_API_KEY` | Yes | API key for automatic authentication |
114
+ | `ATLAS_GRAPHQL_ENDPOINT` | No | GraphQL API base URL (default: `https://api.atlas.kitchen`) |
115
+ | `ATLAS_CLIENT_NAME` | No | Client identifier for API requests |
116
+ | `ATLAS_MERCHANT_ID` | No | Default merchant ID on first run |
117
+ | `ATLAS_OUTLET_ID` | No | Default outlet ID on first run |
117
118
 
118
- # In Claude, test login
119
- # Use atlas_login tool with valid credentials
120
- # Then test other tools like atlas_get_orders
119
+ ## Publishing to npm
120
+
121
+ CI/CD is handled by GitHub Actions (`.github/workflows/`):
122
+
123
+ - **CI** (`ci.yml`): Builds on PRs and pushes to `main` across Node 18/20/22
124
+ - **Publish** (`publish.yml`): Publishes to npm when a GitHub release is created
125
+
126
+ ### How to publish a new version
127
+
128
+ ```bash
129
+ npm run release # patch bump + push + GitHub release
130
+ npm run release:minor # minor bump
131
+ npm run release:major # major bump
121
132
  ```
122
133
 
123
- ## Environment Variables
134
+ ### Required secret
124
135
 
125
- Required in .env:
126
- - `ATLAS_GRAPHQL_ENDPOINT` - GraphQL API endpoint (optional, has default)
127
- - `ATLAS_CLIENT_NAME` - Client identifier for API requests
128
- - `ATLAS_PLATFORM` - Platform identifier (defaults to "mcp")
136
+ `NPM_TOKEN` must be set in GitHub repo settings (Settings > Secrets > Actions). Create a Granular Access Token at https://www.npmjs.com/settings/atlas-kitchen/tokens with read/write package permissions scoped to `@atlas-kitchen`.
129
137
 
130
138
  ## Integration with Claude Code
131
139
 
132
140
  The server is configured via MCP settings. See README.md for the exact configuration needed. Key points:
133
141
  - Must use Node.js 18+ for the command path
134
- - Environment variables can be set in MCP config
135
- - For development, use tsx to run TypeScript directly
142
+ - Set `ATLAS_API_KEY` in MCP config env vars
143
+ - Optionally set `ATLAS_MERCHANT_ID` for auto-merchant selection
144
+ - For development, use tsx to run TypeScript directly
package/README.md CHANGED
@@ -6,9 +6,7 @@ An MCP (Model Context Protocol) server for integrating with the Atlas restaurant
6
6
 
7
7
  - Node.js 18.0.0 or higher (required for native fetch and Headers APIs)
8
8
 
9
- ## Quick Start with npx
10
-
11
- The easiest way to use this MCP server is with npx (no installation required):
9
+ ## Quick start with npx
12
10
 
13
11
  ```bash
14
12
  npx @atlas-kitchen/atlas-mcp
@@ -20,142 +18,127 @@ Add this to your Claude Desktop MCP configuration:
20
18
 
21
19
  ```json
22
20
  {
23
- "atlas-mcp": {
24
- "command": "npx",
25
- "args": ["-y", "@atlas-kitchen/atlas-mcp"],
26
- "env": {
27
- "ATLAS_GRAPHQL_ENDPOINT": "https://api.atlas.kitchen/v1/restaurants/graphql",
28
- "ATLAS_CLIENT_NAME": "atlas-mcp",
29
- "ATLAS_PLATFORM": "mcp"
21
+ "mcpServers": {
22
+ "atlas-mcp": {
23
+ "command": "npx",
24
+ "args": ["-y", "@atlas-kitchen/atlas-mcp"],
25
+ "env": {
26
+ "ATLAS_API_KEY": "your-api-key-here",
27
+ "ATLAS_MERCHANT_ID": "1",
28
+ "ATLAS_GRAPHQL_ENDPOINT": "https://api.atlas.kitchen",
29
+ "ATLAS_CLIENT_NAME": "atlas-mcp"
30
+ }
30
31
  }
31
32
  }
32
33
  }
33
34
  ```
34
35
 
35
- ### Environment Variables
36
-
37
- The following environment variables can be configured:
38
-
39
- - `ATLAS_GRAPHQL_ENDPOINT` - GraphQL API base URL (default: `https://api.atlas.kitchen`)
40
- - `ATLAS_CLIENT_NAME` - Client identifier for API requests (default: `atlas-mcp`)
41
- - `ATLAS_PLATFORM` - Platform identifier (default: `mcp`)
42
-
43
- ## Local Installation
44
-
45
- ```bash
46
- npm install atlas-mcp
47
- # or globally
48
- npm install -g atlas-mcp
49
-
50
- # Then run
51
- atlas-mcp
52
- ```
53
-
54
- ## Configuration
36
+ ### Environment variables
55
37
 
56
- ### Environment Variables
38
+ | Variable | Required | Description |
39
+ |---|---|---|
40
+ | `ATLAS_API_KEY` | Yes | API key for automatic authentication |
41
+ | `ATLAS_GRAPHQL_ENDPOINT` | No | GraphQL API base URL (default: `https://api.atlas.kitchen`) |
42
+ | `ATLAS_CLIENT_NAME` | No | Client identifier for API requests (default: `atlas-mcp-1.0.0`) |
43
+ | `ATLAS_MERCHANT_ID` | No | Default merchant ID on first run |
44
+ | `ATLAS_OUTLET_ID` | No | Default outlet ID on first run (defaults to `all`) |
57
45
 
58
- The server accepts the following environment variables:
46
+ ## Authentication
59
47
 
60
- - `ATLAS_GRAPHQL_ENDPOINT` - Atlas GraphQL API endpoint (default: `https://atlas-api.food.wearelion.com/v1/restaurants/graphql`)
61
- - `ATLAS_CLIENT_NAME` - Client identifier for API requests (default: `atlas-mcp`)
62
- - `ATLAS_PLATFORM` - Platform identifier (default: `mcp`)
48
+ The server authenticates automatically on startup using `ATLAS_API_KEY`. No manual login is needed.
63
49
 
64
- ### Local Development
50
+ - **Tokens are cached** to `~/.atlas-mcp/cache.json` and reused across restarts
51
+ - **Merchant/outlet context persists** across sessions until explicitly switched
52
+ - On auth failure, the server automatically refreshes tokens or re-authenticates
65
53
 
66
- For local development, copy `.env.example` to `.env` and configure as needed:
54
+ ## Local development
67
55
 
68
56
  ```bash
69
- cp .env.example .env
57
+ npm install
58
+ cp .env.example .env # Configure with your API key
59
+ npm run dev # Run with tsx (development)
60
+ npm run build # Compile TypeScript
61
+ npm start # Run compiled JavaScript
70
62
  ```
71
63
 
72
- ## Adding to Claude Desktop
73
-
74
- To use this MCP server with Claude Desktop, update your configuration file:
75
-
76
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
77
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
78
-
79
- ### Option 1: Using npx (Recommended)
64
+ ### Local development config
80
65
 
81
66
  ```json
82
67
  {
83
68
  "mcpServers": {
84
69
  "atlas-mcp": {
85
70
  "command": "npx",
86
- "args": ["-y", "@atlas-kitchen/atlas-mcp"],
71
+ "args": ["tsx", "/path/to/atlas-mcp/src/index.ts"],
87
72
  "env": {
88
- "ATLAS_GRAPHQL_ENDPOINT": "https://atlas-api.food.wearelion.com/v1/restaurants/graphql",
89
- "ATLAS_CLIENT_NAME": "atlas-mcp",
90
- "ATLAS_PLATFORM": "mcp"
73
+ "ATLAS_API_KEY": "your-api-key-here",
74
+ "ATLAS_MERCHANT_ID": "1"
91
75
  }
92
76
  }
93
77
  }
94
78
  }
95
79
  ```
96
80
 
97
- ### Option 2: Local Development
81
+ ## Available tools
98
82
 
99
- For development with source code:
83
+ ### Authentication
84
+ - `atlas_auth_status` - Show current authentication and merchant context
85
+ - `atlas_switch_merchant` - Switch merchant context (fuzzy matches by name, identifier, or ID)
100
86
 
101
- ```json
102
- {
103
- "mcpServers": {
104
- "atlas-mcp": {
105
- "command": "npx",
106
- "args": ["tsx", "/path/to/atlas-mcp/src/index.ts"],
107
- "env": {
108
- "ATLAS_GRAPHQL_ENDPOINT": "https://atlas-api.food.wearelion.com/v1/restaurants/graphql",
109
- "ATLAS_CLIENT_NAME": "atlas-mcp",
110
- "ATLAS_PLATFORM": "mcp"
111
- }
112
- }
113
- }
114
- }
115
- ```
87
+ ### Orders
88
+ - `atlas_get_orders` - List orders with filters
89
+ - `atlas_get_order` - Get detailed order information
90
+ - `atlas_get_cart` - Get cart information
91
+ - `atlas_get_pos_carts` - List open POS carts (requires specific outlet)
92
+
93
+ ### Menu
94
+ - `atlas_get_menus` - List available menus
95
+ - `atlas_get_optimized_menus` - Get optimized menu structure with sections and items
96
+ - `atlas_get_items` - List menu items
97
+ - `atlas_get_menu_sections` - Get menu structure with sections
98
+
99
+ ### Reports
100
+ - `atlas_get_sales_report` - Get sales analytics
101
+ - `atlas_get_product_insights` - Product performance data
102
+
103
+ ## Publishing to npm
104
+
105
+ Releases are published automatically via GitHub Actions when you create a GitHub release.
106
+
107
+ ### One-time setup
116
108
 
117
- **Note:** Ensure you have Node.js 18+ installed. You can verify with `node --version`.
109
+ 1. Go to [npmjs.com token settings](https://www.npmjs.com/settings/atlas-kitchen/tokens)
110
+ 2. Create a **Granular Access Token** with **Read and write** permission on packages, scoped to `@atlas-kitchen`
111
+ 3. In the GitHub repo, go to **Settings > Secrets and variables > Actions**
112
+ 4. Add a secret named `NPM_TOKEN` with the token value
118
113
 
119
- ## Development
114
+ ### Publishing a new version
120
115
 
121
116
  ```bash
122
- npm run dev
117
+ npm run release # patch: 1.0.3 → 1.0.4
118
+ npm run release:minor # minor: 1.0.3 → 1.1.0
119
+ npm run release:major # major: 1.0.3 → 2.0.0
123
120
  ```
124
121
 
125
- ## Building
122
+ This bumps the version, pushes the tag, and creates a GitHub release in one command. The GitHub Action then builds and publishes to npm automatically.
123
+
124
+ ### CI
125
+
126
+ Pull requests and pushes to `main` run a build check across Node.js 18, 20, and 22.
127
+
128
+ ### Usage example
126
129
 
127
- ```bash
128
- npm run build
129
130
  ```
131
+ # No login needed - authentication is automatic!
130
132
 
131
- ## Available Tools
133
+ # Check current status
134
+ atlas_auth_status()
132
135
 
133
- ### Authentication
134
- - `atlas_login` - Login to Atlas with email/password
135
- - `atlas_logout` - Logout and clear authentication
136
- - `atlas_refresh_token` - Refresh access token
137
- - `atlas_switch_merchant` - Switch active merchant context (⚠️ **IMPORTANT**: Always provide `outletId` for POS operations)
138
-
139
- ### Usage Example
140
- ```javascript
141
- // 1. Login first
142
- atlas_login({ email: "user@example.com", password: "password" })
143
-
144
- // 2. CRITICAL: Switch merchant WITH outlet ID
145
- atlas_switch_merchant({
146
- merchantId: "1",
147
- outletId: "1" // Required for POS carts, product insights, etc.
148
- })
149
-
150
- // 3. Now you can use POS endpoints
151
- atlas_get_pos_carts()
136
+ # Switch merchant by name (fuzzy matched)
137
+ atlas_switch_merchant({ merchant: "My Restaurant" })
138
+
139
+ # Switch merchant with specific outlet for POS
140
+ atlas_switch_merchant({ merchant: "My Restaurant", outletId: "5" })
141
+
142
+ # Query orders
143
+ atlas_get_orders({ startDate: "2025-01-01", endDate: "2025-01-31" })
152
144
  ```
153
- - `atlas_get_orders` - List orders with filters
154
- - `atlas_get_order` - Get detailed order information
155
- - `atlas_get_cart` - Get cart information
156
- - `atlas_get_pos_carts` - List open POS carts
157
- - `atlas_get_menus` - List available menus
158
- - `atlas_get_optimized_menus` - Get optimized menu structure with sections and items
159
- - `atlas_get_items` - List menu items
160
- - `atlas_get_sales_report` - Get sales analytics
161
- - `atlas_get_product_insights` - Product performance data
package/dist/auth.d.ts CHANGED
@@ -3,22 +3,16 @@ export declare class AuthManager {
3
3
  private tokens;
4
4
  private merchantId;
5
5
  private outletId;
6
- private brandId;
7
6
  private clientUuid;
8
- private pinToken;
9
7
  constructor();
10
8
  setTokens(tokens: AuthTokens): void;
11
9
  getTokens(): AuthTokens | null;
12
10
  getAccessToken(): string | null;
13
- setPinToken(pinToken: string): void;
14
- getPinToken(): string | null;
15
- setMerchantContext(merchantId: string, outletId?: string, brandId?: string): void;
11
+ setMerchantContext(merchantId: string, outletId?: string): void;
16
12
  getMerchantId(): string | null;
17
13
  getOutletId(): string | null;
18
- getBrandId(): string | null;
19
14
  getClientUuid(): string;
20
15
  getHeaders(): Record<string, string>;
21
- clear(): void;
22
16
  isAuthenticated(): boolean;
23
17
  }
24
18
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,kBAAkB,CAAC;AAG7D,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAuB;;IAOvC,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAInC,SAAS,IAAI,UAAU,GAAG,IAAI;IAI9B,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAInC,WAAW,IAAI,MAAM,GAAG,IAAI;IAI5B,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAMjF,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,WAAW,IAAI,MAAM,GAAG,IAAI;IAI5B,UAAU,IAAI,MAAM,GAAG,IAAI;IAI3B,aAAa,IAAI,MAAM;IAIvB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA0BpC,KAAK,IAAI,IAAI;IAUb,eAAe,IAAI,OAAO;CAG3B"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAS;;IAM3B,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAInC,SAAS,IAAI,UAAU,GAAG,IAAI;IAI9B,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAK/D,aAAa,IAAI,MAAM,GAAG,IAAI;IAI9B,WAAW,IAAI,MAAM,GAAG,IAAI;IAI5B,aAAa,IAAI,MAAM;IAIvB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAsBpC,eAAe,IAAI,OAAO;CAG3B"}
package/dist/auth.js CHANGED
@@ -3,11 +3,8 @@ export class AuthManager {
3
3
  tokens = null;
4
4
  merchantId = null;
5
5
  outletId = null;
6
- brandId = null;
7
6
  clientUuid;
8
- pinToken = null;
9
7
  constructor() {
10
- // Generate a persistent client UUID for this session
11
8
  this.clientUuid = uuidv4();
12
9
  }
13
10
  setTokens(tokens) {
@@ -19,16 +16,9 @@ export class AuthManager {
19
16
  getAccessToken() {
20
17
  return this.tokens?.accessToken || null;
21
18
  }
22
- setPinToken(pinToken) {
23
- this.pinToken = pinToken;
24
- }
25
- getPinToken() {
26
- return this.pinToken;
27
- }
28
- setMerchantContext(merchantId, outletId, brandId) {
19
+ setMerchantContext(merchantId, outletId) {
29
20
  this.merchantId = merchantId;
30
21
  this.outletId = outletId || null;
31
- this.brandId = brandId || null;
32
22
  }
33
23
  getMerchantId() {
34
24
  return this.merchantId;
@@ -36,9 +26,6 @@ export class AuthManager {
36
26
  getOutletId() {
37
27
  return this.outletId;
38
28
  }
39
- getBrandId() {
40
- return this.brandId;
41
- }
42
29
  getClientUuid() {
43
30
  return this.clientUuid;
44
31
  }
@@ -46,31 +33,19 @@ export class AuthManager {
46
33
  const headers = {
47
34
  'Content-Type': 'application/json',
48
35
  };
49
- // Add authorization header
50
36
  if (this.tokens?.accessToken) {
51
37
  headers['Authorization'] = `Bearer ${this.tokens.accessToken}`;
52
38
  }
53
- // Add merchant context headers
54
39
  if (this.merchantId) {
55
40
  headers['X-Merchant-ID'] = this.merchantId;
56
41
  }
57
42
  if (this.outletId) {
58
43
  headers['X-Outlet-ID'] = this.outletId;
59
44
  }
60
- // Add client identification headers (matching restaurant-web format)
61
45
  headers['X-Client-UUID'] = this.clientUuid;
62
46
  headers['X-Client-Name'] = process.env.ATLAS_CLIENT_NAME || 'atlas-mcp-1.0.0';
63
47
  return headers;
64
48
  }
65
- clear() {
66
- this.tokens = null;
67
- this.merchantId = null;
68
- this.outletId = null;
69
- this.brandId = null;
70
- this.pinToken = null;
71
- // Generate new client UUID on clear
72
- this.clientUuid = uuidv4();
73
- }
74
49
  isAuthenticated() {
75
50
  return this.tokens !== null && this.tokens.accessToken !== null;
76
51
  }
package/dist/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,OAAO,WAAW;IACd,MAAM,GAAsB,IAAI,CAAC;IACjC,UAAU,GAAkB,IAAI,CAAC;IACjC,QAAQ,GAAkB,IAAI,CAAC;IAC/B,OAAO,GAAkB,IAAI,CAAC;IAC9B,UAAU,CAAS;IACnB,QAAQ,GAAkB,IAAI,CAAC;IAEvC;QACE,qDAAqD;QACrD,IAAI,CAAC,UAAU,GAAG,MAAM,EAAE,CAAC;IAC7B,CAAC;IAED,SAAS,CAAC,MAAkB;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,EAAE,WAAW,IAAI,IAAI,CAAC;IAC1C,CAAC;IAED,WAAW,CAAC,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CA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C;IAED,UAAU;QACR,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;SACnC,CAAC;QAEF,IAAI,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC;YAC7B,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACjE,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;QAC7C,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QACzC,CAAC;QACD,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC;QAC3C,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,iBAAiB,CAAC;QAE9E,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,KAAK,IAAI,CAAC;IAClE,CAAC;CACF"}
package/dist/client.d.ts CHANGED
@@ -4,19 +4,23 @@ export declare class AtlasClient {
4
4
  private accountClient;
5
5
  private authManager;
6
6
  private baseUrl;
7
+ private _isRetrying;
8
+ onAuthFailure: (() => Promise<boolean>) | null;
7
9
  constructor(authManager: AuthManager);
8
10
  request<T = any>(query: string, variables?: any, context?: 'restaurants' | 'accounts'): Promise<T>;
9
- login(email: string, password: string): Promise<any>;
10
- logout(): Promise<any>;
11
+ private isAuthError;
12
+ apiKeyLogin(apiKey: string): Promise<{
13
+ accessToken: string;
14
+ refreshToken: string;
15
+ }>;
11
16
  refreshToken(refreshToken: string): Promise<any>;
17
+ getMerchants(): Promise<any[]>;
12
18
  getOrders(filters?: any): Promise<any>;
13
19
  getOrder(orderId: string): Promise<any>;
14
20
  getCart(cartId: string): Promise<any>;
15
21
  getOpenPosCarts(): Promise<any>;
16
- getMenus(outletId?: number, servingDate?: string, timeslotType?: string): Promise<any>;
17
- getOptimizedMenus(outletId: number, servingDate: string): Promise<any>;
18
22
  getItems(filter?: any): Promise<any>;
19
23
  getSalesReport(filters: any, dateRange: any): Promise<any>;
20
- getProductInsights(params: any): Promise<any>;
24
+ getOutlets(): Promise<any>;
21
25
  }
22
26
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,WAAW;IACtB,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,OAAO,CAAS;gBAEZ,WAAW,EAAE,WAAW;IAS9B,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,GAAE,aAAa,GAAG,UAA0B,GAAG,OAAO,CAAC,CAAC,CAAC;IAiBjH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAqBpD,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC;IAatB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAgDhD,SAAS,CAAC,OAAO,GAAE,GAAQ,GAAG,OAAO,CAAC,GAAG,CAAC;IAoF1C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IA4WvC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAoQrC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;IAkC/B,QA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