Core Concepts
Related Topics: Glossary (term definitions) | Quickstart (hands-on setup) | Tutorials (step-by-step guides)
MXCP is built around a few core concepts that work together to provide a complete framework for building production AI tools. Understanding these concepts will help you design better endpoints and take full advantage of MXCP’s features.
Endpoints
Section titled “Endpoints”MXCP supports three types of MCP endpoints:
Tools are functions that AI can call to perform actions or retrieve data. They have:
- Parameters - Inputs with types, descriptions, and validation rules
- Return type - The structure of the output
- Source - SQL or Python implementation
tool: name: get_user description: Get user by ID parameters: - name: user_id type: integer return: type: object source: file: ../sql/get_user.sqlResources
Section titled “Resources”Resources are data sources that can be read by AI. They use URI templates:
- URI - Pattern like
users://{user_id} - Parameters - Extracted from the URI
- MIME type - Content type of the response
resource: uri: "users://{user_id}" description: User profile data mime_type: application/json source: file: ../sql/get_user.sqlPrompts
Section titled “Prompts”Prompts are reusable message templates with Jinja2 templating:
prompt: name: analyze_data description: Prompt for data analysis messages: - role: system prompt: "You are a data analyst." - role: user prompt: "Analyze this data: {{ data }}"Type System
Section titled “Type System”MXCP uses a JSON Schema-compatible type system for validation:
Base Types
Section titled “Base Types”string- Text valuesnumber- Floating-point numbersinteger- Whole numbersboolean- True/false valuesarray- Ordered listsobject- Key-value structures
Format Annotations
Section titled “Format Annotations”Strings can have format annotations for specialized handling:
email- Email addressesuri- URLsdate- ISO 8601 datestime- ISO 8601 timesdate-time- ISO 8601 timestampsduration- ISO 8601 durationstimestamp- Unix timestamps
Validation Constraints
Section titled “Validation Constraints”minimum/maximum- Number boundsminLength/maxLength- String lengthsminItems/maxItems- Array lengthsenum- Allowed valuesrequired- Required object properties
Sensitive Data
Section titled “Sensitive Data”Mark fields as sensitive: true to:
- Redact in audit logs
- Filter with policies
- Protect in responses
Learn more about the type system →
Project Structure
Section titled “Project Structure”MXCP enforces a consistent directory structure:
my-project/├── mxcp-site.yml # Project configuration├── tools/ # Tool definitions├── resources/ # Resource definitions├── prompts/ # Prompt definitions├── evals/ # Evaluation definitions├── python/ # Python code├── plugins/ # DuckDB plugins├── sql/ # SQL implementations├── drift/ # Drift snapshots└── audit/ # Audit logsThis structure enables:
- Auto-discovery - MXCP finds endpoints automatically
- Separation of concerns - Clear organization
- Version control - Easy diffs and reviews
Learn more about project structure →
Configuration
Section titled “Configuration”MXCP uses two configuration files:
Site Configuration (mxcp-site.yml)
Section titled “Site Configuration (mxcp-site.yml)”Project-specific settings that live in your repository:
- Project name and profile
- DuckDB settings
- Extensions and plugins
- dbt integration
User Configuration (~/.mxcp/config.yml)
Section titled “User Configuration (~/.mxcp/config.yml)”User-specific settings for secrets and authentication:
- Secrets and credentials
- OAuth provider settings
- Vault/1Password integration
Learn more about configuration →
Execution Flow
Section titled “Execution Flow”When an endpoint is called:
- Validation - Input is validated against parameter types
- Policy Check - Input policies are evaluated
- Execution - SQL or Python code runs
- Output Validation - Result is validated against return type
- Policy Filter - Output policies filter/mask data
- Audit Logging - Execution is logged (if enabled)
This consistent flow ensures:
- Type safety at all stages
- Security through policies
- Traceability through audit logs
Next Steps
Section titled “Next Steps”- Endpoints - Deep dive into tools, resources, and prompts
- Type System - Complete type reference
- Project Structure - Directory organization