MCPcopy Index your code
hub / github.com/simstudioai/sim / getToolPrefixFromName

Function getToolPrefixFromName

scripts/generate-docs.ts:1343–1357  ·  view source on GitHub ↗

* Get the tool prefix (service name) from a tool name. * e.g., "calcom_list_schedules" -> "calcom"

(toolName: string)

Source from the content-addressed store, hash-verified

1341 * e.g., "calcom_list_schedules" -> "calcom"
1342 */
1343function getToolPrefixFromName(toolName: string): string {
1344 const parts = toolName.split('_')
1345
1346 // Try to find a valid tool directory
1347 for (let i = parts.length - 1; i >= 1; i--) {
1348 const possiblePrefix = parts.slice(0, i).join('_')
1349 const toolDirPath = path.join(rootDir, `apps/sim/tools/${possiblePrefix}`)
1350
1351 if (fs.existsSync(toolDirPath) && fs.statSync(toolDirPath).isDirectory()) {
1352 return possiblePrefix
1353 }
1354 }
1355
1356 return parts[0]
1357}
1358
1359/**
1360 * Resolve a const reference from a types file.

Callers 1

extractToolInfoFunction · 0.85

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected