feat: add design object resource for repository configuration access

Add new MCP resource cordra://design to retrieve Cordra's central design object
containing repository configuration, type definitions, and system settings.

- Add CordraClient.get_design() method using /api/objects/design endpoint
- Add get_cordra_design() resource handler with proper MCP annotations
- Include comprehensive error handling for authentication failures
- Document administrative privilege requirements in descriptions
- Add complete test coverage for both client and server functionality

The design object provides AI systems access to understand the complete
data model and configuration structure of a Cordra repository.
This commit is contained in:
Daniel Bauer
2025-07-04 10:07:16 +02:00
parent 94340e2bb1
commit 748d9b604f
4 changed files with 245 additions and 2 deletions

View File

@@ -213,3 +213,44 @@ class CordraClient:
raise CordraClientError(
f"Failed to retrieve schema '{schema_name}': {e}"
) from e
async def get_design(self) -> DigitalObject:
"""Retrieve the Cordra design object containing repository configuration.
The design object contains the central configuration for the Cordra repository
including type definitions, workflow configurations, and system settings.
Administrative privileges are typically required to access this object.
Returns:
The design object as a DigitalObject
Raises:
CordraNotFoundError: If the design object is not found
CordraAuthenticationError: If authentication fails or insufficient privileges
CordraClientError: For other API errors
"""
url = f"{self.config.base_url}/api/objects/design"
try:
response = self.session.get(url, timeout=self.config.timeout)
if not response.ok:
self._handle_http_error(
response, "Failed to retrieve design object"
)
design_obj = response.json()
return DigitalObject(
id="design",
type=design_obj.get("type", "CordraDesign"),
content=design_obj.get("content", design_obj),
metadata=design_obj.get("metadata"),
acl=design_obj.get("acl"),
payloads=design_obj.get("payloads"),
)
except requests.RequestException as e:
raise CordraClientError(
f"Failed to retrieve design object: {e}"
) from e