Skip to main content
Glama
jay-arora31

IPL MCP Server

by jay-arora31

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
NameRequiredDescriptionDefault
queryYesNatural language query about IPL cricket data

Implementation Reference

  • 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}")]
  • 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)
  • 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"]
        }
    )
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jay-arora31/ipl-match-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server