免責事項:このサーバーはまだ試験段階です。注意してご利用ください。
ABAP-ADT-API MCPサーバー
説明
MCPサーバーmcp-abap-abap-adt-api
は、ABAPシステムとMCPクライアント間のシームレスな通信を実現するために設計されたモデルコンテキストプロトコル(MCP)サーバーです。abap -adt-apiのラッパーであり、ABAPオブジェクトの管理、トランスポートリクエストの処理、コード分析の実行などのためのツールとリソーススイートを提供し、ABAP開発ワークフローの効率と効果を高めます。
特徴
- 認証:
login
ツールを使用して ABAP システムで安全に認証します。 - オブジェクト管理: ABAP オブジェクトをシームレスに作成、読み取り、更新、削除します。
- トランスポート処理:
createTransport
やtransportInfo
などのツールを使用してトランスポート要求を管理します。 - コード分析: 構文チェックを実行し、コード補完の提案を取得します。
- 拡張性: 必要に応じて追加のツールやリソースを使用してサーバーを簡単に拡張できます。
- セッション管理:
dropSession
とlogout
を使用してセッションのキャッシュと終了を処理します。
インストール
Smithery経由でインストール
Smithery経由で Claude Desktop 用の ABAP-ADT-API MCP-Server を自動的にインストールするには:
npx -y @smithery/cli install @mario-andreschak/mcp-abap-abap-adt-api --client claude
前提条件
- Node.js :Node.jsがインストールされていることを確認してください。こちらからダウンロードできます。
- ABAP システム アクセス: ABAP システムにアクセスするための資格情報と URL。
手順
- リポジトリのクローンを作成する
git clone https://github.com/mario-andreschak/mcp-abap-abap-adt-api.git
cd mcp-abap-abap-adt-api
- 依存関係をインストールする
- 環境変数を設定する必要な環境変数のテンプレートとして、ルートディレクトリに
.env.example
ファイルが用意されています。環境を設定するには、以下の手順に従ってください。a. .env.example
ファイルをコピーし、名前を.env
に変更します。b. .env
ファイルを開き、プレースホルダー値を実際の SAP 接続の詳細に置き換えます。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
注: SAP_CLIENT および SAP_LANGUAGE 変数はオプションですが、推奨されます。自己署名証明書を使用している場合は、以下も設定できます。NODE_TLS_REJECT_UNAUTHORIZED="0"
重要: .env
ファイルをバージョン管理にコミットしないでください。誤ってコミットされないように、 .gitignore
に既に含まれています。 - プロジェクトを構築する
- サーバーを実行する(またはMCPサーバーをVSCodeに統合する)
使用法
サーバーが起動したら、MCPクライアントまたはモデルコンテキストプロトコル( Clineなど)をサポートするツールを使ってサーバーとやり取りできます。MCPサーバーをClineと統合するには、以下のMCP設定を使用します。
"mcp-abap-abap-adt-api": {
"command": "node",
"args": [
"PATH_TO_YOUR/mcp-abap-abap-adt-api/dist/index.js"
],
"disabled": true,
"autoApprove": [
]
},
カスタム指示
このカスタム指示を使用して、モデルにツールを説明します。
## 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`.
貢献
貢献を歓迎します!貢献するには、次の手順に従ってください。
- リポジトリをフォークする
- 新しいブランチを作成する
git checkout -b feature/your-feature-name
- 変更をコミットする
git commit -m "Add some feature"
- ブランチにプッシュ
git push origin feature/your-feature-name
- プルリクエストを開く
ライセンス
このプロジェクトはMIT ライセンスに基づいてライセンスされています。