Skip to main content
Glama
hidenorigoto

Sakura Cloud MCP Server

by hidenorigoto

update_apprun

Modify an AppRun app on the Sakura Cloud MCP Server by updating its name, description, Docker image, plan ID, environment variables, or zone directly through configurable parameters.

Instructions

Update an existing AppRun application

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appIdYesThe ID of the AppRun application to update
descriptionNoNew description of the AppRun application
dockerImageNoNew Docker image to use for the AppRun application
environmentNoNew environment variables for the AppRun application
nameNoNew name of the AppRun application
planIdNoNew plan ID for the AppRun application
zoneNoThe zone to use (e.g., "tk1v", "is1a", "tk1a"). Defaults to "tk1v" if not specified.

Implementation Reference

  • The main handler for the 'update_apprun' tool within the CallToolRequestSchema request handler. It validates input, fetches current AppRun application state, merges with update parameters, constructs the update payload, and performs a PUT request to the AppRun API.
    } 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; }
  • Input schema definition for the 'update_apprun' tool, registered in the ListToolsRequestSchema handler.
    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'] }
  • Registration of the 'update_apprun' tool in the tools list returned by ListToolsRequestSchema handler.
    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'] } },
  • Helper function used by the update_apprun handler to make authenticated HTTPS requests to the Sakura Cloud AppRun API, including the PUT call for updating the application.
    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(); }); }

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/hidenorigoto/sacloud-mcp'

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