MCPcopy Create free account
hub / github.com/cloudflare/mcp / listNonCodemodeOperations

Function listNonCodemodeOperations

src/openapi.ts:141–179  ·  view source on GitHub ↗
(
  paths: Record<string, Record<string, OperationInfo>>
)

Source from the content-addressed store, hash-verified

139}
140
141function listNonCodemodeOperations(
142 paths: Record<string, Record<string, OperationInfo>>
143): NonCodemodeOperation[] {
144 const operations: NonCodemodeOperation[] = []
145 const registeredNames = new Set<string>()
146
147 for (const [path, pathItem] of Object.entries(paths)) {
148 for (const method of HTTP_METHODS) {
149 const operation = pathItem[method]
150 if (!operation) continue
151
152 let toolName = pathToToolName(method, path)
153 // Deduplicate if truncation caused a collision
154 if (registeredNames.has(toolName)) {
155 let i = 2
156 let candidate: string
157 do {
158 const suffixStr = `_${i}`
159 const maxBase = 128 - suffixStr.length
160 const base =
161 toolName.length > maxBase ? toolName.slice(0, maxBase).replace(/_$/, '') : toolName
162 candidate = `${base}${suffixStr}`
163 i++
164 } while (registeredNames.has(candidate))
165 toolName = candidate
166 }
167 registeredNames.add(toolName)
168
169 const description =
170 `${method.toUpperCase()} ${path}` +
171 (operation.summary ? `\n\n${operation.summary}` : '') +
172 (operation.description ? `\n\n${operation.description}` : '')
173
174 operations.push({ toolName, description, method, path, operation })
175 }
176 }
177
178 return operations
179}
180
181/**
182 * Build the JSON-serializable artifact in the scheduled handler. This moves the

Callers 1

buildNonCodemodeToolsFunction · 0.85

Calls 2

pathToToolNameFunction · 0.85
replaceMethod · 0.65

Tested by

no test coverage detected