MCPcopy Create free account
hub / github.com/idosal/git-mcp / generateCodeSearchToolName

Function generateCodeSearchToolName

src/api/tools/commonTools.ts:969–987  ·  view source on GitHub ↗
({
  urlType,
  repo,
}: RepoData)

Source from the content-addressed store, hash-verified

967 * @returns A descriptive string for the tool
968 */
969export function generateCodeSearchToolName({
970 urlType,
971 repo,
972}: RepoData): string {
973 try {
974 // Default tool name as fallback
975 let toolName = "search_code";
976 if (urlType == "subdomain" || urlType == "github") {
977 // Use enforceLengthLimit to ensure the tool name doesn't exceed 55 characters
978 return enforceToolNameLengthLimit("search_", repo, "_code");
979 }
980 // replace non-alphanumeric characters with underscores
981 return toolName.replace(/[^a-zA-Z0-9]/g, "_");
982 } catch (error) {
983 console.error("Error generating code search tool name:", error);
984 // Return default tool name if there's any error parsing the URL
985 return "search_code";
986 }
987}
988
989/**
990 * Generate a dynamic description for the code search tool based on the URL

Callers 1

getToolsMethod · 0.85

Calls 3

errorMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected