Introduce a Helm-chart-like template system for MCP servers. Templates are YAML files in templates/ that get seeded into the DB on startup. Users can browse them with `mcpctl get templates`, inspect with `mcpctl describe template`, and instantiate with `mcpctl create server --from-template=`. Also adds Portainer deployment scripts, mcplocal systemd service, Streamable HTTP MCP endpoint, and RPM packaging for mcpctl-local. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
87 lines
2.5 KiB
TypeScript
87 lines
2.5 KiB
TypeScript
import { describe, it, expect, beforeAll, afterAll, beforeEach } from 'vitest';
|
|
import type { PrismaClient } from '@prisma/client';
|
|
import { setupTestDb, cleanupTestDb, clearAllTables } from './helpers.js';
|
|
import { seedTemplates } from '../src/seed/index.js';
|
|
import type { SeedTemplate } from '../src/seed/index.js';
|
|
|
|
let prisma: PrismaClient;
|
|
|
|
beforeAll(async () => {
|
|
prisma = await setupTestDb();
|
|
}, 30_000);
|
|
|
|
afterAll(async () => {
|
|
await cleanupTestDb();
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
await clearAllTables(prisma);
|
|
});
|
|
|
|
const testTemplates: SeedTemplate[] = [
|
|
{
|
|
name: 'github',
|
|
version: '1.0.0',
|
|
description: 'GitHub MCP server',
|
|
packageName: '@anthropic/github-mcp',
|
|
transport: 'STDIO',
|
|
env: [{ name: 'GITHUB_TOKEN', description: 'Personal access token', required: true }],
|
|
},
|
|
{
|
|
name: 'slack',
|
|
version: '1.0.0',
|
|
description: 'Slack MCP server',
|
|
packageName: '@anthropic/slack-mcp',
|
|
transport: 'STDIO',
|
|
env: [],
|
|
},
|
|
];
|
|
|
|
describe('seedTemplates', () => {
|
|
it('seeds templates', async () => {
|
|
const count = await seedTemplates(prisma, testTemplates);
|
|
expect(count).toBe(2);
|
|
|
|
const templates = await prisma.mcpTemplate.findMany({ orderBy: { name: 'asc' } });
|
|
expect(templates).toHaveLength(2);
|
|
expect(templates.map((t) => t.name)).toEqual(['github', 'slack']);
|
|
});
|
|
|
|
it('is idempotent (upsert)', async () => {
|
|
await seedTemplates(prisma, testTemplates);
|
|
const count = await seedTemplates(prisma, testTemplates);
|
|
expect(count).toBe(2);
|
|
|
|
const templates = await prisma.mcpTemplate.findMany();
|
|
expect(templates).toHaveLength(2);
|
|
});
|
|
|
|
it('seeds env correctly', async () => {
|
|
await seedTemplates(prisma, testTemplates);
|
|
const github = await prisma.mcpTemplate.findUnique({ where: { name: 'github' } });
|
|
const env = github!.env as Array<{ name: string; description?: string; required?: boolean }>;
|
|
expect(env).toHaveLength(1);
|
|
expect(env[0].name).toBe('GITHUB_TOKEN');
|
|
expect(env[0].required).toBe(true);
|
|
});
|
|
|
|
it('accepts custom template list', async () => {
|
|
const custom: SeedTemplate[] = [
|
|
{
|
|
name: 'custom-template',
|
|
version: '2.0.0',
|
|
description: 'Custom test template',
|
|
packageName: '@test/custom',
|
|
transport: 'STDIO',
|
|
env: [],
|
|
},
|
|
];
|
|
const count = await seedTemplates(prisma, custom);
|
|
expect(count).toBe(1);
|
|
|
|
const templates = await prisma.mcpTemplate.findMany();
|
|
expect(templates).toHaveLength(1);
|
|
expect(templates[0].name).toBe('custom-template');
|
|
});
|
|
});
|