Skip to content
reaatech

Files · Vertex AI Inventory MCP Server for Shopify Merchants

62 (1 binary, 586.9 kB total)attempt 1

README.md·3296 B·markdown
markdown
# Vertex AI Inventory MCP Server for Shopify Merchants
 
> Multi‑tenant MCP server that gives Vertex AI agents secure, rate‑limited access to real‑time Shopify inventory data, isolated per merchant store.
 
## Architecture
 
The server uses a composable Express middleware pipeline:
- **Auth** (`@reaatech/mcp-gateway-auth`) — validates short-lived API keys and JWT tokens, attaching a typed AuthContext
- **Rate Limit** (`@reaatech/mcp-gateway-rate-limit`) — per-tenant token bucket rate limiter (configurable RPM/RPD)
- **Multi‑tenant Middleware** (`@reaatech/multi-tenant-mcp-middleware`) — resolves the tenant from the request, applies tool visibility filtering, and enforces per-tenant isolation
- **MCP Tools** — three tools that call the Shopify Admin REST API under per-tenant credentials
 
The Express server mounts the MCP endpoint at `POST /mcp/:tenantId` and uses JSON-RPC for request/response.
 
## Quick Start
 
```bash
pnpm install
cp .env.example .env
# Edit .env with your Shopify credentials and Langfuse keys
pnpm dev
```
 
Vertex AI agents connect to the MCP endpoint at `POST http://localhost:3001/mcp/:tenantId` using standard JSON-RPC over HTTP with an `Authorization: Bearer <api-key>` header.
 
## Tools
 
Three MCP tools are available:
 
### getProduct
Get a single product by ID from the merchant's Shopify store.
 
**Input:** `{ productId: string }`
**Example request:**
```json
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": { "name": "getProduct", "arguments": { "productId": "123" } },
  "id": "1"
}
```
 
### listInventory
List inventory items from the merchant's store.
 
**Input:** `{ limit?: number }`
**Example request:**
```json
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": { "name": "listInventory", "arguments": { "limit": 10 } },
  "id": "1"
}
```
 
### searchVariants
Search product variants by price range or SKU.
 
**Input:** `{ priceMax?: number, priceMin?: number, sku?: string }`
**Example request:**
```json
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": { "name": "searchVariants", "arguments": { "priceMax": 50, "priceMin": 10 } },
  "id": "1"
}
```
 
## Tenant Configuration
 
Tenants are registered in `src/index.ts` via the `TenantRegistry` class. Each tenant maps to a Shopify store with its own credentials and rate limits:
 
```typescript
{
  "store-1": {
    shopifyStoreUrl: "https://store-1.myshopify.com",
    accessToken: "shpat_...",
    requestsPerMinute: 100,
    requestsPerDay: 10000,
    burstSize: 50,
    allowedTools: ["getProduct", "listInventory", "searchVariants"]
  }
}
```
 
## Deployment
 
```bash
# Build and start
pnpm build
pnpm start
```
 
The server listens on the port specified by the `PORT` environment variable (default `3001`).
 
## Project layout
 
```
app/                  Next.js App Router pages + API routes
src/config/           Tenant registry with Zod validation
src/lib/              Shopify REST client, Langfuse logger
src/mcp/tools/        MCP tool definitions (getProduct, listInventory, searchVariants)
src/mcp/server.ts     MCP server wiring
src/middleware/       Auth, rate-limit, visibility pipeline composition
src/index.ts          Express app entry point
tests/                Vitest suite (mirrors src/)
```
 
## License
 
MIT — see [LICENSE](./LICENSE).