update_apprun
Modify an existing AppRun application's configuration, including its name, Docker image, plan, environment variables, and description.
Instructions
Update an existing AppRun application
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appId | Yes | The ID of the AppRun application to update | |
| name | No | New name of the AppRun application | |
| description | No | New description of the AppRun application | |
| dockerImage | No | New Docker image to use for the AppRun application | |
| planId | No | New plan ID for the AppRun application | |
| environment | No | New environment variables for the AppRun application | |
| zone | No | The zone to use (e.g., "tk1v", "is1a", "tk1a"). Defaults to "tk1v" if not specified. |
Implementation Reference
- src/server.ts:2387-2437 (handler)Handler function that executes the 'update_apprun' tool: fetches current app data, merges with provided updates (name, description, dockerImage, planId, environment), sends PUT request to AppRun API, returns result.} else if (request.params.name === 'update_apprun') { try { validateCredentials(); const appId = request.params.arguments?.appId as string; if (!appId) { throw new Error('AppRun application ID is required'); } // Get current application data first const currentApp = await fetchFromAppRunAPI(`/applications/${appId}`); // Extract current values const currentName = currentApp.name || ''; const currentDescription = currentApp.description || ''; const currentPlanId = currentApp.planId || ''; const currentDockerImage = currentApp.image || ''; const currentEnvironment = currentApp.environment || []; // Get update values from request or use current values const name = request.params.arguments?.name as string || currentName; const description = request.params.arguments?.description as string || currentDescription; const planId = request.params.arguments?.planId as string || currentPlanId; const dockerImage = request.params.arguments?.dockerImage as string || currentDockerImage; const environment = request.params.arguments?.environment as Array<{key: string, value: string}> || currentEnvironment.map((env: {Key: string, Value: string}) => ({ key: env.Key, value: env.Value })); const zone = request.params.arguments?.zone as string || DEFAULT_ZONE; const updateBody = { name: name, description: description, planId: planId, image: dockerImage, environment: environment.map(env => ({ key: env.key, value: env.value })), }; const updateResult = await fetchFromAppRunAPI(`/applications/${appId}`, 'PUT', updateBody); return { content: [ { type: 'text', text: JSON.stringify(updateResult, null, 2) } ] }; } catch (error) { console.error('Error calling tool:', error); throw error; }
- src/server.ts:1352-1394 (registration)Registration of 'update_apprun' tool in ListToolsRequestSchema handler, including input schema definition.name: 'update_apprun', description: 'Update an existing AppRun application', inputSchema: { type: 'object', properties: { appId: { type: 'string', description: 'The ID of the AppRun application to update' }, name: { type: 'string', description: 'New name of the AppRun application' }, description: { type: 'string', description: 'New description of the AppRun application' }, dockerImage: { type: 'string', description: 'New Docker image to use for the AppRun application' }, planId: { type: 'string', description: 'New plan ID for the AppRun application' }, environment: { type: 'array', description: 'New environment variables for the AppRun application', items: { type: 'object', properties: { key: { type: 'string' }, value: { type: 'string' } } } }, zone: { type: 'string', description: 'The zone to use (e.g., "tk1v", "is1a", "tk1a"). Defaults to "tk1v" if not specified.' } }, required: ['appId'] }
- src/server.ts:75-122 (helper)Helper function used by update_apprun (and other AppRun tools) to make authenticated HTTPS requests to Sakura Cloud AppRun API.async function fetchFromAppRunAPI(path: string, method: string = 'GET', bodyData?: any): Promise<any> { return new Promise((resolve, reject) => { validateCredentials(); const options = { hostname: 'secure.sakura.ad.jp', port: 443, path: `/cloud/api/apprun/1.0/apprun/api${path}`, method: method, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': `Basic ${Buffer.from(`${SACLOUD_API_TOKEN}:${SACLOUD_API_SECRET}`).toString('base64')}` } }; const req = https.request(options, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { try { if (data) { const parsedData = JSON.parse(data); resolve(parsedData); } else { resolve({}); } } catch (err) { reject(new Error(`Failed to parse response: ${err}`)); } }); }); req.on('error', (error) => { reject(error); }); if (bodyData && (method === 'POST' || method === 'PUT')) { req.write(JSON.stringify(bodyData)); } req.end(); }); }