@atlas-kitchen/atlas-mcp
Version:
Model Context Protocol server for Atlas restaurant management system - enables Claude to interact with restaurant orders, menus, and reports
158 lines • 6.68 kB
JavaScript
import { z } from 'zod';
const OrderStateEnum = z.enum([
'unpaid',
'confirmed',
'dispatched',
'ready_for_pickup',
'completed',
'cancelled',
]);
const GetOrdersSchema = z.object({
startDate: z.string().optional(),
endDate: z.string().optional(),
state: OrderStateEnum.optional(),
limit: z.number().min(1).max(100).default(20),
page: z.number().min(1).optional(),
});
const GetOrderSchema = z.object({
identifier: z.string(),
});
const GetCartSchema = z.object({
cartId: z.string(),
});
export function createOrderTools(client, authManager) {
return [
{
name: 'atlas_get_orders',
description: 'List orders with optional filters. Returns a paginated summary: order ID, state, date, fulfilment type, contact info, items, and payment total. Use startDate/endDate (YYYY-MM-DD) to scope by serving date. Use atlas_get_order for full details on a single order.',
inputSchema: {
type: 'object',
properties: {
startDate: { type: 'string', description: 'Start date for filtering (ISO format YYYY-MM-DD)' },
endDate: { type: 'string', description: 'End date for filtering (ISO format YYYY-MM-DD)' },
state: {
type: 'string',
enum: ['unpaid', 'confirmed', 'dispatched', 'ready_for_pickup', 'completed', 'cancelled'],
description: 'Order state filter',
},
limit: { type: 'number', description: 'Number of orders to return (1-100, default: 20)' },
page: { type: 'number', description: 'Page number for pagination (starts at 1)' },
},
},
handler: async (input) => {
const { startDate, endDate, state, limit, page } = GetOrdersSchema.parse(input);
try {
const filters = {
perPage: limit,
};
if (startDate)
filters.startDate = startDate;
if (endDate)
filters.endDate = endDate;
if (state)
filters.state = state;
if (page)
filters.page = page;
const response = await client.getOrders(filters);
return {
success: true,
orders: response.orders,
totalCount: response.totalCount,
page: response.page,
perPage: response.perPage,
};
}
catch (error) {
return {
success: false,
error: error.message || 'Failed to fetch orders',
};
}
},
},
{
name: 'atlas_get_order',
description: 'Get full details of a single order by its identifier (e.g. W525321), including line items with modifiers, payment breakdown, discounts, refunds, customer info, delivery address, and delivery trip details (external logistics ID for Lalamove/GoGoX/pandago, tracking URL, driver info, status). The currentTrip.externalLogisticsId is the Lalamove order ID you can use with the Lalamove CLI to check delivery status.',
inputSchema: {
type: 'object',
properties: {
identifier: { type: 'string', description: 'Order identifier (e.g. W525321)' },
},
required: ['identifier'],
},
handler: async (input) => {
const { identifier } = GetOrderSchema.parse(input);
try {
const order = await client.getOrderByIdentifier(identifier);
return {
success: true,
order,
};
}
catch (error) {
return {
success: false,
error: error.message || 'Failed to fetch order',
};
}
},
},
{
name: 'atlas_get_cart',
description: 'Get details of a specific POS cart by its ID, including items, payment breakdown, billing status, and customer info. Requires a specific outlet context — use atlas_switch_merchant to set one if needed.',
inputSchema: {
type: 'object',
properties: {
cartId: { type: 'string', description: 'Cart ID (numeric string)' },
},
required: ['cartId'],
},
handler: async (input) => {
const { cartId } = GetCartSchema.parse(input);
try {
const cart = await client.getCart(cartId);
return {
success: true,
cart,
};
}
catch (error) {
return {
success: false,
error: error.message || 'Failed to fetch cart',
};
}
},
},
{
name: 'atlas_get_pos_carts',
description: 'List all open POS carts for the current outlet. Returns cart summaries: ID, table, fulfilment type, item status, and customer. Requires a specific outlet — use atlas_switch_merchant with an outletId first.',
inputSchema: {
type: 'object',
properties: {},
},
handler: async () => {
if (!authManager.getOutletId()) {
return {
success: false,
error: 'POS carts require a specific outlet. Use atlas_switch_merchant with an outletId, or set ATLAS_OUTLET_ID in your env config.',
};
}
try {
const carts = await client.getOpenPosCarts();
return {
success: true,
carts,
};
}
catch (error) {
return {
success: false,
error: error.message || 'Failed to fetch POS carts',
};
}
},
},
];
}
//# sourceMappingURL=orders.js.map