Tutorials
Related Topics: Quickstart (project setup) | Concepts (understand MXCP) | Common Tasks (quick how-to)
This section contains step-by-step tutorials to help you build MXCP endpoints. Each tutorial focuses on a specific skill and builds on the concepts from the quickstart guide.
Getting Started Tutorials
Section titled “Getting Started Tutorials”Your first MXCP tool. Learn the basics of:
- Creating a tool definition
- Writing SQL implementation
- Running and testing tools
Build data query tools with SQL:
- Parameter binding
- Complex queries with joins
- Aggregations and grouping
- Working with DuckDB features
Build complex logic with Python:
- Accessing the runtime API
- Database operations from Python
- Async operations
- Lifecycle hooks
Prerequisites
Section titled “Prerequisites”Before starting these tutorials, ensure you have:
-
MXCP installed
Terminal window pip install mxcp -
A project initialized
Terminal window mkdir tutorialscd tutorialsmxcp init --bootstrap -
Basic understanding of:
- YAML syntax
- SQL (for SQL tutorials)
- Python (for Python tutorials)
Tutorial Format
Section titled “Tutorial Format”Each tutorial follows a consistent format:
- Goal - What you’ll build
- Prerequisites - What you need
- Steps - Detailed instructions
- Verification - How to test your work
- Next Steps - Where to go from here
All code examples are tested and working. You can copy-paste them directly into your project.
Recommended Order
Section titled “Recommended Order”If you’re new to MXCP, follow this learning path:
- Hello World - Understand the basics
- SQL Endpoints - Master data queries
- Python Endpoints - Build complex logic
After completing these tutorials, explore:
- Security section - Add authentication and policies
- Quality section - Test and validate your endpoints
- Operations section - Deploy to production
Quick Reference
Section titled “Quick Reference”Running Tools
Section titled “Running Tools”# Run with parametersmxcp run tool tool_name --param key=value
# Run with complex values from JSON filemxcp run tool tool_name --param data=@input.json
# Run with user context (for policy testing)mxcp run tool tool_name --user-context '{"role": "admin"}'Validation Commands
Section titled “Validation Commands”# Validate all endpointsmxcp validate
# Run testsmxcp test
# Check for issuesmxcp lint
# List endpointsmxcp listServer Commands
Section titled “Server Commands”# Start stdio server (for Claude Desktop)mxcp serve
# Start HTTP servermxcp serve --transport streamable-http --port 8000
# Debug modemxcp serve --debugTesting with AI Tools
Section titled “Testing with AI Tools”Your MXCP server works with any MCP-compatible AI client:
- Claude Desktop - Anthropic’s desktop app with native MCP support
- Claude Code - CLI tool for developers
- Other MCP clients - Any tool implementing the Model Context Protocol
MCP Inspector
Section titled “MCP Inspector”For debugging and testing without an AI client, use the MCP Inspector:
npx @modelcontextprotocol/inspectorThe Inspector provides:
- Resources Tab - Browse available resources
- Tools Tab - Test tools with custom inputs and view results
- Prompts Tab - Test prompt templates
- Notifications - View server logs and debug messages
This is useful for:
- Debugging tool implementations
- Testing parameter validation
- Verifying output formats
- Development without an AI client