MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / policyPrefixForTool

Function policyPrefixForTool

packages/plugins/toolkits/src/page.tsx:213–235  ·  view source on GitHub ↗
(tool: ToolRow)

Source from the content-addressed store, hash-verified

211};
212
213const policyPrefixForTool = (tool: ToolRow): string => {
214 const matchId = toolMatchId(tool);
215 const integration = String(tool.integration);
216 if (tool.connection && tool.connection.length > 0) {
217 const connection = String(tool.connection);
218 if (tool.owner) {
219 const ownerConnectionPrefix = `${integration}.${tool.owner}.${connection}`;
220 if (matchId === ownerConnectionPrefix || matchId.startsWith(`${ownerConnectionPrefix}.`)) {
221 return ownerConnectionPrefix;
222 }
223 }
224 const connectionPrefix = `${integration}.${connection}`;
225 if (matchId === connectionPrefix || matchId.startsWith(`${connectionPrefix}.`)) {
226 return connectionPrefix;
227 }
228 }
229 const name = String(tool.name);
230 if (name.length > 0 && matchId.endsWith(`.${name}`)) {
231 return matchId.slice(0, -name.length - 1);
232 }
233 const segments = matchId.split(".");
234 return segments.length > 1 ? segments.slice(0, -1).join(".") : matchId;
235};
236
237const connectionPatternForTool = (tool: ToolRow): string => `${policyPrefixForTool(tool)}.*`;
238

Callers 1

connectionPatternForToolFunction · 0.85

Calls 1

toolMatchIdFunction · 0.85

Tested by

no test coverage detected