MCP Server + Flight + XGBoost
Overview
In this example, we’ll create: - A Claude integration with MCP server that can access the sentiment analysis capabilities - A sentiment analysis model server using Arrow Flight using UDFs with xorq - a XGBoost UDF with pre-trained model that will be served by Flight
This pattern enables AI assistants like Claude to access specialized machine learning models while maintaining a conversational interface, expanding Claude’s capabilities beyond its training data.
Demo
Watch this demonstration of the MCP server with Claude in action:
Try It Yourself
The complete source code for this example is available in the xorq GitHub repository: mcp_flight_server.py
How It Works
sequenceDiagram
participant U as User
participant C as Claude
participant MCP as MCP Server
participant FS as Flight Service
U->>C: "How positive is this headline?"
C->>MCP: Request sentiment analysis
Note right of MCP: Input mapping
MCP->>FS: Transform text and predict
FS-->>MCP: Return sentiment score
Note right of MCP: Output mapping
MCP-->>C: Return formatted results
C-->>U: "The headline has a sentiment score of 1 (positive)"
MCP Server: The example initializes a specialized Flight server with a Model Control Protocol (MCP) server. This provides a standardized way for Claude to interact with the ML model.
Flight Service: The server loads two pre-trained models:
- A TF-IDF vectorizer to transform text data
- An XGBoost regression model trained to predict sentiment scores
Input/Output Mappers: Custom functions translate between Claude’s natural language requests and the ML model’s required format, then transform the model outputs back into a Claude-friendly response.
Next Steps
Try modifying this example to: - Create a more complex input mapping to handle various types of user queries