Skip to content

MCP Server

Model Context Protocol server for machine-readable permission queries.

Server

server

MCP Server for AI platform consent and attribution queries.

Implements the "Permission Patchbay" from Teikari (2026, Section 6). The Model Context Protocol (MCP) enables AI platforms to issue machine-readable queries about training rights, attribution provenance, and permission scopes before incorporating musical works.

This server uses the FastMCP framework to register three tools:

  • query_attribution(work_id) -- retrieve a full AttributionRecord including credits, assurance level, and confidence score.
  • check_permission(entity_id, permission_type) -- check whether a specific permission (e.g. AI_TRAINING, COMMERCIAL_USE) is granted, denied, or conditional for a given entity.
  • list_permissions(entity_id) -- enumerate all permissions in an entity's PermissionBundle with scope and delegation chain.

The server maintains in-memory dictionaries of attribution records and permission bundles, suitable for development and testing. Production deployments would replace these with database-backed repositories.

Notes

MCP is part of the "consent infrastructure" layer that sits between AI platforms and rights holders. It complements the REST API by providing a protocol-native interface for LLM tool use.

See Also

music_attribution.schemas.permissions : PermissionBundle and related models. music_attribution.schemas.attribution : AttributionRecord boundary object.

MCPAttributionServer

MCPAttributionServer()

MCP server for music attribution and permission queries.

Wraps a FastMCP instance and registers three domain tools for querying attribution records and permission bundles. Designed as the "Permission Patchbay" -- a machine-readable consent layer enabling AI platforms to verify training rights before use.

The server holds in-memory stores of AttributionRecord and PermissionBundle objects keyed by UUID. In production, these would be backed by the PostgreSQL repositories.

ATTRIBUTE DESCRIPTION
name

MCP server name ("music-attribution"), used for service discovery and logging.

TYPE: str

METHOD DESCRIPTION
_query_attribution

Retrieve an attribution record by work entity UUID.

_check_permission

Check a single permission for an entity.

_list_permissions

List all permissions for an entity.

Examples:

>>> server = MCPAttributionServer()
>>> result = await server._query_attribution("550e8400-...")

Initialise the MCP server and register tools.

Creates the underlying FastMCP instance and registers the three domain tools (query_attribution, check_permission, list_permissions) via _register_tools.

Source code in src/music_attribution/mcp/server.py
def __init__(self) -> None:
    """Initialise the MCP server and register tools.

    Creates the underlying ``FastMCP`` instance and registers the
    three domain tools (``query_attribution``, ``check_permission``,
    ``list_permissions``) via ``_register_tools``.
    """
    self.name = "music-attribution"
    self._mcp = FastMCP(self.name)
    self._attributions: dict[uuid.UUID, AttributionRecord] = {}
    self._permissions: dict[uuid.UUID, PermissionBundle] = {}
    self._register_tools()

create_mcp_server

create_mcp_server() -> MCPAttributionServer

Create and return a new MCP attribution server instance.

Factory function that instantiates an MCPAttributionServer with empty in-memory stores. Callers should populate the _attributions and _permissions dictionaries before serving.

RETURNS DESCRIPTION
MCPAttributionServer

Configured server instance with tools registered.

Source code in src/music_attribution/mcp/server.py
def create_mcp_server() -> MCPAttributionServer:
    """Create and return a new MCP attribution server instance.

    Factory function that instantiates an ``MCPAttributionServer``
    with empty in-memory stores. Callers should populate the
    ``_attributions`` and ``_permissions`` dictionaries before serving.

    Returns
    -------
    MCPAttributionServer
        Configured server instance with tools registered.
    """
    return MCPAttributionServer()