Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
MCP presets: warn when a required key is still blank
Lin (kwant bot)5df89c618289
diff --git a/frontend/src/components/McpServersModal.tsx b/frontend/src/components/McpServersModal.tsxindex 48f8104e..725e6252 100644--- a/frontend/src/components/McpServersModal.tsx+++ b/frontend/src/components/McpServersModal.tsx@@ -51,6 +51,7 @@ import {serverStatusKind,isSignedIn,readOAuthMessage,+ isBlankRequired,} from '../mcp';interface McpServersModalProps {@@ -117,52 +118,68 @@ const SecretRows: React.FC<{keyPlaceholder: string;keyLabel: string;addLabel: string;-}> = ({ rows, onChange, keyPlaceholder, keyLabel, addLabel }) => {+ /** Prefix for the ids that tie a row's warning to its value field. */+ idPrefix: string;+}> = ({ rows, onChange, keyPlaceholder, keyLabel, addLabel, idPrefix }) => {const [shown, setShown] = useState<Record<number, boolean>>({});const update = (i: number, patch: Partial<SecretRow>) => onChange(rows.map((r, j) => (j === i ? { ...r, ...patch } : r)));return (<div className="space-y-1.5">- {rows.map((row, i) => (- <div key={i} className="flex flex-col sm:flex-row gap-1.5">- <input- aria-label={keyLabel}- value={row.key}- disabled={row.saved}- onChange={(e) => update(i, { key: e.target.value })}- placeholder={keyPlaceholder}- className={`${inputCls} sm:w-2/5 font-mono disabled:text-zinc-400 disabled:bg-zinc-950/60`}- />- <div className="flex gap-1.5 flex-1 min-w-0">- <div className="relative flex-1 min-w-0">+ {rows.map((row, i) => {+ // A preset's key that is still empty: say so, but saving stays allowed.+ const missing = isBlankRequired(row);+ const warnId = `${idPrefix}-missing-${i}`;+ return (+ <div key={i} className="space-y-1">+ <div className="flex flex-col sm:flex-row gap-1.5"><input- aria-label={`Value for ${row.key || 'this entry'}`}- type={shown[i] ? 'text' : 'password'}- autoComplete="off"- value={row.value}- onChange={(e) => update(i, { value: e.target.value })}- placeholder={row.saved ? '•••••••• saved, leave blank to keep' : row.hint || 'Secret value'}- className={`${inputCls} pr-8 font-mono`}+ aria-label={keyLabel}+ value={row.key}+ disabled={row.saved}+ onChange={(e) => update(i, { key: e.target.value })}+ placeholder={keyPlaceholder}+ className={`${inputCls} sm:w-2/5 font-mono disabled:text-zinc-400 disabled:bg-zinc-950/60`}/>- <button- type="button"- onClick={() => setShown((s) => ({ ...s, [i]: !s[i] }))}- aria-label={shown[i] ? 'Hide value' : 'Show value'}- className="absolute right-1.5 top-1/2 -translate-y-1/2 p-1 rounded text-zinc-500 hover:text-zinc-200"- >- {shown[i] ? <EyeOff size={13} /> : <Eye size={13} />}- </button>+ <div className="flex gap-1.5 flex-1 min-w-0">+ <div className="relative flex-1 min-w-0">+ <input+ aria-label={`Value for ${row.key || 'this entry'}`}+ aria-describedby={missing ? warnId : undefined}+ type={shown[i] ? 'text' : 'password'}+ autoComplete="off"+ value={row.value}+ onChange={(e) => update(i, { value: e.target.value })}+ placeholder={row.saved ? '•••••••• saved, leave blank to keep' : row.hint || 'Secret value'}+ className={`${inputCls} pr-8 font-mono ${missing ? 'border-amber-500/40' : ''}`}+ />+ <button+ type="button"+ onClick={() => setShown((s) => ({ ...s, [i]: !s[i] }))}+ aria-label={shown[i] ? 'Hide value' : 'Show value'}+ className="absolute right-1.5 top-1/2 -translate-y-1/2 p-1 rounded text-zinc-500 hover:text-zinc-200"+ >+ {shown[i] ? <EyeOff size={13} /> : <Eye size={13} />}+ </button>+ </div>+ <button+ type="button"+ onClick={() => onChange(rows.filter((_, j) => j !== i))}+ aria-label={`Remove ${row.key || 'entry'}`}+ className="p-2 rounded-lg text-zinc-500 hover:text-rose-300 hover:bg-rose-500/10 transition-colors"+ >+ <Trash2 size={14} />+ </button>+ </div></div>- <button- type="button"- onClick={() => onChange(rows.filter((_, j) => j !== i))}- aria-label={`Remove ${row.key || 'entry'}`}- className="p-2 rounded-lg text-zinc-500 hover:text-rose-300 hover:bg-rose-500/10 transition-colors"- >- <Trash2 size={14} />- </button>+ {missing && (+ <p id={warnId} className="flex items-start gap-1.5 text-[11px] text-amber-300/90">+ <KeyRound size={12} className="flex-shrink-0 mt-px text-amber-400" aria-hidden="true" />+ <span>This server needs a key to work. Add it now, or save and edit later.</span>+ </p>+ )}</div>- </div>- ))}+ );+ })}<buttontype="button"onClick={() => onChange([...rows, { key: '', value: '', saved: false }])}@@ -948,6 +965,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onCloskeyPlaceholder="API_TOKEN"keyLabel="Variable name"addLabel="Add variable"+ idPrefix="mcp-env"/></div></>@@ -975,6 +993,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onCloskeyPlaceholder="Authorization"keyLabel="Header name"addLabel="Add header"+ idPrefix="mcp-header"/><p className="mt-1.5 text-[11px] text-zinc-500">Servers that need sign-in (like Notion) don’t need a header. Use <span className="text-zinc-300">Connect</span> on the server after saving.diff --git a/frontend/src/mcp.ts b/frontend/src/mcp.tsindex fda61b36..5e7ec146 100644--- a/frontend/src/mcp.ts+++ b/frontend/src/mcp.ts@@ -48,6 +48,8 @@ export interface SecretRow {saved: boolean;/** Placeholder for an empty value, like the format a preset expects. */hint?: string;+ /** Set by presets: the server won't work until this has a value. */+ required?: boolean;}export interface McpFormState {@@ -98,18 +100,24 @@ export interface McpPreset {form: McpFormState;}-const stdioPreset = (name: string, commandLine: string, env: Array<[string, string]> = []): McpFormState => ({+/** A preset's secret: name, placeholder, and whether the server needs it to work. */+type PresetSecret = [key: string, hint: string, required?: boolean];++const presetRows = (secrets: PresetSecret[]): SecretRow[] =>+ secrets.map(([key, hint, required]) => ({ key, value: '', saved: false, hint, ...(required ? { required: true } : {}) }));++const stdioPreset = (name: string, commandLine: string, env: PresetSecret[] = []): McpFormState => ({...emptyMcpForm('stdio'),name,commandLine,- env: env.map(([key, hint]) => ({ key, value: '', saved: false, hint })),+ env: presetRows(env),});-const httpPreset = (name: string, url: string, headers: Array<[string, string]> = []): McpFormState => ({+const httpPreset = (name: string, url: string, headers: PresetSecret[] = []): McpFormState => ({...emptyMcpForm('http'),name,url,- headers: headers.map(([key, hint]) => ({ key, value: '', saved: false, hint })),+ headers: presetRows(headers),});/**@@ -149,7 +157,7 @@ export const MCP_PRESETS: McpPreset[] = [category: 'files',needs: ['Token'],source: 'https://github.com/github/github-mcp-server',- form: httpPreset('github', 'https://api.githubcopilot.com/mcp/', [['Authorization', 'Bearer ghp_…']]),+ form: httpPreset('github', 'https://api.githubcopilot.com/mcp/', [['Authorization', 'Bearer ghp_…', true]]),},{// PyPI mcp-server-fetch 2026.10.10@@ -179,7 +187,7 @@ export const MCP_PRESETS: McpPreset[] = [category: 'web',needs: ['Node.js', 'API key'],source: 'https://github.com/brave/brave-search-mcp-server',- form: stdioPreset('brave-search', 'npx -y @brave/brave-search-mcp-server --transport stdio', [['BRAVE_API_KEY', 'From api-dashboard.search.brave.com']]),+ form: stdioPreset('brave-search', 'npx -y @brave/brave-search-mcp-server --transport stdio', [['BRAVE_API_KEY', 'From api-dashboard.search.brave.com', true]]),},{// Upstash's hosted server; works without a key, a key (Authorization: Bearer …) raises limits.@@ -200,7 +208,7 @@ export const MCP_PRESETS: McpPreset[] = [category: 'data',needs: ['uv'],source: 'https://github.com/crystaldba/postgres-mcp',- form: stdioPreset('postgres', 'uvx postgres-mcp --access-mode=restricted', [['DATABASE_URI', 'postgresql://user:password@host:5432/db']]),+ form: stdioPreset('postgres', 'uvx postgres-mcp --access-mode=restricted', [['DATABASE_URI', 'postgresql://user:password@host:5432/db', true]]),},{// Supabase's hosted server with sign-in.@@ -358,6 +366,17 @@ export const validateMcpForm = (form: McpFormState): string | null => {return null;};+/**+ * Whether a row the server needs is still empty. A saved row is never blank: leaving it empty+ * keeps the stored value. "Bearer" or "Basic" with nothing after it counts as empty.+ */+export const isBlankRequired = (row: SecretRow): boolean =>+ !!row.required && !row.saved && /^((bearer|basic)\b)?$/i.test(row.value.trim());++/** Names of required keys in the form that are still empty, for the "needs a key" warning. Saving is still allowed. */+export const blankRequiredKeys = (form: McpFormState): string[] =>+ (form.transport === 'stdio' ? form.env : form.headers).filter(isBlankRequired).map((r) => r.key.trim() || 'key');+const rowsToMap = (rows: SecretRow[]): Record<string, string> => {const out: Record<string, string> = {};for (const row of rows) {diff --git a/frontend/tests/mcp.test.mjs b/frontend/tests/mcp.test.mjsindex 0fae3819..643a9dae 100644--- a/frontend/tests/mcp.test.mjs+++ b/frontend/tests/mcp.test.mjs@@ -34,6 +34,8 @@ const {readOAuthMessage,kwantUsage,defaultKwantServerIds,+ isBlankRequired,+ blankRequiredKeys,} = mcp;test('splits command lines like a README shows them', () => {@@ -335,3 +337,57 @@ test('a new kwant starts with every server on, paused ones included', () => {['a', 'b'],);});++const presetForm = (id) => {+ const f = MCP_PRESETS.find((p) => p.id === id).form;+ return { ...f, env: f.env.map((r) => ({ ...r })), headers: f.headers.map((r) => ({ ...r })) };+};++test('only presets that need a key or token mark it required', () => {+ const marked = Object.fromEntries(+ MCP_PRESETS.map((p) => [p.id, [...p.form.env, ...p.form.headers].filter((r) => r.required).map((r) => r.key)]).filter(([, keys]) => keys.length > 0),+ );+ assert.deepEqual(marked, { github: ['Authorization'], 'brave-search': ['BRAVE_API_KEY'], postgres: ['DATABASE_URI'] });+ // Every preset tagged as needing a key or token has a required field, and no Sign-in preset does.+ for (const p of MCP_PRESETS) {+ const hasRequired = [...p.form.env, ...p.form.headers].some((r) => r.required);+ assert.equal(hasRequired, p.needs.includes('Token') || p.needs.includes('API key') || p.id === 'postgres', p.id);+ if (p.needs.includes('Sign-in')) assert.equal(hasRequired, false, p.id);+ }+});++test('warns about required keys that are still blank, and only those', () => {+ const github = presetForm('github');+ assert.deepEqual(blankRequiredKeys(github), ['Authorization']);+ for (const blank of ['', ' ', 'Bearer', 'bearer ', 'Basic']) {+ github.headers[0].value = blank;+ assert.deepEqual(blankRequiredKeys(github), ['Authorization'], JSON.stringify(blank));+ }+ github.headers[0].value = 'Bearer ghp_abc123';+ assert.deepEqual(blankRequiredKeys(github), []);++ const brave = presetForm('brave-search');+ assert.deepEqual(blankRequiredKeys(brave), ['BRAVE_API_KEY']);+ brave.env[0].value = 'BSA123';+ assert.deepEqual(blankRequiredKeys(brave), []);+ assert.deepEqual(blankRequiredKeys(presetForm('postgres')), ['DATABASE_URI']);++ // Sign-in, no-key and custom servers never warn.+ for (const id of ['notion', 'context7', 'files', 'supabase']) assert.deepEqual(blankRequiredKeys(presetForm(id)), [], id);+ const custom = { ...emptyMcpForm('http'), headers: [{ key: 'Authorization', value: '', saved: false }] };+ assert.deepEqual(blankRequiredKeys(custom), []);+});++test('a saved key left blank is kept, so it never warns', () => {+ assert.equal(isBlankRequired({ key: 'Authorization', value: '', saved: true, required: true }), false);+ assert.equal(isBlankRequired({ key: 'Authorization', value: '', saved: false, required: true }), true);+ assert.equal(isBlankRequired({ key: 'Authorization', value: '', saved: false }), false);+});++test('a blank required key still saves, and the flag stays out of the request', () => {+ const github = presetForm('github');+ assert.equal(validateMcpForm(github), null);+ const payload = formToPayload(github);+ assert.deepEqual(payload.headers, { Authorization: '' });+ assert.equal(JSON.stringify(payload).includes('required'), false);+});