rossum-mcp 0.3.4__tar.gz

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.
@@ -0,0 +1,1537 @@
1
+ Metadata-Version: 2.4
2
+ Name: rossum-mcp
3
+ Version: 0.3.4
4
+ Summary: MCP server for AI-powered Rossum orchestration: document workflows, debug pipelines automatically, and configure intelligent document processing through natural language.
5
+ Author-email: "Dan Stancl (Rossum AI)" <daniel.stancl@gmail.com>
6
+ License: MIT
7
+ Keywords: mcp,rossum,document-processing
8
+ Requires-Python: >=3.12
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: fastmcp>2.0.0
11
+ Requires-Dist: pydantic>2.0.0
12
+ Requires-Dist: rossum-api>=3.7.0
13
+ Provides-Extra: docs
14
+ Requires-Dist: myst-parser>=2.0.0; extra == "docs"
15
+ Requires-Dist: sphinx>=7.0.0; extra == "docs"
16
+ Requires-Dist: sphinx-autodoc-typehints>=1.25.0; extra == "docs"
17
+ Requires-Dist: sphinx-copybutton>=0.5.2; extra == "docs"
18
+ Requires-Dist: sphinx-rtd-theme>=2.0.0; extra == "docs"
19
+ Provides-Extra: tests
20
+ Requires-Dist: coverage>=7.0.0; extra == "tests"
21
+ Requires-Dist: pytest>=7.0.0; extra == "tests"
22
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "tests"
23
+ Requires-Dist: pytest-cov>=4.0.0; extra == "tests"
24
+ Requires-Dist: redis>=7.0.0; extra == "tests"
25
+ Provides-Extra: all
26
+ Requires-Dist: coverage>=7.0.0; extra == "all"
27
+ Requires-Dist: fastmcp>=1.0.0; extra == "all"
28
+ Requires-Dist: myst-parser>=2.0.0; extra == "all"
29
+ Requires-Dist: pydantic>2.0.0; extra == "all"
30
+ Requires-Dist: pytest>=7.0.0; extra == "all"
31
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "all"
32
+ Requires-Dist: redis>=7.0.0; extra == "all"
33
+ Requires-Dist: rossum-api>=3.7.0; extra == "all"
34
+ Requires-Dist: sphinx>=7.0.0; extra == "all"
35
+ Requires-Dist: sphinx-autodoc-typehints>=1.25.0; extra == "all"
36
+ Requires-Dist: sphinx-copybutton>=0.5.2; extra == "all"
37
+ Requires-Dist: sphinx-rtd-theme>=2.0.0; extra == "all"
38
+
39
+ # Rossum MCP Server
40
+
41
+ <div align="center">
42
+
43
+ [![Documentation](https://img.shields.io/badge/docs-latest-blue.svg)](https://stancld.github.io/rossum-mcp/)
44
+ [![Python](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
45
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
46
+ [![MCP](https://img.shields.io/badge/MCP-compatible-green.svg)](https://modelcontextprotocol.io/)
47
+ [![MCP Tools](https://img.shields.io/badge/MCP_Tools-39-blue.svg)](#available-tools)
48
+ [![Rossum API](https://img.shields.io/badge/Rossum-API-orange.svg)](https://github.com/rossumai/rossum-api)
49
+
50
+ </div>
51
+
52
+ A Model Context Protocol (MCP) server that provides tools for uploading documents and retrieving annotations using the Rossum API. Built with Python and the official [rossum-api](https://github.com/rossumai/rossum-api).
53
+
54
+ ## Features
55
+
56
+ ### Document Processing
57
+ - **upload_document**: Upload a document to Rossum for processing
58
+ - **get_annotation**: Retrieve annotation data for a previously uploaded document
59
+ - **list_annotations**: List all annotations for a queue with optional filtering
60
+ - **start_annotation**: Start annotation to move it to 'reviewing' status
61
+ - **bulk_update_annotation_fields**: Bulk update annotation field values using JSON Patch operations
62
+ - **confirm_annotation**: Confirm annotation to move it to 'confirmed' status
63
+
64
+ ### Queue & Schema Management
65
+ - **get_queue**: Retrieve queue details including schema_id
66
+ - **get_schema**: Retrieve schema details and content
67
+ - **get_queue_schema**: Retrieve complete schema for a queue in a single call
68
+ - **get_queue_engine**: Retrieve engine information for a queue
69
+ - **create_queue**: Create a new queue with schema and optional engine assignment
70
+ - **create_schema**: Create a new schema with sections and datapoints
71
+ - **update_queue**: Update queue settings including automation thresholds
72
+ - **update_schema**: Update schema with field-level automation thresholds
73
+ - **patch_schema**: Add, update, or remove individual schema nodes without replacing entire content
74
+
75
+ ### Workspace Management
76
+ - **get_workspace**: Retrieve workspace details by ID
77
+ - **list_workspaces**: List all workspaces with optional filtering
78
+ - **create_workspace**: Create a new workspace
79
+
80
+ ### User Management
81
+ - **get_user**: Retrieve user details by ID
82
+ - **list_users**: List users with optional filtering by username, email, etc.
83
+ - **list_user_roles**: List all user roles (permission groups) in the organization
84
+
85
+ ### Engine Management
86
+ - **get_engine**: Retrieve engine details by ID
87
+ - **list_engines**: List all engines with optional filters
88
+ - **create_engine**: Create a new engine (extractor or splitter)
89
+ - **update_engine**: Update engine settings including learning and training queues
90
+ - **create_engine_field**: Create engine fields and link them to schemas
91
+ - **get_engine_fields**: Retrieve engine fields for a specific engine or all engine fields
92
+
93
+ ### Extensions & Rules
94
+ - **get_hook**: Get hook/extension details
95
+ - **list_hooks**: List webhooks and serverless functions (extensions)
96
+ - **create_hook**: Create webhooks or serverless function hooks for custom logic
97
+ - **update_hook**: Update existing hook properties (name, queues, config, events, settings)
98
+ - **list_hook_templates**: List available hook templates from Rossum Store
99
+ - **create_hook_from_template**: Create a hook from a Rossum Store template
100
+ - **list_hook_logs**: List hook execution logs for debugging and monitoring
101
+ - **get_rule**: Get business rule details
102
+ - **list_rules**: List business rules with trigger conditions and actions
103
+
104
+ ### Relations Management
105
+ - **get_relation**: Retrieve relation details by ID
106
+ - **list_relations**: List all relations between annotations (edit, attachment, duplicate)
107
+ - **get_document_relation**: Retrieve document relation details by ID
108
+ - **list_document_relations**: List all document relations (export, einvoice)
109
+
110
+ ## Prerequisites
111
+
112
+ - Python 3.12 or higher
113
+ - Rossum account with API credentials
114
+ - A Rossum queue ID
115
+
116
+ ## Installation
117
+
118
+ ### Docker (Recommended)
119
+
120
+ ```bash
121
+ git clone https://github.com/stancld/rossum-mcp.git
122
+ cd rossum-mcp
123
+
124
+ # Set up environment variables
125
+ export ROSSUM_API_TOKEN="your-api-token"
126
+ export ROSSUM_API_BASE_URL="https://api.elis.rossum.ai/v1"
127
+ export ROSSUM_MCP_MODE="read-write" # Optional: "read-only" or "read-write" (default)
128
+
129
+ # Run the MCP server
130
+ docker-compose up rossum-agent
131
+ ```
132
+
133
+ <details>
134
+ <summary>Install from source (alternative)</summary>
135
+
136
+ ```bash
137
+ git clone https://github.com/stancld/rossum-mcp.git
138
+ cd rossum-mcp/rossum-mcp
139
+ uv sync
140
+ ```
141
+
142
+ Install with extras:
143
+ ```bash
144
+ uv sync --extra all # All extras (docs, tests)
145
+ uv sync --extra docs # Documentation only
146
+ uv sync --extra tests # Testing only
147
+ ```
148
+
149
+ </details>
150
+
151
+ ### Environment Variables
152
+
153
+ - **ROSSUM_API_TOKEN** (required): Your Rossum API authentication token
154
+ - **ROSSUM_API_BASE_URL** (required): Base URL for the Rossum API
155
+ - **ROSSUM_MCP_MODE** (optional): Controls which tools are available
156
+ - `read-write` (default): All tools available (GET, LIST, CREATE, UPDATE operations)
157
+ - `read-only`: Only read operations available (GET and LIST operations only)
158
+
159
+ #### Read-Only vs Read-Write Mode
160
+
161
+ When `ROSSUM_MCP_MODE` is set to `read-only`, only read operations are available:
162
+ - **Annotations:** `get_annotation`, `list_annotations`
163
+ - **Queues:** `get_queue`, `get_queue_schema`, `get_queue_engine`
164
+ - **Schemas:** `get_schema`
165
+ - **Engines:** `get_engine`, `list_engines`, `get_engine_fields`
166
+ - **Hooks:** `get_hook`, `list_hooks`, `list_hook_templates`, `list_hook_logs`
167
+ - **Users:** `get_user`, `list_users`, `list_user_roles`
168
+ - **Rules:** `get_rule`, `list_rules`
169
+ - **Relations:** `get_relation`, `list_relations`
170
+ - **Document Relations:** `get_document_relation`, `list_document_relations`
171
+ - **Workspaces:** `get_workspace`, `list_workspaces`
172
+
173
+ All CREATE, UPDATE, and UPLOAD operations are disabled in read-only mode for security purposes.
174
+
175
+ ## Usage
176
+
177
+ <details>
178
+ <summary>Running the MCP Server</summary>
179
+
180
+ Start the server using:
181
+ ```bash
182
+ python server.py
183
+ ```
184
+
185
+ Or using the installed script:
186
+ ```bash
187
+ rossum-mcp
188
+ ```
189
+
190
+ </details>
191
+
192
+ <details>
193
+ <summary>Claude Desktop Configuration</summary>
194
+
195
+ Configure your MCP client to use this server. In Claude Desktop's config:
196
+
197
+ **Read-write mode:**
198
+ ```json
199
+ {
200
+ "mcpServers": {
201
+ "rossum": {
202
+ "command": "python",
203
+ "args": ["/path/to/rossum-mcp/rossum-mcp/rossum_mcp/server.py"],
204
+ "env": {
205
+ "ROSSUM_API_TOKEN": "your-api-token",
206
+ "ROSSUM_API_BASE_URL": "https://api.elis.rossum.ai/v1",
207
+ "ROSSUM_MCP_MODE": "read-write"
208
+ }
209
+ }
210
+ }
211
+ }
212
+ ```
213
+
214
+ **Read-only mode:**
215
+ ```json
216
+ {
217
+ "mcpServers": {
218
+ "rossum-readonly": {
219
+ "command": "python",
220
+ "args": ["/path/to/rossum-mcp/rossum-mcp/rossum_mcp/server.py"],
221
+ "env": {
222
+ "ROSSUM_API_TOKEN": "your-api-token",
223
+ "ROSSUM_API_BASE_URL": "https://api.elis.rossum.ai/v1",
224
+ "ROSSUM_MCP_MODE": "read-only"
225
+ }
226
+ }
227
+ }
228
+ }
229
+ ```
230
+
231
+ </details>
232
+
233
+ ## Available Tools
234
+
235
+ ### Document Processing
236
+
237
+ #### upload_document
238
+
239
+ Uploads a document to Rossum for processing. Returns a task ID. Use `list_annotations` to get the annotation ID.
240
+
241
+ **Parameters:**
242
+ - `file_path` (string, required): Absolute path to the document file
243
+ - `queue_id` (integer, required): Rossum queue ID where the document should be uploaded
244
+
245
+ **Returns:**
246
+ ```json
247
+ {
248
+ "task_id": "12345",
249
+ "task_status": "created",
250
+ "queue_id": 12345,
251
+ "message": "Document upload initiated. Use `list_annotations` to find the annotation ID for this queue."
252
+ }
253
+ ```
254
+
255
+ #### get_annotation
256
+
257
+ Retrieves annotation data for a previously uploaded document. Use this to check the status of a document.
258
+
259
+ **Parameters:**
260
+ - `annotation_id` (integer, required): The annotation ID obtained from list_annotations
261
+ - `sideloads` (array, optional): List of sideloads to include. Use `['content']` to fetch annotation content with datapoints
262
+
263
+ **Returns:**
264
+ ```json
265
+ {
266
+ "id": "12345",
267
+ "status": "to_review",
268
+ "url": "https://elis.rossum.ai/api/v1/annotations/12345",
269
+ "schema": "67890",
270
+ "modifier": "11111",
271
+ "document": "22222",
272
+ "content": [...],
273
+ "created_at": "2024-01-01T00:00:00Z",
274
+ "modified_at": "2024-01-01T00:00:00Z"
275
+ }
276
+ ```
277
+
278
+ #### list_annotations
279
+
280
+ Lists all annotations for a queue with optional filtering. Useful for checking the status of multiple uploaded documents.
281
+
282
+ **Parameters:**
283
+ - `queue_id` (integer, required): Rossum queue ID to list annotations from
284
+ - `status` (string, optional): Filter by annotation status (default: 'importing,to_review,confirmed,exported')
285
+
286
+ **Returns:**
287
+ ```json
288
+ {
289
+ "count": 42,
290
+ "results": [
291
+ {
292
+ "id": "12345",
293
+ "status": "to_review",
294
+ "url": "https://elis.rossum.ai/api/v1/annotations/12345",
295
+ "document": "67890",
296
+ "created_at": "2024-01-01T00:00:00Z",
297
+ "modified_at": "2024-01-01T00:00:00Z"
298
+ }
299
+ ]
300
+ }
301
+ ```
302
+
303
+ #### start_annotation
304
+
305
+ Starts an annotation to move it from 'importing' to 'reviewing' status. This is required before you can update annotation fields.
306
+
307
+ **Parameters:**
308
+ - `annotation_id` (integer, required): Rossum annotation ID to start
309
+
310
+ **Returns:**
311
+ ```json
312
+ {
313
+ "annotation_id": 12345,
314
+ "message": "Annotation 12345 started successfully. Status changed to 'reviewing'."
315
+ }
316
+ ```
317
+
318
+ #### bulk_update_annotation_fields
319
+
320
+ Bulk update annotation field values using JSON Patch operations. This is the correct way to update annotation field values. Must be called after `start_annotation`.
321
+
322
+ **Parameters:**
323
+ - `annotation_id` (integer, required): Rossum annotation ID to update
324
+ - `operations` (array, required): List of JSON Patch operations with format:
325
+ ```json
326
+ [
327
+ {
328
+ "op": "replace",
329
+ "id": 1234,
330
+ "value": {
331
+ "content": {
332
+ "value": "new_value",
333
+ "page": 1,
334
+ "position": [x, y, w, h]
335
+ }
336
+ }
337
+ }
338
+ ]
339
+ ```
340
+
341
+ **Important:** Use the numeric datapoint `id` from `annotation.content`, NOT the `schema_id`.
342
+
343
+ **Returns:**
344
+ ```json
345
+ {
346
+ "annotation_id": 12345,
347
+ "operations_count": 1,
348
+ "message": "Annotation 12345 updated with 1 operations successfully."
349
+ }
350
+ ```
351
+
352
+ #### confirm_annotation
353
+
354
+ Confirms an annotation to move it to 'confirmed' status. Can be called after `bulk_update_annotation_fields`.
355
+
356
+ **Parameters:**
357
+ - `annotation_id` (integer, required): Rossum annotation ID to confirm
358
+
359
+ **Returns:**
360
+ ```json
361
+ {
362
+ "annotation_id": 12345,
363
+ "message": "Annotation 12345 confirmed successfully. Status changed to 'confirmed'."
364
+ }
365
+ ```
366
+
367
+ ### Queue & Schema Management
368
+
369
+ #### get_queue
370
+
371
+ Retrieves queue details including the schema_id.
372
+
373
+ **Parameters:**
374
+ - `queue_id` (integer, required): Rossum queue ID to retrieve
375
+
376
+ #### get_schema
377
+
378
+ Retrieves schema details including the schema content/structure.
379
+
380
+ **Parameters:**
381
+ - `schema_id` (integer, required): Rossum schema ID to retrieve
382
+
383
+ #### get_queue_schema
384
+
385
+ Retrieves the complete schema for a queue in a single call. This is the recommended way to get a queue's schema.
386
+
387
+ **Parameters:**
388
+ - `queue_id` (integer, required): Rossum queue ID
389
+
390
+ #### get_queue_engine
391
+
392
+ Retrieves the complete engine information for a given queue in a single call.
393
+
394
+ **Parameters:**
395
+ - `queue_id` (integer, required): Rossum queue ID
396
+
397
+ #### create_queue
398
+
399
+ Creates a new queue with schema and optional engine assignment.
400
+
401
+ **Parameters:**
402
+ - `name` (string, required): Name of the queue to create
403
+ - `workspace_id` (integer, required): Workspace ID where the queue should be created
404
+ - `schema_id` (integer, required): Schema ID to assign to the queue
405
+ - `engine_id` (integer, optional): Optional engine ID to assign for document processing
406
+ - Additional optional parameters for automation, locale, training, etc.
407
+
408
+ #### update_queue
409
+
410
+ Updates an existing queue's settings including automation thresholds.
411
+
412
+ **Parameters:**
413
+ - `queue_id` (integer, required): Queue ID to update
414
+ - `queue_data` (object, required): Dictionary containing queue fields to update
415
+
416
+ #### create_schema
417
+
418
+ Creates a new schema with sections and datapoints.
419
+
420
+ **Parameters:**
421
+ - `name` (string, required): Schema name
422
+ - `content` (array, required): Schema content array containing sections with datapoints. Must follow Rossum schema structure with sections containing children.
423
+
424
+ **Example content structure:**
425
+ ```json
426
+ [
427
+ {
428
+ "category": "section",
429
+ "id": "document_info",
430
+ "label": "Document Information",
431
+ "children": [
432
+ {
433
+ "category": "datapoint",
434
+ "id": "document_type",
435
+ "label": "Document Type",
436
+ "type": "enum",
437
+ "rir_field_names": [],
438
+ "constraints": {"required": false},
439
+ "options": [
440
+ {"value": "invoice", "label": "Invoice"},
441
+ {"value": "receipt", "label": "Receipt"}
442
+ ]
443
+ }
444
+ ]
445
+ }
446
+ ]
447
+ ```
448
+
449
+ **Returns:**
450
+ ```json
451
+ {
452
+ "id": 12345,
453
+ "name": "My Schema",
454
+ "url": "https://elis.rossum.ai/api/v1/schemas/12345",
455
+ "content": [...],
456
+ "message": "Schema 'My Schema' created successfully with ID 12345"
457
+ }
458
+ ```
459
+
460
+ #### update_schema
461
+
462
+ Updates an existing schema, typically used to set field-level automation thresholds.
463
+
464
+ **Parameters:**
465
+ - `schema_id` (integer, required): Schema ID to update
466
+ - `schema_data` (object, required): Dictionary containing schema fields to update
467
+
468
+ #### patch_schema
469
+
470
+ Patch a schema by adding, updating, or removing individual nodes without replacing the entire content. This is particularly useful for making incremental changes to schemas.
471
+
472
+ **Parameters:**
473
+ - `schema_id` (integer, required): Schema ID to patch
474
+ - `operation` (string, required): One of "add", "update", or "remove"
475
+ - `node_id` (string, required): ID of the node to operate on
476
+ - `node_data` (object, optional): Data for add/update operations. Required for "add" and "update"
477
+ - `parent_id` (string, optional): Parent node ID for add operation. Required for "add"
478
+ - `position` (integer, optional): Position for add operation (appends if not specified)
479
+
480
+ **Operations:**
481
+ - **add**: Add a new datapoint/multivalue to a parent (section or tuple). Requires `parent_id` and `node_data`.
482
+ - **update**: Update properties of an existing node. Requires `node_data` with fields to update.
483
+ - **remove**: Remove a node from the schema. Only `node_id` is required.
484
+
485
+ **Returns:**
486
+ ```json
487
+ {
488
+ "id": 123,
489
+ "name": "Invoice Schema",
490
+ "content": [
491
+ {
492
+ "id": "header_section",
493
+ "label": "Header",
494
+ "category": "section",
495
+ "children": [
496
+ {"id": "invoice_number", "label": "Invoice Number", "category": "datapoint"},
497
+ {"id": "vendor_name", "label": "Vendor Name", "category": "datapoint"}
498
+ ]
499
+ }
500
+ ]
501
+ }
502
+ ```
503
+
504
+ **Example usage:**
505
+ ```python
506
+ # Add a new datapoint to a section
507
+ patch_schema(
508
+ schema_id=123,
509
+ operation="add",
510
+ node_id="vendor_name",
511
+ parent_id="header_section",
512
+ node_data={"label": "Vendor Name", "type": "string", "category": "datapoint"}
513
+ )
514
+
515
+ # Update a field's label and threshold
516
+ patch_schema(
517
+ schema_id=123,
518
+ operation="update",
519
+ node_id="invoice_number",
520
+ node_data={"label": "Invoice #", "score_threshold": 0.9}
521
+ )
522
+
523
+ # Remove a field
524
+ patch_schema(
525
+ schema_id=123,
526
+ operation="remove",
527
+ node_id="old_field"
528
+ )
529
+ ```
530
+
531
+ ### Engine Management
532
+
533
+ #### get_engine
534
+
535
+ Retrieves detailed information about a specific engine by its ID.
536
+
537
+ **Parameters:**
538
+ - `engine_id` (integer, required): Engine ID to retrieve
539
+
540
+ **Returns:**
541
+ ```json
542
+ {
543
+ "id": 12345,
544
+ "name": "Invoice Extractor",
545
+ "url": "https://elis.rossum.ai/api/v1/engines/12345",
546
+ "type": "extractor",
547
+ "learning_enabled": true,
548
+ "training_queues": ["https://elis.rossum.ai/api/v1/queues/100", "https://elis.rossum.ai/api/v1/queues/200"],
549
+ "description": "Extracts invoice data",
550
+ "agenda_id": "agenda-123",
551
+ "organization": "https://elis.rossum.ai/api/v1/organizations/10",
552
+ "message": "Engine 'Invoice Extractor' (ID 12345) retrieved successfully"
553
+ }
554
+ ```
555
+
556
+ **Example usage:**
557
+ ```python
558
+ # Get engine details
559
+ engine = get_engine(engine_id=12345)
560
+ ```
561
+
562
+ #### list_engines
563
+
564
+ Lists all engines with optional filtering.
565
+
566
+ **Parameters:**
567
+ - `id` (integer, optional): Filter by engine ID
568
+ - `engine_type` (string, optional): Filter by engine type ('extractor' or 'splitter')
569
+ - `agenda_id` (string, optional): Filter by agenda ID
570
+
571
+ **Returns:**
572
+ ```json
573
+ {
574
+ "count": 2,
575
+ "results": [
576
+ {
577
+ "id": 12345,
578
+ "name": "My Engine",
579
+ "url": "https://elis.rossum.ai/api/v1/engines/12345",
580
+ "type": "extractor",
581
+ "learning_enabled": true,
582
+ "training_queues": ["https://elis.rossum.ai/api/v1/queues/100"],
583
+ "description": "Engine description",
584
+ "agenda_id": "abc123",
585
+ "organization": "https://elis.rossum.ai/api/v1/organizations/123"
586
+ }
587
+ ],
588
+ "message": "Retrieved 2 engine(s)"
589
+ }
590
+ ```
591
+
592
+ **Example usage:**
593
+ ```python
594
+ # List all engines
595
+ all_engines = list_engines()
596
+
597
+ # List specific engine by ID
598
+ engine = list_engines(id=12345)
599
+
600
+ # List extractors only
601
+ extractors = list_engines(engine_type="extractor")
602
+
603
+ # List engines by agenda
604
+ agenda_engines = list_engines(agenda_id="abc123")
605
+ ```
606
+
607
+ #### create_engine
608
+
609
+ Creates a new engine for document processing.
610
+
611
+ **Parameters:**
612
+ - `name` (string, required): Engine name
613
+ - `organization_id` (integer, required): Organization ID where the engine should be created
614
+ - `engine_type` (string, required): Engine type - either 'extractor' or 'splitter'
615
+
616
+ **Returns:**
617
+ ```json
618
+ {
619
+ "id": 12345,
620
+ "name": "My Engine",
621
+ "url": "https://elis.rossum.ai/api/v1/engines/12345",
622
+ "type": "extractor",
623
+ "organization": "https://elis.rossum.ai/api/v1/organizations/123",
624
+ "message": "Engine 'My Engine' created successfully with ID 12345"
625
+ }
626
+ ```
627
+
628
+ #### update_engine
629
+
630
+ Updates an existing engine's settings including learning and training queues.
631
+
632
+ **Parameters:**
633
+ - `engine_id` (integer, required): Engine ID to update
634
+ - `engine_data` (object, required): Dictionary containing engine fields to update
635
+ - `name` (string): Engine name
636
+ - `description` (string): Engine description
637
+ - `learning_enabled` (boolean): Enable/disable learning
638
+ - `training_queues` (array): List of queue URLs for training
639
+
640
+ **Example:**
641
+ ```json
642
+ {
643
+ "learning_enabled": true,
644
+ "training_queues": [
645
+ "https://elis.rossum.ai/api/v1/queues/12345",
646
+ "https://elis.rossum.ai/api/v1/queues/67890"
647
+ ]
648
+ }
649
+ ```
650
+
651
+ **Returns:**
652
+ ```json
653
+ {
654
+ "id": 12345,
655
+ "name": "My Engine",
656
+ "url": "https://elis.rossum.ai/api/v1/engines/12345",
657
+ "type": "extractor",
658
+ "learning_enabled": true,
659
+ "training_queues": [...],
660
+ "description": "Engine description",
661
+ "message": "Engine 'My Engine' (ID 12345) updated successfully"
662
+ }
663
+ ```
664
+
665
+ #### get_hook
666
+
667
+ Retrieves details of a specific hook/extension by its ID.
668
+
669
+ **Parameters:**
670
+ - `hook_id` (integer, required): Hook ID
671
+
672
+ **Returns:**
673
+ ```json
674
+ {
675
+ "id": 12345,
676
+ "name": "Validation Hook",
677
+ "url": "https://elis.rossum.ai/api/v1/hooks/12345",
678
+ "type": "webhook",
679
+ "active": true,
680
+ "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
681
+ "events": ["annotation_status", "annotation_content"],
682
+ "config": {
683
+ "url": "https://example.com/webhook",
684
+ "secret": "***"
685
+ },
686
+ "settings": {},
687
+ "extension_source": "rossum_store"
688
+ }
689
+ ```
690
+
691
+ **Example usage:**
692
+ ```python
693
+ # Get hook details
694
+ hook = get_hook(hook_id=12345)
695
+ ```
696
+
697
+ #### list_hooks
698
+
699
+ Lists all hooks/extensions configured in your organization. Hooks (also called extensions) are webhooks or serverless functions that respond to Rossum events.
700
+
701
+ **Parameters:**
702
+ - `queue_id` (integer, optional): Filter hooks by queue ID
703
+ - `active` (boolean, optional): Filter by active status (true for active hooks, false for inactive)
704
+
705
+ **Returns:**
706
+ ```json
707
+ {
708
+ "count": 2,
709
+ "results": [
710
+ {
711
+ "id": 12345,
712
+ "name": "Validation Hook",
713
+ "url": "https://elis.rossum.ai/api/v1/hooks/12345",
714
+ "type": "webhook",
715
+ "active": true,
716
+ "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
717
+ "events": ["annotation_status", "annotation_content"],
718
+ "config": {
719
+ "url": "https://example.com/webhook",
720
+ "secret": "***"
721
+ },
722
+ "extension_source": "rossum_store"
723
+ }
724
+ ]
725
+ }
726
+ ```
727
+
728
+ **Example usage:**
729
+ ```python
730
+ # List all hooks
731
+ all_hooks = list_hooks()
732
+
733
+ # List hooks for a specific queue
734
+ queue_hooks = list_hooks(queue_id=12345)
735
+
736
+ # List only active hooks
737
+ active_hooks = list_hooks(active=True)
738
+
739
+ # List inactive hooks for a queue
740
+ inactive_queue_hooks = list_hooks(queue_id=12345, active=False)
741
+ ```
742
+
743
+ #### create_hook
744
+
745
+ Creates a new hook (webhook or serverless function). Hooks respond to Rossum events and can be used for custom validation, data enrichment, or integration with external systems.
746
+
747
+ **Parameters:**
748
+ - `name` (string, required): Hook name
749
+ - `type` (string, required): Hook type - either 'webhook' or 'function'
750
+ - `queues` (array, optional): List of queue URLs to attach the hook to. If not provided, hook applies to all queues
751
+ - Format: `["https://api.elis.rossum.ai/v1/queues/12345"]`
752
+ - `events` (array, optional): List of events that trigger the hook. Common events:
753
+ - `annotation_content.initialize` - When annotation is first created
754
+ - `annotation_content.confirm` - When annotation is confirmed
755
+ - `annotation_content.export` - When annotation is exported
756
+ - `annotation_status` - When annotation status changes
757
+ - `annotation_content` - When annotation content changes
758
+ - `datapoint_value` - When individual field value changes
759
+ - `config` (object, optional): Hook configuration
760
+ - For webhook: `{"url": "https://example.com/webhook"}`
761
+ - For function: `{"runtime": "python3.12", "function": "import json\ndef rossum_hook_request_handler(payload):\n return {}"}`
762
+ - `settings` (object, optional): Specific settings included in the payload when executing the hook
763
+ - `secret` (string, optional): Secret key for securing webhook requests
764
+
765
+ **Returns:**
766
+ ```json
767
+ {
768
+ "id": 12345,
769
+ "name": "My Hook",
770
+ "url": "https://elis.rossum.ai/api/v1/hooks/12345",
771
+ "enabled": true,
772
+ "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
773
+ "events": ["annotation_content.initialize"],
774
+ "config": {"runtime": "python3.12", "function": "..."},
775
+ "settings": {"custom_key": "custom_value"},
776
+ "message": "Hook 'My Hook' created successfully with ID 12345"
777
+ }
778
+ ```
779
+
780
+ **Example usage:**
781
+ ```python
782
+ # Create a serverless function hook
783
+ create_hook(
784
+ name="Splitting & Sorting",
785
+ type="function",
786
+ queues=["https://api.elis.rossum.ai/v1/queues/12345"],
787
+ events=["annotation_content.initialize", "annotation_content.confirm"],
788
+ config={"runtime": "python3.12", "function": "import json\ndef rossum_hook_request_handler(payload):\n return {}"},
789
+ settings={"sorting_queues": {"A": 1, "B": 2}}
790
+ )
791
+
792
+ # Create a webhook hook
793
+ create_hook(
794
+ name="External Validation",
795
+ type="webhook",
796
+ queues=["https://api.elis.rossum.ai/v1/queues/12345"],
797
+ events=["annotation_content.confirm"],
798
+ config={"url": "https://example.com/validate"},
799
+ secret="webhook_secret_123"
800
+ )
801
+ ```
802
+
803
+ #### update_hook
804
+
805
+ Updates an existing hook. Use this to modify hook properties like name, queues, config, events, or settings. Only provide the fields you want to change - other fields will remain unchanged.
806
+
807
+ **Parameters:**
808
+ - `hook_id` (integer, required): The ID of the hook to update
809
+ - `name` (string, optional): New hook name
810
+ - `queues` (array, optional): New list of queue URLs
811
+ - `events` (array, optional): New list of events that trigger the hook
812
+ - `config` (object, optional): New hook configuration
813
+ - `settings` (object, optional): New hook settings
814
+ - `active` (boolean, optional): Enable or disable the hook
815
+
816
+ **Returns:**
817
+ ```json
818
+ {
819
+ "id": 12345,
820
+ "name": "Updated Hook Name",
821
+ "url": "https://elis.rossum.ai/api/v1/hooks/12345",
822
+ "active": true,
823
+ "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
824
+ "events": ["annotation_content.initialize", "annotation_content.confirm"],
825
+ "config": {"runtime": "python3.12", "function": "..."},
826
+ "settings": {"updated_key": "updated_value"}
827
+ }
828
+ ```
829
+
830
+ **Example usage:**
831
+ ```python
832
+ # Update hook name and add a new event
833
+ update_hook(
834
+ hook_id=12345,
835
+ name="Renamed Hook",
836
+ events=["annotation_content.initialize", "annotation_content.confirm"]
837
+ )
838
+
839
+ # Disable a hook
840
+ update_hook(hook_id=12345, active=False)
841
+
842
+ # Update hook settings
843
+ update_hook(hook_id=12345, settings={"new_setting": "value"})
844
+ ```
845
+
846
+ #### list_hook_templates
847
+
848
+ Lists available hook templates from Rossum Store. Hook templates provide pre-built extension configurations (e.g., data validation, field mapping, notifications) that can be used to quickly create hooks instead of writing code from scratch.
849
+
850
+ **Parameters:**
851
+ None
852
+
853
+ **Returns:**
854
+ ```json
855
+ [
856
+ {
857
+ "id": 5,
858
+ "url": "https://elis.rossum.ai/api/v1/hook_templates/5",
859
+ "name": "Document Splitting",
860
+ "description": "Automatically split multi-page documents into separate annotations",
861
+ "type": "function",
862
+ "events": ["annotation_content.initialize"],
863
+ "config": {"runtime": "python3.12", "function": "..."},
864
+ "settings_schema": {"type": "object", "properties": {...}},
865
+ "guide": "https://knowledge-base.rossum.ai/docs/..."
866
+ }
867
+ ]
868
+ ```
869
+
870
+ **Example usage:**
871
+ ```python
872
+ # List all available hook templates
873
+ templates = list_hook_templates()
874
+
875
+ # Find a template by name
876
+ for template in templates:
877
+ if "splitting" in template.name.lower():
878
+ print(f"Found: {template.name} (ID: {template.id})")
879
+ ```
880
+
881
+ #### create_hook_from_template
882
+
883
+ Creates a hook from a Rossum Store template. Use `list_hook_templates` first to find available templates and their IDs. This is the recommended way to create hooks as it uses battle-tested configurations from the Rossum Store.
884
+
885
+ **Parameters:**
886
+ - `name` (string, required): Name for the new hook
887
+ - `hook_template_id` (integer, required): ID of the hook template to use (from `list_hook_templates`)
888
+ - `queues` (array, required): List of queue URLs to attach the hook to
889
+ - `events` (array, optional): List of events to trigger the hook (overrides template defaults if provided)
890
+ - `token_owner` (string, optional): User URL for token ownership. Required when the hook template has `use_token_owner=True`. Use `list_users` to find the user URL by username.
891
+
892
+ **Important:** If the hook template has `use_token_owner=True`, you must provide the `token_owner` parameter with a valid user URL. Ask the user for their username and use `list_users` to find the correct user URL.
893
+
894
+ **Returns:**
895
+ ```json
896
+ {
897
+ "id": 12345,
898
+ "name": "My Document Splitting Hook",
899
+ "url": "https://elis.rossum.ai/api/v1/hooks/12345",
900
+ "hook_template": "https://elis.rossum.ai/api/v1/hook_templates/5",
901
+ "type": "function",
902
+ "queues": ["https://elis.rossum.ai/api/v1/queues/100"],
903
+ "events": ["annotation_content.initialize"],
904
+ "config": {...},
905
+ "settings": {...}
906
+ }
907
+ ```
908
+
909
+ **Example usage:**
910
+ ```python
911
+ # Create a hook from template
912
+ create_hook_from_template(
913
+ name="Invoice Splitting",
914
+ hook_template_id=5,
915
+ queues=["https://api.elis.rossum.ai/v1/queues/12345"],
916
+ settings={"split_by": "barcode", "target_queue": 67890}
917
+ )
918
+
919
+ # Create a hook with token_owner (for templates with use_token_owner=True)
920
+ create_hook_from_template(
921
+ name="Data Export Hook",
922
+ hook_template_id=17,
923
+ queues=["https://api.elis.rossum.ai/v1/queues/12345"],
924
+ token_owner="https://api.elis.rossum.ai/v1/users/456"
925
+ )
926
+ ```
927
+
928
+ #### list_hook_logs
929
+
930
+ Lists hook execution logs for debugging, monitoring performance, and troubleshooting errors. Logs are retained for 7 days and at most 100 logs are returned per call.
931
+
932
+ **Parameters:**
933
+ - `hook_id` (integer, optional): Filter by hook ID
934
+ - `queue_id` (integer, optional): Filter by queue ID
935
+ - `annotation_id` (integer, optional): Filter by annotation ID
936
+ - `email_id` (integer, optional): Filter by email ID
937
+ - `log_level` (string, optional): Filter by log level - 'INFO', 'ERROR', or 'WARNING'
938
+ - `status` (string, optional): Filter by execution status
939
+ - `status_code` (integer, optional): Filter by HTTP status code
940
+ - `request_id` (string, optional): Filter by request ID
941
+ - `timestamp_before` (string, optional): ISO 8601 timestamp, filter logs triggered before this time
942
+ - `timestamp_after` (string, optional): ISO 8601 timestamp, filter logs triggered after this time
943
+ - `start_before` (string, optional): ISO 8601 timestamp, filter logs started before this time
944
+ - `start_after` (string, optional): ISO 8601 timestamp, filter logs started after this time
945
+ - `end_before` (string, optional): ISO 8601 timestamp, filter logs ended before this time
946
+ - `end_after` (string, optional): ISO 8601 timestamp, filter logs ended after this time
947
+ - `search` (string, optional): Full-text search across log messages
948
+ - `page_size` (integer, optional): Number of results per page (default 100, max 100)
949
+
950
+ **Returns:**
951
+ ```json
952
+ {
953
+ "count": 2,
954
+ "results": [
955
+ {
956
+ "log_level": "INFO",
957
+ "action": "initialize",
958
+ "event": "annotation_content",
959
+ "request_id": "abc123",
960
+ "organization_id": 100,
961
+ "hook_id": 12345,
962
+ "hook_type": "function",
963
+ "queue_id": 200,
964
+ "annotation_id": 300,
965
+ "message": "Hook executed successfully",
966
+ "start": "2024-01-01T00:00:00Z",
967
+ "end": "2024-01-01T00:00:01Z",
968
+ "status": "success",
969
+ "status_code": 200,
970
+ "timestamp": "2024-01-01T00:00:00Z",
971
+ "uuid": "uuid-here"
972
+ }
973
+ ]
974
+ }
975
+ ```
976
+
977
+ **Example usage:**
978
+ ```python
979
+ # List all logs for a specific hook
980
+ logs = list_hook_logs(hook_id=12345)
981
+
982
+ # List error logs only
983
+ error_logs = list_hook_logs(log_level="ERROR")
984
+
985
+ # List logs for a specific annotation
986
+ annotation_logs = list_hook_logs(annotation_id=300)
987
+
988
+ # Search logs by message content
989
+ search_logs = list_hook_logs(search="validation failed")
990
+
991
+ # List logs from the last hour
992
+ from datetime import datetime, timedelta
993
+ one_hour_ago = (datetime.utcnow() - timedelta(hours=1)).isoformat() + "Z"
994
+ recent_logs = list_hook_logs(timestamp_after=one_hour_ago)
995
+ ```
996
+
997
+ #### create_engine_field
998
+
999
+ Creates a new engine field and links it to schemas. Engine fields define what data the engine extracts and must be created for each field in the schema when setting up an engine.
1000
+
1001
+ **Parameters:**
1002
+ - `engine_id` (integer, required): Engine ID to which this field belongs
1003
+ - `name` (string, required): Field name (slug format, max 50 chars)
1004
+ - `label` (string, required): Human-readable label (max 100 chars)
1005
+ - `field_type` (string, required): Field type - 'string', 'number', 'date', or 'enum'
1006
+ - `schema_ids` (array, required): List of schema IDs to link this engine field to (at least one required)
1007
+ - `tabular` (boolean, optional): Whether this field is in a table (default: false)
1008
+ - `multiline` (string, optional): Multiline setting - 'true', 'false', or '' (default: 'false')
1009
+ - `subtype` (string, optional): Optional field subtype (max 50 chars)
1010
+ - `pre_trained_field_id` (string, optional): Optional pre-trained field ID (max 50 chars)
1011
+
1012
+ **Returns:**
1013
+ ```json
1014
+ {
1015
+ "id": 12345,
1016
+ "name": "invoice_number",
1017
+ "label": "Invoice Number",
1018
+ "url": "https://elis.rossum.ai/api/v1/engine_fields/12345",
1019
+ "type": "string",
1020
+ "engine": "https://elis.rossum.ai/api/v1/engines/123",
1021
+ "tabular": false,
1022
+ "multiline": "false",
1023
+ "schema_ids": [456, 789],
1024
+ "message": "Engine field 'Invoice Number' created successfully with ID 12345 and linked to 2 schema(s)"
1025
+ }
1026
+ ```
1027
+
1028
+ #### get_engine_fields
1029
+
1030
+ Retrieves engine fields for a specific engine or all engine fields.
1031
+
1032
+ **Parameters:**
1033
+ - `engine_id` (integer, optional): Engine ID to filter fields by. If not provided, retrieves all engine fields.
1034
+
1035
+ **Returns:**
1036
+ ```json
1037
+ {
1038
+ "count": 2,
1039
+ "results": [
1040
+ {
1041
+ "id": 12345,
1042
+ "url": "https://elis.rossum.ai/api/v1/engine_fields/12345",
1043
+ "engine": "https://elis.rossum.ai/api/v1/engines/123",
1044
+ "name": "invoice_number",
1045
+ "label": "Invoice Number",
1046
+ "type": "string",
1047
+ "subtype": null,
1048
+ "tabular": false,
1049
+ "multiline": "false",
1050
+ "pre_trained_field_id": null,
1051
+ "schemas": ["https://elis.rossum.ai/api/v1/schemas/456"]
1052
+ },
1053
+ {
1054
+ "id": 12346,
1055
+ "url": "https://elis.rossum.ai/api/v1/engine_fields/12346",
1056
+ "engine": "https://elis.rossum.ai/api/v1/engines/123",
1057
+ "name": "invoice_date",
1058
+ "label": "Invoice Date",
1059
+ "type": "date",
1060
+ "subtype": null,
1061
+ "tabular": false,
1062
+ "multiline": "false",
1063
+ "pre_trained_field_id": null,
1064
+ "schemas": ["https://elis.rossum.ai/api/v1/schemas/456"]
1065
+ }
1066
+ ]
1067
+ }
1068
+ ```
1069
+
1070
+ **Example usage:**
1071
+ ```python
1072
+ # Get all engine fields for a specific engine
1073
+ engine_fields = get_engine_fields(engine_id=123)
1074
+
1075
+ # Get all engine fields
1076
+ all_fields = get_engine_fields()
1077
+ ```
1078
+
1079
+ ### User Management
1080
+
1081
+ #### get_user
1082
+
1083
+ Retrieves a single user by ID. Use `list_users` first to find users by username or email.
1084
+
1085
+ **Parameters:**
1086
+ - `user_id` (integer, required): The user ID to retrieve
1087
+
1088
+ **Returns:**
1089
+ ```json
1090
+ {
1091
+ "id": 12345,
1092
+ "url": "https://elis.rossum.ai/api/v1/users/12345",
1093
+ "username": "john.doe@example.com",
1094
+ "first_name": "John",
1095
+ "last_name": "Doe",
1096
+ "email": "john.doe@example.com",
1097
+ "organization": "https://elis.rossum.ai/api/v1/organizations/100",
1098
+ "is_active": true,
1099
+ "date_joined": "2024-01-01T00:00:00Z",
1100
+ "last_login": "2024-01-15T10:30:00Z"
1101
+ }
1102
+ ```
1103
+
1104
+ #### list_users
1105
+
1106
+ Lists users in the organization. Use this to find a user's URL when you need it for `token_owner` in `create_hook_from_template`.
1107
+
1108
+ **Parameters:**
1109
+ - `username` (string, optional): Filter by exact username
1110
+ - `email` (string, optional): Filter by email address
1111
+ - `first_name` (string, optional): Filter by first name
1112
+ - `last_name` (string, optional): Filter by last name
1113
+ - `is_active` (boolean, optional): Filter by active status
1114
+ - `is_organization_group_admin` (boolean, optional): Filter by organization group admin role. Use `false` to exclude admin users (e.g., when finding users for `token_owner`)
1115
+
1116
+ **Returns:**
1117
+ ```json
1118
+ [
1119
+ {
1120
+ "id": 12345,
1121
+ "url": "https://elis.rossum.ai/api/v1/users/12345",
1122
+ "username": "john.doe@example.com",
1123
+ "first_name": "John",
1124
+ "last_name": "Doe",
1125
+ "email": "john.doe@example.com",
1126
+ "organization": "https://elis.rossum.ai/api/v1/organizations/100",
1127
+ "is_active": true
1128
+ }
1129
+ ]
1130
+ ```
1131
+
1132
+ **Example usage:**
1133
+ ```python
1134
+ # Find user by username to get their URL for token_owner
1135
+ users = list_users(username="john.doe@example.com")
1136
+ if users:
1137
+ user_url = users[0].url
1138
+ # Use user_url in create_hook_from_template
1139
+
1140
+ # Find non-admin users suitable for token_owner
1141
+ non_admin_users = list_users(is_organization_group_admin=False)
1142
+ ```
1143
+
1144
+ #### list_user_roles
1145
+
1146
+ Lists all user roles (groups of permissions) in the organization. Useful for understanding what roles are available and identifying users with specific permissions.
1147
+
1148
+ **Parameters:**
1149
+ None
1150
+
1151
+ **Returns:**
1152
+ ```json
1153
+ [
1154
+ {
1155
+ "id": 12345,
1156
+ "url": "https://elis.rossum.ai/api/v1/groups/12345",
1157
+ "name": "admin",
1158
+ "organization": "https://elis.rossum.ai/api/v1/organizations/100"
1159
+ },
1160
+ {
1161
+ "id": 12346,
1162
+ "url": "https://elis.rossum.ai/api/v1/groups/12346",
1163
+ "name": "annotator",
1164
+ "organization": "https://elis.rossum.ai/api/v1/organizations/100"
1165
+ }
1166
+ ]
1167
+ ```
1168
+
1169
+ **Example usage:**
1170
+ ```python
1171
+ # List all available roles
1172
+ roles = list_user_roles()
1173
+ ```
1174
+
1175
+ ### Rules Management
1176
+
1177
+ #### get_rule
1178
+
1179
+ Retrieves details of a specific business rule by its ID.
1180
+
1181
+ **Parameters:**
1182
+ - `rule_id` (integer, required): Rule ID
1183
+
1184
+ **Returns:**
1185
+ ```json
1186
+ {
1187
+ "id": 12345,
1188
+ "name": "Auto-calculate Total",
1189
+ "url": "https://elis.rossum.ai/api/v1/rules/12345",
1190
+ "enabled": true,
1191
+ "organization": "https://elis.rossum.ai/api/v1/organizations/100",
1192
+ "schema": "https://elis.rossum.ai/api/v1/schemas/200",
1193
+ "trigger_condition": "field.amount_total.changed",
1194
+ "created_by": "https://elis.rossum.ai/api/v1/users/300",
1195
+ "created_at": "2024-01-01T00:00:00Z",
1196
+ "modified_by": "https://elis.rossum.ai/api/v1/users/300",
1197
+ "modified_at": "2024-01-01T00:00:00Z",
1198
+ "rule_template": null,
1199
+ "synchronized_from_template": false,
1200
+ "actions": [
1201
+ {
1202
+ "id": 54321,
1203
+ "type": "set_datapoint_value",
1204
+ "payload": {
1205
+ "datapoint_id": "tax_amount",
1206
+ "value": "field.amount_total.value * 0.2"
1207
+ },
1208
+ "event": "trigger",
1209
+ "enabled": true
1210
+ }
1211
+ ]
1212
+ }
1213
+ ```
1214
+
1215
+ **Example usage:**
1216
+ ```python
1217
+ # Get rule details
1218
+ rule = get_rule(rule_id=12345)
1219
+ ```
1220
+
1221
+ #### list_rules
1222
+
1223
+ Lists all business rules configured in your organization. Rules define custom business logic with trigger conditions (TxScript formulas) and actions that execute when conditions are met.
1224
+
1225
+ **Parameters:**
1226
+ - `schema_id` (integer, optional): Filter rules by schema ID
1227
+ - `organization_id` (integer, optional): Filter rules by organization ID
1228
+ - `enabled` (boolean, optional): Filter by enabled status (true for enabled rules, false for disabled)
1229
+
1230
+ **Returns:**
1231
+ ```json
1232
+ {
1233
+ "count": 2,
1234
+ "results": [
1235
+ {
1236
+ "id": 12345,
1237
+ "name": "Auto-calculate Total",
1238
+ "url": "https://elis.rossum.ai/api/v1/rules/12345",
1239
+ "enabled": true,
1240
+ "organization": "https://elis.rossum.ai/api/v1/organizations/100",
1241
+ "schema": "https://elis.rossum.ai/api/v1/schemas/200",
1242
+ "trigger_condition": "field.amount_total.changed",
1243
+ "created_by": "https://elis.rossum.ai/api/v1/users/300",
1244
+ "created_at": "2024-01-01T00:00:00Z",
1245
+ "modified_by": "https://elis.rossum.ai/api/v1/users/300",
1246
+ "modified_at": "2024-01-01T00:00:00Z",
1247
+ "rule_template": null,
1248
+ "synchronized_from_template": false,
1249
+ "actions": [
1250
+ {
1251
+ "id": 54321,
1252
+ "type": "set_datapoint_value",
1253
+ "payload": {
1254
+ "datapoint_id": "tax_amount",
1255
+ "value": "field.amount_total.value * 0.2"
1256
+ },
1257
+ "event": "trigger",
1258
+ "enabled": true
1259
+ }
1260
+ ]
1261
+ }
1262
+ ]
1263
+ }
1264
+ ```
1265
+
1266
+ **Example usage:**
1267
+ ```python
1268
+ # List all rules
1269
+ all_rules = list_rules()
1270
+
1271
+ # List rules for a specific schema
1272
+ schema_rules = list_rules(schema_id=12345)
1273
+
1274
+ # List only enabled rules
1275
+ enabled_rules = list_rules(enabled=True)
1276
+
1277
+ # List enabled rules for a specific organization
1278
+ org_enabled_rules = list_rules(organization_id=100, enabled=True)
1279
+ ```
1280
+
1281
+ ### Relations Management
1282
+
1283
+ #### get_relation
1284
+
1285
+ Retrieves details of a specific relation by its ID. Relations introduce common relations between annotations.
1286
+
1287
+ **Parameters:**
1288
+ - `relation_id` (integer, required): Relation ID
1289
+
1290
+ **Returns:**
1291
+ ```json
1292
+ {
1293
+ "id": 12345,
1294
+ "type": "duplicate",
1295
+ "key": "abc123def456",
1296
+ "parent": "https://elis.rossum.ai/api/v1/annotations/100",
1297
+ "annotations": [
1298
+ "https://elis.rossum.ai/api/v1/annotations/100",
1299
+ "https://elis.rossum.ai/api/v1/annotations/101"
1300
+ ],
1301
+ "url": "https://elis.rossum.ai/api/v1/relations/12345"
1302
+ }
1303
+ ```
1304
+
1305
+ **Example usage:**
1306
+ ```python
1307
+ # Get relation details
1308
+ relation = get_relation(relation_id=12345)
1309
+ ```
1310
+
1311
+ #### list_relations
1312
+
1313
+ Lists all relations between annotations with optional filters. Relations introduce common relations between annotations:
1314
+ - **edit**: Created after editing annotation in user interface (rotation or split of the document)
1315
+ - **attachment**: One or more documents are attachments to another document
1316
+ - **duplicate**: Created after importing the same document that already exists in Rossum
1317
+
1318
+ **Parameters:**
1319
+ - `id` (integer, optional): Filter by relation ID
1320
+ - `type` (string, optional): Filter by relation type ('edit', 'attachment', 'duplicate')
1321
+ - `parent` (integer, optional): Filter by parent annotation ID
1322
+ - `key` (string, optional): Filter by relation key
1323
+ - `annotation` (integer, optional): Filter by annotation ID
1324
+
1325
+ **Returns:**
1326
+ ```json
1327
+ {
1328
+ "count": 2,
1329
+ "results": [
1330
+ {
1331
+ "id": 12345,
1332
+ "type": "duplicate",
1333
+ "key": "abc123def456",
1334
+ "parent": "https://elis.rossum.ai/api/v1/annotations/100",
1335
+ "annotations": [
1336
+ "https://elis.rossum.ai/api/v1/annotations/100",
1337
+ "https://elis.rossum.ai/api/v1/annotations/101"
1338
+ ],
1339
+ "url": "https://elis.rossum.ai/api/v1/relations/12345"
1340
+ },
1341
+ {
1342
+ "id": 12346,
1343
+ "type": "edit",
1344
+ "key": null,
1345
+ "parent": "https://elis.rossum.ai/api/v1/annotations/200",
1346
+ "annotations": [
1347
+ "https://elis.rossum.ai/api/v1/annotations/201",
1348
+ "https://elis.rossum.ai/api/v1/annotations/202"
1349
+ ],
1350
+ "url": "https://elis.rossum.ai/api/v1/relations/12346"
1351
+ }
1352
+ ]
1353
+ }
1354
+ ```
1355
+
1356
+ **Example usage:**
1357
+ ```python
1358
+ # List all relations
1359
+ all_relations = list_relations()
1360
+
1361
+ # List duplicate relations
1362
+ duplicate_relations = list_relations(type="duplicate")
1363
+
1364
+ # List relations for a specific parent annotation
1365
+ parent_relations = list_relations(parent=12345)
1366
+
1367
+ # List relations containing a specific annotation
1368
+ annotation_relations = list_relations(annotation=12345)
1369
+ ```
1370
+
1371
+ #### get_document_relation
1372
+
1373
+ Retrieves details of a specific document relation by its ID. Document relations introduce additional relations between annotations and documents.
1374
+
1375
+ **Parameters:**
1376
+ - `document_relation_id` (integer, required): Document relation ID
1377
+
1378
+ **Returns:**
1379
+ ```json
1380
+ {
1381
+ "id": 12345,
1382
+ "type": "export",
1383
+ "annotation": "https://elis.rossum.ai/api/v1/annotations/100",
1384
+ "key": "exported_file_key",
1385
+ "documents": [
1386
+ "https://elis.rossum.ai/api/v1/documents/200",
1387
+ "https://elis.rossum.ai/api/v1/documents/201"
1388
+ ],
1389
+ "url": "https://elis.rossum.ai/api/v1/document_relations/12345"
1390
+ }
1391
+ ```
1392
+
1393
+ **Example usage:**
1394
+ ```python
1395
+ # Get document relation details
1396
+ doc_relation = get_document_relation(document_relation_id=12345)
1397
+ ```
1398
+
1399
+ #### list_document_relations
1400
+
1401
+ Lists all document relations with optional filters. Document relations introduce additional relations between annotations and documents:
1402
+ - **export**: Documents generated from exporting an annotation
1403
+ - **einvoice**: Electronic invoice documents associated with an annotation
1404
+
1405
+ **Parameters:**
1406
+ - `id` (integer, optional): Filter by document relation ID
1407
+ - `type` (string, optional): Filter by relation type ('export', 'einvoice')
1408
+ - `annotation` (integer, optional): Filter by annotation ID
1409
+ - `key` (string, optional): Filter by relation key
1410
+ - `documents` (integer, optional): Filter by document ID
1411
+
1412
+ **Returns:**
1413
+ ```json
1414
+ {
1415
+ "count": 2,
1416
+ "results": [
1417
+ {
1418
+ "id": 12345,
1419
+ "type": "export",
1420
+ "annotation": "https://elis.rossum.ai/api/v1/annotations/100",
1421
+ "key": "exported_file_key",
1422
+ "documents": [
1423
+ "https://elis.rossum.ai/api/v1/documents/200",
1424
+ "https://elis.rossum.ai/api/v1/documents/201"
1425
+ ],
1426
+ "url": "https://elis.rossum.ai/api/v1/document_relations/12345"
1427
+ },
1428
+ {
1429
+ "id": 12346,
1430
+ "type": "einvoice",
1431
+ "annotation": "https://elis.rossum.ai/api/v1/annotations/102",
1432
+ "key": null,
1433
+ "documents": [
1434
+ "https://elis.rossum.ai/api/v1/documents/300"
1435
+ ],
1436
+ "url": "https://elis.rossum.ai/api/v1/document_relations/12346"
1437
+ }
1438
+ ]
1439
+ }
1440
+ ```
1441
+
1442
+ **Example usage:**
1443
+ ```python
1444
+ # List all document relations
1445
+ all_doc_relations = list_document_relations()
1446
+
1447
+ # List export-type document relations
1448
+ export_relations = list_document_relations(type="export")
1449
+
1450
+ # List document relations for a specific annotation
1451
+ annotation_doc_relations = list_document_relations(annotation=100)
1452
+
1453
+ # List document relations containing a specific document
1454
+ document_relations = list_document_relations(documents=200)
1455
+ ```
1456
+
1457
+ ## Annotation Status Workflow
1458
+
1459
+ When a document is uploaded, the annotation progresses through various states:
1460
+
1461
+ 1. **importing** - Initial state after upload. Document is being processed.
1462
+ 2. **to_review** - Extraction complete, ready for user validation.
1463
+ 3. **reviewing** - Annotation is being reviewed (triggered by `start_annotation`). This state is required before you can update annotation fields.
1464
+ 4. **confirmed** - The annotation has been validated and confirmed (via `confirm_annotation`).
1465
+ 5. **exporting** - The annotation is being exported.
1466
+ 6. **exported** - Final state for successfully processed documents.
1467
+
1468
+ Other possible states include: `created`, `failed_import`, `split`, `in_workflow`, `rejected`, `failed_export`, `postponed`, `deleted`, `purged`.
1469
+
1470
+ **Important Notes:**
1471
+ - After uploading documents, agents should wait for annotations to transition from `importing` to `to_review` (or later states) before considering them fully processed.
1472
+ - To update annotation field values, you must first call `start_annotation` to move the annotation to 'reviewing' status.
1473
+ - After updating fields with `bulk_update_annotation_fields`, you can call `confirm_annotation` to move to 'confirmed' status.
1474
+
1475
+ ## Example Workflows
1476
+
1477
+ <details>
1478
+ <summary>Single Document Upload</summary>
1479
+
1480
+ 1. Upload a document using `upload_document`
1481
+ 2. Get the annotation ID using `list_annotations`
1482
+ 3. Check annotation status using `get_annotation`
1483
+ 4. Wait until status is `to_review`, `confirmed`, or `exported`
1484
+
1485
+ </details>
1486
+
1487
+ <details>
1488
+ <summary>Document Upload with Field Updates</summary>
1489
+
1490
+ 1. Upload a document using `upload_document`
1491
+ 2. Get the annotation ID using `list_annotations`
1492
+ 3. Wait until status is `importing` or `to_review`
1493
+ 4. Start the annotation using `start_annotation` (moves to 'reviewing')
1494
+ 5. Get annotation content using `get_annotation` with `sideloads=['content']`
1495
+ 6. Update field values using `bulk_update_annotation_fields` with datapoint IDs from content
1496
+ 7. Confirm the annotation using `confirm_annotation` (moves to 'confirmed')
1497
+
1498
+ </details>
1499
+
1500
+ <details>
1501
+ <summary>Bulk Document Upload</summary>
1502
+
1503
+ 1. Upload all documents in bulk using `upload_document` for each file
1504
+ 2. Check status of all annotations using `list_annotations`
1505
+ 3. Monitor until all documents finish processing
1506
+
1507
+ </details>
1508
+
1509
+ <details>
1510
+ <summary>Create Queue with Engine</summary>
1511
+
1512
+ 1. Create a schema using `create_schema` with sections and datapoints
1513
+ 2. Create an engine using `create_engine` with type 'extractor' or 'splitter'
1514
+ 3. Create engine fields using `create_engine_field` for each schema field
1515
+ 4. Create a queue using `create_queue` linking the schema and engine
1516
+ 5. Optionally update engine training queues using `update_engine`
1517
+
1518
+ </details>
1519
+
1520
+ ## Error Handling
1521
+
1522
+ The server provides detailed error messages for common issues:
1523
+ - Missing API token
1524
+ - File not found
1525
+ - Upload failures
1526
+ - API errors
1527
+
1528
+ ## License
1529
+
1530
+ MIT License - see LICENSE file for details
1531
+
1532
+ ## Resources
1533
+
1534
+ - [Rossum API Documentation](https://elis.rossum.ai/api/docs/)
1535
+ - [Model Context Protocol](https://modelcontextprotocol.io/)
1536
+ - [Rossum SDK](https://github.com/rossumai/rossum-sdk)
1537
+ - [Main Repository](https://github.com/stancld/rossum-mcp)