Skip to main content
Glama
shahidla

MCP Server for SAP OData v4

by shahidla

schedule_background_job

Schedule an ABAP background job to run in SAP by specifying the program, job name, and scramble option.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
program_nameYesName of the ABAP program to execute
scrambleoptionYesScramble option to send to SAP, for example SCRD
job_nameYesName to assign to the background job

Implementation Reference

  • The async handler function that executes the tool logic. Generates a job ID/timestamp, calls scrambleAll() with the scrambleoption, and returns a success/failure response with request details and SAP result.
      async ({ program_name, scrambleoption, job_name }) => {
        const jobId = `JOB_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
        const scheduledAt = new Date().toISOString();
    
        try {
          const result = await scrambleAll(scrambleoption);
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    success: true,
                    message: "ScrambleAll submitted successfully",
                    request: {
                      program_name,
                      scrambleoption,
                      job_name,
                      job_id: jobId,
                      scheduled_at: scheduledAt
                    },
                    sap_result: result
                  },
                  null,
                  2
                )
              }
            ]
          };
        } catch (error: any) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    success: false,
                    message: "SAP call failed",
                    request: {
                      program_name,
                      scrambleoption,
                      job_name,
                      job_id: jobId,
                      scheduled_at: scheduledAt
                    },
                    error: error?.message || "Unknown error"
                  },
                  null,
                  2
                )
              }
            ],
            isError: true
          };
        }
      }
    );
  • Input schema for the tool using Zod: program_name (string), scrambleoption (string), job_name (string).
    {
      program_name: z.string().describe("Name of the ABAP program to execute"),
      scrambleoption: z.string().describe("Scramble option to send to SAP, for example SCRD"),
      job_name: z.string().describe("Name to assign to the background job")
    },
  • src/index.ts:28-92 (registration)
    Tool registration via server.tool() with the name 'schedule_background_job'.
    server.tool(
      "schedule_background_job",
      {
        program_name: z.string().describe("Name of the ABAP program to execute"),
        scrambleoption: z.string().describe("Scramble option to send to SAP, for example SCRD"),
        job_name: z.string().describe("Name to assign to the background job")
      },
      async ({ program_name, scrambleoption, job_name }) => {
        const jobId = `JOB_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
        const scheduledAt = new Date().toISOString();
    
        try {
          const result = await scrambleAll(scrambleoption);
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    success: true,
                    message: "ScrambleAll submitted successfully",
                    request: {
                      program_name,
                      scrambleoption,
                      job_name,
                      job_id: jobId,
                      scheduled_at: scheduledAt
                    },
                    sap_result: result
                  },
                  null,
                  2
                )
              }
            ]
          };
        } catch (error: any) {
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    success: false,
                    message: "SAP call failed",
                    request: {
                      program_name,
                      scrambleoption,
                      job_name,
                      job_id: jobId,
                      scheduled_at: scheduledAt
                    },
                    error: error?.message || "Unknown error"
                  },
                  null,
                  2
                )
              }
            ],
            isError: true
          };
        }
      }
    );
  • The scrambleAll helper function called by the handler. Fetches a CSRF token from SAP, then POSTs the scrambleoption to the SAP action endpoint and returns the API response with status/headers/data.
    export async function scrambleAll(scrambleoption: string) {
      const { token, cookies } = await getCsrfToken();
    
      const res = await axios.post(
        `${baseUrl}/${actionPath}`,
        { scrambleoption },
        {
          auth: { username, password },
          params: {
            "sap-client": client,
            "sap-language": "EN"
          },
          headers: {
            "X-CSRF-Token": token,
            Cookie: cookies,
            "Content-Type": "application/json",
            Accept: "application/json"
          },
          httpsAgent: agent,
          validateStatus: () => true
        }
      );
    
      if (res.status < 200 || res.status >= 300) {
        throw new Error(
          `SAP call failed: ${res.status} ${JSON.stringify(res.data)}`
        );
      }
    
      return {
        success: true,
        status: res.status,
        headers: {
          sap_messages: res.headers["sap-messages"],
          location: res.headers["location"],
          preference_applied: res.headers["preference-applied"]
        },
        data: res.data
      };
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/shahidla/MCP'

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