@atlas-kitchen/atlas-mcp
Version:
Model Context Protocol server for Atlas restaurant management system - enables Claude to interact with restaurant orders, menus, and reports
170 lines • 6.31 kB
JavaScript
import { z } from 'zod';
const GetOrdersSchema = z.object({
startDate: z.string().optional(),
endDate: z.string().optional(),
state: z.string().optional(),
limit: z.number().min(1).max(100).default(20),
cursor: z.string().optional(),
});
const GetOrderSchema = z.object({
orderId: 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',
inputSchema: {
type: 'object',
properties: {
startDate: { type: 'string', description: 'Start date for filtering (ISO format)' },
endDate: { type: 'string', description: 'End date for filtering (ISO format)' },
state: { type: 'string', description: 'Order state filter (unpaid, confirmed, dispatched, ready_for_pickup, completed, cancelled)' },
limit: { type: 'number', description: 'Number of orders to return (1-100, default: 20)' },
cursor: { type: 'string', description: 'Pagination cursor from previous request' },
},
},
handler: async (input) => {
const { startDate, endDate, state, limit, cursor } = GetOrdersSchema.parse(input);
if (!authManager.isAuthenticated()) {
return {
success: false,
error: 'Not authenticated. Please login first.',
};
}
try {
const filters = {
first: limit,
};
if (startDate)
filters.startDate = startDate;
if (endDate)
filters.endDate = endDate;
if (state)
filters.state = state;
if (cursor)
filters.after = cursor;
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 detailed information about a specific order',
inputSchema: {
type: 'object',
properties: {
orderId: { type: 'string', description: 'Order ID or identifier' },
},
required: ['orderId'],
},
handler: async (input) => {
const { orderId } = GetOrderSchema.parse(input);
if (!authManager.isAuthenticated()) {
return {
success: false,
error: 'Not authenticated. Please login first.',
};
}
try {
const order = await client.getOrder(orderId);
return {
success: true,
order,
};
}
catch (error) {
return {
success: false,
error: error.message || 'Failed to fetch order',
};
}
},
},
{
name: 'atlas_get_cart',
description: 'Get information about a specific cart',
inputSchema: {
type: 'object',
properties: {
cartId: { type: 'string', description: 'Cart ID' },
},
required: ['cartId'],
},
handler: async (input) => {
const { cartId } = GetCartSchema.parse(input);
if (!authManager.isAuthenticated()) {
return {
success: false,
error: 'Not authenticated. Please login first.',
};
}
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',
inputSchema: {
type: 'object',
properties: {},
},
handler: async () => {
if (!authManager.isAuthenticated()) {
return {
success: false,
error: 'Not authenticated. Please login first.',
};
}
if (!authManager.getOutletId()) {
return {
success: false,
error: 'No outlet selected. Please use atlas_switch_merchant with an outletId first.',
};
}
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