Skip to content
Star -

Tool Schema

Related Topics: Endpoints (tool concepts) | SQL Endpoints (tutorial) | Python Endpoints (tutorial) | Type System (parameter types)

This reference documents the complete YAML schema for tool definitions in MXCP.

mxcp: 1
tool:
name: get_employee
description: Retrieve employee information by ID
language: sql
tags:
- hr
- employee
annotations:
title: "Get Employee"
readOnlyHint: true
destructiveHint: false
idempotentHint: true
openWorldHint: false
parameters:
- name: employee_id
type: integer
description: The employee's unique identifier
minimum: 1
examples: [1, 42, 100]
return:
type: object
properties:
id:
type: integer
name:
type: string
email:
type: string
sensitive: true
department:
type: string
salary:
type: number
sensitive: true
source:
file: ../sql/get_employee.sql
policies:
input:
- condition: "user.role == 'guest'"
action: deny
reason: "Guests cannot access employee data"
output:
- condition: "user.role != 'hr'"
action: filter_sensitive_fields
reason: "Sensitive data restricted to HR"
tests:
- name: get_existing_employee
arguments:
- key: employee_id
value: 1
result_contains:
id: 1
name: "Alice"
enabled: true
FieldTypeRequiredDefaultDescription
mxcpintegerYes-Schema version. Must be 1.
toolobjectYes-Tool definition object.
metadataobjectNo-Custom metadata (not processed by MXCP).

Note: The mxcp field accepts both integer (1) and string ("1") values - strings are automatically coerced to integers.

FieldTypeRequiredDefaultDescription
namestringYes-Unique identifier. Must start with letter/underscore, alphanumeric only.
descriptionstringNo-Human-readable description for AI clients.
languagestringNo"sql"Implementation language: sql or python.
tagsarrayNo-List of tags for categorization.
annotationsobjectNo-MCP tool annotations (hints for AI).
parametersarrayNo-Input parameter definitions.
returnobjectNo-Return type definition.
sourceobjectYes-Implementation source (code or file).
policiesobjectNo-Input and output policy rules.
testsarrayNo-Test case definitions.
enabledbooleanNotrueWhether the tool is enabled.

Tool annotations provide hints to AI clients about the tool’s behavior.

FieldTypeDefaultDescription
titlestring-Display title for the tool.
readOnlyHintboolean-Hint that the tool only reads data.
destructiveHintboolean-Hint that the tool may delete or modify data.
idempotentHintboolean-Hint that repeated calls produce the same result.
openWorldHintboolean-Hint that the tool interacts with external systems.
annotations:
title: "Delete User"
readOnlyHint: false
destructiveHint: true
idempotentHint: false

Each parameter defines an input to the tool.

FieldTypeRequiredDefaultDescription
namestringYes-Parameter identifier (snake_case).
typestringYes-Data type: string, integer, number, boolean, array, object.
descriptionstringNo-Human-readable description.
defaultanyNo-Default value (makes parameter optional).
examplesarrayNo-Example values for documentation.
enumarrayNo-Allowed values.
sensitivebooleanNofalseMark as sensitive (for filtering).

String constraints:

FieldTypeDescription
minLengthintegerMinimum string length.
maxLengthintegerMaximum string length.
patternstringRegex pattern to match.
formatstringFormat hint: email, uri, date, time, date-time, duration, timestamp.

Number/Integer constraints:

FieldTypeDescription
minimumnumberMinimum value (inclusive).
maximumnumberMaximum value (inclusive).
exclusiveMinimumnumberMinimum value (exclusive).
exclusiveMaximumnumberMaximum value (exclusive).
multipleOfnumberValue must be multiple of this.

Array constraints:

FieldTypeDescription
itemsobjectType definition for array items.
minItemsintegerMinimum array length.
maxItemsintegerMaximum array length.
uniqueItemsbooleanWhether items must be unique.

Object constraints:

FieldTypeDescription
propertiesobjectMap of property names to type definitions.
requiredarrayList of required property names.
additionalPropertiesbooleanWhether extra (unspecified) object properties are accepted and preserved. Default: true (if omitted). Use false to reject unknown keys.

Note: If additionalProperties is omitted, MXCP treats it as true (extra keys are allowed and preserved). Set additionalProperties: false to forbid unknown keys.

# Allow unknown keys (default behavior)
type: object
properties:
objid:
type: integer
required: ["objid"]
# Forbid unknown keys
type: object
properties:
objid:
type: integer
required: ["objid"]
additionalProperties: false
parameters:
# Required string with validation
- name: email
type: string
description: User email address
format: email
maxLength: 255
# Optional integer with range
- name: limit
type: integer
description: Maximum results
default: 10
minimum: 1
maximum: 100
# Enum parameter
- name: status
type: string
description: Order status
enum: ["pending", "shipped", "delivered"]
# Array parameter
- name: ids
type: array
description: List of IDs to fetch
items:
type: integer
minItems: 1
maxItems: 100
# Object parameter
- name: filters
type: object
description: Search filters
properties:
department:
type: string
min_salary:
type: number
required:
- department

The return type defines the structure of the tool’s output.

return:
type: object
properties:
id:
type: integer
name:
type: string
email:
type: string
sensitive: true
created_at:
type: string
format: date-time

Same fields as parameters, minus name and default.

The source defines where the implementation lives.

FieldTypeDescription
codestringInline SQL or Python code.
filestringPath to external file (relative to YAML file).
languagestringOverride language detection: sql or python.

Note: Exactly one of code or file must be specified.

source:
code: |
SELECT id, name, email
FROM users
WHERE id = $user_id
source:
file: ../sql/get_user.sql

For Python tools, the function name in the Python file must match the tool name:

tools/calculate_tax.yml
tool:
name: calculate_tax # Function name must match
language: python
source:
file: ../python/tax.py
python/tax.py
def calculate_tax(amount: float, rate: float) -> float:
"""Function name must match tool name."""
return amount * rate

Policies control access and data filtering.

policies:
input:
- condition: "user.role == 'guest'"
action: deny
reason: "Guests cannot access this tool"
output:
- condition: "user.role != 'admin'"
action: filter_fields
fields: ["salary", "ssn"]
reason: "Sensitive fields restricted"
FieldTypeRequiredDescription
conditionstringYesCEL expression to evaluate.
actionstringYesAction to take: deny, filter_fields, mask_fields, filter_sensitive_fields.
reasonstringNoHuman-readable reason.
fieldsarrayNoFields to filter/mask (for filter_fields, mask_fields).
ActionTypeDescription
denyinputBlock the request entirely.
filter_fieldsoutputRemove specified fields from response.
mask_fieldsoutputReplace field values with masks.
filter_sensitive_fieldsoutputRemove fields marked sensitive: true.

See Policies for complete documentation.

Tests verify tool behavior.

tests:
- name: get_user_success
description: Successfully retrieves a user
arguments:
- key: user_id
value: 1
result_contains:
id: 1
name: "Alice"
- name: get_user_not_found
description: Returns null for non-existent user
arguments:
- key: user_id
value: 99999
result: null
- name: admin_sees_all_fields
description: Admin can see sensitive fields
arguments:
- key: user_id
value: 1
user_context:
role: admin
result_contains:
salary: 75000
FieldTypeRequiredDescription
namestringYesUnique test identifier.
descriptionstringNoHuman-readable description.
argumentsarrayYesInput arguments as key-value pairs.
user_contextobjectNoSimulated user context for policy testing.
FieldTypeDescription
resultanyExpected exact result.
result_containsanyPartial match - fields must exist with values.
result_not_containsarrayField names that must NOT exist.
result_contains_itemobjectFor arrays - at least one item must match.
result_contains_allarrayFor arrays - all items must be present.
result_lengthintegerFor arrays - exact length required.
result_contains_textstringFor strings - must contain substring.

See Testing for complete documentation.

  • Tool names: Use snake_case (e.g., get_user, search_orders)
  • Parameter names: Use snake_case (e.g., user_id, max_results)
  • File paths: Relative to the YAML file location

Validate your tool definitions:

Terminal window
mxcp validate
mxcp validate tools/my-tool.yml