Skip to main content
Glama

android_sdk_setup

Configure Android SDK and development environment by checking, installing, or setting up required components for Android app development.

Instructions

Setup Android SDK and configure environment for Android development

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNoAction to performcheck
componentsNoSDK components to install (platform-tools, build-tools, platforms, etc.)

Implementation Reference

  • The main handler function implementing the android_sdk_setup tool. Handles 'check', 'install', and 'configure' actions for Android SDK setup, including detecting SDK path, sdkmanager, and installing components.
    handler: async (args: any) => { const homeDir = os.homedir(); const platform = process.platform; const androidPath = platform === 'darwin' ? path.join(homeDir, 'Library', 'Android', 'sdk') : platform === 'win32' ? path.join(homeDir, 'AppData', 'Local', 'Android', 'Sdk') : path.join(homeDir, 'Android', 'Sdk'); const results = { platform, androidPath, status: {} as any, installation: null as any, configuration: null as any }; // Check current status if (args.action === 'check' || args.action === 'install') { try { await fs.access(androidPath); results.status.sdkFound = true; // Check for sdkmanager const sdkManagerPaths = [ path.join(androidPath, 'cmdline-tools', 'latest', 'bin', 'sdkmanager'), path.join(androidPath, 'cmdline-tools', '17.0', 'bin', 'sdkmanager'), path.join(androidPath, 'tools', 'bin', 'sdkmanager') ]; let sdkManagerPath = null; for (const path of sdkManagerPaths) { try { await fs.access(path); sdkManagerPath = path; break; } catch (e) { // Continue checking } } results.status.sdkManager = sdkManagerPath; if (sdkManagerPath && args.action === 'install') { // Install requested components results.installation = { components: args.components || [], results: [] }; for (const component of args.components || []) { try { await processExecutor.execute(sdkManagerPath, [ '--install', component, '--sdk_root=' + androidPath ], { timeout: 300000 }); results.installation.results.push({ component, status: 'success' }); } catch (error) { results.installation.results.push({ component, status: 'failed', error: error instanceof Error ? error.message : String(error) }); } } } } catch (e) { results.status.sdkFound = false; results.status.message = 'Android SDK not found. Install Android Studio or command-line tools.'; } } return { success: true, data: results }; }
  • Zod-like input schema defining parameters for the tool: action (check/install/configure) and components array.
    inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['check', 'install', 'configure'], description: 'Action to perform', default: 'check' }, components: { type: 'array', items: { type: 'string' }, description: 'SDK components to install (platform-tools, build-tools, platforms, etc.)', default: ['platform-tools', 'build-tools;34.0.0', 'platforms;android-34'] } } },
  • Registration of the android_sdk_setup tool in the createSetupTools function's tools Map, including name, description, schema, and handler.
    tools.set('android_sdk_setup', { name: 'android_sdk_setup', description: 'Setup Android SDK and configure environment for Android development', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['check', 'install', 'configure'], description: 'Action to perform', default: 'check' }, components: { type: 'array', items: { type: 'string' }, description: 'SDK components to install (platform-tools, build-tools, platforms, etc.)', default: ['platform-tools', 'build-tools;34.0.0', 'platforms;android-34'] } } }, handler: async (args: any) => { const homeDir = os.homedir(); const platform = process.platform; const androidPath = platform === 'darwin' ? path.join(homeDir, 'Library', 'Android', 'sdk') : platform === 'win32' ? path.join(homeDir, 'AppData', 'Local', 'Android', 'Sdk') : path.join(homeDir, 'Android', 'Sdk'); const results = { platform, androidPath, status: {} as any, installation: null as any, configuration: null as any }; // Check current status if (args.action === 'check' || args.action === 'install') { try { await fs.access(androidPath); results.status.sdkFound = true; // Check for sdkmanager const sdkManagerPaths = [ path.join(androidPath, 'cmdline-tools', 'latest', 'bin', 'sdkmanager'), path.join(androidPath, 'cmdline-tools', '17.0', 'bin', 'sdkmanager'), path.join(androidPath, 'tools', 'bin', 'sdkmanager') ]; let sdkManagerPath = null; for (const path of sdkManagerPaths) { try { await fs.access(path); sdkManagerPath = path; break; } catch (e) { // Continue checking } } results.status.sdkManager = sdkManagerPath; if (sdkManagerPath && args.action === 'install') { // Install requested components results.installation = { components: args.components || [], results: [] }; for (const component of args.components || []) { try { await processExecutor.execute(sdkManagerPath, [ '--install', component, '--sdk_root=' + androidPath ], { timeout: 300000 }); results.installation.results.push({ component, status: 'success' }); } catch (error) { results.installation.results.push({ component, status: 'failed', error: error instanceof Error ? error.message : String(error) }); } } } } catch (e) { results.status.sdkFound = false; results.status.message = 'Android SDK not found. Install Android Studio or command-line tools.'; } } return { success: true, data: results }; } });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cristianoaredes/mcp-mobile-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server