@opra-app/mcp
Version:
MCP server for OPRA's business and discount data
80 lines (79 loc) • 2.28 kB
JavaScript
import { env } from "./env.js";
const API_BASE = `${env.API_BASE}/api`;
const USER_AGENT = "opra-mcp/1.0";
const headers = {
"User-Agent": USER_AGENT,
"x-api-key": env.OPRA_API_KEY,
};
export const listCategories = async () => {
const response = await fetch(`${API_BASE}/app/categories/all`, {
headers,
});
return response.json();
};
export const listDiscountsInCategory = async (categoryId) => {
const response = await fetch(`${API_BASE}/app/categories/${categoryId}`, {
headers,
});
return response.json();
};
export const listDiscounts = async () => {
const response = await fetch(`${API_BASE}/app/discounts/all`, {
headers,
});
return response.json();
};
export const listCampaigns = async () => {
const response = await fetch(`${API_BASE}/app/campaigns/all`, {
headers,
});
return response.json();
};
export const getDiscountDetails = async (id) => {
const response = await fetch(`${API_BASE}/app/discounts/${id}`, {
headers,
});
return response.json();
};
export const getCampaignDetails = async (id) => {
const response = await fetch(`${API_BASE}/app/campaigns/${id}`, {
headers,
});
return response.json();
};
export const getDiscountCode = async (id) => {
const response = await fetch(`${API_BASE}/discounts/${id}`, {
headers,
});
return response.json();
};
export const getCities = async () => {
const response = await fetch(`${API_BASE}/app/cities/all`, {
headers,
});
return response.json();
};
export const getDiscountsByCity = async (cityId) => {
const response = await fetch(`${API_BASE}/app/cities/${cityId}`, {
headers,
});
return response.json();
};
export const getFavoriteDiscounts = async () => {
const response = await fetch(`${API_BASE}/app/discounts/favorites`, {
headers,
});
return response.json();
};
export const listBusinesses = async () => {
const response = await fetch(`${API_BASE}/app/businesses/all`, {
headers,
});
return response.json();
};
export const getBusinessDetails = async (id) => {
const response = await fetch(`${API_BASE}/app/businesses/${id}`, {
headers,
});
return response.json();
};