( tool: NonCodemodeTool, resolvedAccountId: string | undefined, props: AuthProps )
| 137 | } |
| 138 | |
| 139 | function 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 | } |
no test coverage detected