fix: changed truncation length for MCP tools and projects (#8494)

* updated mcp backend to truncate tools name to 30 chars

* updated frontend to truncate tools with 30 chars and truncate project name with 26 chars

* changed it to not exceed 25

* updated one click install to truncate at 26

* updated name

* used constants and helper functions to refactor code

* updated constants

---------

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
This commit is contained in:
Lucas Oliveira 2025-06-12 17:33:24 -03:00 committed by GitHub
commit 1710c56e82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 64 additions and 14 deletions

View file

@ -554,6 +554,8 @@ export const USER_PROJECTS_HEADER = "My Collection";
export const DEFAULT_FOLDER = "Starter Project";
export const DEFAULT_FOLDER_DEPRECATED = "My Projects";
export const MAX_MCP_SERVER_NAME_LENGTH = 30;
/**
* Header text for admin page
* @constant

View file

@ -134,7 +134,7 @@ export default function AddMcpServerModal({
"snake_case",
"no_blank",
"lowercase",
]).slice(0, 20);
]).slice(0, 30);
try {
await modifyMCPServer({
name,
@ -168,7 +168,7 @@ export default function AddMcpServerModal({
"snake_case",
"no_blank",
"lowercase",
]).slice(0, 20);
]).slice(0, 30);
try {
await modifyMCPServer({
name,
@ -202,7 +202,7 @@ export default function AddMcpServerModal({
"snake_case",
"no_blank",
"lowercase",
]).slice(0, 20),
]).slice(0, 30),
}));
} catch (e: any) {
setError(e.message || "Invalid input");

View file

@ -3,6 +3,11 @@ import ShadTooltip from "@/components/common/shadTooltipComponent";
import ToolsComponent from "@/components/core/parameterRenderComponent/components/ToolsComponent";
import { Button } from "@/components/ui/button";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs-button";
import {
DEFAULT_FOLDER,
DEFAULT_FOLDER_DEPRECATED,
MAX_MCP_SERVER_NAME_LENGTH,
} from "@/constants/constants";
import { createApiKey } from "@/controllers/API";
import {
useGetFlowsMCP,
@ -183,7 +188,7 @@ const McpServerTab = ({ folderName }: { folderName: string }) => {
const MCP_SERVER_JSON = `{
"mcpServers": {
"lf-${parseString(folderName ?? "project", ["snake_case", "no_blank", "lowercase"]).slice(0, 11)}": {
"lf-${parseString(folderName === DEFAULT_FOLDER_DEPRECATED ? DEFAULT_FOLDER : (folderName ?? "project"), ["snake_case", "no_blank", "lowercase"]).slice(0, MAX_MCP_SERVER_NAME_LENGTH - 4)}": {
"command": "${selectedPlatform === "windows" ? "cmd" : selectedPlatform === "wsl" ? "wsl" : "uvx"}",
"args": [
${

View file

@ -153,7 +153,7 @@ export function extractMcpServersFromJson(
throw new Error("No valid MCP server found in the input.");
}
return validServers.map(([name, server]) => ({
name: name.slice(0, 20),
name: name.slice(0, 30),
command: server.command,
args: server.args,
env: server.env && typeof server.env === "object" ? server.env : {},