Skip to content

armgit / kwant

Public Imported from GitHub
0

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.

Find a tool: start a public-directory install with a valid server name (0.9.8) (#584)

Oleksandr Ivanchenko775e53badb42
diff --git a/frontend/src/components/McpServersModal.tsx b/frontend/src/components/McpServersModal.tsx
index 3e3dda18..78eed9dd 100644
--- a/frontend/src/components/McpServersModal.tsx
+++ b/frontend/src/components/McpServersModal.tsx
@@ -51,6 +51,7 @@ import {
isSignedIn,
readOAuthMessage,
isBlankRequired,
+ directoryServerName,
} from '../mcp';
import { inDesktopApp, leaveForSignIn, pollUntil, signInChanged } from '../externalLinks';
import { useEscapeLayer } from '../escape';
@@ -628,7 +629,7 @@ export const McpServersModal: React.FC<McpServersModalProps> = ({ isOpen, onClos
const rows: SecretRow[] = (entry.inputs ?? []).map((i) => ({ key: i.name, value: '', saved: false, hint: i.description, required: !!i.required }));
const start: McpFormState = {
...emptyMcpForm(remote ? 'http' : 'stdio'),
- name: (entry.title || entry.registry_name.split('/').pop() || entry.registry_name).trim(),
+ name: directoryServerName(entry),
url: remote ? entry.url ?? '' : '',
commandLine: remote ? '' : entry.command ?? '',
env: remote ? [] : rows,
diff --git a/frontend/src/mcp.ts b/frontend/src/mcp.ts
index d88d5e1b..fa7a8701 100644
--- a/frontend/src/mcp.ts
+++ b/frontend/src/mcp.ts
@@ -534,6 +534,16 @@ export const toServerName = (label: string): string =>
.replace(/^[-_]+|[-_]+$/g, '')
.slice(0, 48);
+/**
+ * The server name a public-directory listing starts with: its title made valid ("ElevenLabs Voices" →
+ * "elevenlabs-voices"), else the last part of its registry name, so Add & test works without a rename.
+ */
+export const directoryServerName = (entry: { title?: string | null; registry_name: string }): string =>
+ toServerName(entry.title ?? '') ||
+ toServerName(entry.registry_name.split('/').pop() ?? '') ||
+ toServerName(entry.registry_name) ||
+ 'tool';
+
/** Returns a friendly message for the first problem in the form, or null when it can be saved. */
export const validateMcpForm = (form: McpFormState): string | null => {
const name = form.name.trim();
diff --git a/frontend/tests/mcp.test.mjs b/frontend/tests/mcp.test.mjs
index 57430ae8..9f1b9248 100644
--- a/frontend/tests/mcp.test.mjs
+++ b/frontend/tests/mcp.test.mjs
@@ -23,6 +23,7 @@ const {
joinCommandLine,
validateMcpForm,
toServerName,
+ directoryServerName,
parseMcpToolName,
parseToolCalls,
formatArgs,
@@ -427,3 +428,20 @@ test('a blank required key still saves, and the flag stays out of the request',
assert.deepEqual(payload.headers, { Authorization: '' });
assert.equal(JSON.stringify(payload).includes('required'), false);
});
+
+test('a public-directory tool starts with a valid name, so Add & test works without a rename', () => {
+ const ok = (name) => assert.equal(validateMcpForm({ ...emptyMcpForm('http'), name, url: 'https://x.example/mcp' }), null, name);
+ const cases = [
+ [{ title: 'ElevenLabs Voices', registry_name: 'io.github.elevenlabs/voices' }, 'elevenlabs-voices'],
+ [{ title: ' Notion (official) ', registry_name: 'com.notion/mcp' }, 'notion-official'],
+ [{ title: '', registry_name: 'io.github.acme/pg-tools' }, 'pg-tools'],
+ [{ title: '日本語', registry_name: 'io.github.acme/Weather.API' }, 'weather-api'],
+ [{ title: 'x'.repeat(60) + ' tail', registry_name: 'a/b' }, 'x'.repeat(48)],
+ [{ title: '__ä__', registry_name: '🙂' }, 'tool'],
+ ];
+ for (const [entry, want] of cases) {
+ const got = directoryServerName(entry);
+ assert.equal(got, want);
+ ok(got);
+ }
+});