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

Function toolForAccountAccess

src/tools/non-codemode.ts:139–162  ·  view source on GitHub ↗
(
  tool: NonCodemodeTool,
  resolvedAccountId: string | undefined,
  props: AuthProps
)

Source from the content-addressed store, hash-verified

137}
138
139function toolForAccountAccess(
140 tool: NonCodemodeTool,
141 resolvedAccountId: string | undefined,
142 props: AuthProps
143): NonCodemodeTool {
144 if (!tool.inputSchema.properties['account_id']) return tool
145
146 const properties = { ...tool.inputSchema.properties }
147 let required = tool.inputSchema.required
148
149 if (resolvedAccountId) {
150 delete properties['account_id']
151 required = required?.filter((name) => name !== 'account_id')
152 } else if (isMultiAccountUser(props)) {
153 properties['account_id'] = {
154 type: 'string',
155 description: `Cloudflare account ID. Required for multi-account tokens. ${NON_CODEMODE_ACCOUNT_DISCOVERY_GUIDANCE}`
156 }
157 }
158
159 const inputSchema = { ...tool.inputSchema, properties, required }
160 if (required?.length === 0) delete inputSchema.required
161 return { ...tool, inputSchema }
162}

Callers 1

registerNonCodemodeToolsFunction · 0.85

Calls 1

isMultiAccountUserFunction · 0.90

Tested by

no test coverage detected