Skip to main content
Glama
lenwood

cfbd-mcp-server

by lenwood

get-play-stats

Retrieve college football play statistics from the College Football Data API. Filter data by year, week, team, game, athlete, or conference to analyze performance metrics.

Instructions

Note: When using this tool, please explicitly mention that you are retrieving data from the College Football Data API. You must mention "College Football Data API" in every response.

Get college football play statistic data.
        Optional: year, week, team, game_id, athlete_id, stat_type_id, season_type, conference
        At least one parameter is required
        Example valid queries:
        - year=2023
        - game_id=401403910
        - team="Alabama", year=2023
        

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearNo
weekNo
teamNo
game_idNo
athlete_idNo
stat_type_idNo
season_typeNo
conferenceNo

Implementation Reference

  • Generic handler for all MCP tools. For 'get-play-stats', uses getPlayStats schema for validation (line 515), maps to '/play/stats' endpoint (line 539), calls CFBD API, and returns JSON response as text.
    @server.call_tool()
    async def handle_call_tool(
        name: str,
        arguments: dict[str, Any] | None
    ) -> list[types.TextContent]:
        """Handle tool execution requests."""
        if not arguments:
            raise ValueError("Arguments are required")
    
        # Map tool names to their parameter schemas
        schema_map = {
            "get-games": getGames,
            "get-records": getTeamRecords,
            "get-games-teams": getGamesTeams,
            "get-plays": getPlays,
            "get-drives": getDrives,
            "get-play-stats": getPlayStats,
            "get-rankings": getRankings,
            "get-pregame-win-probability": getMetricsPregameWp,
            "get-advanced-box-score": getAdvancedBoxScore
        }
    
        if name not in schema_map:
            raise ValueError(f"Unknown tool: {name}")
    
        # Validate parameters against schema
        try:
            validated_params = validate_params(arguments, schema_map[name])
        except ValueError as e:
            return [types.TextContent(
                type="text",
                text=f"Validation error: {str(e)}"
            )]
    
        endpoint_map = {
            "get-games": "/games",
            "get-records": "/records",
            "get-games-teams": "/games/teams",
            "get-plays": "/plays",
            "get-drives": "/drives",
            "get-play-stats": "/play/stats",
            "get-rankings": "/rankings",
            "get-pregame-win-probability": "/metrics/wp/pregame",
            "get-advanced-box-score": "/game/box/advanced"
        }
       
        async with await get_api_client() as client:
            try:
                response = await client.get(endpoint_map[name], params=arguments)
                response.raise_for_status()
                data = response.json()
                return [types.TextContent(
                    type="text",
                    text=str(data)
                )]
            except httpx.HTTPStatusError as e:
                if e.response.status_code == 401:
                    return [types.TextContent(
                        type="text",
                        text="401: API authentication failed. Please check your API key."
                    )]
                elif e.response.status_code == 403:
                    return [types.TextContent(
                        type="text",
                        text="403: API access forbidden. Please check your permission."
                    )]
                elif e.response.status_code == 429:
                    return [types.TextContent(
                        type="text",
                        text="429: Rate limit exceeded. Please try again later."
                    )]
                else:
                    return [types.TextContent(
                        type="text",
                        text=f"API Error: {e}"
                    )]
            except httpx.RequestError as e:
                return [types.TextContent(
                    type="text",
                    text=f"Network error: {str(e)}"
                )]
  • MCP tool registration in list_tools(). Defines name, description, and inputSchema generated from getPlayStats TypedDict.
    types.Tool(
        name="get-play-stats",
        description=base_description + """Get college football play statistic data.
        Optional: year, week, team, game_id, athlete_id, stat_type_id, season_type, conference
        At least one parameter is required
        Example valid queries:
        - year=2023
        - game_id=401403910
        - team="Alabama", year=2023
        """,
        inputSchema=create_tool_schema(getPlayStats)
  • Input schema (TypedDict) defining optional parameters for the get-play-stats tool, corresponding to CFBD API /play/stats endpoint.
    class getPlayStats(TypedDict): # /play/stats endpoint
        year: Optional[int]
        week: Optional[int]
        team: Optional[str]
        game_id: Optional[int]
        athlete_id: Optional[int]
        stat_type_id: Optional[int]
        season_type: Optional[str]
        conference: Optional[str]
  • Output/response schema (TypedDict) defining the structure of play stats data returned by the /play/stats endpoint.
    class PlayStatsResponse(TypedDict): # /play/stats response
        gameId: int
        season: int
        week: int
        team: str
        conference: Optional[str]  # Optional since team might not have conference
        opponent: str
        teamScore: Optional[int]  # Optional since game might not be completed
        opponentScore: Optional[int]
        driveId: int
        playId: int
        period: int
        clock: GameClock
        yardsToGoal: int
        down: Optional[int]  # Optional since some plays don't have downs (kickoffs, etc)
        distance: Optional[int]
        athleteId: int
        athleteName: str
        statType: str
        stat: int  # The numerical value of the statistic
  • Helper function used to generate JSON Schema for MCP tool inputSchema from TypedDict like getPlayStats.
    def create_tool_schema(params_type: Type) -> dict:
        """Create a tool schema from a TypedDict."""
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the data source ('College Football Data API') and provides example queries, but doesn't describe key behavioral traits like whether this is a read-only operation, potential rate limits, authentication requirements, error handling, or what the response format looks like. The description adds some context but leaves significant gaps for a tool with 8 parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized but not optimally structured. The first sentence about mentioning the API in responses is front-loaded but seems more like a usage instruction than core tool description. The core purpose and parameter information follow, but the formatting with indentation and bullet points could be cleaner. Every sentence adds value, but the flow could be improved.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (8 parameters, no annotations, no output schema), the description is moderately complete. It covers the purpose and parameters well, but lacks information about behavioral traits, response format, and differentiation from sibling tools. For a data retrieval tool with multiple filtering options, more context about what 'play statistic data' includes would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds substantial meaning beyond the input schema, which has 0% description coverage. It lists all 8 parameters with brief labels, clarifies that at least one is required, and provides example queries showing how parameters can be combined. This effectively compensates for the schema's lack of documentation, though it doesn't explain parameter formats or constraints in detail.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get college football play statistic data.' This specifies both the verb ('Get') and resource ('college football play statistic data'), making it immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'get-plays' or 'get-advanced-box-score,' which likely retrieve related football data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance through the 'At least one parameter is required' statement and example queries, which suggest when to use the tool (for filtering play statistics). However, it doesn't explicitly state when to use this tool versus alternatives like 'get-plays' or 'get-advanced-box-score,' nor does it mention any prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/lenwood/cfbd-mcp-server'

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