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

Function planToolPaths

packages/plugins/openapi/src/sdk/definitions.ts:246–284  ·  view source on GitHub ↗
(inputs: readonly OperationPathInput[])

Source from the content-addressed store, hash-verified

244 * The returned `operationIndex` points back into the `inputs` array.
245 */
246export const planToolPaths = (inputs: readonly OperationPathInput[]): PlannedToolPath[] => {
247 const raw: RawToolPath[] = inputs.map((op, index) => {
248 const operationId = op.operationId;
249 const operationHash = stableHash({
250 method: op.method,
251 path: op.pathTemplate,
252 operationId,
253 });
254 const versionSegment = deriveVersionSegment(op.pathTemplate);
255
256 if (op.explicitToolPath) {
257 const [group = "root", ...leafParts] = op.explicitToolPath.split(".").filter(Boolean);
258 const leaf = leafParts.join(".") || group;
259 return {
260 toolPath: op.explicitToolPath,
261 group,
262 leaf,
263 versionSegment,
264 method: op.method,
265 operationHash,
266 operationIndex: index,
267 };
268 }
269
270 const group = normalizeGroupSegment(op.tag0) ?? derivePathGroup(op.pathTemplate);
271 const leaf = deriveLeaf(operationId, op.method, op.pathTemplate, group);
272 return {
273 toolPath: `${group}.${leaf}`,
274 group,
275 leaf,
276 versionSegment,
277 method: op.method,
278 operationHash,
279 operationIndex: index,
280 };
281 });
282
283 return resolveCollisions(raw).sort((a, b) => a.toolPath.localeCompare(b.toolPath));
284};
285
286/**
287 * Compile extracted operations into tool definitions with structured

Callers 3

streamOperationBindingsFunction · 0.90
compileToolDefinitionsFunction · 0.85

Calls 6

stableHashFunction · 0.85
deriveVersionSegmentFunction · 0.85
normalizeGroupSegmentFunction · 0.85
derivePathGroupFunction · 0.85
deriveLeafFunction · 0.85
resolveCollisionsFunction · 0.85

Tested by

no test coverage detected