Skip to main content
Glama
naticity1-build

Priority MCP Platform

README.md
# Priority MCP Platform

מערכת MCP רב-לקוחית שמחברת Claude/AI ל-Priority ERP דרך OData, עם ממשק ניהול Web.

## ארכיטקטורה

- **Web (Vercel)** — Next.js Admin UI
- **MCP Server (Render)** — Streamable HTTP MCP + Priority OData client
- **Supabase** — Postgres, Auth, migrations

```
Claude → MCP Server (Render) → Priority OData
Admin  → Web (Vercel) → Supabase + Render Internal API
```

## התחלה מהירה (מקומי)

### 1. התקנת תלויות

```bash
pnpm install
pnpm build
```

### 2. Supabase

1. צור פרויקט ב-[Supabase](https://supabase.com)
2. הרץ migrations:

```bash
npx supabase link --project-ref <your-ref>
npx supabase db push
```

3. צור משתמש אדמין ב-Authentication → Users

### 3. משתני סביבה

העתק `.env.example` לכל אפליקציה:

**apps/mcp-server/.env**
```
SUPABASE_URL=
SUPABASE_SERVICE_ROLE_KEY=
ENCRYPTION_KEY=   # node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
CORS_ORIGINS=http://localhost:3000
PORT=3001
```

**apps/web/.env.local**
```
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
RENDER_INTERNAL_API_URL=http://localhost:3001/internal
NEXT_PUBLIC_MCP_SERVER_URL=http://localhost:3001/mcp
```

### 4. הרצה

```bash
pnpm dev
```

- Web: http://localhost:3000
- MCP: http://localhost:3001/mcp
- Health: http://localhost:3001/health

## Deploy

### Render (MCP Server)

1. חבר את ה-repo ל-Render
2. השתמש ב-[render.yaml](render.yaml)
3. הגדר env vars: `SUPABASE_URL`, `SUPABASE_SERVICE_ROLE_KEY`, `ENCRYPTION_KEY`, `CORS_ORIGINS`

### Vercel (Web)

1. Import הפרויקט, root directory: `apps/web`
2. הגדר env vars מ-`.env.example`
3. עדכן `RENDER_INTERNAL_API_URL` ו-`NEXT_PUBLIC_MCP_SERVER_URL` לכתובות Render

### Supabase

הרץ migrations על הפרויקט ב-production.

## חיבור Claude

1. בממשק הניהול → לקוח → "יצירת מפתח MCP"
2. הוסף ל-Claude Desktop config:

```json
{
  "mcpServers": {
    "priority-mcp": {
      "url": "https://<render-app>.onrender.com/mcp",
      "headers": {
        "Authorization": "Bearer <tenant_api_key>"
      }
    }
  }
}
```

## MVP — Read Only

המערכת תומכת רק ב-GET OData. כל ה-tools מוגדרים כ-`read_only`.

## מבנה הפרויקט

```
apps/web/           # Next.js admin
apps/mcp-server/    # MCP + Priority client + internal API
packages/shared/    # types, schemas, crypto, odata helpers
supabase/           # migrations
```