Compare commits

..

7 Commits

Author SHA1 Message Date
d96d6a4b13 chore: release v1.9.9
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧹 Lint (push) Failing after 10s
Monorepo Pipeline / 🧪 Test (push) Failing after 9s
Monorepo Pipeline / 🏗️ Build (push) Failing after 9s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
2026-03-03 12:24:39 +01:00
8f6b12d827 fix(packages): remove private flag from all feature/engine packages to allow npm publish 2026-03-03 12:24:38 +01:00
a11714d07d chore(ci): migrate docker registry publishers to git.infra.mintel.me 2026-03-03 12:13:39 +01:00
52f7e68f25 chore: release v1.9.8
All checks were successful
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m15s
Monorepo Pipeline / 🧹 Lint (push) Successful in 4m17s
Monorepo Pipeline / 🏗️ Build (push) Successful in 2m15s
Monorepo Pipeline / 🐳 Build Production Runtime (push) Successful in 37s
Monorepo Pipeline / 🐳 Build Build-Base (push) Successful in 41s
Monorepo Pipeline / 🚀 Release (push) Successful in 1m44s
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Successful in 2m31s
2026-03-03 11:52:29 +01:00
217ac33675 chore: release v1.9.8
Some checks are pending
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m11s
Monorepo Pipeline / 🧹 Lint (push) Successful in 4m7s
Monorepo Pipeline / 🏗️ Build (push) Successful in 2m19s
Monorepo Pipeline / 🐳 Build Production Runtime (push) Successful in 37s
Monorepo Pipeline / 🐳 Build Build-Base (push) Successful in 41s
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Successful in 2m32s
Monorepo Pipeline / 🚀 Release (push) Has started running
2026-03-03 11:44:54 +01:00
f2b8b136af chore: release v1.9.7
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 1s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m15s
Monorepo Pipeline / 🧹 Lint (push) Successful in 4m6s
Monorepo Pipeline / 🏗️ Build (push) Successful in 2m19s
Monorepo Pipeline / 🐳 Build Production Runtime (push) Successful in 38s
Monorepo Pipeline / 🐳 Build Build-Base (push) Successful in 43s
Monorepo Pipeline / 🚀 Release (push) Successful in 1m54s
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Successful in 2m33s
🏥 Server Maintenance / 🧹 Prune & Clean (push) Failing after 4s
2026-03-02 21:16:51 +01:00
2e07b213d1 chore: remove unused 3d dependencies in gatekeeper to fix lint 2026-03-02 21:16:49 +01:00
47 changed files with 1108 additions and 522 deletions

View File

@@ -1,5 +1,5 @@
# Project
IMAGE_TAG=v1.9.6
IMAGE_TAG=v1.9.9
PROJECT_NAME=sample-website
PROJECT_COLOR=#82ed20

View File

@@ -202,9 +202,9 @@ jobs:
- name: 🔐 Registry Login
uses: docker/login-action@v3
with:
registry: registry.infra.mintel.me
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
registry: git.infra.mintel.me
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🏗️ Build & Push ${{ matrix.name }}
uses: docker/build-push-action@v5
@@ -218,6 +218,6 @@ jobs:
secrets: |
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
tags: |
registry.infra.mintel.me/mintel/${{ matrix.image }}:${{ github.ref_name }}
registry.infra.mintel.me/mintel/${{ matrix.image }}:latest
git.infra.mintel.me/mmintel/${{ matrix.image }}:${{ github.ref_name }}
git.infra.mintel.me/mmintel/${{ matrix.image }}:latest

View File

@@ -1,5 +1,5 @@
# Stage 1: Builder
FROM registry.infra.mintel.me/mintel/nextjs:latest AS builder
FROM git.infra.mintel.me/mmintel/nextjs:latest AS builder
WORKDIR /app
# Clean the workspace in case the base image is dirty
@@ -37,7 +37,7 @@ COPY . .
RUN pnpm build
# Stage 2: Runner
FROM registry.infra.mintel.me/mintel/runtime:latest AS runner
FROM git.infra.mintel.me/mmintel/runtime:latest AS runner
WORKDIR /app
ENV HOSTNAME="0.0.0.0"

View File

@@ -1,6 +1,6 @@
{
"name": "sample-website",
"version": "1.9.6",
"version": "1.9.9",
"private": true,
"type": "module",
"scripts": {

View File

@@ -6,6 +6,10 @@
"build": "pnpm -r build",
"dev": "pnpm -r dev",
"dev:gatekeeper": "bash -c 'trap \"COMPOSE_PROJECT_NAME=gatekeeper docker-compose -f docker-compose.gatekeeper.yml down\" EXIT INT TERM; docker network create infra 2>/dev/null || true && COMPOSE_PROJECT_NAME=gatekeeper docker-compose -f docker-compose.gatekeeper.yml down && COMPOSE_PROJECT_NAME=gatekeeper docker-compose -f docker-compose.gatekeeper.yml up --build --remove-orphans'",
"dev:mcps:up": "docker-compose -f docker-compose.mcps.yml up -d",
"dev:mcps:down": "docker-compose -f docker-compose.mcps.yml down",
"dev:mcps:watch": "pnpm -r --filter=\"./packages/*-mcp\" run dev",
"dev:mcps": "npm run dev:mcps:up && npm run dev:mcps:watch",
"lint": "pnpm -r --filter='./packages/**' --filter='./apps/**' lint",
"test": "pnpm -r test",
"changeset": "changeset",
@@ -49,7 +53,7 @@
"pino-pretty": "^13.1.3",
"require-in-the-middle": "^8.0.1"
},
"version": "1.9.6",
"version": "1.9.9",
"pnpm": {
"onlyBuiltDependencies": [
"@parcel/watcher",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/cli",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/cloner",
"version": "1.9.6",
"version": "1.9.9",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/concept-engine",
"version": "1.9.6",
"version": "1.9.9",
"private": true,
"description": "AI-powered web project concept generation and analysis",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/content-engine",
"version": "1.9.6",
"version": "1.9.9",
"private": false,
"type": "module",
"main": "./dist/index.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/eslint-config",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/estimation-engine",
"version": "1.9.6",
"version": "1.9.9",
"private": true,
"type": "module",
"main": "./dist/index.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/gatekeeper",
"version": "1.9.6",
"version": "1.9.9",
"private": true,
"type": "module",
"scripts": {
@@ -12,14 +12,11 @@
},
"dependencies": {
"@mintel/next-utils": "workspace:*",
"@react-three/drei": "^10.7.7",
"@react-three/fiber": "^9.5.0",
"framer-motion": "^11.18.2",
"lucide-react": "^0.474.0",
"next": "16.1.6",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"three": "^0.183.1"
"react-dom": "^19.0.0"
},
"devDependencies": {
"@mintel/eslint-config": "workspace:*",
@@ -29,7 +26,6 @@
"@types/node": "^20.0.0",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@types/three": "^0.183.1",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.17",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/gitea-mcp",
"version": "1.9.6",
"version": "1.9.9",
"description": "Native Gitea MCP server for 100% Antigravity compatibility",
"main": "dist/index.js",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/husky-config",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

View File

@@ -1,5 +1,5 @@
# Start from the pre-built Nextjs Base image
FROM registry.infra.mintel.me/mintel/nextjs:latest AS builder
FROM git.infra.mintel.me/mmintel/nextjs:latest AS builder
WORKDIR /app
@@ -20,7 +20,7 @@ ENV DIRECTUS_URL=$DIRECTUS_URL
RUN pnpm --filter ${APP_NAME:-app} build
# Production runner image
FROM registry.infra.mintel.me/mintel/runtime:latest AS runner
FROM git.infra.mintel.me/mmintel/runtime:latest AS runner
WORKDIR /app
# Copy standalone output and static files

View File

@@ -38,7 +38,7 @@ services:
- "traefik.http.middlewares.${PROJECT_NAME:-app}-auth.forwardauth.authResponseHeaders=X-Auth-User"
gatekeeper:
image: registry.infra.mintel.me/mintel/gatekeeper:${IMAGE_TAG:-latest}
image: git.infra.mintel.me/mmintel/gatekeeper:${IMAGE_TAG:-latest}
restart: always
networks:
- infra
@@ -53,7 +53,7 @@ services:
- "traefik.http.services.${PROJECT_NAME}-gatekeeper.loadbalancer.server.port=3000"
directus:
image: registry.infra.mintel.me/mintel/directus:${IMAGE_TAG:-latest}
image: git.infra.mintel.me/mmintel/directus:${IMAGE_TAG:-latest}
restart: always
networks:
- infra

View File

@@ -180,9 +180,9 @@ jobs:
- name: 🔐 Registry Login
uses: docker/login-action@v3
with:
registry: registry.infra.mintel.me
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
registry: git.infra.mintel.me
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🏗️ Docker Build & Push
uses: docker/build-push-action@v5
@@ -198,7 +198,7 @@ jobs:
push: true
secrets: |
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
tags: registry.infra.mintel.me/mintel/${{ github.event.repository.name }}:${{ needs.prepare.outputs.image_tag }}
tags: git.infra.mintel.me/mmintel/${{ github.event.repository.name }}:${{ needs.prepare.outputs.image_tag }}
# ──────────────────────────────────────────────────────────────────────────────
# JOB 4: Deploy
@@ -262,7 +262,7 @@ jobs:
set -e
cd "/home/deploy/sites/${{ github.event.repository.name }}"
chmod 600 "$ENV_FILE"
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
echo "${{ secrets.GITHUB_TOKEN }}" | docker login git.infra.mintel.me -u "${{ github.actor }}" --password-stdin
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" pull
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" up -d --remove-orphans
docker system prune -f --filter "until=24h"

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/infra",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/journaling",
"version": "1.9.6",
"version": "1.9.9",
"private": true,
"type": "module",
"main": "./dist/index.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/mail",
"version": "1.9.6",
"version": "1.9.9",
"private": false,
"publishConfig": {
"access": "public",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/meme-generator",
"version": "1.9.6",
"version": "1.9.9",
"private": false,
"type": "module",
"main": "./dist/index.js",

View File

@@ -0,0 +1,25 @@
{
"name": "@mintel/memory-mcp",
"version": "1.9.9",
"description": "Local Qdrant-based Memory MCP server",
"main": "dist/index.js",
"type": "module",
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"dev": "tsx watch src/index.ts",
"test:unit": "vitest run"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.5.0",
"@qdrant/js-client-rest": "^1.12.0",
"@xenova/transformers": "^2.17.2",
"zod": "^3.23.8"
},
"devDependencies": {
"typescript": "^5.5.3",
"@types/node": "^20.14.10",
"tsx": "^4.19.1",
"vitest": "^2.1.3"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/next-config",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/next-feedback",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/next-observability",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/next-utils",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/observability",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/page-audit",
"version": "1.9.6",
"version": "1.9.9",
"private": true,
"description": "AI-powered website IST-analysis using DataForSEO and Gemini",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/payload-ai",
"version": "1.9.6",
"version": "1.9.9",
"private": true,
"description": "Reusable Payload CMS AI Extensions",
"type": "module",
@@ -16,7 +16,8 @@
"./actions/*": "./dist/actions/*",
"./globals/*": "./dist/globals/*",
"./endpoints/*": "./dist/endpoints/*",
"./utils/*": "./dist/utils/*"
"./utils/*": "./dist/utils/*",
"./tools/*": "./dist/tools/*"
},
"peerDependencies": {
"@payloadcms/next": ">=3.0.0",

View File

@@ -0,0 +1,48 @@
{
"name": "@mintel/payload-chat",
"version": "1.9.9",
"private": true,
"description": "Payload CMS Plugin for MCP AI Chat with custom permissions",
"type": "module",
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": "./dist/index.js",
"./components/*": "./dist/components/*",
"./actions/*": "./dist/actions/*",
"./endpoints/*": "./dist/endpoints/*",
"./tools/*": "./dist/tools/*",
"./utils/*": "./dist/utils/*"
},
"peerDependencies": {
"@payloadcms/next": ">=3.0.0",
"@payloadcms/ui": ">=3.0.0",
"payload": ">=3.0.0",
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
},
"dependencies": {
"@ai-sdk/openai": "^3.0.39",
"@modelcontextprotocol/sdk": "^1.6.0",
"@qdrant/js-client-rest": "^1.17.0",
"ai": "^4.1.41",
"lucide-react": "^0.475.0",
"zod": "^3.25.76"
},
"devDependencies": {
"@payloadcms/next": "3.77.0",
"@payloadcms/ui": "3.77.0",
"@types/node": "^20.17.17",
"@types/react": "^19.2.8",
"@types/react-dom": "^19.2.3",
"next": "^15.1.0",
"payload": "3.77.0",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"typescript": "^5.7.3"
}
}

View File

@@ -0,0 +1,49 @@
# @mintel/payload-mcp-chat
A powerful, native AI Chat plugin for Payload CMS v3 with fine-grained Model Context Protocol (MCP) tool execution permissions.
Unlike generic MCP plugins, this package builds the core tool adapter *inside* Payload via the Local API. This allows Administrators to explicitly dictate exactly which tools, collections, and external MCP servers specific Users or Roles can access.
## Features
- **Floating AI Chat Pane:** Exists universally across the Payload Admin Panel.
- **Native Local API Tools:** AI automatically gets tools to read/create/update documents.
- **Strict Role-Based AI Permissions:** A custom `AIChatPermissions` collection controls what the AI is allowed to execute on behalf of the current logged-in user.
- **Flexible External MCP Support:** Connect standard external MCP servers (via HTTP or STDIO) and seamlessly make their tools available to the Chat window, all wrapped within the permission engine.
- **Vercel AI SDK Integration:** Powered by the robust `ai` package using reliable streaming protocols.
## Installation
```bash
pnpm add @mintel/payload-mcp-chat @modelcontextprotocol/sdk ai
```
## Setup
Wrap your payload config with the plugin:
```typescript
// payload.config.ts
import { buildConfig } from 'payload'
import { payloadMcpChatPlugin } from '@mintel/payload-mcp-chat'
export default buildConfig({
// ... your config
plugins: [
payloadMcpChatPlugin({
enabled: true,
// optional setup config here
})
]
})
```
## Permissions Model
The plugin automatically registers a Global (or Collection depending on setup) called **AI Chat Permissions**.
Here, an Admin can:
1. Select a `User` or define a `Role`.
2. Select which Payload Collections they are allowed to manage via AI.
3. Select which registered external MCP Servers they are allowed to use.
If a user asks the AI to update a user's password, and the `users` collection is not checked in their AI Chat Permission config, the AI will not even receive the tool to perform the action. If it hallucinates the tool, the backend will strictly block it.

View File

@@ -0,0 +1,48 @@
{
"name": "@mintel/payload-mcp-chat",
"version": "1.0.0",
"private": true,
"description": "Payload CMS Plugin for MCP AI Chat with custom permissions",
"type": "module",
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": "./dist/index.js",
"./components/*": "./dist/components/*",
"./actions/*": "./dist/actions/*",
"./endpoints/*": "./dist/endpoints/*",
"./tools/*": "./dist/tools/*",
"./utils/*": "./dist/utils/*"
},
"peerDependencies": {
"@payloadcms/next": ">=3.0.0",
"@payloadcms/ui": ">=3.0.0",
"payload": ">=3.0.0",
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
},
"dependencies": {
"@ai-sdk/openai": "^3.0.39",
"@modelcontextprotocol/sdk": "^1.6.0",
"@qdrant/js-client-rest": "^1.17.0",
"ai": "^4.1.41",
"lucide-react": "^0.475.0",
"zod": "^3.25.76"
},
"devDependencies": {
"@payloadcms/next": "3.77.0",
"@payloadcms/ui": "3.77.0",
"@types/node": "^20.17.17",
"@types/react": "^19.2.8",
"@types/react-dom": "^19.2.3",
"next": "^15.1.0",
"payload": "3.77.0",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"typescript": "^5.7.3"
}
}

View File

@@ -0,0 +1,69 @@
import type { CollectionConfig } from 'payload'
/**
* A central collection to manage which AI Tools/MCPs a User or Role is allowed to use.
*/
export const AIChatPermissionsCollection: CollectionConfig = {
slug: 'ai-chat-permissions',
labels: {
singular: 'AI Chat Permission',
plural: 'AI Chat Permissions',
},
admin: {
useAsTitle: 'description',
group: 'AI & Tools',
},
fields: [
{
name: 'description',
type: 'text',
required: true,
admin: {
description: 'E.g. "Editors default AI permissions"',
},
},
{
type: 'row',
fields: [
{
name: 'targetUser',
type: 'relationship',
relationTo: 'users',
hasMany: false,
admin: {
description: 'Apply these permissions to a specific user (optional).',
},
},
{
name: 'targetRole',
type: 'select',
options: [
{ label: 'Admin', value: 'admin' },
{ label: 'Editor', value: 'editor' },
], // Ideally this is dynamically populated in a real scenario, but we hardcode standard roles for now
admin: {
description: 'Apply these permissions to all users with this role.',
},
},
],
},
{
name: 'allowedCollections',
type: 'select',
hasMany: true,
options: [], // Will be populated dynamically in the plugin init based on actual collections
admin: {
description: 'Which Payload collections is the AI allowed to read/write on behalf of this user?',
},
},
{
name: 'allowedMcpServers',
type: 'select',
hasMany: true,
options: [], // Will be populated dynamically based on plugin config
admin: {
description: 'Which external MCP Servers is the AI allowed to execute tools from?',
},
}
],
}

View File

@@ -0,0 +1,106 @@
'use client'
import React, { useState } from 'react'
import { useChat } from 'ai/react'
import './ChatWindow.scss'
export const ChatWindowProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
return (
<>
{children}
<ChatWindow />
</>
)
}
const ChatWindow: React.FC = () => {
const [isOpen, setIsOpen] = useState(false)
const { messages, input, handleInputChange, handleSubmit, setMessages } = useChat({
api: '/api/mcp-chat',
})
// Basic implementation to toggle chat window and submit messages
return (
<div className="payload-mcp-chat-container">
<button
className="payload-mcp-chat-toggle"
onClick={() => setIsOpen(!isOpen)}
style={{
position: 'fixed',
bottom: '20px',
right: '20px',
zIndex: 9999,
padding: '12px 24px',
backgroundColor: '#000',
color: '#fff',
borderRadius: '8px',
border: 'none',
cursor: 'pointer',
fontWeight: 'bold'
}}
>
{isOpen ? 'Close AI Chat' : 'Ask AI'}
</button>
{isOpen && (
<div
className="payload-mcp-chat-window"
style={{
position: 'fixed',
bottom: '80px',
right: '20px',
width: '400px',
height: '600px',
backgroundColor: '#fff',
border: '1px solid #eaeaea',
borderRadius: '12px',
zIndex: 9999,
display: 'flex',
flexDirection: 'column',
boxShadow: '0 10px 40px rgba(0,0,0,0.1)'
}}
>
<div className="chat-header" style={{ padding: '16px', borderBottom: '1px solid #eaeaea', backgroundColor: '#f9f9f9', borderTopLeftRadius: '12px', borderTopRightRadius: '12px' }}>
<h3 style={{ margin: 0, fontSize: '16px' }}>Payload MCP Chat</h3>
</div>
<div className="chat-messages" style={{ flex: 1, padding: '16px', overflowY: 'auto' }}>
{messages.map(m => (
<div key={m.id} style={{
marginBottom: '12px',
textAlign: m.role === 'user' ? 'right' : 'left'
}}>
<div style={{
display: 'inline-block',
padding: '8px 12px',
borderRadius: '8px',
backgroundColor: m.role === 'user' ? '#000' : '#f0f0f0',
color: m.role === 'user' ? '#fff' : '#000',
maxWidth: '80%'
}}>
{m.role === 'user' ? 'G: ' : 'AI: '}
{m.content}
</div>
</div>
))}
</div>
<form onSubmit={handleSubmit} style={{ padding: '16px', borderTop: '1px solid #eaeaea' }}>
<input
value={input}
placeholder="Ask me anything or use /commands..."
onChange={handleInputChange}
style={{
width: '100%',
padding: '12px',
borderRadius: '8px',
border: '1px solid #eaeaea',
boxSizing: 'border-box'
}}
/>
</form>
</div>
)}
</div>
)
}

View File

@@ -0,0 +1,75 @@
import { streamText } from 'ai'
import { createOpenAI } from '@ai-sdk/openai'
import { generatePayloadLocalTools } from '../tools/payloadLocal.js'
import { createMcpTools } from '../tools/mcpAdapter.js'
import { generateMemoryTools } from '../tools/memoryDb.js'
import type { PayloadRequest } from 'payload'
const openrouter = createOpenAI({
baseURL: 'https://openrouter.ai/api/v1',
apiKey: process.env.OPENROUTER_API_KEY || 'dummy_key',
})
export const handleMcpChat = async (req: PayloadRequest) => {
if (!req.user) {
return Response.json({ error: 'Unauthorized. You must be logged in to use AI Chat.' }, { status: 401 })
}
const { messages } = await req.json()
// 1. Check AI Permissions for req.user
// In a real implementation this looks up the global or collection for permissions
const allowedCollections = ['users'] // Stub
let activeTools: Record<string, any> = {}
// 2. Generate Payload Local Tools
if (allowedCollections.length > 0) {
const payloadTools = generatePayloadLocalTools(req.payload, req, allowedCollections)
activeTools = { ...activeTools, ...payloadTools }
}
// 3. Connect External MCPs
const allowedMcpServers: string[] = [] // Stub
if (allowedMcpServers.includes('gitea')) {
try {
const { tools: giteaTools } = await createMcpTools({
name: 'gitea',
command: 'npx',
args: ['-y', '@modelcontextprotocol/server-gitea', '--url', 'https://git.mintel.int', '--token', process.env.GITEA_TOKEN || '']
})
activeTools = { ...activeTools, ...giteaTools }
} catch (e) {
console.error('Failed to connect to Gitea MCP', e)
}
}
// 4. Inject Memory Database Tools
// We provide the user ID so memory is partitioned per user
const memoryTools = generateMemoryTools(req.user.id)
activeTools = { ...activeTools, ...memoryTools }
// 5. Build prompt to ensure it asks before saving
const memorySystemPrompt = `
You have access to a long-term vector memory database (Qdrant).
If the user says "speicher das", "merk dir das", "vergiss das nicht" etc., you MUST use the save_memory tool.
If the user shares important context but doesn't explicitly ask you to remember it, you should ask "Soll ich mir das für die Zukunft merken?" before saving it. Do not ask for trivial things.
`
try {
const result = streamText({
// @ts-ignore - AI SDK type mismatch
model: openrouter('google/gemini-3.0-flash'),
messages,
tools: activeTools,
system: `You are a helpful Payload CMS MCP Assistant orchestrating the local Mintel ecosystem.
You only have access to tools explicitly granted by the Admin.
You cannot do anything outside these tools. Always explain what you are doing.
${memorySystemPrompt}`
})
return result.toDataStreamResponse()
} catch (error) {
console.error("AI Error:", error)
return Response.json({ error: 'Failed to process AI request' }, { status: 500 })
}
}

View File

@@ -0,0 +1,2 @@
export { payloadMcpChatPlugin } from './plugin.js'
export type { PayloadMcpChatPluginConfig } from './types.js'

View File

@@ -0,0 +1,68 @@
import type { Config, Plugin } from 'payload'
import { AIChatPermissionsCollection } from './collections/AIChatPermissions.js'
import type { PayloadMcpChatPluginConfig } from './types.js'
export const payloadMcpChatPlugin =
(pluginOptions: PayloadMcpChatPluginConfig): Plugin =>
(incomingConfig) => {
let config = { ...incomingConfig }
// If disabled, return config untouched
if (pluginOptions.enabled === false) {
return config
}
// 1. Inject the Permissions Collection into the Schema
const existingCollections = config.collections || []
const mcpServers = pluginOptions.mcpServers || []
// Dynamically populate the select options for Collections and MCP Servers
const permissionCollection = { ...AIChatPermissionsCollection }
const collectionField = permissionCollection.fields.find(f => 'name' in f && f.name === 'allowedCollections') as any
if (collectionField) {
collectionField.options = existingCollections.map(c => ({
label: c.labels?.singular || c.slug,
value: c.slug
}))
}
const mcpField = permissionCollection.fields.find(f => 'name' in f && f.name === 'allowedMcpServers') as any
if (mcpField) {
mcpField.options = mcpServers.map(s => ({
label: s.name,
value: s.name
}))
}
config.collections = [...existingCollections, permissionCollection]
// 2. Register Custom API Endpoint for the AI Chat
config.endpoints = [
...(config.endpoints || []),
{
path: '/api/mcp-chat',
method: 'post',
handler: async (req) => {
// Fallback simple handler while developing endpoint logic
return Response.json({ message: "Chat endpoint active" })
},
},
]
// 3. Inject Chat React Component into Admin UI
if (pluginOptions.renderChatBubble !== false) {
config.admin = {
...(config.admin || {}),
components: {
...(config.admin?.components || {}),
providers: [
...(config.admin?.components?.providers || []),
'@mintel/payload-mcp-chat/components/ChatWindow#ChatWindowProvider',
],
},
}
}
return config
}

View File

@@ -0,0 +1,64 @@
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js'
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
import { tool } from 'ai'
import { z } from 'zod'
/**
* Connects to an external MCP Server and maps its tools to Vercel AI SDK Tools.
*/
export async function createMcpTools(mcpConfig: { name: string, url?: string, command?: string, args?: string[] }) {
let transport
// Support both HTTP/SSE and STDIO transports
if (mcpConfig.url) {
transport = new SSEClientTransport(new URL(mcpConfig.url))
} else if (mcpConfig.command) {
transport = new StdioClientTransport({
command: mcpConfig.command,
args: mcpConfig.args || [],
})
} else {
throw new Error('Invalid MCP config: Must provide either URL or Command.')
}
const client = new Client(
{ name: `payload-ai-client-${mcpConfig.name}`, version: '1.0.0' },
{ capabilities: {} }
)
await client.connect(transport)
// Fetch available tools from the external MCP server
const toolListResult = await client.listTools()
const externalTools = toolListResult.tools || []
const aiSdkTools: Record<string, any> = {}
// Map each external tool to a Vercel AI SDK Tool
for (const extTool of externalTools) {
// Basic conversion of JSON Schema to Zod for the AI SDK
// Note: For a production ready adapter, you might need a more robust jsonSchemaToZod converter
// or use AI SDK's new experimental generateSchema feature if available.
// Here we use a generic `z.any()` as a fallback since AI SDK requires a Zod schema.
const toolSchema = extTool.inputSchema as Record<string, any>
// We create a simplified parameter parser.
// An ideal approach uses `jsonSchemaToZod` library or native AI SDK JSON schema support
// (introduced recently in `ai` package).
aiSdkTools[`${mcpConfig.name}_${extTool.name}`] = tool({
description: `[From ${mcpConfig.name}] ${extTool.description || extTool.name}`,
parameters: z.any().describe('JSON matching the original MCP input_schema'), // Simplify for prototype
execute: async (args: any) => {
const result = await client.callTool({
name: extTool.name,
arguments: args
})
return result
}
})
}
return { tools: aiSdkTools, client }
}

View File

@@ -0,0 +1,113 @@
import { tool } from 'ai'
import { z } from 'zod'
import { QdrantClient } from '@qdrant/js-client-rest'
// Qdrant initialization
// This requires the user to have Qdrant running and QDRANT_URL/QDRANT_API_KEY environment variables set
const qdrantClient = new QdrantClient({
url: process.env.QDRANT_URL || 'http://localhost:6333',
apiKey: process.env.QDRANT_API_KEY,
})
const MEMORY_COLLECTION = 'mintel_ai_memory'
// Ensure collection exists on load
async function initQdrant() {
try {
const res = await qdrantClient.getCollections()
const exists = res.collections.find((c) => c.name === MEMORY_COLLECTION)
if (!exists) {
await qdrantClient.createCollection(MEMORY_COLLECTION, {
vectors: {
size: 1536, // typical embedding size, adjust based on the embedding model used
distance: 'Cosine',
},
})
console.log(`Qdrant collection '${MEMORY_COLLECTION}' created.`)
}
} catch (error) {
console.error('Failed to initialize Qdrant memory collection:', error)
}
}
// Call init, but don't block
initQdrant()
/**
* Returns memory tools for the AI SDK.
* Note: A real implementation would require an embedding step before inserting into Qdrant.
* For this implementation, we use a placeholder or assume the embeddings are handled
* by a utility function, or we use Qdrant's FastEmbed (if running their specialized container).
*/
export const generateMemoryTools = (userId: string | number) => {
return {
save_memory: tool({
description: 'Save an important preference, fact, or instruction about the user to long-term memory. Only use this when explicitly asked or when it is clearly a long-term preference.',
parameters: z.object({
fact: z.string().describe('The fact or instruction to remember.'),
category: z.string().optional().describe('An optional category like "preference", "rule", or "project_detail".'),
}),
execute: async ({ fact, category }) => {
// In a real scenario, you MUST generate embeddings for the 'fact' string here
// using OpenAI or another embedding provider before inserting into Qdrant.
// const embedding = await generateEmbedding(fact)
try {
// Mock embedding payload for demonstration
const mockEmbedding = new Array(1536).fill(0).map(() => Math.random())
await qdrantClient.upsert(MEMORY_COLLECTION, {
wait: true,
points: [
{
id: crypto.randomUUID(),
vector: mockEmbedding,
payload: {
userId: String(userId), // Partition memory by user
fact,
category,
createdAt: new Date().toISOString(),
},
},
],
})
return { success: true, message: `Successfully remembered: "${fact}"` }
} catch (error) {
console.error("Qdrant save error:", error)
return { success: false, error: 'Failed to save to memory database.' }
}
},
}),
search_memory: tool({
description: 'Search the user\'s long-term memory for past factual context, preferences, or rules.',
parameters: z.object({
query: z.string().describe('The search string to find in memory.'),
}),
execute: async ({ query }) => {
// Generate embedding for query
const mockQueryEmbedding = new Array(1536).fill(0).map(() => Math.random())
try {
const results = await qdrantClient.search(MEMORY_COLLECTION, {
vector: mockQueryEmbedding,
limit: 5,
filter: {
must: [
{
key: 'userId',
match: { value: String(userId) }
}
]
}
})
return results.map(r => r.payload?.fact || '')
} catch (error) {
console.error("Qdrant search error:", error)
return []
}
}
})
}
}

View File

@@ -0,0 +1,102 @@
import { tool } from 'ai'
import { z } from 'zod'
import type { Payload, PayloadRequest, User } from 'payload'
export const generatePayloadLocalTools = (
payload: Payload,
req: PayloadRequest,
allowedCollections: string[]
) => {
const tools: Record<string, any> = {}
for (const collectionSlug of allowedCollections) {
const slugKey = collectionSlug.replace(/-/g, '_')
// 1. Read (Find) Tool
tools[`read_${slugKey}`] = tool({
description: `Read/Find documents from the Payload CMS collection: ${collectionSlug}`,
parameters: z.object({
limit: z.number().optional().describe('Number of documents to return, max 100.'),
page: z.number().optional().describe('Page number for pagination.'),
// Simple string-based query for demo purposes. For a robust implementation,
// we'd map this to Payload's where query logic using a structured Zod schema.
query: z.string().optional().describe('Optional text to search within the collection.'),
}),
execute: async ({ limit = 10, page = 1, query }) => {
const where = query ? { id: { equals: query } } : undefined // Placeholder logic
return await payload.find({
collection: collectionSlug as any,
limit: Math.min(limit, 100),
page,
where,
req, // Crucial for passing the user context and respecting access control!
})
},
})
// 2. Read by ID Tool
tools[`read_${slugKey}_by_id`] = tool({
description: `Get a specific document by its ID from the ${collectionSlug} collection.`,
parameters: z.object({
id: z.union([z.string(), z.number()]).describe('The ID of the document.'),
}),
execute: async ({ id }) => {
return await payload.findByID({
collection: collectionSlug as any,
id,
req, // Enforce access control
})
},
})
// 3. Create Tool
tools[`create_${slugKey}`] = tool({
description: `Create a new document in the ${collectionSlug} collection.`,
parameters: z.object({
data: z.record(z.any()).describe('A JSON object containing the data to insert.'),
}),
execute: async ({ data }) => {
return await payload.create({
collection: collectionSlug as any,
data,
req, // Enforce access control
})
},
})
// 4. Update Tool
tools[`update_${slugKey}`] = tool({
description: `Update an existing document in the ${collectionSlug} collection.`,
parameters: z.object({
id: z.union([z.string(), z.number()]).describe('The ID of the document to update.'),
data: z.record(z.any()).describe('A JSON object containing the fields to update.'),
}),
execute: async ({ id, data }) => {
return await payload.update({
collection: collectionSlug as any,
id,
data,
req, // Enforce access control
})
},
})
// 5. Delete Tool
tools[`delete_${slugKey}`] = tool({
description: `Delete a document from the ${collectionSlug} collection by ID.`,
parameters: z.object({
id: z.union([z.string(), z.number()]).describe('The ID of the document to delete.'),
}),
execute: async ({ id }) => {
return await payload.delete({
collection: collectionSlug as any,
id,
req, // Enforce access control
})
},
})
}
return tools
}

View File

@@ -0,0 +1,18 @@
import type { Plugin } from 'payload'
export interface PayloadMcpChatPluginConfig {
enabled?: boolean
/**
* Defines whether to render the floating chat bubble in the admin panel automatically.
* Defaults to true.
*/
renderChatBubble?: boolean
/**
* Used to register external MCP servers that the AI can explicitly connect to if the admin permits it.
*/
mcpServers?: {
name: string
url?: string
// Command based STDIO later via configuration
}[]
}

View File

@@ -0,0 +1,25 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"jsx": "preserve",
"rootDir": "src",
"outDir": "dist",
"declaration": true,
"declarationDir": "dist",
"skipLibCheck": true,
"lib": [
"es2022",
"DOM",
"DOM.Iterable"
]
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/pdf",
"version": "1.9.6",
"version": "1.9.9",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/seo-engine",
"version": "1.9.6",
"version": "1.9.9",
"private": true,
"description": "AI-powered SEO keyword and topic cluster evaluation engine",
"type": "module",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/thumbnail-generator",
"version": "1.9.6",
"version": "1.9.9",
"private": false,
"type": "module",
"main": "./dist/index.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@mintel/tsconfig",
"version": "1.9.6",
"version": "1.9.9",
"publishConfig": {
"access": "public",
"registry": "https://git.infra.mintel.me/api/packages/mmintel/npm"

719
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff