Common Tasks
Quick answers to “How do I…?” questions. Each task links to full documentation.
Getting Started
Section titled “Getting Started”How do I create a new project?
Section titled “How do I create a new project?”mkdir my-project && cd my-projectmxcp init --bootstrap # Creates example endpointHow do I run my first tool?
Section titled “How do I run my first tool?”mxcp run tool hello_world --param name=AliceHow do I connect to Claude Desktop?
Section titled “How do I connect to Claude Desktop?”Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{ "mcpServers": { "my-project": { "command": "mxcp", "args": ["serve", "--transport", "stdio"], "cwd": "/path/to/my-project" } }}Creating Endpoints
Section titled “Creating Endpoints”How do I create a SQL tool?
Section titled “How do I create a SQL tool?”mxcp: 1tool: name: my_tool description: What this tool does parameters: - name: param_name type: string description: Parameter description return: type: object source: file: ../sql/my-tool.sqlHow do I create a Python tool?
Section titled “How do I create a Python tool?”mxcp: 1tool: name: my_tool description: What this tool does language: python parameters: - name: param_name type: string description: Parameter description return: type: object source: file: ../python/my_module.pyfrom mxcp.runtime import db
def my_tool(param_name: str) -> dict: results = db.execute("SELECT * FROM data WHERE name = $name", {"name": param_name}) return {"data": results}How do I create a resource?
Section titled “How do I create a resource?”mxcp: 1resource: uri: users://{id} description: Get user by ID parameters: - name: id type: integer description: User ID return: type: object source: code: "SELECT * FROM users WHERE id = $id"Security
Section titled “Security”How do I add authentication?
Section titled “How do I add authentication?”Add to ~/.mxcp/config.yml:
projects: my-project: profiles: default: auth: provider: github github: client_id: your_client_id client_secret: your_client_secretHow do I restrict access to a tool?
Section titled “How do I restrict access to a tool?”Add input policy:
policies: input: - condition: "user.role != 'admin'" action: deny reason: "Admin access required"How do I filter sensitive data?
Section titled “How do I filter sensitive data?”Add output policy:
policies: output: - condition: "user.role != 'admin'" action: filter_fields fields: ["salary", "ssn"] reason: "Restricted to admins"Or mark fields as sensitive:
return: type: object properties: ssn: type: string sensitive: trueHow do I enable audit logging?
Section titled “How do I enable audit logging?”Add to mxcp-site.yml:
profiles: default: audit: enabled: true path: audit/logs.jsonlQuery logs:
mxcp log --since 1hmxcp log --tool my_tool --status errorTesting & Quality
Section titled “Testing & Quality”How do I add tests to an endpoint?
Section titled “How do I add tests to an endpoint?”Add tests section to your endpoint YAML:
tests: - name: basic_test arguments: - key: param_name value: "test_value" result_contains: expected_field: "expected_value"Run tests:
mxcp testHow do I test with different user roles?
Section titled “How do I test with different user roles?”mxcp run tool my_tool \ --param id=123 \ --user-context '{"role": "admin", "permissions": ["read", "write"]}'Or in YAML tests:
tests: - name: admin_access user_context: role: admin arguments: - key: id value: 123How do I validate my endpoints?
Section titled “How do I validate my endpoints?”mxcp validate # All endpointsmxcp validate tools/my_tool.yml # Specific endpointmxcp validate --debug # Detailed outputHow do I check for linting issues?
Section titled “How do I check for linting issues?”mxcp lintConfiguration
Section titled “Configuration”How do I use environment-specific settings?
Section titled “How do I use environment-specific settings?”Define profiles in mxcp-site.yml:
profiles: development: duckdb: path: dev.db audit: enabled: false
production: duckdb: path: /data/prod.db audit: enabled: trueUse profile:
mxcp serve --profile production# orexport MXCP_PROFILE=productionHow do I use secrets?
Section titled “How do I use secrets?”Add to ~/.mxcp/config.yml:
projects: my-project: profiles: default: secrets: - name: api_key type: custom parameters: value: "secret-value"Access in Python:
from mxcp.runtime import configsecret = config.get_secret("api_key")api_key = secret["value"] if secret else NoneHow do I use Vault for secrets?
Section titled “How do I use Vault for secrets?”vault: enabled: true address: https://vault.example.com token_env: VAULT_TOKEN
projects: my-project: profiles: default: secrets: - name: db_password parameters: password: "vault://secret/database#password"Operations
Section titled “Operations”How do I deploy to production?
Section titled “How do I deploy to production?”With Docker:
FROM python:3.11-slimRUN pip install mxcpCOPY . /appWORKDIR /appCMD ["mxcp", "serve", "--transport", "streamable-http", "--port", "8000"]How do I enable monitoring?
Section titled “How do I enable monitoring?”Set OpenTelemetry environment variables:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4318export OTEL_SERVICE_NAME=mxcp-prodexport MXCP_TELEMETRY_ENABLED=trueHow do I reload configuration without restart?
Section titled “How do I reload configuration without restart?”# Send SIGHUPkill -HUP $(pgrep -f "mxcp serve")
# Or use admin socketcurl --unix-socket /run/mxcp/mxcp.sock -X POST http://localhost/reloadHow do I check for drift?
Section titled “How do I check for drift?”# Create baselinemxcp drift-snapshot
# Check for changesmxcp drift-checkDatabase
Section titled “Database”How do I access the database from Python?
Section titled “How do I access the database from Python?”from mxcp.runtime import db
# Execute queryresults = db.execute( "SELECT * FROM users WHERE id = $id", {"id": 123})
# results is a list of dictsfor row in results: print(row["name"])How do I use DuckDB extensions?
Section titled “How do I use DuckDB extensions?”Add to mxcp-site.yml:
extensions: - httpfs - parquet - name: h3 repo: communityHow do I integrate with dbt?
Section titled “How do I integrate with dbt?”Enable in mxcp-site.yml:
dbt: enabled: true model_paths: ["models"]Run dbt through MXCP:
mxcp dbt runTroubleshooting
Section titled “Troubleshooting”Tool not found
Section titled “Tool not found”mxcp list # See available endpointsCheck that:
- File is in
tools/directory enabled: trueis set- YAML is valid (
mxcp validate)
Validation errors
Section titled “Validation errors”mxcp validate --debugCheck YAML indentation and required fields.
Policy denials
Section titled “Policy denials”mxcp run tool my_tool --user-context '{"role": "admin"}' --debugCheck policy conditions match user context.
Python import errors
Section titled “Python import errors”# Ensure virtual environmentsource .venv/bin/activate
# Debugmxcp run tool my_tool --debug