{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "MXCP Resource Definition Schema", "type": "object", "required": ["mxcp", "resource"], "properties": { "mxcp": { "type": "integer", "description": "Schema version. Must be 1.", "enum": [1], "default": 1 }, "resource": { "$ref": "#/definitions/resourceDefinition", "description": "Defines an MCP resource endpoint." }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Short display title." }, "description": { "type": "string", "description": "Longer description." } }, "description": "Optional metadata for documentation purposes." } }, "definitions": { "resourceDefinition": { "type": "object", "required": ["uri", "source"], "properties": { "uri": { "type": "string", "description": "Logical URI identifying this resource.", "pattern": "^[A-Za-z][A-Za-z0-9+.-]*://(?:[A-Za-z0-9._-]+|\\{[A-Za-z_][A-Za-z0-9_]*\\})(?:/(?:[A-Za-z0-9._-]+|\\{[A-Za-z_][A-Za-z0-9_]*\\}))*$", "minLength": 1, "maxLength": 255 }, "name": { "type": "string", "description": "Name of this resource.", "minLength": 1 }, "description": { "type": "string", "description": "Description of this resource." }, "tags": { "type": "array", "items": { "type": "string" }, "description": "Tags to classify this resource." }, "mime_type": { "type": "string", "description": "MIME type of this resource." }, "parameters": { "type": "array", "description": "Input parameters for this endpoint.", "items": { "$ref": "common-types-schema-1.json#/definitions/paramDefinition" } }, "return": { "$ref": "common-types-schema-1.json#/definitions/typeDefinition", "description": "Description of the output schema." }, "language": { "type": "string", "default": "sql", "enum": ["sql", "python"], "description": "The language used to define the logic of this endpoint. 'sql' or 'python'." }, "source": { "type": "object", "description": "Source for the endpoint logic, either inline or a file reference.", "oneOf": [ { "required": ["code"], "not": { "required": ["file"] } }, { "required": ["file"], "not": { "required": ["code"] } } ], "properties": { "code": { "type": "string", "description": "The inline code snippet to execute." }, "file": { "type": "string", "description": "A relative path to a file containing the code." } }, "additionalProperties": false }, "enabled": { "type": "boolean", "default": true, "description": "Whether this endpoint is active." }, "tests": { "type": "array", "description": "Tests to validate this endpoint.", "items": { "type": "object", "required": ["name", "arguments"], "properties": { "name": { "type": "string", "description": "Name of the test." }, "description": { "type": "string", "description": "What the test checks." }, "arguments": { "type": "array", "items": { "type": "object", "required": ["key", "value"], "properties": { "key": { "type": "string", "description": "Input parameter to pass to test." }, "value": { "description": "Value of the input parameter to test." } }, "additionalProperties": false } }, "result": { "description": "Expected result." }, "user_context": { "type": "object", "description": "User context for policy testing. Can include role, permissions, user_id, etc." }, "result_contains": { "description": "Partial match - result must contain these fields/values. For arrays, checks if array contains this item." }, "result_not_contains": { "type": "array", "items": { "type": "string" }, "description": "List of field names that should NOT be present in the result." }, "result_contains_item": { "description": "For array results - at least one array item must match this object/value." }, "result_contains_all": { "type": "array", "description": "For array results - all these items must be present (any order)." }, "result_length": { "type": "integer", "minimum": 0, "description": "For array results - array must have exactly this many items." }, "result_contains_text": { "type": "string", "description": "For string results - result must contain this substring." } }, "additionalProperties": false } }, "policies": { "$ref": "common-types-schema-1.json#/definitions/policySet", "description": "Policy definitions for access control and data filtering." } } } } }