Wrap a REST API class as an MCP DPC
Learn how to wrap an existing REST API class from the Hub API Designer as a Data Provider Class (DPC) for the Hub MCP Designer, using a sales orders API class as an example.
Unlike the Hub API Designer, which uses public class attributes for importing and exporting data, the Hub MCP Designer derives tools solely from the method signature. The wrapper class therefore declares each tool as an explicit method, with all inputs as importing parameters and all outputs as exporting parameters.
Creating the wrapper class also gives you the opportunity to improve on the naming used in the source class, with cleaner method names, natural language parameter names, and the removal of Hungarian notation prefixes — without modifying the source class itself.
Prerequisites
-
You have an existing REST API class implementing
/neptune/if_restapi. -
You have reviewed each operation you want to expose in the Hub API Designer and confirmed which public attributes carry input and output data for it, using the Request and Response tabs.
Procedure
Define the MCP wrapper class
Create a new ABAP class and declare the MCP DPC interface
/neptune/if_dxp_mcp_dpc. For each operation you want to expose as a tool,
declare a public method with the relevant request fields as importing parameters
and the relevant response fields as exporting parameters. Signature typing can
refer to public attributes in the API class using like for simplicity.
The following shows the source API class definition, followed by the corresponding MCP wrapper class definition. No improvements to naming or parameters have been made in this example. It illustrates a strict 1:1 wrapping.
class ycl_sd_sales_orders_api definition
public
final
create public .
public section.
interfaces /neptune/if_restapi .
types:
begin of ty_order.
include type zui5_sd_order_vbak.
types:
name1 type kna1-name1,
kunnr type vbak-kunnr,
end of ty_order .
data it_order_items type zui5_sd_vbap_tt .
data it_order_list type table of ty_order .
data it_customer_list type zui5_sd_customer_list_tt .
data it_return type bapiret2_tt .
data it_material_list type zui5_sd_search_material_tt .
data wa_customer type zui5_sd_customer_list .
data gv_page_home type zui5_sd_global_customer .
data gv_settings type zui5_sd_settings .
data it_order_items_bapi type table of bapisdit .
data it_order_schedule_bapi type table of bapisdhedu .
data it_order_statusitems_bapi type table of bapisditst .
data it_order_statusheaders_bapi type table of bapisdhdst .
data it_order_flows_bapi type table of bapisdflow .
data it_order_address_bapi type table of bapisdcoad .
methods get_customer_list
importing
!vkorg type vkorg default '1000' .
methods get_order_list
importing
!vbeln type vbeln optional
!vkorg type vkorg default '1000'
!erdat type erdat optional
!kunnr type kunnr optional
!auart type auart optional
!ernam type ernam optional .
methods get_order_detail
importing
!vbeln type vbeln .
methods save_order_bapi
importing
!vbeln type vbeln .
methods save_order .
methods get_order_detail_by_po
importing
!bstkd type bstkd .
methods get_material_list
importing
value(werks) type werks_d default '1000'
value(vkorg) type vkorg default '1000' .
endclass.
class ycl_sd_sales_orders_mcp definition
public
final
create public .
public section.
interfaces /neptune/if_dxp_mcp_dpc.
types ty_order type ycl_sd_sales_orders_api=>ty_order.
methods get_customer_list
importing
!vkorg type vkorg default '1000'
exporting
it_customer_list like ycl_sd_sales_orders_api=>it_customer_list
gv_page_home like ycl_sd_sales_orders_api=>gv_page_home.
methods get_order_list
importing
!vbeln type vbeln optional
!vkorg type vkorg default '1000'
!erdat type erdat optional
!kunnr type kunnr optional
!auart type auart optional
!ernam type ernam optional
exporting
it_order_list like ycl_sd_sales_orders_api=>it_order_list.
methods get_order_detail
importing
!vbeln type vbeln
exporting
it_order_items like ycl_sd_sales_orders_api=>it_order_items
it_order_list like ycl_sd_sales_orders_api=>it_order_list.
methods save_order_bapi
importing
!vbeln type vbeln
it_order_items_bapi like ycl_sd_sales_orders_api=>it_order_items_bapi
it_order_schedule_bapi like ycl_sd_sales_orders_api=>it_order_schedule_bapi
exporting
it_return like ycl_sd_sales_orders_api=>it_return.
methods save_order
importing
it_order_items like ycl_sd_sales_orders_api=>it_order_items
gv_settings like ycl_sd_sales_orders_api=>gv_settings
wa_customer like ycl_sd_sales_orders_api=>wa_customer
exporting
it_order_list like ycl_sd_sales_orders_api=>it_order_list.
methods get_order_detail_by_po
importing
!bstkd type bstkd
exporting
it_order_address_bapi like ycl_sd_sales_orders_api=>it_order_address_bapi
it_order_flows_bapi like ycl_sd_sales_orders_api=>it_order_flows_bapi
it_order_headers_bapi like ycl_sd_sales_orders_api=>it_order_headers_bapi
it_order_items_bapi like ycl_sd_sales_orders_api=>it_order_items_bapi
it_order_schedule_bapi like ycl_sd_sales_orders_api=>it_order_schedule_bapi
it_order_statusheaders_bapi like ycl_sd_sales_orders_api=>it_order_statusheaders_bapi
it_order_statusitems_bapi like ycl_sd_sales_orders_api=>it_order_statusitems_bapi.
methods get_material_list
importing
value(werks) type werks_d default '1000'
value(vkorg) type vkorg default '1000'
exporting
it_material_list like ycl_sd_sales_orders_api=>it_material_list.
protected section.
private section.
endclass.
| The method names defined here become the tool names in the Hub MCP Designer, and the parameter names become the JSON schema for those tools. See MCP tool design best practices for naming and parameter design guidance. |
Implement each method
For each method, the implementation follows the same four steps:
-
Instantiate the API class.
-
Set any public attributes on the instance from the importing parameters relevant to this call, corresponding to the request data for the operation.
-
Call the method on the API class instance.
-
Assign the relevant public attributes of the instance to the exporting parameters of the wrapper method, corresponding to the response data.
If you have used different names for methods or parameters in the wrapper, adapt the assignments in steps 2 and 4 accordingly.
class ycl_sd_sales_orders_mcp implementation.
method get_customer_list.
data wrapped type ref to ycl_sd_sales_orders_api.
create object wrapped.
wrapped->get_customer_list( vkorg = vkorg ).
it_customer_list = wrapped->it_customer_list.
gv_page_home = wrapped->gv_page_home.
endmethod.
method get_order_list.
data wrapped type ref to ycl_sd_sales_orders_api.
create object wrapped.
wrapped->get_order_list( vbeln = vbeln
vkorg = vkorg
erdat = erdat
kunnr = kunnr
auart = auart
ernam = ernam ).
it_order_list = wrapped->it_order_list.
endmethod.
method get_order_detail.
data wrapped type ref to ycl_sd_sales_orders_api.
create object wrapped.
wrapped->get_order_detail( vbeln = vbeln ).
it_order_items = wrapped->it_order_items.
it_order_list = wrapped->it_order_list.
endmethod.
method save_order_bapi.
data wrapped type ref to ycl_sd_sales_orders_api.
create object wrapped.
wrapped->it_order_items_bapi = it_order_items_bapi.
wrapped->it_order_schedule_bapi = it_order_schedule_bapi.
wrapped->save_order_bapi( vbeln = vbeln ).
it_return = wrapped->it_return.
endmethod.
method save_order.
data wrapped type ref to ycl_sd_sales_orders_api.
create object wrapped.
wrapped->it_order_items = it_order_items.
wrapped->gv_settings = gv_settings.
wrapped->wa_customer = wa_customer.
wrapped->save_order( ).
it_order_list = wrapped->it_order_list.
endmethod.
method get_order_detail_by_po.
data wrapped type ref to ycl_sd_sales_orders_api.
create object wrapped.
wrapped->get_order_detail_by_po( bstkd = bstkd ).
it_order_address_bapi = wrapped->it_order_address_bapi.
it_order_flows_bapi = wrapped->it_order_flows_bapi.
it_order_headers_bapi = wrapped->it_order_headers_bapi.
it_order_items_bapi = wrapped->it_order_items_bapi.
it_order_schedule_bapi = wrapped->it_order_schedule_bapi.
it_order_statusheaders_bapi = wrapped->it_order_statusheaders_bapi.
it_order_statusitems_bapi = wrapped->it_order_statusitems_bapi.
endmethod.
method get_material_list.
data wrapped type ref to ycl_sd_sales_orders_api.
create object wrapped.
wrapped->get_material_list( vkorg = vkorg
werks = werks ).
it_material_list = wrapped->it_material_list.
endmethod.
endclass.
Register the class as a DPC and configure tools
In the Hub MCP Designer, create a new MCP server and select your wrapper class as the Data Provider Class. Enable and configure the tools you want to expose on the Tools tab, then validate them in the Inspector tab. See Create an MCP server in the Hub MCP Designer.
Results
-
Your existing REST API class logic is exposed as MCP tools without modification to the source class, and is ready to be consumed by AI agents operating within Naia Agent Studio.
-
The MCP server is transportable across SAP environments and can be promoted through development, quality, and production via a transport request.