query_ipl_data
Query IPL cricket data using natural language to get player statistics, team performances, and match results from the dataset.
Instructions
Query IPL cricket data using natural language. Examples: - 'Show me all matches in the dataset' - 'Which team won the most matches?' - 'Who scored the most runs across all matches?' - 'What was the highest total score?' - 'Show matches played in Mumbai' - 'Who has the best bowling figures?' - 'Show me Virat Kohli batting stats' - 'What's the average first innings score?' - 'Show me all centuries scored' - 'Which venue has the highest scoring matches?'
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Natural language query about IPL cricket data |
Implementation Reference
- src/mcp_server/server.py:54-68 (handler)Tool call handler in the MCP server that routes 'query_ipl_data' to the QueryEngine.
@self.server.call_tool() async def handle_call_tool(name: str, arguments: Dict[str, Any]) -> List[TextContent]: """Handle tool calls""" if name == "query_ipl_data": query = arguments.get("query", "") if not query: return [TextContent(type="text", text="Please provide a query.")] try: result = self.query_engine.process_query(query) return [TextContent(type="text", text=result)] except Exception as e: return [TextContent(type="text", text=f"Error processing query: {str(e)}")] return [TextContent(type="text", text=f"Unknown tool: {name}")] - src/mcp_server/query_engine.py:111-133 (handler)The core logic that parses the query using regex patterns and dispatches it to the appropriate data handling method.
def process_query(self, query: str) -> str: """Process natural language query and return formatted results""" query_lower = query.lower().strip() # Try to match query patterns for pattern_info in self.query_patterns: pattern = pattern_info['pattern'] handler = pattern_info['handler'] match = re.search(pattern, query_lower) if match: try: # Extract parameters from regex groups if any groups = match.groups() params = [g.strip() if g else None for g in groups if g and g.strip()] result = handler(*params) if params else handler() return self.format_result(result, pattern_info['description']) except Exception as e: return f"Error executing query: {str(e)}" # If no pattern matches, try to handle as a general query return self.handle_general_query(query) - src/mcp_server/server.py:26-51 (schema)Tool definition, including schema and description.
Tool( name="query_ipl_data", description="""Query IPL cricket data using natural language. Examples: - 'Show me all matches in the dataset' - 'Which team won the most matches?' - 'Who scored the most runs across all matches?' - 'What was the highest total score?' - 'Show matches played in Mumbai' - 'Who has the best bowling figures?' - 'Show me Virat Kohli batting stats' - 'What's the average first innings score?' - 'Show me all centuries scored' - 'Which venue has the highest scoring matches?' """, inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "Natural language query about IPL cricket data" } }, "required": ["query"] } )