Skip to content

resources

resources

Marianne MCP resources for score and conductor-facing configuration access.

This module implements MCP resources that expose score schemas, examples, and conductor records as readable content. Resources provide context and reference material for AI agents working with Marianne.

Resources are organized by category: - ConfigResources: Access to score schemas and examples

Attributes

Classes

ConfigResources

ConfigResources(state_backend=None, workspace_root=None)

Marianne score configuration resources.

Provides access to score configuration schemas, examples, and documentation as MCP resources. These resources help AI agents understand Marianne's score format and available instrument options.

Source code in src/marianne/mcp/resources.py
def __init__(
    self, state_backend: StateBackend | None = None, workspace_root: Path | None = None
) -> None:
    # Base project directory (assuming we're in src/marianne/mcp/)
    self.project_root = Path(__file__).parent.parent.parent.parent
    self.state_backend = state_backend
    self.workspace_root = workspace_root or Path.cwd()
Methods:
list_resources async
list_resources()

List all configuration resources.

Source code in src/marianne/mcp/resources.py
async def list_resources(self) -> list[dict[str, Any]]:
    """List all configuration resources."""
    resources = [
        {
            "uri": "config://schema",
            "name": "Marianne Score Schema",
            "description": "Complete JSON schema for Marianne score YAML files",
            "mimeType": _CONTENT_TYPE_JSON
        },
        {
            "uri": "config://example",
            "name": "Marianne Score Example",
            "description": "Example Marianne score YAML with current syntax",
            "mimeType": "text/yaml"
        },
        {
            "uri": "config://instrument-options",
            "name": "Instrument Options",
            "description": "Available instrument profiles and their configuration options",
            "mimeType": _CONTENT_TYPE_JSON
        },
        {
            "uri": "config://validation-types",
            "name": "Validation Types Reference",
            "description": "Available validation types and their parameters",
            "mimeType": _CONTENT_TYPE_JSON
        },
        {
            "uri": "config://learning-options",
            "name": "Learning Configuration Options",
            "description": "Learning system configuration parameters and patterns",
            "mimeType": _CONTENT_TYPE_JSON
        },
        # Job management resources
        {
            "uri": "marianne://jobs",
            "name": "Submitted Scores Overview",
            "description": (
                "List of conductor records for submitted scores with status and metadata"
            ),
            "mimeType": _CONTENT_TYPE_JSON
        },
        {
            "uri": "marianne://templates",
            "name": "Marianne Score Templates",
            "description": "Collection of Marianne score YAML templates",
            "mimeType": _CONTENT_TYPE_JSON
        }
    ]

    # Dynamic job detail resources - only available if we have state backend
    if self.state_backend:
        resources.append({
            "uri": "marianne://jobs/{job_id}",
            "name": "Submitted Score Details (Template)",
            "description": (
                "Detailed conductor record for a submitted score; "
                "job_id is the runtime identifier"
            ),
            "mimeType": _CONTENT_TYPE_JSON
        })

    return resources
read_resource async
read_resource(uri)

Read a configuration resource by URI.

Source code in src/marianne/mcp/resources.py
async def read_resource(self, uri: str) -> dict[str, Any]:
    """Read a configuration resource by URI."""
    try:
        handler_name = self._URI_HANDLERS.get(uri)
        if handler_name:
            result: dict[str, Any] = await getattr(self, handler_name)()
            return result

        if uri.startswith("marianne://jobs/"):
            job_id = uri.replace("marianne://jobs/", "")
            return await self._get_job_details(job_id)

        raise ValueError(f"Unknown resource URI: {uri}")

    except (OSError, ValueError, KeyError, TypeError, json.JSONDecodeError) as e:
        logger.warning("mcp.resource_read_error", uri=uri, error=str(e))
        return {
            "contents": [
                {
                    "uri": uri,
                    "mimeType": "text/plain",
                    "text": f"Error reading resource: {str(e)}"
                }
            ]
        }

Functions: