mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-20 21:43:56 +08:00
- 抽取 MCP 草稿 seed 构建逻辑供 UI 和内置工具复用 - inspect_mcp_draft 返回脱敏 suggestedServerSeed - 同步 slash 命令、系统指导和回归测试
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { parseMCPCommandDraft } from './mcpCommandDraft';
|
|
import { buildMCPQuickAddServerSeed, buildMCPServerDraftSeed } from './mcpServerDraftSeed';
|
|
|
|
describe('mcpServerDraftSeed', () => {
|
|
it('builds an editable draft seed from a parsed uvx command with env vars', () => {
|
|
const parsed = parseMCPCommandDraft('$env:GITHUB_TOKEN=***; uvx mcp-server-github --stdio');
|
|
|
|
expect(parsed.ok).toBe(true);
|
|
const seed = buildMCPQuickAddServerSeed(parsed.draft!);
|
|
|
|
expect(seed).toMatchObject({
|
|
name: 'mcp-server-github',
|
|
transport: 'stdio',
|
|
command: 'uvx',
|
|
args: ['mcp-server-github', '--stdio'],
|
|
env: { GITHUB_TOKEN: '***' },
|
|
enabled: true,
|
|
timeoutSeconds: 20,
|
|
});
|
|
});
|
|
|
|
it('uses a wider default timeout and image-based name for docker drafts', () => {
|
|
const parsed = parseMCPCommandDraft('docker run --rm -i -e API_KEY=*** mcp/server-fetch:latest');
|
|
|
|
expect(parsed.ok).toBe(true);
|
|
const seed = buildMCPQuickAddServerSeed(parsed.draft!);
|
|
|
|
expect(seed).toMatchObject({
|
|
name: 'server-fetch:latest',
|
|
command: 'docker',
|
|
args: ['run', '--rm', '-i', '-e', 'API_KEY=***', 'mcp/server-fetch:latest'],
|
|
timeoutSeconds: 45,
|
|
});
|
|
});
|
|
|
|
it('respects explicit draft names and timeouts for inspection snapshots', () => {
|
|
const seed = buildMCPServerDraftSeed({
|
|
name: 'GitHub MCP',
|
|
command: 'uvx',
|
|
args: ['mcp-server-github', '--stdio'],
|
|
timeoutSeconds: 60,
|
|
env: { GITHUB_TOKEN: '***' },
|
|
});
|
|
|
|
expect(seed).toMatchObject({
|
|
name: 'GitHub MCP',
|
|
command: 'uvx',
|
|
timeoutSeconds: 60,
|
|
env: { GITHUB_TOKEN: '***' },
|
|
});
|
|
});
|
|
});
|