Abap Abap Adt Api
    Abap Abap Adt Api

    Abap Abap Adt Api

    MCP-Server for SAP ABAP wrapping abap-adt-api

    3.1

    GitHub Stats

    Stars

    28

    Forks

    10

    Release Date

    6/6/2025

    about a month ago

    Detailed Description

    disclaimer: this server is still in experimental status! use it with caution!

    abap-adt-api mcp-server

    smithery badge

    description

    the mcp-server mcp-abap-abap-adt-api is a model context protocol (mcp) server designed to facilitate seamless communication between abap systems and mcp clients. it is a wrapper for abap-adt-api and provides a suite of tools and resources for managing abap objects, handling transport requests, performing code analysis, and more, enhancing the efficiency and effectiveness of abap development workflows.

    features

    • authentication: securely authenticate with abap systems using the login tool.
    • object management: create, read, update, and delete abap objects seamlessly.
    • transport handling: manage transport requests with tools like createtransport and transportinfo.
    • code analysis: perform syntax checks and retrieve code completion suggestions.
    • extensibility: easily extend the server with additional tools and resources as needed.
    • session management: handle session caching and termination using dropsession and logout.

    installation

    installing via smithery

    to install abap-adt-api mcp-server for claude desktop automatically via smithery:

    npx -y @smithery/cli install @mario-andreschak/mcp-abap-abap-adt-api --client claude
    

    prerequisites

    • node.js: ensure you have node.js installed. you can download it from here.
    • abap system access: credentials and url to access the abap system.

    steps

    1. clone the repository

      git clone https://github.com/mario-andreschak/mcp-abap-abap-adt-api.git
      cd mcp-abap-abap-adt-api
      
    2. install dependencies

      npm install
      
    3. configure environment variables

      an .env.example file is provided in the root directory as a template for the required environment variables. to set up your environment:

      a. copy the .env.example file and rename it to .env:

      cp .env.example .env
      

      b. open the .env file and replace the placeholder values with your actual sap connection details:

      sap_url=https://your-sap-server.com:44300
      sap_user=your_sap_username
      sap_password=your_sap_password
      sap_client=your_sap_client
      sap_language=your_sap_language
      

      note: the sap_client and sap_language variables are optional but recommended.

      if you're using self-signed certificates, you can also set:

      node_tls_reject_unauthorized="0"
      

      important: never commit your .env file to version control. it's already included in .gitignore to prevent accidental commits.

    4. build the project

      npm run build
      
    5. run the server

      npm run start
      

      (or alternatively integrate the mcp server into vscode)

    usage

    once the server is running, you can interact with it using mcp clients or tools that support the model context protocol (e.g. cline). in order to integrate the mcp server with cline, use the following mcp configuration:

        "mcp-abap-abap-adt-api": {
          "command": "node",
          "args": [
            "path_to_your/mcp-abap-abap-adt-api/dist/index.js"
          ],
          "disabled": true,
          "autoapprove": [
          ]
        },
    
    

    custom instruction

    use this custom instruction to explain the tool to your model:

    ## mcp-abap-abap-adt-api server
    
    this server provides tools for interacting with an sap system via adt (abap development tools) apis. it allows you to retrieve information about abap objects, modify source code, and manage transports.
    
    **key tools and usage:**
    
    *   **`searchobject`:** finds abap objects based on a query string (e.g., class name).
        *   `query`: (string, required) the search term.
        *   returns the object's uri.  example: `/sap/bc/adt/oo/classes/zcl_invoice_xml_gen_model`
    
    *   **`transportinfo`:** retrieves transport information for a given object.
        *   `objsourceurl`: (string, required) the object's uri (obtained from `searchobject`).
        *   returns transport details, including the transport request number (`trkorr` or `transportinfo.locks.header.trkorr` in the json response).
    
    *   **`lock`:** locks an abap object for editing.
        *   `objecturl`: (string, required) the object's uri.
        *   returns a `lockhandle`, which is required for subsequent modifications.
    
    *   **`unlock`:** unlocks a previously locked abap object.
        *   `objecturl`: (string, required) the object's uri.
        *   `lockhandle`: (string, required) the lock handle obtained from the `lock` operation.
    
    *   **`setobjectsource`:** modifies the source code of an abap object.
        *   `objectsourceurl`: (string, required) the object's uri *with the suffix `/source/main`*.  example: `/sap/bc/adt/oo/classes/zcl_invoice_xml_gen_model/source/main`
        *   `lockhandle`: (string, required) the lock handle obtained from the `lock` operation.
        *   `source`: (string, required) the complete, modified abap source code.
        *   `transport`: (string, optional) the transport request number.
    
    *   **`syntaxcheckcode`:** performs a syntax check on a given abap source code.
        *   `code`: (string, required) the abap source code to check.
        *   `url`: (string, optional) the url of the object.
        *   `mainurl`: (string, optional) the main url.
        *   `mainprogram`: (string, optional) the main program.
        *   `version`: (string, optional) the version.
        *   returns syntax check results, including any errors.
    
    *   **`activate`:** activates an abap object. (see notes below on activation/unlocking.)
        *    `object`: the object to be activated.
    
    *   **`getobjectsource`:** retrieves the source code of an abap object.
        *   `objectsourceurl`: (string, required) the object's uri *with the suffix `/source/main`*.
    
    **workflow for modifying abap code:**
    
    1.  **find the object uri:** use `searchobject`.
    2.  **read the original source code:** use `getobjectsource` (with the `/source/main` suffix).
    3.  **clone and modify the source code locally:** (e.g., `write_to_file` for creating a local copy, and using `read_file`, `replace_in_file` for modifying this local copy).
    4.  **get transport information:** use `transportinfo`.
    5.  **lock the object:** use `lock`.
    6.  **set the modified source code:** use `setobjectsource` (with the `/source/main` suffix).
    7.  **perform a syntax check:** use `syntaxcheckcode`.
    8.  **activate** the object, use `activate`..
    9.  **unlock the object:** use `unlock`.
    
    **important notes:**
    *   **file handling:** sap is completly de-coupled from the local file system. reading source code will only return the code as tool result - it has no effect on file. files are not synchronized with sap but merely a local copy for our reference. fyi: it's not strictly necessary for you to create local copies of source codes, as they have no effect on sap, but it helps us track changes.
    *   **file handling:** the local filenames you will use will not contain any paths, but only a filename! it's preferable to use a pattern like "[objectname].[objecttype].abap". (e.g., sapmv45a.prog.abap for a abap program sapmv45a, cl_ixml.clas.abap for a class cl_ixml)
    *   **url suffix:**  remember to add `/source/main` to the object uri when using `setobjectsource` and `getobjectsource`.
    *   **transport request:** obtain the transport request number (e.g., from `transportinfo` or from the user) and include it in relevant operations.
    *   **lock handle:**  the `lockhandle` obtained from the `lock` operation is crucial for `setobjectsource` and `unlock`. ensure you are using a valid `lockhandle`. if a lock fails, you may need to re-acquire the lock. locks can expire or be released by other users.
    *   **activation/unlocking order:** the exact order of `activate` and `unlock` operations might need clarification. refer to the tool descriptions or ask the user. it appears `activate` can be used without unlocking first.
    * **error handling:** the tools return json responses. check for error messages within these responses.
    
    ## efficient database access
    
    sap systems contain vast amounts of data.  it's crucial to write abap code that accesses the database efficiently to minimize performance impact and network traffic.  avoid selecting entire tables or using broad `where` clauses when you only need specific data.
    
    *   **use `where` clauses:** always use `where` clauses in your `select` statements to filter the data retrieved from the database.  select only the specific rows you need.
    *   **`up to 1 rows`:** if you only need a single record, use the `select single` statement, if you can guarantee that you can provide all the key fields for the `select single` statement. otherwise, use the `select` statement with the `up to 1 rows` addition. this tells the database to stop searching after finding the first matching record, improving performance. example:
    
        ```abap
        select vgbel from vbrp where vbeln = @me->lv_vbeln into @data(lv_vgbel) up to 1 rows.
          exit. " exit any loop after this.
        endselect.
        ```
    ## checking table and structure definitions
    
    when working with abap objects, you may encounter errors related to unknown field names or incorrect table usage.  you can use the following tools to inspect table and structure definitions:
    
    *   **`gettable`:** use this tool to retrieve the structure of an abap dictionary table, including its field names and data types. this is helpful for verifying the correct fields to use in your `select` statements.
    *    if you need to inspect an include structure, you may need to use `searchobject` to find the include and then use `gettypeinfo` or `getstructure`. you may get a 404 error and try again with `getstructure`
    *   **`getstructure`:** use this tool to retrieve the structure of an abap dictionary structure, including its field names and data types. this is helpful for verifying the correct fields to use in your `select` statements.
    *    if you need to inspect an include structure, you may need to use `searchobject` to find the include and then use `gettypeinfo` or `getstructure`.
    
    

    contributing

    contributions are welcome! please follow these steps to contribute:

    1. fork the repository

    2. create a new branch

      git checkout -b feature/your-feature-name
      
    3. commit your changes

      git commit -m "add some feature"
      
    4. push to the branch

      git push origin feature/your-feature-name
      
    5. open a pull request

    license

    this project is licensed under the mit license.

    Star History

    Star History

    Feb 8Mar 25Mar 31Apr 15Apr 30May 15Jun 6Jun 18Jul 707142128
    Powered by MSeeP Analytics

    About the Project

    This app has not been claimed by its owner yet.

    Claim Ownership

    Receive Updates

    Security Updates

    Get notified about trust rating changes

    to receive email notifications.