Files
2025-11-30 08:49:50 +08:00

168 lines
6.2 KiB
JSON

{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "MXCP Tool Definition Schema",
"type": "object",
"required": ["mxcp", "tool"],
"properties": {
"mxcp": {
"type": "integer",
"description": "Schema version. Must be 1.",
"enum": [1],
"default": 1
},
"tool": {
"$ref": "#/definitions/toolDefinition",
"description": "Defines an MCP tool 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": {
"toolDefinition": {
"type": "object",
"required": ["name", "source"],
"properties": {
"name": {
"type": "string",
"description": "Name of this tool.",
"minLength": 1
},
"description": { "type": "string", "description": "Description of this tool." },
"tags": {
"type": "array",
"items": { "type": "string" },
"description": "Tags to classify this tool."
},
"annotations": {
"type": "object",
"description": "Optional behavioral hints for this tool.",
"properties": {
"title": {
"type": "string",
"description": "Human-readable display title for the tool."
},
"readOnlyHint": {
"type": "boolean",
"description": "Hint: tool does not modify its environment (side-effect-free)."
},
"destructiveHint": {
"type": "boolean",
"description": "Hint: tool may perform destructive updates (e.g. delete, overwrite)."
},
"idempotentHint": {
"type": "boolean",
"description": "Hint: repeated calls with same arguments yield the same result."
},
"openWorldHint": {
"type": "boolean",
"description": "Hint: tool interacts with external systems or entities (non-closed-world)."
}
},
"additionalProperties": false
},
"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."
}
}
}
}
}