Integrations
Related Topics: Quickstart (first setup) | Configuration (dbt, extensions) | SQL Endpoints (use DuckDB)
MXCP integrates with AI platforms, data transformation tools, and database systems to create production-ready AI applications.
Integration Architecture
Section titled “Integration Architecture”Integrations
Section titled “Integrations”Native MCP integration with Claude Desktop:
- Zero-code connection
- Stdio transport
- Multi-server support
- Developer console access
Data transformation and quality layer:
- Model preparation for AI
- Data quality testing
- Performance optimization
- Documentation generation
Powerful SQL execution engine:
- Extension ecosystem
- Multi-source connectivity
- Secret management
- Performance tuning
OpenAI Integration
Section titled “OpenAI Integration”Connect MXCP with OpenAI’s API for custom integrations.
Configuration
Section titled “Configuration”import openaiimport subprocessimport json
# Start MXCP servermxcp_process = subprocess.Popen( ["mxcp", "serve", "--transport", "stdio"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True, cwd="/path/to/project")
# Get available tools from MXCPdef get_mxcp_tools(): request = {"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}} mxcp_process.stdin.write(json.dumps(request) + "\n") mxcp_process.stdin.flush() response = json.loads(mxcp_process.stdout.readline()) return response.get("result", {}).get("tools", [])
# Convert MXCP tools to OpenAI formatdef mxcp_to_openai_tools(mxcp_tools): openai_tools = [] for tool in mxcp_tools: openai_tools.append({ "type": "function", "function": { "name": tool["name"], "description": tool.get("description", ""), "parameters": tool.get("inputSchema", {}) } }) return openai_tools
# Call MXCP tooldef call_mxcp_tool(name, arguments): request = { "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": name, "arguments": arguments} } mxcp_process.stdin.write(json.dumps(request) + "\n") mxcp_process.stdin.flush() response = json.loads(mxcp_process.stdout.readline()) return response.get("result", {}).get("content", [])Usage with OpenAI
Section titled “Usage with OpenAI”client = openai.OpenAI()
# Get tools from MXCPmxcp_tools = get_mxcp_tools()openai_tools = mxcp_to_openai_tools(mxcp_tools)
# Create chat completion with toolsresponse = client.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": "Get user with ID 123"}], tools=openai_tools, tool_choice="auto")
# Handle tool callsif response.choices[0].message.tool_calls: for tool_call in response.choices[0].message.tool_calls: result = call_mxcp_tool( tool_call.function.name, json.loads(tool_call.function.arguments) ) print(f"Tool result: {result}")HTTP Integration
Section titled “HTTP Integration”For HTTP transport:
import requests
MXCP_URL = "http://localhost:8000"
def call_mxcp_http(tool_name, arguments): response = requests.post( f"{MXCP_URL}/tools/call", json={"name": tool_name, "arguments": arguments} ) return response.json()
# Use with OpenAI function callingresult = call_mxcp_http("get_user", {"user_id": 123})Built-in SQL Tools
Section titled “Built-in SQL Tools”MXCP provides optional SQL exploration tools that let AI clients query your data directly:
Available Tools
Section titled “Available Tools”| Tool | Description |
|---|---|
execute_sql_query | Run custom SQL queries |
list_tables | See all available tables |
get_table_schema | Inspect table structure |
Enable SQL Tools
Section titled “Enable SQL Tools”By default, SQL tools are disabled. Enable them in your configuration:
sql_tools: enabled: trueUsage Examples
Section titled “Usage Examples”# With mcp-climcp-cli tools call list_tablesmcp-cli tools call execute_sql_query --sql "SELECT COUNT(*) FROM users"mcp-cli tools call get_table_schema --table_name "orders"AI clients can use these tools to:
- Explore available data
- Run ad-hoc queries
- Inspect table structures
Security Note: Enable SQL tools only when appropriate. Consider using policies to restrict access.
Quick Start
Section titled “Quick Start”Connect to Claude Desktop
Section titled “Connect to Claude Desktop”-
Start MXCP Server:
Terminal window cd your-projectmxcp serve --transport stdio -
Configure Claude Desktop:
{"mcpServers": {"my-project": {"command": "mxcp","args": ["serve", "--transport", "stdio"],"cwd": "/path/to/your-project"}}} -
Restart Claude Desktop and start using your tools.
Use dbt for Data Preparation
Section titled “Use dbt for Data Preparation”-
Enable dbt:
mxcp-site.yml dbt:enabled: true -
Generate Config:
Terminal window mxcp dbt-config -
Run Models:
Terminal window mxcp dbt run
Access External Data with DuckDB
Section titled “Access External Data with DuckDB”-
Enable Extensions:
mxcp-site.yml extensions:- httpfs- postgres -
Query Remote Data:
SELECT * FROM read_parquet('s3://bucket/data.parquet');
Transport Modes
Section titled “Transport Modes”MXCP supports multiple transport protocols:
stdio (Default)
Section titled “stdio (Default)”Direct process communication:
mxcp serve --transport stdioBest for:
- Claude Desktop
- Local development
- Process-based clients
Streamable HTTP
Section titled “Streamable HTTP”HTTP with server-sent events for streaming:
mxcp serve --transport streamable-http --port 8000Best for:
- Web applications
- Custom integrations
- Streaming responses
SSE (Server-Sent Events) - Deprecated
Section titled “SSE (Server-Sent Events) - Deprecated”Legacy SSE transport (deprecated in MCP protocol version 2025-03-26):
mxcp serve --transport sse --port 8000Use only for:
- Backwards compatibility with older MCP clients
- Prefer
streamable-httpfor new integrations
Additional Options
Section titled “Additional Options”# Enable/disable built-in SQL toolsmxcp serve --sql-tools true
# Read-only database modemxcp serve --readonly
# Stateless mode for serverless deploymentsmxcp serve --statelessCustom Integrations
Section titled “Custom Integrations”Direct MCP Protocol
Section titled “Direct MCP Protocol”For custom clients, implement the MCP protocol:
import subprocessimport json
# Start MXCP serverprocess = subprocess.Popen( ["mxcp", "serve", "--transport", "stdio"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True, cwd="/path/to/project")
# Send MCP requestrequest = { "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}
process.stdin.write(json.dumps(request) + "\n")process.stdin.flush()
# Read responseresponse = json.loads(process.stdout.readline())print(response)HTTP API
Section titled “HTTP API”For HTTP mode, use standard REST calls:
import requests
# List toolstools = requests.get("http://localhost:8000/tools").json()
# Call a toolresult = requests.post( "http://localhost:8000/tools/call", json={ "name": "get_user", "arguments": {"user_id": 123} }).json()mcp-cli
Section titled “mcp-cli”Use the MCP command-line tool:
# Installpip install mcp-cli
# Configurecat > server_config.json << 'EOF'{ "mcpServers": { "local": { "command": "mxcp", "args": ["serve", "--transport", "stdio"], "cwd": "/path/to/project" } }}EOF
# List toolsmcp-cli tools list
# Call toolmcp-cli tools call get_user --user_id 123Debugging Integrations
Section titled “Debugging Integrations”Enable Debug Logging
Section titled “Enable Debug Logging”# Environment variableexport MXCP_DEBUG=true
# CLI flagmxcp serve --debugCheck Server Status
Section titled “Check Server Status”# List endpointsmxcp list
# Validate configurationmxcp validate
# Run testsmxcp testClaude Desktop Logs
Section titled “Claude Desktop Logs”Access Claude Desktop’s developer console to see:
- Connection status
- Request/response logs
- Error messages
Next Steps
Section titled “Next Steps”- Claude Desktop - Detailed setup
- dbt - Data transformation
- DuckDB - SQL engine and extensions