update_activity_state
Modify activity status in Adobe Target by specifying tenant and state parameters to control campaign execution.
Instructions
Update the state of an activity in Adobe Target.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tenant | Yes | The tenant identifier. | |
| state | Yes | The new state to set for the activity. |
Implementation Reference
- The core handler function `executeFunction` that performs the HTTP PUT request to the Adobe Target API to update the activity state.
const executeFunction = async ({ tenant, state }) => { const baseUrl = 'https://mc.adobe.io'; const apiKey = process.env.ADOBE_API_KEY; const token = process.env.ADOBE_API_KEY; try { // Construct the URL for the request const url = `${baseUrl}/${tenant}/target/activities/ab/168816/state`; // Set up headers for the request const headers = { 'Authorization': `Bearer ${token}`, 'X-Api-Key': apiKey, 'Content-Type': 'application/vnd.adobe.target.v1+json' }; // Set up the body of the request const body = JSON.stringify({ state }); // Perform the fetch request const response = await fetch(url, { method: 'PUT', headers, body }); // Check if the response was successful if (!response.ok) { const errorData = await response.json(); throw new Error(errorData); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { console.error('Error updating activity state:', error); return { error: 'An error occurred while updating the activity state.' }; } }; - The `apiTool` object defining the tool's name, description, input schema (parameters), and reference to the handler function.
const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'update_activity_state', description: 'Update the state of an activity in Adobe Target.', parameters: { type: 'object', properties: { tenant: { type: 'string', description: 'The tenant identifier.' }, state: { type: 'string', description: 'The new state to set for the activity.' } }, required: ['tenant', 'state'] } } } }; export { apiTool }; - tools/paths.js:1-5 (registration)Lists the file path for the `update_activity_state` tool, enabling its discovery and loading.
export const toolPaths = [ 'adobe/adobe-target-admin-ap-is/update-activity-state.js', 'adobe/adobe-target-admin-ap-is/update-activity-priority.js', 'adobe/adobe-target-admin-ap-is/update-activity-schedule.js' ]; - lib/tools.js:7-16 (registration)Dynamically imports modules from `toolPaths` and extracts `apiTool` objects for registration in the MCP server.
export async function discoverTools() { const toolPromises = toolPaths.map(async (file) => { const module = await import(`../tools/${file}`); return { ...module.apiTool, path: file, }; }); return Promise.all(toolPromises); }