@mseep/bw-modeling-mcp 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,598 @@
1
+ # bw-modeling-mcp
2
+
3
+ A Model Context Protocol (MCP) server that enables AI assistants like Claude to work directly inside SAP BW/4HANA systems — reading, creating and modifying BW modeling objects via the internal REST API used by Eclipse BWMT.
4
+
5
+ **This is not a simulation.** Every tool call connects to a live BW system — write operations produce real changes.
6
+
7
+ ---
8
+
9
+ ## 📖 Featured Blog Post
10
+
11
+ **Agentic AI meets SAP BW** — the full story behind this project: why I built it, what's inside, what happens when Claude walks through a complete BW data lineage on its own.
12
+
13
+ Read the blog (DE + EN): https://www.nextlytics.com/blog/agentic-ai-meets-sap-bw
14
+
15
+ ![Agentic AI meets SAP BW](docs/blog-cover.png)
16
+
17
+ ---
18
+
19
+ ## 🆕 What's New — v0.8.0
20
+
21
+ **Runtime tools & request monitoring** — the first tools driven by the BW/4HANA `/sap/bc/.../bw4` manage API (the same operations you'd otherwise perform in the BW/4HANA Cockpit), not the `/sap/bw/modeling` tool API:
22
+
23
+ - `bw_run_dtp` — start (execute) a DTP load; returns the run request id (RSPM TSN) usable directly with `bw_get_request`
24
+ - `bw_list_requests` / `bw_get_request` — monitor load requests: status, records, DTP info, process steps, message log
25
+ - `bw_activate_request` — activate loaded data (move a finished load from the inbound table into the active data table + change log)
26
+
27
+ **BW Bridge connectivity** — authenticate against BW systems running on the SAP BTP ABAP stack (BW Bridge) via a browser-exported cookie file (`BW_COOKIE_FILE`), in addition to Basic Auth; login/session approach analogous to [vibing-steampunk](https://github.com/oisee/vibing-steampunk).
28
+
29
+ **DataSource (RSDS) across the modeling lifecycle** — create an aDSO from a DataSource template (`bw_create_adso`), use a DataSource as DTP source (`bw_create_dtp`), and activate a DataSource (`bw_activate`).
30
+
31
+ **Fixes** — query reads negotiate the backend content-type version via discovery (fixes HTTP 415 on higher SP levels, #11); DTP activation no longer reports a false "transformation inactive"; field-add works on staging/inbound aDSOs without key elements; DATS date constants survive activation; transformation rule editing picks the correct rule when a start/end routine exists.
32
+
33
+ ---
34
+
35
+ ## What's New — v0.7.0
36
+
37
+ Process Chain support and DataSource data preview:
38
+
39
+ - `bw_get_process_chain` — reads a complete Process Chain definition including all steps, conditional dependencies, DECISION branch labels, and inline variant configuration; automatically fetches and embeds variant detail (ABAP program + selection variant, TRIGGER scheduling, ADSOACT target aDSO, ADSOREM cleanup settings, PLSWITCHL/P target, DECISION branching formulas) for each step in a single call — deterministic, no additional prompting needed; supports recursive sub-chain expansion by calling the tool again on any referenced chain name
40
+ - `bw_get_process_variant` — reads the configuration detail of any individual process step variant; generic across all 93 BW/4HANA process types; oDetail returned as structured JSON
41
+ - `bw_preview_datasource` — fetches a live data preview from any DataSource; resolves field names automatically from the DataSource structure and renders a formatted table; record count configurable (default 20)
42
+
43
+ ---
44
+
45
+ ## What's New — v0.6.0
46
+
47
+ BW Role Management — four new tools for reading and managing query-to-role assignments: `bw_get_roles` (full role hierarchy), `bw_get_role_queries` (all published queries per role), `bw_get_query_roles` (which roles a query is published in), `bw_set_query_roles` (publish or remove a query from a role or folder, including support for nested menu folders).
48
+
49
+ ---
50
+
51
+ ## What's New — v0.5.0
52
+
53
+ Live data querying:
54
+
55
+ - `bw_query_data` — executes a BEx Query or previews data from any InfoProvider (aDSO, CompositeProvider) via the BICS reporting endpoint; supports variable input, axis layout control (ROWS/COLUMNS/FREE), characteristic filters with include/exclude and range operators, hierarchy drill-down (expand/collapse nodes), pagination, and structure member selection; renders a formatted table with hierarchy indentation
56
+ - `bw_get_filter_values` — looks up valid characteristic values before setting filters or variables; supports wildcard search and optional InfoProvider scoping
57
+ - `bw_get_query` — now returns a compact human-readable summary by default; use `format="raw"` to get the previous full JSON output
58
+
59
+ ---
60
+
61
+ ## What's New — v0.4.0
62
+
63
+ DataSource and source system navigation:
64
+
65
+ - `bw_get_dataflow` — traces the complete structural data flow graph of any BW object in any direction (upwards / downwards / both); mirrors the Eclipse BWMT Transient Data Flow view
66
+ - `bw_list_source_systems` — lists all logical source systems (LSYS) registered in BW, filterable by type (ODP_SAP, ODP_CDS, ODP_BW, ODP, FILE, HANA_SDA, HANA_LOCAL)
67
+ - `bw_list_datasources` — recursively lists all DataSources under a source system with full APCO hierarchy path
68
+ - `bw_get_source_system` — reads full source system metadata: type, description, connection details (ODP context/destination, HANA remote source, schema)
69
+ - `bw_get_datasource` — reads complete DataSource structure: all fields with types, lengths, transfer flags, key flags, conversion exits, unit/currency references, and adapter configuration
70
+ - `bw_xref` — new `source_system` parameter for `object_type=RSDS`; the correct space-padded objectName is built automatically
71
+
72
+ ---
73
+
74
+ ## What's New — v0.3.0
75
+
76
+ CompositeProvider read support and BW repository navigation:
77
+
78
+ - `bw_get_composite_provider` — reads a CompositeProvider structure: view node type (Union/Join), source providers with mapping counts, all fields with dimension classification, join conditions, and temporal join details
79
+ - `bw_get_ckf` — reads a global Calculated Key Figure with recursively resolved human-readable formula and full dependency graph of referenced sub-components
80
+ - `bw_get_rkf` — reads a global Restricted Key Figure: base measure and all characteristic restriction groups
81
+ - `bw_get_structure` — reads a global Structure: all members with Formula/Selection breakdown, characteristic filters, and optional child members
82
+ - `bw_list_contents` — navigates the full BW repository tree (InfoAreas → type folders → objects → sub-folders), mirroring the Eclipse BWMT Project Explorer
83
+
84
+ > **Work in Progress** — bw-modeling-mcp already covers many typical BW development and analysis scenarios, but not everything yet. More is coming. The server has so far only been tested on our own demo systems — if you are running it against your own BW/4HANA system, feedback and bug reports are very welcome. Please use the [Issue templates](https://github.com/dnic-dev/bw-modeling-mcp/issues/new/choose) — you will be helping shape what gets built next.
85
+
86
+ ---
87
+
88
+ ## What it can do
89
+
90
+ ### Search & Discovery
91
+ - Search BW objects by name or description (wildcards supported), filtered by type
92
+ - Where-used / dependency analysis (xref) for any BW object
93
+
94
+ ### aDSO
95
+ - Read aDSO structure (fields, settings, version state)
96
+ - Create a new aDSO — from an aDSO template, from a DataSource (RSDS) template, or empty
97
+ - Add InfoObject-backed fields or pure (field-based) fields
98
+ - Remove fields
99
+ - Manage key fields
100
+ - Update field properties (aggregation, data type, length, etc.)
101
+ - Update aDSO settings (type preset, flags, description)
102
+ - Write-interface aDSO support (`pushMode`)
103
+
104
+ ### InfoObject
105
+ - Read InfoObject definition
106
+ - Create Characteristic — all data types (CHAR, NUMC, DATS, TIMS, SNUMC), with or without master data and texts, with referenced InfoObject, with compounding parents
107
+ - Create Key Figure — all types (NUM, AMT, QTY, DAT, INT), all aggregations (SUM, MAX, MIN)
108
+ - Add and remove display and navigation attributes
109
+
110
+ ### InfoArea
111
+ - Read InfoArea definition (name, label, parent area, status)
112
+ - Create a new InfoArea (immediately active, no activation step needed)
113
+ - Move any BW object to a different InfoArea
114
+
115
+ ### InfoSource
116
+ - Read InfoSource structure (fields, key fields, label, InfoArea)
117
+ - Create InfoSource with full field definitions
118
+
119
+ ### Transformation
120
+ - Read Transformation structure (all sources, all targets)
121
+ - Map source fields to target InfoObjects (StepDirect)
122
+ - Set formula rules (StepFormula)
123
+ - Set field routines — ABAP and AMDP (StepRoutine)
124
+ - Set start routines — ABAP and AMDP
125
+ - Set end routines — ABAP and AMDP
126
+ - Switch runtime between ABAP and AMDP
127
+
128
+ ### DTP (Data Transfer Process)
129
+ - Read DTP structure and settings
130
+ - Create DTPs — including DataSource (RSDS) sources
131
+ - Run (execute) a DTP load — returns the run request id for monitoring
132
+ - Update DTP settings and description
133
+ - Switch extraction mode between Full and Delta
134
+ - Set value filters on fields
135
+ - Set routine filters (ABAP code)
136
+
137
+ ### BW Query (Read)
138
+ - Read a BW Query — metadata, variables, filter, layout, measures, exceptions, and settings
139
+ - Variables: type, processing type (UserEntry, Authorization, CustomerExit), input behavior
140
+ - Filter: fixed values and variable references fully resolved, including mixed selections
141
+ - Layout: rows, columns, free characteristics with full member lists and nested members
142
+ - Calculated key figures: recursively resolved human-readable formulas
143
+ - Restricted key figures: selection conditions (key figure + characteristic restrictions)
144
+ - Inline local measures inside structures: both formulas and selections
145
+ - Exceptions with alert levels and thresholds, cell definitions for grid layout queries
146
+ - Active version with automatic fallback to inactive
147
+
148
+ ### Live Data Querying
149
+ - Execute a BEx Query or preview data from any InfoProvider (aDSO, CompositeProvider) — returns a formatted result table
150
+ - Fill query variables, control axis layout (rows / columns / free), apply characteristic filters with include/exclude and range operators
151
+ - Drill into hierarchy nodes and structure members (expand / collapse by tuple index)
152
+ - Look up valid characteristic values before setting filters or variables — returns both internal and external key formats
153
+
154
+ ### CompositeProvider (Read)
155
+ - Read CompositeProvider structure — view node type (Union/Join), source providers (inputs) with mapping count, all fields with dimension classification, join conditions, and temporal join details
156
+
157
+ ### Global CP Components (Read)
158
+ - Read global Calculated Key Figure (CKF) — formula recursively resolved to a human-readable string, full dependency graph of all referenced sub-components
159
+ - Read global Restricted Key Figure (RKF) — base measure, all characteristic restriction groups with field and value details
160
+ - Read global Structure — all members with Formula/Selection breakdown, referenced components, characteristic filters, optional child members
161
+
162
+ ### Repository Navigation
163
+ - Navigate the full BW repository tree — drill from InfoArea to type folder to object to sub-folder, mirroring the Eclipse BWMT Project Explorer; each entry returns a `children_path` for seamless drill-down
164
+
165
+ ### Data Flow Navigation
166
+ - Traverse the complete structural data flow graph of any BW object — all connected sources and targets resolved recursively through Transformations, DTPs, InfoSources, aDSOs, DataSources, CompositeProviders, and InfoObjects; mirrors the Eclipse BWMT Transient Data Flow view
167
+
168
+ ### DataSource Navigation
169
+ - List all source systems connected to the BW system (ODP_SAP, ODP_CDS, ODP_BW, ODP, FILE, HANA_SDA, HANA_LOCAL)
170
+ - Recursively list all DataSources in a source system with full APCO hierarchy path
171
+ - Read full source system metadata including connection details (ODP context/destination, HANA remote source and schema)
172
+ - Read complete DataSource structure: fields with types, lengths, transfer flags, adapter configuration
173
+
174
+ ### BW Role Management
175
+ - Read the full role hierarchy (ROLE + FOLDER structure)
176
+ - List all queries published per role
177
+ - Check which roles a specific query is assigned to
178
+ - Publish a query into a role or a specific sub-folder
179
+ - Remove a query from a role or folder
180
+ - Move a query between roles (remove from old, add to new)
181
+
182
+ ### Push API
183
+ - Get JSON push schema for a write-interface aDSO
184
+ - Push JSON record arrays directly into an aDSO
185
+
186
+ ### Process Chain Navigation
187
+ - Read complete Process Chain definitions — all steps with type, variant, description, and last execution status
188
+ - Conditional flow semantics fully resolved: DECISION branch labels (including ABAP formula expressions), OR/AND join nodes, positive/negative/neutral edge conditions
189
+ - Automatic variant detail per step: ABAP program and selection variant, TRIGGER scheduling parameters, ADSOACT/ADSOREM aDSO targets and cleanup settings, PLSWITCHL/P target aDSO, DECISION branching formulas — all embedded inline in a single tool call
190
+ - Recursive sub-chain expansion: CHAIN-type steps reference other Process Chains — call `bw_get_process_chain` again on any referenced chain name to expand the full hierarchy
191
+ - Generic process variant reader: covers all 93 BW/4HANA process types including custom Z-types; unknown types return oDetail as raw JSON
192
+
193
+ ### DataSource Data Preview
194
+ - Fetch a live data preview from any DataSource (RSDS) directly from the source system
195
+ - Field names resolved automatically from the DataSource structure; configurable record count (default 20)
196
+ - Rendered as a padded plain-text table with column alignment
197
+
198
+ ### Request Monitor & Runtime
199
+ - List load requests for a target InfoProvider — status, last process status/action, record count, timestamp, user, TSN
200
+ - Full status analysis of a single load request — header, DTP information (start/finish/duration), process step chain, and message log in one call
201
+ - Activate loaded data (DSO request activation) — move a finished load from the inbound table into the active data table + change log
202
+ - Uses the BW/4HANA `/sap/bc/.../bw4` manage API (the same operations as the BW/4HANA Cockpit)
203
+
204
+ ### General
205
+ - Search & Where-Used (xref)
206
+ - Activate BW objects (aDSO, InfoObject, Transformation, DTP, DataSource)
207
+ - Release locks without activating (discard changes)
208
+ - Delete BW objects
209
+ - Transport request assignment
210
+
211
+ ---
212
+
213
+ ## Combining with an ADT MCP Server
214
+
215
+ For tasks involving ABAP or SQLScript (AMDP) logic inside Transformations, **bw-modeling-mcp works best alongside an ADT MCP server** such as [vibing-steampunk](https://github.com/oisee/vibing-steampunk).
216
+
217
+ The BW MCP server handles the BW modeling structure — creating the Transformation, setting up routines, activating objects. The ADT MCP server handles reading and writing the actual ABAP class source code that backs the routine. Together, they cover the full development cycle from BW object creation to ABAP logic implementation.
218
+
219
+ ---
220
+
221
+ ## System Compatibility
222
+
223
+ | System | Support |
224
+ |---|---|
225
+ | SAP BW/4HANA (all versions) | ✅ Full support |
226
+ | SAP BW Bridge (SAP BTP ABAP stack) | ✅ Via cookie authentication (`BW_COOKIE_FILE`) |
227
+
228
+ <p><em><sub>SAP BW on HANA (7.5) is not supported. While individual tools may work, most HTTP communications cannot reliably pass through the server-side version negotiation in BW 7.5, causing most tools to fail with HTTP 406 errors.</sub></em></p>
229
+
230
+ ---
231
+
232
+ ## Requirements
233
+
234
+ - SAP BW/4HANA system with REST API access (`/sap/bw/modeling/`)
235
+ - Node.js 18 or later
236
+ - An MCP-compatible AI client (Claude Desktop, Claude Code, etc.)
237
+
238
+ ---
239
+
240
+ ## Installation
241
+
242
+ ```bash
243
+ # Option 1: Install via npm (recommended)
244
+ npm install -g bw-modeling-mcp
245
+
246
+ # Option 2: Clone and build
247
+ git clone https://github.com/dnic-dev/bw-modeling-mcp.git
248
+ cd bw-modeling-mcp
249
+ npm install
250
+ npm run build
251
+ ```
252
+
253
+ ---
254
+
255
+ ## Configuration
256
+
257
+ The server is configured via environment variables:
258
+
259
+ | Variable | Description | Required |
260
+ |---|---|---|
261
+ | `BW_URL` | BW system URL (e.g. `https://myhost:50001`) | yes |
262
+ | `BW_USER` | SAP user name | yes (or `BW_COOKIE_FILE`) |
263
+ | `BW_PASSWORD` | SAP password | yes (or `BW_COOKIE_FILE`) |
264
+ | `BW_CLIENT` | SAP client (e.g. `001`) | yes |
265
+ | `BW_LANGUAGE` | Language for object texts (e.g. `EN`, `DE`). Default: `DE` | no |
266
+ | `BW_COOKIE_FILE` | Path to a browser-exported cookie file for SAML-/OAuth-fronted systems (e.g. BW Bridge). Netscape or `name=value` format. When set, `BW_USER` / `BW_PASSWORD` are optional. | no |
267
+
268
+ **Cookie authentication (BW Bridge / SAP BTP):** For BW systems that sit behind a SAML or OAuth login (such as BW Bridge on the SAP BTP ABAP stack), Basic Auth is not available. Export the authenticated session cookies from your browser into a file and point `BW_COOKIE_FILE` at it. The login/session approach is analogous to [vibing-steampunk](https://github.com/oisee/vibing-steampunk). When the session expires, refresh the cookie file and restart the server.
269
+
270
+ ### Claude Desktop
271
+
272
+ Add to `claude_desktop_config.json`:
273
+
274
+ ```json
275
+ {
276
+ "mcpServers": {
277
+ "bw-modeling-mcp": {
278
+ "command": "node",
279
+ "args": ["/path/to/bw-modeling-mcp/dist/index.js"],
280
+ "env": {
281
+ "BW_URL": "https://your-bw-host:50001",
282
+ "BW_USER": "YOUR_USER",
283
+ "BW_PASSWORD": "YOUR_PASSWORD",
284
+ "BW_CLIENT": "001",
285
+ "BW_LANGUAGE": "EN"
286
+ }
287
+ }
288
+ }
289
+ }
290
+ ```
291
+
292
+ ### Claude Code
293
+
294
+ Add `.mcp.json` to your project root:
295
+
296
+ ```json
297
+ {
298
+ "mcpServers": {
299
+ "bw-modeling-mcp": {
300
+ "command": "node",
301
+ "args": ["/path/to/bw-modeling-mcp/dist/index.js"],
302
+ "env": {
303
+ "BW_URL": "https://your-bw-host:50001",
304
+ "BW_USER": "YOUR_USER",
305
+ "BW_PASSWORD": "YOUR_PASSWORD",
306
+ "BW_CLIENT": "001",
307
+ "BW_LANGUAGE": "EN"
308
+ }
309
+ }
310
+ }
311
+ }
312
+ ```
313
+
314
+ ---
315
+
316
+ ## Tools Reference
317
+
318
+ ### `bw_search`
319
+ Search BW objects by name or description. Supports wildcards (`*`). Optionally filter by object type (`ADSO`, `IOBJ`, `TRFN`, `DTPA`, etc.).
320
+
321
+ ### `bw_xref`
322
+ Find all objects that reference a given BW object (where-used analysis). Use this to find Transformations and DTPs connected to an aDSO, or to find the process chain(s) a DTP belongs to (`object_type=DTPA`).
323
+
324
+ For DataSources (`object_type=RSDS`): pass `source_system` — the correctly space-padded objectName is built automatically.
325
+
326
+ ### `bw_get_adso`
327
+ Read the full structure of an aDSO — fields, key fields, settings, version state.
328
+
329
+ ### `bw_create_adso`
330
+ Create a new aDSO. Supports two modes: `from_template` (copies structure from an existing aDSO) or `empty`. Supports all aDSO type presets including write-interface (`pushMode`).
331
+
332
+ ### `bw_update_adso`
333
+ Modify an existing aDSO. Actions:
334
+ - `add_field` — add an InfoObject-backed field
335
+ - `add_pure_field` — add a field-based (pure) field without an InfoObject
336
+ - `remove_field` — remove a field
337
+ - `manage_keys` — set or update key fields
338
+ - `update_field_properties` — change aggregation, data type, length, etc.
339
+ - `update_settings` — change aDSO type preset, flags, or description
340
+
341
+ ### `bw_get_infoobject`
342
+ Read an InfoObject definition (Characteristic or Key Figure).
343
+
344
+ ### `bw_create_infoobject`
345
+ Create a new InfoObject. Supports:
346
+ - **Characteristic (CHA):** all data types (CHAR, NUMC, DATS, TIMS, SNUMC), with or without master data and texts, with compound parent InfoObjects, with referenced InfoObject
347
+ - **Key Figure (KYF):** all types (NUM, AMT, QTY, DAT, INT), all aggregations (SUM, MAX, MIN)
348
+
349
+ Created as inactive — activate with `bw_activate`.
350
+
351
+ ### `bw_update_infoobject`
352
+ Add or remove display (`DIS`) and navigation (`NAV`) attributes on an existing Characteristic.
353
+
354
+ ### `bw_get_infoarea`
355
+ Read an InfoArea definition — name, label, parent area, object status.
356
+
357
+ ### `bw_create_infoarea`
358
+ Create a new InfoArea. Immediately active after creation, no activation step needed.
359
+
360
+ ### `bw_move_object`
361
+ Move any BW object (aDSO, InfoObject, InfoArea, etc.) to a different InfoArea.
362
+
363
+ ### `bw_get_infosource`
364
+ Read an InfoSource (TRCS) structure — fields, key fields, label, InfoArea, version status.
365
+
366
+ ### `bw_create_infosource`
367
+ Create a new InfoSource with full field definitions.
368
+
369
+ ### `bw_update_infosource`
370
+ Update an existing InfoSource — fields and description.
371
+
372
+ ### `bw_get_transformation`
373
+ Read a Transformation structure including all field mapping rules, routines, source, and target. Transformation names are UUID-like keys — use `bw_xref` on the target aDSO to find them.
374
+
375
+ ### `bw_create_transformation`
376
+ Create a new Transformation. Supports all source types (aDSO, InfoSource, DataSource/RSDS) and all target types (aDSO). Can copy structure from an existing Transformation.
377
+
378
+ ### `bw_update_transformation`
379
+ Modify field mappings in an existing Transformation:
380
+ - Map source field to target InfoObject (StepDirect)
381
+ - Set formula rule for a target field (StepFormula)
382
+
383
+ ### `bw_set_transformation_routine`
384
+ Set a field routine, start routine, or end routine on a Transformation. Supports both ABAP and AMDP (SQLScript). The routine code is written in combination with an ADT MCP server.
385
+
386
+ ### `bw_delete_transformation_routine`
387
+ Remove an existing routine from a Transformation field.
388
+
389
+ ### `bw_set_transformation_runtime`
390
+ Switch the Transformation runtime between ABAP and AMDP.
391
+
392
+ ### `bw_get_dtp`
393
+ Read the full definition of a single DTP — source, target, transformation reference, extraction settings (mode, package size), and all filter fields including value selections and routine code. DTP names are UUID-like keys — use `bw_xref` or `bw_get_dtps` to find them.
394
+
395
+ ### `bw_get_dtps`
396
+ List all DTPs that depend on a given BW object or Transformation.
397
+
398
+ ### `bw_create_dtp`
399
+ Create a new DTP on a Transformation. Source and target are derived from the Transformation automatically. For a DataSource source, set `source_type="RSDS"` and pass `source_system`.
400
+
401
+ ### `bw_run_dtp`
402
+ Start (execute) a run of an existing, active DTP. Returns the new run request id (an RSPM TSN) that can be passed directly to `bw_get_request` for monitoring.
403
+
404
+ ### `bw_update_dtp`
405
+ Update a DTP — description, value filters on fields, and extraction mode (`extraction_mode` = `full` / `delta`). Note: switching between Delta and Full has BW delta-init implications — a later delta load may require re-initialization.
406
+
407
+ ### `bw_set_dtp_filter_routine`
408
+ Set an ABAP routine filter on a DTP field.
409
+
410
+ ### `bw_get_push_schema`
411
+ Get the expected JSON schema for pushing data into a write-interface aDSO.
412
+
413
+ ### `bw_push_data`
414
+ Push a JSON record array directly into a write-interface aDSO via the BW Push API (`/sap/bw4/v1/push/`).
415
+
416
+ ### `bw_get_query` _(Read only)_
417
+ Read a BW Query definition — variables, filter logic (fixed values and variable references resolved), layout with full member lists, calculated key figures with recursively resolved formulas, restricted key figures with selection conditions, exceptions, and query settings. Output format: `text` (default, compact human-readable summary) or `raw` (full parsed JSON).
418
+
419
+ ### `bw_query_data` _(Read only)_
420
+ Execute a BEx Query or preview data from an InfoProvider (aDSO, CompositeProvider) via the BICS reporting endpoint. Returns a formatted result table with hierarchy indentation.
421
+
422
+ Parameters: `comp_id` (query or provider name), `is_provider` (set `true` for direct aDSO/HCPR access), `state` (axis placement — ROWS/COLUMNS/FREE — and per-characteristic filters supporting EQ/BT/GT/LT/GE/LE, include/exclude, external key, internal GUID key, and hierarchy-node filters), `variables` (fill query variables; name and id must be copied verbatim from the GET response), `from_row`/`to_row` (pagination), `drill_operations` (expand or collapse hierarchy and structure nodes by 1-based tuple index: `drill_state=3` expands, `drill_state=2` collapses), `format` (`text` default — formatted table; `raw` — XML).
423
+
424
+ Always call `bw_get_query` or `bw_get_adso` first to discover the axis layout and characteristic IDs, and call `bw_get_filter_values` before setting any filter or variable value.
425
+
426
+ ### `bw_get_filter_values` _(Read only)_
427
+ Look up valid values for a characteristic — required before setting any filter or variable. Returns `CHAVL_EXT` (use for state filters) and `CHAVL_INT` (use for variable inputs); formats differ for date-type characteristics. Supports wildcard search (`*` for all values, prefix match e.g. `2022*`). Optionally scope results to a specific InfoProvider.
428
+
429
+ ### `bw_get_process_chain` _(Read only)_
430
+ Read a Process Chain (RSPC) definition — header metadata, scheduling and monitoring settings, all steps with type, variant, last execution status, conditional dependencies with DECISION branch labels, and automatically embedded variant configuration per step. Set `include_variant_details=false` for a fast structural overview. Output format: `text` (default) or `raw` (full JSON).
431
+
432
+ ### `bw_get_process_variant` _(Read only)_
433
+ Read the detail configuration of a single Process Chain step variant. Generic across all process types — oDetail rendered as indented JSON. Use process_type and variant_name from `bw_get_process_chain` output.
434
+
435
+ ### `bw_preview_datasource` _(Read only)_
436
+ Fetch a live data preview from a DataSource. Resolves field names automatically and renders a formatted table. Parameters: `datasource_name`, `source_system`, `records` (default 20).
437
+
438
+ ### `bw_get_roles` _(Read only)_
439
+ Read the complete BW role hierarchy as displayed in the Eclipse BWMT "Publish to Role" dialog. Returns all ROLE and FOLDER nodes with technical names, descriptions, and nodeids. Optional `role_filter` parameter limits output to roles whose name starts with the given prefix (e.g. `"BW:"`).
440
+
441
+ ### `bw_get_role_queries` _(Read only)_
442
+ List all BW Queries published in the role hierarchy, grouped by role and folder. Only `SAP_BW_QUERY` objects are returned — PFCG menu entries of other types (e.g. AFO workbooks added as transactions) are not included. Optional `role_name` to scope to a specific role.
443
+
444
+ ### `bw_get_query_roles` _(Read only)_
445
+ Return all roles and folders where a specific BW Query is currently published. Returns a clear "not published" message if the query has no role assignments.
446
+
447
+ ### `bw_set_query_roles`
448
+ Publish or remove a BW Query from a role or folder. Parameters: `query_name`, `action` (`"add"` or `"remove"`), `target_type` (`"role"` or `"folder"`), `target_name` (role name attribute for role-level, folder txt for folder-level), `parent_role_name` (required when `target_type="folder"`). For add operations, the full role subtree is fetched automatically from `bw_get_roles` — no manual lookup needed.
449
+
450
+ ### `bw_get_composite_provider` _(Read only)_
451
+ Read a CompositeProvider (HCPR) — view node type (Union/Join), source providers with input mapping counts, all fields with dimension classification, join conditions, and temporal join details.
452
+
453
+ ### `bw_get_ckf` _(Read only)_
454
+ Read a global Calculated Key Figure — formula recursively resolved to a human-readable string, metadata (package, InfoArea, author), and full dependency graph of all referenced sub-components.
455
+
456
+ ### `bw_get_rkf` _(Read only)_
457
+ Read a global Restricted Key Figure — base measure, all characteristic restriction groups (field and value), and metadata.
458
+
459
+ ### `bw_get_structure` _(Read only)_
460
+ Read a global Structure — all members with type (Formula/Selection), referenced components, characteristic filters, optional child members, and metadata.
461
+
462
+ ### `bw_list_contents` _(Read only)_
463
+ Navigate the BW repository tree. Pass a path such as `""` (all InfoAreas), `"area/MYAREA"` (InfoArea contents), `"hcpr/CP_NAME"` (CP sub-folders), or `"adso/ADSO_NAME/trfn"` (Transformations on an aDSO). Each entry includes `children_path` to drill down further.
464
+
465
+ ### `bw_list_source_systems` _(Read only)_
466
+ List all logical source systems (LSYS) registered in the BW DataSource structure. Optionally filter by type (`ODP_BW`, `ODP_SAP`, `ODP_CDS`, `ODP`, `FILE`). Each entry includes `children_path` — pass it directly to `bw_list_datasources` as `source_system`.
467
+
468
+ ### `bw_list_datasources` _(Read only)_
469
+ List all DataSources available under a logical source system. Recursively traverses the full APCO hierarchy. Each DataSource entry includes name, description, status, and the full `apco_path` (ordered list of application component titles from root to the DataSource). Output format: `text` (default table) or `raw` (XML feed bodies).
470
+
471
+ ### `bw_get_source_system` _(Read only)_
472
+ Read the metadata of a single logical source system — type, description, and connection details. For ODP systems: context, destination, validity flags. For HANA systems: remote source, database, schema, SDI adapter.
473
+
474
+ ### `bw_get_datasource` _(Read only)_
475
+ Read the complete structure of a DataSource (RSDS): metadata (status, delta type, direct access, application component, package, timestamps), all fields with type, length, transfer flag, key flag, position, selection options, conversion exit, and unit/currency reference, plus active adapter configuration (ODP, HANA, File, CSV). Output format: `text` (default human-readable summary) or `raw` (XML from BW).
476
+
477
+ ### `bw_get_dataflow` _(Read only)_
478
+ Read the complete structural data flow of a BW object — all connected sources and targets resolved recursively through Transformations, DTPs, InfoSources, aDSOs, DataSources, CompositeProviders, and InfoObjects. Mirrors the Eclipse BWMT Transient Data Flow view. Supports direction (`upwards` / `downwards` / `both`) and configurable depth. Note: routine-based lookups (ABAP/SQLScript) are not reflected — only structural BW dependencies.
479
+
480
+ ### `bw_list_requests` _(Read only)_
481
+ List load requests for a target InfoProvider via the BW/4HANA manage API — status, last process status and last action, record count, timestamp, user, and TSN. The TSN feeds `bw_get_request`.
482
+
483
+ ### `bw_get_request` _(Read only)_
484
+ Full status analysis of one load request in a single call — request header, DTP information (start/finish/duration), process step chain, and message log. Output format: `text` (default) or `raw` (parsed JSON of all four payloads).
485
+
486
+ ### `bw_activate_request`
487
+ Activate loaded data (DSO request activation) — move a finished load from the inbound table into the active data table and change log. This is the runtime request activation (BW/4HANA manage API), distinct from the modeling-object activation done by `bw_activate`; it applies only to aDSOs that have an activation step and runs asynchronously.
488
+
489
+ ### `bw_activate`
490
+ Activate one or more BW objects. Handles impact analysis and automatically deactivated DTPs. Supports: `adso`, `iobj`, `trfn`, `dtp`, `rsds` (DataSource).
491
+
492
+ ### `bw_unlock`
493
+ Release a lock on a BW object without activating (discard changes).
494
+
495
+ ### `bw_delete`
496
+ Delete a BW object. Works for aDSO, InfoObject, InfoArea, and other types.
497
+
498
+ ---
499
+
500
+ ## Example Prompts
501
+
502
+ > **Fun starter** — this one was actually run by a colleague :-)
503
+ ```
504
+ Create a write-interface aDSO to store all match results of the Bundesliga 2024/2025 season.
505
+ Include all relevant fields: matchday, home team, away team, home goals, away goals, match date.
506
+ Suggest a technical name that fits the existing objects in InfoArea MCPBW.
507
+ Then load the aDSO with real data from the completed 2024/2025 season using the Push API.
508
+ ```
509
+
510
+ ### Modify — working in the BW system
511
+
512
+ **Setting up a new BW area for a CRM integration:**
513
+ ```
514
+ We are setting up a new BW area for our CRM integration project.
515
+ Create the InfoArea "ZCRM" with description "CRM Integration" below InfoArea "ZSALES".
516
+ Inside it, create a field-based aDSO to store sales order data loaded from the OpenCRX REST API.
517
+ The aDSO should contain the following fields: order_id (key, CHAR 20), customer_id (CHAR 10),
518
+ order_date (DATS), amount (DEC 15,2), currency (CUKY 5), status (CHAR 4).
519
+ Name the aDSO starting with "Z".
520
+ ```
521
+
522
+ **Building a full data flow from field-based to InfoObject-based:**
523
+ ```
524
+ Create a second aDSO in InfoArea "ZCRM" — this time InfoObject-based, same business content
525
+ as ZCRM_ORDERS. Create all required InfoObjects for this aDSO. Decide independently on type
526
+ (Characteristic/Key Figure), master data, and texts based on the field semantics.
527
+ Then create a Transformation from ZCRM_ORDERS to the new aDSO and map all fields 1:1.
528
+ Activate the Transformation. Finally, create a DTP on the Transformation and activate it.
529
+ ```
530
+
531
+ **Adding derived logic with an AMDP routine and DTP filter:** — In Combination with an ADT MCP Server
532
+ ```
533
+ Create a new InfoObject to flag high-value orders above $10,000.
534
+ Choose an appropriate technical name and description.
535
+ Add the InfoObject to aDSO ZCRM_ORDERS.
536
+ Create an AMDP field routine for this field in the Transformation and derive the logic
537
+ in SQLScript: set the flag if the calculated order total (quantity × unit price) exceeds 10,000.
538
+ Adjust the DTP filter: load only orders with status "CONFIRMED" (value filter)
539
+ and only orders from the current calendar year (routine filter).
540
+ ```
541
+
542
+ ---
543
+
544
+ ### Read-Only — understanding existing models
545
+
546
+ **Full data lineage analysis:**
547
+ ```
548
+ Analyze the complete data lineage of aDSO ZSLS_ORDSUM down to all connected DataSources
549
+ from source system OCRXCLNT100.
550
+ Include all intermediate objects: aDSOs, Transformations, InfoSources, and DataSources.
551
+ Also trace any objects referenced inside transformation routines (e.g. via AMDP or ABAP logic)
552
+ and follow their lineage as well.
553
+ Present the result as a structured table with columns:
554
+ Level (1 = closest to ZSLS_ORDSUM), Object Type, Technical Name, Description, Source System.
555
+ Use full object type names — no abbreviations.
556
+ ```
557
+
558
+ ---
559
+
560
+ ## How it works
561
+
562
+ The server connects to the SAP BW Modeling REST API (`/sap/bw/modeling/`) — the same internal API used by Eclipse BWMT. All write operations follow the BW locking protocol:
563
+
564
+ 1. **Lock** — acquires an exclusive lock and returns a `lockHandle`
565
+ 2. **Read** — fetches the current complete XML of the object
566
+ 3. **Modify** — applies changes to the XML
567
+ 4. **PUT** — sends the full modified XML back (never partial updates)
568
+ 5. **Activate** — promotes the inactive version to active
569
+ 6. **Unlock** — releases the lock
570
+
571
+ Session cookies and CSRF tokens are managed automatically.
572
+
573
+ See [ARCHITECTURE.md](ARCHITECTURE.md) for the full technical architecture and complete API reference.
574
+
575
+ ---
576
+
577
+ ## Roadmap
578
+
579
+ - **CompositeProvider** — Read: `bw_get_composite_provider` ✅, global components (`bw_get_ckf` / `bw_get_rkf` / `bw_get_structure`) ✅ — Create and modify: planned
580
+ - **BW Queries** — Read: `bw_get_query` ✅ — Create and modify: planned
581
+ - **Process Chains** — build and manage Process Chains
582
+ - **Open ODS View** — create Open ODS Views
583
+ - **BW/4HANA Cockpit functions** — runtime request monitor and data activation ✅ (`bw_run_dtp`, `bw_list_requests`, `bw_get_request`, `bw_activate_request`) — further runtime operations planned
584
+ - **Further BW/4HANA objects** — additional modeling objects
585
+
586
+ ---
587
+
588
+ ## Contributing
589
+
590
+ Issues and feature requests are welcome — please use the [Issue templates](https://github.com/dnic-dev/bw-modeling-mcp/issues/new/choose).
591
+
592
+ If you have access to a BW/4HANA system and want to help expand coverage, I am happy to hear from you. The best way to contribute is to try it out and report what works, what doesn't, and what's missing.
593
+
594
+ ---
595
+
596
+ ## License
597
+
598
+ MIT