Skip to content

Commit 2979b35

Browse files
committed
fix(mcp): align tool-name regex with server sanitization, add disabled-combobox hint
1 parent 17e6b8f commit 2979b35

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/mcp

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/mcp/mcp.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ import { useWorkflowStore } from '@/stores/workflows/workflow/store'
3333

3434
const logger = createLogger('McpToolDeploy')
3535

36-
/** MCP tool names allow lowercase letters, numbers, and underscores only */
37-
const TOOL_NAME_PATTERN = /^[a-z0-9_]+$/
36+
/**
37+
* Mirrors the server's `sanitizeToolName` output: lowercase alphanumerics with single
38+
* underscores between segments. Disallows leading/trailing and consecutive underscores so
39+
* the validated name matches exactly what the server persists (no silent rewrite).
40+
*/
41+
const TOOL_NAME_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/
3842
const MAX_TOOL_NAME_LENGTH = 64
3943

4044
/** InputFormatField with guaranteed name (after normalization) */
@@ -178,7 +182,7 @@ export function McpDeploy({
178182
return `Tool name must be ${MAX_TOOL_NAME_LENGTH} characters or fewer`
179183
}
180184
if (!TOOL_NAME_PATTERN.test(trimmed)) {
181-
return 'Tool name can only contain lowercase letters, numbers, and underscores'
185+
return 'Use lowercase letters and numbers, separated by single underscores'
182186
}
183187
return null
184188
}, [toolName])
@@ -593,11 +597,15 @@ export function McpDeploy({
593597
<span className='truncate text-[var(--text-primary)]'>{selectedServersLabel}</span>
594598
}
595599
/>
596-
{!toolName.trim() && (
600+
{!toolName.trim() ? (
597601
<p className='mt-[6.5px] text-[var(--text-secondary)] text-xs'>
598602
Enter a tool name to select servers
599603
</p>
600-
)}
604+
) : toolNameError ? (
605+
<p className='mt-[6.5px] text-[var(--text-secondary)] text-xs'>
606+
Fix the tool name to select servers
607+
</p>
608+
) : null}
601609
</div>
602610

603611
{saveErrors.length > 0 && (

0 commit comments

Comments
 (0)