mcp-eregistrations-bpa 0.8.5__py3-none-any.whl

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.

Potentially problematic release.


This version of mcp-eregistrations-bpa might be problematic. Click here for more details.

Files changed (66) hide show
  1. mcp_eregistrations_bpa/__init__.py +121 -0
  2. mcp_eregistrations_bpa/__main__.py +6 -0
  3. mcp_eregistrations_bpa/arazzo/__init__.py +21 -0
  4. mcp_eregistrations_bpa/arazzo/expression.py +379 -0
  5. mcp_eregistrations_bpa/audit/__init__.py +56 -0
  6. mcp_eregistrations_bpa/audit/context.py +66 -0
  7. mcp_eregistrations_bpa/audit/logger.py +236 -0
  8. mcp_eregistrations_bpa/audit/models.py +131 -0
  9. mcp_eregistrations_bpa/auth/__init__.py +64 -0
  10. mcp_eregistrations_bpa/auth/callback.py +391 -0
  11. mcp_eregistrations_bpa/auth/cas.py +409 -0
  12. mcp_eregistrations_bpa/auth/oidc.py +252 -0
  13. mcp_eregistrations_bpa/auth/permissions.py +162 -0
  14. mcp_eregistrations_bpa/auth/token_manager.py +348 -0
  15. mcp_eregistrations_bpa/bpa_client/__init__.py +84 -0
  16. mcp_eregistrations_bpa/bpa_client/client.py +740 -0
  17. mcp_eregistrations_bpa/bpa_client/endpoints.py +193 -0
  18. mcp_eregistrations_bpa/bpa_client/errors.py +276 -0
  19. mcp_eregistrations_bpa/bpa_client/models.py +203 -0
  20. mcp_eregistrations_bpa/config.py +349 -0
  21. mcp_eregistrations_bpa/db/__init__.py +21 -0
  22. mcp_eregistrations_bpa/db/connection.py +64 -0
  23. mcp_eregistrations_bpa/db/migrations.py +168 -0
  24. mcp_eregistrations_bpa/exceptions.py +39 -0
  25. mcp_eregistrations_bpa/py.typed +0 -0
  26. mcp_eregistrations_bpa/rollback/__init__.py +19 -0
  27. mcp_eregistrations_bpa/rollback/manager.py +616 -0
  28. mcp_eregistrations_bpa/server.py +152 -0
  29. mcp_eregistrations_bpa/tools/__init__.py +372 -0
  30. mcp_eregistrations_bpa/tools/actions.py +155 -0
  31. mcp_eregistrations_bpa/tools/analysis.py +352 -0
  32. mcp_eregistrations_bpa/tools/audit.py +399 -0
  33. mcp_eregistrations_bpa/tools/behaviours.py +1042 -0
  34. mcp_eregistrations_bpa/tools/bots.py +627 -0
  35. mcp_eregistrations_bpa/tools/classifications.py +575 -0
  36. mcp_eregistrations_bpa/tools/costs.py +765 -0
  37. mcp_eregistrations_bpa/tools/debug_strategies.py +351 -0
  38. mcp_eregistrations_bpa/tools/debugger.py +1230 -0
  39. mcp_eregistrations_bpa/tools/determinants.py +2235 -0
  40. mcp_eregistrations_bpa/tools/document_requirements.py +670 -0
  41. mcp_eregistrations_bpa/tools/export.py +899 -0
  42. mcp_eregistrations_bpa/tools/fields.py +162 -0
  43. mcp_eregistrations_bpa/tools/form_errors.py +36 -0
  44. mcp_eregistrations_bpa/tools/formio_helpers.py +971 -0
  45. mcp_eregistrations_bpa/tools/forms.py +1269 -0
  46. mcp_eregistrations_bpa/tools/jsonlogic_builder.py +466 -0
  47. mcp_eregistrations_bpa/tools/large_response.py +163 -0
  48. mcp_eregistrations_bpa/tools/messages.py +523 -0
  49. mcp_eregistrations_bpa/tools/notifications.py +241 -0
  50. mcp_eregistrations_bpa/tools/registration_institutions.py +680 -0
  51. mcp_eregistrations_bpa/tools/registrations.py +897 -0
  52. mcp_eregistrations_bpa/tools/role_status.py +447 -0
  53. mcp_eregistrations_bpa/tools/role_units.py +400 -0
  54. mcp_eregistrations_bpa/tools/roles.py +1236 -0
  55. mcp_eregistrations_bpa/tools/rollback.py +335 -0
  56. mcp_eregistrations_bpa/tools/services.py +674 -0
  57. mcp_eregistrations_bpa/tools/workflows.py +2487 -0
  58. mcp_eregistrations_bpa/tools/yaml_transformer.py +991 -0
  59. mcp_eregistrations_bpa/workflows/__init__.py +28 -0
  60. mcp_eregistrations_bpa/workflows/loader.py +440 -0
  61. mcp_eregistrations_bpa/workflows/models.py +336 -0
  62. mcp_eregistrations_bpa-0.8.5.dist-info/METADATA +965 -0
  63. mcp_eregistrations_bpa-0.8.5.dist-info/RECORD +66 -0
  64. mcp_eregistrations_bpa-0.8.5.dist-info/WHEEL +4 -0
  65. mcp_eregistrations_bpa-0.8.5.dist-info/entry_points.txt +2 -0
  66. mcp_eregistrations_bpa-0.8.5.dist-info/licenses/LICENSE +86 -0
@@ -0,0 +1,965 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-eregistrations-bpa
3
+ Version: 0.8.5
4
+ Summary: MCP server for eRegistrations BPA platform
5
+ Project-URL: Homepage, https://github.com/UNCTAD-eRegistrations/mcp-eregistrations-bpa
6
+ Project-URL: Repository, https://github.com/UNCTAD-eRegistrations/mcp-eregistrations-bpa
7
+ Project-URL: Documentation, https://github.com/UNCTAD-eRegistrations/mcp-eregistrations-bpa#readme
8
+ Author-email: Moulay Mehdi Benmoumen <benmoumen@gmail.com>
9
+ Maintainer: UNCTAD Business Facilitation Section
10
+ License: Proprietary - UNCTAD/DIAE/Business Facilitation Section
11
+ License-File: LICENSE
12
+ Keywords: ai,bpa,claude,eregistrations,govtech,mcp,unctad
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: Other/Proprietary License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Office/Business :: Groupware
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: aiosqlite>=0.22.1
24
+ Requires-Dist: authlib
25
+ Requires-Dist: fastmcp>=2.11.3
26
+ Requires-Dist: httpx
27
+ Requires-Dist: pydantic>=2.0
28
+ Requires-Dist: pyyaml
29
+ Description-Content-Type: text/markdown
30
+
31
+ # MCP eRegistrations BPA
32
+
33
+ **AI-powered Service Design for Government Digital Transformation**
34
+
35
+ An MCP server that enables AI assistants like Claude to design, configure, and deploy government services on the eRegistrations BPA platform using natural language.
36
+
37
+ ## What It Does
38
+
39
+ Design and configure BPA services through conversation:
40
+
41
+ ```
42
+ You: Create a "Business License" service
43
+ Claude: Created service with registration. Service ID: abc-123
44
+
45
+ You: Add a reviewer role
46
+ Claude: Added "Reviewer" role to the service
47
+
48
+ You: Set a $50 processing fee
49
+ Claude: Created fixed cost of $50 attached to the registration
50
+ ```
51
+
52
+ Each step uses the right MCP tool. Full audit trail. Rollback if needed.
53
+
54
+ ## Prerequisites
55
+
56
+ Install [uv](https://docs.astral.sh/uv/) (includes `uvx`):
57
+
58
+ ```bash
59
+ # macOS (recommended)
60
+ brew install uv
61
+
62
+ # Other platforms
63
+ curl -LsSf https://astral.sh/uv/install.sh | sh
64
+ ```
65
+
66
+ ## Quick Install
67
+
68
+ The MCP server supports two authentication providers:
69
+ - **Keycloak** (modern BPA systems) — OIDC with PKCE
70
+ - **CAS** (legacy BPA systems) — OAuth2 with Basic Auth
71
+
72
+ The provider is auto-detected based on which environment variables you set.
73
+
74
+ ### Keycloak Configuration (Modern Systems)
75
+
76
+ **For Claude Desktop** — add to `claude_desktop_config.json`:
77
+
78
+ ```json
79
+ {
80
+ "mcpServers": {
81
+ "BPA-elsalvador-dev": {
82
+ "command": "uvx",
83
+ "args": ["--refresh", "mcp-eregistrations-bpa"],
84
+ "env": {
85
+ "BPA_INSTANCE_URL": "https://bpa.dev.els.eregistrations.org",
86
+ "KEYCLOAK_URL": "https://login.dev.els.eregistrations.org",
87
+ "KEYCLOAK_REALM": "SV"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ **For Claude Code** — add to `.mcp.json` in your project:
95
+
96
+ ```json
97
+ {
98
+ "mcpServers": {
99
+ "BPA-elsalvador-dev": {
100
+ "command": "uvx",
101
+ "args": ["--refresh", "mcp-eregistrations-bpa"],
102
+ "env": {
103
+ "BPA_INSTANCE_URL": "https://bpa.dev.els.eregistrations.org",
104
+ "KEYCLOAK_URL": "https://login.dev.els.eregistrations.org",
105
+ "KEYCLOAK_REALM": "SV"
106
+ }
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ **Or via CLI** — install globally with one command:
113
+
114
+ ```bash
115
+ claude mcp add --scope user --transport stdio BPA-kenya \
116
+ --env BPA_INSTANCE_URL=https://bpa.test.kenya.eregistrations.org \
117
+ --env KEYCLOAK_URL=https://login.test.kenya.eregistrations.org \
118
+ --env KEYCLOAK_REALM=KE \
119
+ -- uvx --refresh mcp-eregistrations-bpa
120
+ ```
121
+
122
+ ### CAS Configuration (Legacy Systems)
123
+
124
+ For older BPA deployments using CAS (e.g., Cuba test environment):
125
+
126
+ #### Step 1: Register OAuth Client in CAS
127
+
128
+ Before configuring the MCP server, you must register an OAuth client in CAS with:
129
+
130
+ | Setting | Value |
131
+ |---------|-------|
132
+ | Client ID | Your chosen ID (e.g., `mcp-bpa`) |
133
+ | Client Secret | Generated secret |
134
+ | Redirect URI | `http://127.0.0.1:8914/callback` |
135
+
136
+ > **Important:** The redirect URI must be exactly `http://127.0.0.1:8914/callback`. The MCP server uses a fixed port (8914) because CAS requires exact redirect URI matching.
137
+
138
+ #### Step 2: Configure MCP Server
139
+
140
+ **For Claude Desktop** — add to `claude_desktop_config.json`:
141
+
142
+ ```json
143
+ {
144
+ "mcpServers": {
145
+ "BPA-cuba-test": {
146
+ "command": "uvx",
147
+ "args": ["--refresh", "mcp-eregistrations-bpa"],
148
+ "env": {
149
+ "BPA_INSTANCE_URL": "https://bpa.test.cuba.eregistrations.org",
150
+ "CAS_URL": "https://eid.test.cuba.eregistrations.org/cback/v1.0",
151
+ "CAS_CLIENT_ID": "mcp-bpa",
152
+ "CAS_CLIENT_SECRET": "your-client-secret",
153
+ "PARTC_URL": "https://eid.test.cuba.eregistrations.org/partc/v1.0"
154
+ }
155
+ }
156
+ }
157
+ }
158
+ ```
159
+
160
+ **For Claude Code** — add to `~/.claude.json` (global) or `.mcp.json` (project):
161
+
162
+ ```json
163
+ {
164
+ "mcpServers": {
165
+ "BPA-cuba-test": {
166
+ "command": "uvx",
167
+ "args": ["--refresh", "mcp-eregistrations-bpa"],
168
+ "env": {
169
+ "BPA_INSTANCE_URL": "https://bpa.test.cuba.eregistrations.org",
170
+ "CAS_URL": "https://eid.test.cuba.eregistrations.org/cback/v1.0",
171
+ "CAS_CLIENT_ID": "mcp-bpa",
172
+ "CAS_CLIENT_SECRET": "your-client-secret",
173
+ "PARTC_URL": "https://eid.test.cuba.eregistrations.org/partc/v1.0"
174
+ }
175
+ }
176
+ }
177
+ }
178
+ ```
179
+
180
+ **Or via CLI** — install globally with one command:
181
+
182
+ ```bash
183
+ claude mcp add --scope user --transport stdio BPA-cuba-test \
184
+ --env BPA_INSTANCE_URL=https://bpa.test.cuba.eregistrations.org \
185
+ --env CAS_URL=https://eid.test.cuba.eregistrations.org/cback/v1.0 \
186
+ --env CAS_CLIENT_ID=mcp-bpa \
187
+ --env CAS_CLIENT_SECRET=your-client-secret \
188
+ --env PARTC_URL=https://eid.test.cuba.eregistrations.org/partc/v1.0 \
189
+ -- uvx --refresh mcp-eregistrations-bpa
190
+ ```
191
+
192
+ > **Note:** CAS requires `CAS_CLIENT_SECRET` (unlike Keycloak which uses PKCE). Get this from your BPA administrator.
193
+
194
+ > **Troubleshooting:** If you get "command not found: uvx", you installed via curl which puts uvx in `~/.local/bin` (not in GUI app PATH). Fix: either `brew install uv`, or use `"command": "/bin/zsh", "args": ["-c", "$HOME/.local/bin/uvx mcp-eregistrations-bpa"]`
195
+
196
+ On first use, a browser opens for login. Your BPA permissions apply automatically.
197
+
198
+ > **Tip:** Name each MCP after its instance (e.g., `BPA-elsalvador-dev`, `BPA-cuba-test`) to manage multiple environments.
199
+
200
+ ## 119 MCP Tools
201
+
202
+ | Category | Capabilities |
203
+ | ----------------- | --------------------------------------------------------------- |
204
+ | **Services** | Create, read, update, copy, export, transform to YAML |
205
+ | **Registrations** | Full CRUD with parent service linking |
206
+ | **Institutions** | Assign/unassign institutions to registrations |
207
+ | **Forms** | Read/write Form.io components with container support |
208
+ | **Roles** | Create reviewer/approver/processor roles |
209
+ | **Bots** | Configure workflow automation |
210
+ | **Determinants** | Text, select, numeric, boolean, date, classification, grid |
211
+ | **Behaviours** | Component visibility/validation effects with JSONLogic |
212
+ | **Costs** | Fixed fees and formula-based pricing |
213
+ | **Documents** | Link document requirements to registrations |
214
+ | **Workflows** | Arazzo-driven intent-based natural language service design |
215
+ | **Debugging** | Scan, investigate, and fix service configuration issues |
216
+ | **Audit** | Complete operation history with rollback |
217
+ | **Analysis** | Service inspection and dependency mapping |
218
+
219
+ ## Natural Language Workflows
220
+
221
+ Ask Claude to design services using plain English:
222
+
223
+ | What you say | What happens |
224
+ | --------------------------------------- | ---------------------------------------------------- |
225
+ | "Create a permit service" | Creates service + registration with proper structure |
226
+ | "Add a reviewer role to this service" | Adds UserRole with 'processing' assignment |
227
+ | "Set a $75 application fee" | Creates fixed cost attached to registration |
228
+ | "Add document requirement for ID proof" | Links requirement to the registration |
229
+
230
+ The workflow system uses [Arazzo](https://spec.openapis.org/arazzo/latest.html) specifications to orchestrate multi-step operations. It extracts your intent, validates inputs, and executes with full audit trail.
231
+
232
+ ### Workflow Tools
233
+
234
+ | Tool | Purpose |
235
+ |------|---------|
236
+ | `workflow_list` | List available workflows by category |
237
+ | `workflow_search` | Find workflows matching natural language intent |
238
+ | `workflow_describe` | Get workflow details, inputs, and steps |
239
+ | `workflow_execute` | Run workflow with provided inputs |
240
+ | `workflow_start_interactive` | Begin guided step-by-step execution |
241
+ | `workflow_status` | Check execution progress |
242
+ | `workflow_rollback` | Undo a completed workflow |
243
+
244
+ ## Service Debugger Tools
245
+
246
+ AI-assisted debugging for BPA service configuration issues. Scan, investigate, and fix problems collaboratively.
247
+
248
+ ### Available Tools
249
+
250
+ | Tool | Purpose |
251
+ |------|---------|
252
+ | `debug_scan` | Scan service for configuration issues |
253
+ | `debug_investigate` | Analyze root cause of a specific issue |
254
+ | `debug_fix` | Execute fix for a single issue |
255
+ | `debug_fix_batch` | Fix multiple issues of the same type |
256
+ | `debug_group_issues` | Group issues by type, severity, or fix strategy |
257
+ | `debug_plan` | Generate phased fix plan with dependencies |
258
+ | `debug_verify` | Verify fixes were applied successfully |
259
+
260
+ ### Issue Types Detected
261
+
262
+ | Type | Severity | Auto-Fixable |
263
+ |------|----------|--------------|
264
+ | `effects_determinant` | High | Yes |
265
+ | `determinant` | High | Yes |
266
+ | `translation_moustache` | Medium | Yes |
267
+ | `catalog` | Medium | Yes |
268
+ | `missing_determinants_in_component_behaviours` | Medium | Yes |
269
+ | Component moustache issues | Low | Manual |
270
+ | Role/registration issues | Low | Manual |
271
+
272
+ ### Usage Example
273
+
274
+ ```
275
+ You: Scan this service for issues
276
+
277
+ Claude: Found 144 issues across 5 categories:
278
+ - 67 effects referencing deleted determinants (HIGH)
279
+ - 18 orphaned determinants (HIGH)
280
+ - 33 translation issues (MEDIUM)
281
+ [shows summary]
282
+
283
+ You: Fix all the high severity issues
284
+
285
+ Claude: I'll fix these in two phases:
286
+ Phase 1: Delete 67 orphaned effects
287
+ Phase 2: Delete 18 orphaned determinants
288
+
289
+ Proceed? [waits for approval]
290
+
291
+ You: Yes, proceed
292
+
293
+ Claude: Fixed 85 issues. Audit IDs saved for rollback.
294
+ Verification scan shows 0 high-severity issues remaining.
295
+ ```
296
+
297
+ ## Key Features
298
+
299
+ **Audit Trail** — Every operation logged (who, what, when). Query history with `audit_list`.
300
+
301
+ **Rollback** — Undo any write operation. Restore previous state with `rollback`.
302
+
303
+ **Export** — Get complete service definitions as clean YAML (~25x smaller than raw JSON) for review or version control.
304
+
305
+ **Copy** — Clone existing services with selective component inclusion.
306
+
307
+ **Pagination** — All list endpoints support `limit` and `offset` for large datasets. Responses include `total` and `has_more` for navigation.
308
+
309
+ ## Form MCP Tools
310
+
311
+ BPA uses Form.io for dynamic forms. These tools provide full CRUD operations on form components.
312
+
313
+ ### Available Tools
314
+
315
+ | Tool | Purpose |
316
+ |------|---------|
317
+ | `form_get` | Get form structure with simplified component list |
318
+ | `form_component_get` | Get full details of a specific component |
319
+ | `form_component_add` | Add new component to form |
320
+ | `form_component_update` | Update component properties |
321
+ | `form_component_remove` | Remove component from form |
322
+ | `form_component_move` | Move component to new position/parent |
323
+ | `form_update` | Replace entire form schema |
324
+
325
+ ### Form Types
326
+
327
+ - `applicant` (default) - Main application form
328
+ - `guide` - Guidance/help form
329
+ - `send_file` - File submission form
330
+ - `payment` - Payment form
331
+
332
+ ### Property Availability
333
+
334
+ Properties vary by tool. Use `form_get` for overview, `form_component_get` for full details:
335
+
336
+ | Property | `form_get` | `form_component_get` |
337
+ |----------|------------|----------------------|
338
+ | key | Yes | Yes |
339
+ | type | Yes | Yes |
340
+ | label | Yes | Yes |
341
+ | path | Yes | Yes |
342
+ | is_container | Yes | No |
343
+ | children_count | For containers | No |
344
+ | required | When present | Yes (in validate) |
345
+ | validate | No | Yes |
346
+ | registrations | No | Yes |
347
+ | determinant_ids | No | Yes (in raw) |
348
+ | data | No | Yes |
349
+ | default_value | No | Yes |
350
+ | raw | No | Yes (complete object) |
351
+
352
+ ### Container Types
353
+
354
+ Form.io uses containers to organize components. Each has different child accessors:
355
+
356
+ ```
357
+ Container Type Children Accessor
358
+ -------------- -----------------
359
+ tabs components[] (tab panes)
360
+ panel components[]
361
+ columns columns[].components[] (2-level)
362
+ fieldset components[]
363
+ editgrid components[] (repeatable)
364
+ datagrid components[]
365
+ table rows[][] (HTML table)
366
+ well components[]
367
+ container components[]
368
+ ```
369
+
370
+ ### Usage Examples
371
+
372
+ **Get form overview:**
373
+ ```
374
+ form_get(service_id="abc-123", form_type="applicant")
375
+ # Returns: component_count, component_keys, simplified components list
376
+ ```
377
+
378
+ **Get specific component details:**
379
+ ```
380
+ form_component_get(service_id="abc-123", component_key="firstName")
381
+ # Returns: full component with validate, data, determinant_ids, raw object
382
+ ```
383
+
384
+ **Add component to form:**
385
+ ```
386
+ form_component_add(
387
+ service_id="abc-123",
388
+ component={"key": "email", "type": "email", "label": "Email Address"},
389
+ parent_key="personalInfo", # Optional: nest under panel
390
+ position=0 # Optional: insert at position
391
+ )
392
+ ```
393
+
394
+ **Update component:**
395
+ ```
396
+ form_component_update(
397
+ service_id="abc-123",
398
+ component_key="firstName",
399
+ updates={"validate": {"required": True}, "label": "First Name *"}
400
+ )
401
+ ```
402
+
403
+ **Move component:**
404
+ ```
405
+ form_component_move(
406
+ service_id="abc-123",
407
+ component_key="phoneNumber",
408
+ new_parent_key="contactPanel",
409
+ new_position=1
410
+ )
411
+ ```
412
+
413
+ All write operations include `audit_id` for rollback capability.
414
+
415
+ ## Determinant & Conditional Logic Tools
416
+
417
+ Create conditional logic that controls form behavior based on user input.
418
+
419
+ ### Determinant Types
420
+
421
+ | Type | Use Case | Example |
422
+ |------|----------|---------|
423
+ | `textdeterminant` | Text field conditions | Show panel if country = "USA" |
424
+ | `selectdeterminant` | Dropdown selection | Different fees by business type |
425
+ | `numericdeterminant` | Numeric comparisons | Require docs if amount > 10000 |
426
+ | `booleandeterminant` | Checkbox conditions | Show section if newsletter = true |
427
+ | `datedeterminant` | Date comparisons | Validate expiry > today |
428
+ | `classificationdeterminant` | Catalog selections | Requirements by industry code |
429
+ | `griddeterminant` | Grid/table row conditions | Validate line items |
430
+
431
+ ### Behaviour Effects
432
+
433
+ Apply determinants to components to control visibility and validation:
434
+
435
+ ```
436
+ effect_create(
437
+ service_id="abc-123",
438
+ determinant_id="det-456",
439
+ component_key="additionalDocs",
440
+ effect_type="visibility" # or "required", "disabled"
441
+ )
442
+ ```
443
+
444
+ Use `componentbehaviour_list` and `componentbehaviour_get` to inspect existing effects.
445
+
446
+ ## Example Session
447
+
448
+ ```
449
+ You: List all services
450
+
451
+ Claude: Found 12 services. [displays table with IDs, names, status]
452
+
453
+ You: Analyze the "Business Registration" service
454
+
455
+ Claude: [shows registrations, roles, determinants, documents, costs]
456
+ Found 3 potential issues: orphaned determinant, missing cost...
457
+
458
+ You: Create a copy called "Business Registration v2"
459
+
460
+ Claude: Created service with ID abc-123. Copied 2 registrations,
461
+ 4 roles, 8 determinants. Audit ID: xyz-789
462
+ ```
463
+
464
+ ## Authentication
465
+
466
+ The MCP server supports two authentication providers, auto-detected based on configuration:
467
+
468
+ ### Keycloak (Modern Systems)
469
+
470
+ Uses OIDC with Authorization Code + PKCE:
471
+
472
+ 1. Browser opens automatically on first connection
473
+ 2. Login with your Keycloak/BPA credentials
474
+ 3. Tokens managed automatically with refresh
475
+ 4. Your BPA permissions apply to all operations
476
+
477
+ **No client secret required** — Keycloak uses PKCE for secure public clients.
478
+
479
+ ### CAS (Legacy Systems)
480
+
481
+ Uses OAuth2 with Basic Auth (client credentials):
482
+
483
+ 1. Browser opens to CAS login page (`/cas/spa.html`)
484
+ 2. Login with your eRegistrations credentials
485
+ 3. Tokens exchanged using HTTP Basic Auth
486
+ 4. User roles fetched from PARTC service (if configured)
487
+
488
+ **Client secret required** — CAS doesn't support PKCE, so `CAS_CLIENT_SECRET` must be provided.
489
+
490
+ ### Provider Detection
491
+
492
+ The provider is automatically detected based on which environment variables are set:
493
+
494
+ | Configuration | Provider Used |
495
+ |---------------|---------------|
496
+ | `CAS_URL` set | CAS |
497
+ | `KEYCLOAK_URL` set (no `CAS_URL`) | Keycloak |
498
+
499
+ If both are set, CAS takes precedence.
500
+
501
+ ## Configuration
502
+
503
+ ### Common Variables
504
+
505
+ | Variable | Description | Required |
506
+ | ------------------ | --------------------------- | -------- |
507
+ | `BPA_INSTANCE_URL` | BPA server URL | Yes |
508
+ | `LOG_LEVEL` | DEBUG, INFO, WARNING, ERROR | No |
509
+
510
+ ### Keycloak Variables
511
+
512
+ | Variable | Description | Required |
513
+ | ------------------ | --------------------------- | -------- |
514
+ | `KEYCLOAK_URL` | Keycloak server URL | Yes |
515
+ | `KEYCLOAK_REALM` | Keycloak realm name | Yes |
516
+
517
+ ### CAS Variables
518
+
519
+ | Variable | Description | Required | Default |
520
+ | ------------------- | ------------------------------------ | -------- | ------- |
521
+ | `CAS_URL` | CAS OAuth2 server URL | Yes | — |
522
+ | `CAS_CLIENT_ID` | OAuth2 client ID | Yes | — |
523
+ | `CAS_CLIENT_SECRET` | OAuth2 client secret | Yes | — |
524
+ | `CAS_CALLBACK_PORT` | Local callback port for redirect URI | No | 8914 |
525
+ | `PARTC_URL` | PARTC service URL (for user roles) | No | — |
526
+
527
+ > **Note:** The callback port must match the redirect URI registered in CAS. Default is 8914 (`http://127.0.0.1:8914/callback`).
528
+
529
+ > **Note:** If `PARTC_URL` is configured, user roles are fetched from the PARTC service after authentication. This provides additional permissions not included in the CAS JWT token.
530
+
531
+ Logs: `~/.config/mcp-eregistrations-bpa/instances/{instance-slug}/server.log`
532
+
533
+ ## Development
534
+
535
+ ```bash
536
+ # Clone and install
537
+ git clone https://github.com/UNCTAD-eRegistrations/mcp-eregistrations-bpa.git
538
+ cd mcp-eregistrations-bpa
539
+ uv sync
540
+
541
+ # Run tests (1200+ tests)
542
+ uv run pytest
543
+
544
+ # Lint and format
545
+ uv run ruff check . && uv run ruff format .
546
+
547
+ # Type checking
548
+ uv run mypy src/
549
+ ```
550
+
551
+ ## Complete Tool Reference
552
+
553
+ ### Authentication (2 tools)
554
+
555
+ | Tool | Description |
556
+ |------|-------------|
557
+ | `auth_login` | Browser-based Keycloak OIDC login |
558
+ | `connection_status` | Check current authentication state |
559
+
560
+ ### Services (6 tools)
561
+
562
+ | Tool | Description |
563
+ |------|-------------|
564
+ | `service_list` | List all services with pagination |
565
+ | `service_get` | Get service details by ID |
566
+ | `service_create` | Create new service |
567
+ | `service_update` | Update service properties |
568
+ | `service_publish` | Publish service for frontend |
569
+ | `service_activate` | Activate/deactivate service |
570
+
571
+ ### Registrations (6 tools)
572
+
573
+ | Tool | Description |
574
+ |------|-------------|
575
+ | `registration_list` | List registrations with service filter |
576
+ | `registration_get` | Get registration details |
577
+ | `registration_create` | Create registration in service |
578
+ | `registration_delete` | Delete registration |
579
+ | `registration_activate` | Activate/deactivate registration |
580
+ | `serviceregistration_link` | Link registration to service |
581
+
582
+ ### Institutions (7 tools)
583
+
584
+ | Tool | Description |
585
+ |------|-------------|
586
+ | `registrationinstitution_list` | List institution assignments |
587
+ | `registrationinstitution_get` | Get assignment details |
588
+ | `registrationinstitution_create` | Assign institution to registration |
589
+ | `registrationinstitution_delete` | Remove institution assignment |
590
+ | `registrationinstitution_list_by_institution` | List registrations by institution |
591
+ | `institution_discover` | Discover institution IDs |
592
+ | `institution_create` | Create institution in Keycloak |
593
+
594
+ ### Fields (2 tools)
595
+
596
+ | Tool | Description |
597
+ |------|-------------|
598
+ | `field_list` | List fields for a service |
599
+ | `field_get` | Get field details |
600
+
601
+ ### Forms (7 tools)
602
+
603
+ | Tool | Description |
604
+ |------|-------------|
605
+ | `form_get` | Get form structure |
606
+ | `form_component_get` | Get component details |
607
+ | `form_component_add` | Add component to form |
608
+ | `form_component_update` | Update component properties |
609
+ | `form_component_remove` | Remove component |
610
+ | `form_component_move` | Move component |
611
+ | `form_update` | Replace entire form schema |
612
+
613
+ ### Determinants (12 tools)
614
+
615
+ | Tool | Description |
616
+ |------|-------------|
617
+ | `determinant_list` | List determinants for service |
618
+ | `determinant_get` | Get determinant details |
619
+ | `determinant_search` | Search determinants by criteria |
620
+ | `determinant_delete` | Delete determinant |
621
+ | `textdeterminant_create` | Create text comparison |
622
+ | `textdeterminant_update` | Update text determinant |
623
+ | `selectdeterminant_create` | Create dropdown selection |
624
+ | `numericdeterminant_create` | Create numeric comparison |
625
+ | `booleandeterminant_create` | Create checkbox condition |
626
+ | `datedeterminant_create` | Create date comparison |
627
+ | `classificationdeterminant_create` | Create catalog selection |
628
+ | `griddeterminant_create` | Create grid row condition |
629
+
630
+ ### Behaviours (5 tools)
631
+
632
+ | Tool | Description |
633
+ |------|-------------|
634
+ | `componentbehaviour_list` | List behaviours for service |
635
+ | `componentbehaviour_get` | Get behaviour by ID |
636
+ | `componentbehaviour_get_by_component` | Get behaviour for component |
637
+ | `effect_create` | Create visibility/validation effect |
638
+ | `effect_delete` | Delete behaviour/effect |
639
+
640
+ ### Actions (2 tools)
641
+
642
+ | Tool | Description |
643
+ |------|-------------|
644
+ | `componentaction_get` | Get component actions by ID |
645
+ | `componentaction_get_by_component` | Get actions for component |
646
+
647
+ ### Bots (5 tools)
648
+
649
+ | Tool | Description |
650
+ |------|-------------|
651
+ | `bot_list` | List bots for service |
652
+ | `bot_get` | Get bot details |
653
+ | `bot_create` | Create workflow bot |
654
+ | `bot_update` | Update bot properties |
655
+ | `bot_delete` | Delete bot |
656
+
657
+ ### Classifications (5 tools)
658
+
659
+ | Tool | Description |
660
+ |------|-------------|
661
+ | `classification_list` | List catalog classifications |
662
+ | `classification_get` | Get classification with entries |
663
+ | `classification_create` | Create classification catalog |
664
+ | `classification_update` | Update classification |
665
+ | `classification_export_csv` | Export as CSV |
666
+
667
+ ### Notifications (2 tools)
668
+
669
+ | Tool | Description |
670
+ |------|-------------|
671
+ | `notification_list` | List service notifications |
672
+ | `notification_create` | Create notification trigger |
673
+
674
+ ### Messages (5 tools)
675
+
676
+ | Tool | Description |
677
+ |------|-------------|
678
+ | `message_list` | List global message templates |
679
+ | `message_get` | Get message details |
680
+ | `message_create` | Create message template |
681
+ | `message_update` | Update message |
682
+ | `message_delete` | Delete message |
683
+
684
+ ### Roles (8 tools)
685
+
686
+ | Tool | Description |
687
+ |------|-------------|
688
+ | `role_list` | List roles for service |
689
+ | `role_get` | Get role with statuses |
690
+ | `role_create` | Create UserRole or BotRole |
691
+ | `role_update` | Update role properties |
692
+ | `role_delete` | Delete role |
693
+ | `roleinstitution_create` | Assign institution to role |
694
+ | `roleregistration_create` | Assign registration to role |
695
+
696
+ ### Role Status (4 tools)
697
+
698
+ | Tool | Description |
699
+ |------|-------------|
700
+ | `rolestatus_get` | Get status transition details |
701
+ | `rolestatus_create` | Create workflow transition |
702
+ | `rolestatus_update` | Update status |
703
+ | `rolestatus_delete` | Delete status |
704
+
705
+ ### Role Units (4 tools)
706
+
707
+ | Tool | Description |
708
+ |------|-------------|
709
+ | `roleunit_list` | List units for role |
710
+ | `roleunit_get` | Get unit assignment |
711
+ | `roleunit_create` | Assign unit to role |
712
+ | `roleunit_delete` | Remove unit assignment |
713
+
714
+ ### Documents (5 tools)
715
+
716
+ | Tool | Description |
717
+ |------|-------------|
718
+ | `requirement_list` | List global requirements |
719
+ | `documentrequirement_list` | List requirements for registration |
720
+ | `documentrequirement_create` | Link requirement to registration |
721
+ | `documentrequirement_update` | Update requirement |
722
+ | `documentrequirement_delete` | Remove requirement |
723
+
724
+ ### Costs (4 tools)
725
+
726
+ | Tool | Description |
727
+ |------|-------------|
728
+ | `cost_create_fixed` | Create fixed fee |
729
+ | `cost_create_formula` | Create formula-based cost |
730
+ | `cost_update` | Update cost |
731
+ | `cost_delete` | Delete cost |
732
+
733
+ ### Export (3 tools)
734
+
735
+ | Tool | Description |
736
+ |------|-------------|
737
+ | `service_export_raw` | Export service as JSON |
738
+ | `service_to_yaml` | Transform to AI-optimized YAML |
739
+ | `service_copy` | Clone service with new name |
740
+
741
+ ### Analysis (1 tool)
742
+
743
+ | Tool | Description |
744
+ |------|-------------|
745
+ | `analyze_service` | AI-optimized service analysis |
746
+
747
+ ### Audit (2 tools)
748
+
749
+ | Tool | Description |
750
+ |------|-------------|
751
+ | `audit_list` | List audit log entries |
752
+ | `audit_get` | Get audit entry details |
753
+
754
+ ### Rollback (3 tools)
755
+
756
+ | Tool | Description |
757
+ |------|-------------|
758
+ | `rollback` | Undo write operation |
759
+ | `rollback_history` | Get object state history |
760
+ | `rollback_cleanup` | Clean old rollback states |
761
+
762
+ ### Workflows (13 tools)
763
+
764
+ | Tool | Description |
765
+ |------|-------------|
766
+ | `workflow_list` | List available workflows |
767
+ | `workflow_describe` | Get workflow details |
768
+ | `workflow_search` | Search by intent |
769
+ | `workflow_execute` | Run workflow |
770
+ | `workflow_status` | Check execution status |
771
+ | `workflow_cancel` | Cancel running workflow |
772
+ | `workflow_retry` | Retry failed workflow |
773
+ | `workflow_rollback` | Undo completed workflow |
774
+ | `workflow_chain` | Execute workflow sequence |
775
+ | `workflow_start_interactive` | Begin guided mode |
776
+ | `workflow_continue` | Continue interactive session |
777
+ | `workflow_confirm` | Confirm and execute |
778
+ | `workflow_validate` | Validate workflow definitions |
779
+
780
+ ### Debugging (7 tools)
781
+
782
+ | Tool | Description |
783
+ |------|-------------|
784
+ | `debug_scan` | Scan for configuration issues |
785
+ | `debug_investigate` | Analyze issue root cause |
786
+ | `debug_fix` | Fix single issue |
787
+ | `debug_fix_batch` | Fix multiple issues |
788
+ | `debug_group_issues` | Group issues by criteria |
789
+ | `debug_plan` | Generate fix plan |
790
+ | `debug_verify` | Verify fixes applied |
791
+
792
+ ## Arazzo Workflow Reference (96 workflows)
793
+
794
+ ### Service Creation
795
+
796
+ | Workflow | Description |
797
+ |----------|-------------|
798
+ | `createMinimalService` | Create service with registration |
799
+ | `createCompleteService` | Full service with roles and costs |
800
+ | `createQuickService` | Minimal service setup |
801
+
802
+ ### Service Publishing
803
+
804
+ | Workflow | Description |
805
+ |----------|-------------|
806
+ | `fullPublish` | Complete publish workflow |
807
+ | `publishServiceChanges` | Publish pending changes |
808
+ | `activateService` | Activate service |
809
+ | `deactivateService` | Deactivate service |
810
+
811
+ ### Roles & Workflow
812
+
813
+ | Workflow | Description |
814
+ |----------|-------------|
815
+ | `addRole` | Add role to service |
816
+ | `updateRole` | Update role properties |
817
+ | `configureStandardWorkflow` | Setup standard approval flow |
818
+ | `createCustomStatus` | Create workflow status |
819
+ | `updateCustomStatus` | Update status |
820
+ | `deleteRoleStatus` | Remove status |
821
+ | `createUserDefinedStatusWithMessage` | Status with notification |
822
+ | `updateUserDefinedStatusMessage` | Update status message |
823
+ | `getRoleFull` | Get complete role details |
824
+ | `getRoleStatus` | Get status details |
825
+ | `getRoleBots` | Get role bots |
826
+ | `getRoleUnits` | Get role units |
827
+ | `getRoleInstitutions` | Get role institutions |
828
+ | `getRoleHistory` | Get role version history |
829
+ | `listRolesWithDetails` | List all roles with details |
830
+ | `addUnitToRole` | Assign unit to role |
831
+ | `assignRoleInstitution` | Assign institution |
832
+ | `assignRegistrationToRole` | Assign single registration |
833
+ | `assignRegistrationsToRole` | Assign multiple registrations |
834
+ | `revertRoleVersion` | Rollback role version |
835
+
836
+ ### Forms
837
+
838
+ | Workflow | Description |
839
+ |----------|-------------|
840
+ | `getApplicantForm` | Get applicant form |
841
+ | `getGuideForm` | Get guide form |
842
+ | `getDocumentForm` | Get document form |
843
+ | `updateApplicantForm` | Update applicant form |
844
+ | `updateGuideForm` | Update guide form |
845
+ | `toggleApplicantForm` | Enable/disable form |
846
+ | `deleteComponent` | Remove form component |
847
+ | `getField` | Get field details |
848
+ | `listFields` | List all fields |
849
+ | `getComponentActions` | Get component actions |
850
+ | `getComponentValidation` | Get validation rules |
851
+ | `getComponentFormula` | Get calculation formula |
852
+ | `updateComponentActions` | Update actions |
853
+ | `updateComponentValidation` | Update validation |
854
+ | `updateComponentFormula` | Update formula |
855
+ | `getFormHistory` | Get form version history |
856
+ | `revertFormVersion` | Rollback form version |
857
+ | `linkFieldToDeterminant` | Link field to condition |
858
+
859
+ ### Determinants
860
+
861
+ | Workflow | Description |
862
+ |----------|-------------|
863
+ | `addTextDeterminant` | Create text condition |
864
+ | `addSelectDeterminant` | Create dropdown condition |
865
+ | `addRadioDeterminant` | Create radio condition |
866
+ | `addNumericDeterminant` | Create numeric condition |
867
+ | `addClassificationDeterminant` | Create catalog condition |
868
+ | `addGridDeterminant` | Create grid row condition |
869
+ | `updateTextDeterminant` | Update text determinant |
870
+
871
+ ### Classifications
872
+
873
+ | Workflow | Description |
874
+ |----------|-------------|
875
+ | `listClassifications` | List all classifications |
876
+ | `searchClassifications` | Search classifications |
877
+ | `getClassificationType` | Get classification type |
878
+ | `createClassificationType` | Create classification type |
879
+ | `updateClassificationType` | Update type |
880
+ | `deleteClassificationType` | Delete type |
881
+ | `createClassificationGroup` | Create group |
882
+ | `deleteClassificationGroup` | Delete group |
883
+ | `listClassificationGroups` | List groups |
884
+ | `addClassificationField` | Add field to classification |
885
+ | `addClassificationFields` | Add multiple fields |
886
+ | `updateClassificationField` | Update field |
887
+ | `deleteClassificationField` | Delete field |
888
+ | `listClassificationFields` | List fields |
889
+ | `generateClassificationKeys` | Generate unique keys |
890
+ | `addSubcatalogs` | Add subcatalogs |
891
+ | `copyClassification` | Copy classification |
892
+ | `getServiceClassifications` | Get service classifications |
893
+
894
+ ### Institutions
895
+
896
+ | Workflow | Description |
897
+ |----------|-------------|
898
+ | `completeInstitutionSetup` | Full institution setup |
899
+ | `assignRegistrationInstitution` | Assign to registration |
900
+ | `getRegistrationInstitution` | Get assignment |
901
+ | `removeRegistrationInstitution` | Remove assignment |
902
+ | `listRegistrationsByInstitution` | List by institution |
903
+
904
+ ### Payments & Costs
905
+
906
+ | Workflow | Description |
907
+ |----------|-------------|
908
+ | `addFixedCost` | Add fixed fee |
909
+ | `addFormulaCost` | Add formula cost |
910
+ | `configureCompletePayments` | Full payment setup |
911
+ | `configureTieredPricing` | Tiered pricing rules |
912
+
913
+ ### Documents
914
+
915
+ | Workflow | Description |
916
+ |----------|-------------|
917
+ | `addDocumentRequirement` | Add required document |
918
+
919
+ ### Bots
920
+
921
+ | Workflow | Description |
922
+ |----------|-------------|
923
+ | `addBot` | Add automation bot |
924
+ | `updateBot` | Update bot |
925
+
926
+ ### Notifications & Messages
927
+
928
+ | Workflow | Description |
929
+ |----------|-------------|
930
+ | `createServiceNotification` | Create notification |
931
+ | `updateNotification` | Update notification |
932
+ | `getNotification` | Get notification details |
933
+ | `listServiceNotifications` | List notifications |
934
+ | `sortServiceNotifications` | Reorder notifications |
935
+ | `createMessage` | Create message template |
936
+ | `getMessage` | Get message |
937
+ | `updateMessage` | Update message |
938
+ | `deleteMessage` | Delete message |
939
+ | `listMessages` | List messages |
940
+ | `updateFileStatus` | Update file status message |
941
+ | `updateFileValidatedStatusMessage` | Update validated message |
942
+ | `updateFileDeclineStatusMessage` | Update decline message |
943
+ | `updateFilePendingStatusMessage` | Update pending message |
944
+ | `updateFileRejectStatusMessage` | Update reject message |
945
+
946
+ ### Debugging
947
+
948
+ | Workflow | Description |
949
+ |----------|-------------|
950
+ | `scanService` | Scan for issues |
951
+ | `planFixes` | Generate fix plan |
952
+ | `verifyFixes` | Verify fixes applied |
953
+
954
+ ## License
955
+
956
+ Copyright (c) 2025-2026
957
+ UN for Trade & Development (UNCTAD)
958
+ Division on Investment and Enterprise (DIAE)
959
+ Business Facilitation Section
960
+
961
+ All rights reserved. See [LICENSE](LICENSE).
962
+
963
+ ---
964
+
965
+ Part of [eRegistrations](https://businessfacilitation.org)