A Model Context Protocol (MCP) server that provides real-time sports scores, schedules, and game information from ESPN's sports API. This server enables AI assistants to answer questions about game results, schedules, team performance, and sports outcomes across professional and college leagues.
- π Live Scores & Results: Get real-time scores and final results for games
- π Schedule Information: View upcoming games and past game results
- π Comprehensive League Coverage: Support for 27+ sports leagues
- π Detailed Game Data: Team stats, venue information, broadcast details, and more
- π§ MCP Compatible: Works with any MCP-compatible AI assistant
This project relies on ESPN's undocumented API. The ESPN API used by this server is not officially documented or supported by ESPN. As such:
- The API may change without notice, potentially breaking functionality
- The API could become inaccessible or restricted at any time
- There are no guarantees of service availability or data accuracy
- Use this project at your own risk for non-commercial purposes
This is an unofficial tool built for educational and personal use.
- .NET 8.0 SDK or later
- MCP-compatible client (e.g., Claude Desktop, Cline, etc.)
git clone <repository-url>
cd sports-mcp
dotnet buildCopy the example configuration and update with the ESPN API endpoint:
cp appsettings.example.json appsettings.jsonEdit appsettings.json:
{
"SportsApi": {
"BaseUrl": "http://site.api.espn.com/apis/site/v2"
}
}Add the server to your MCP client configuration. For Claude Desktop, edit your claude_desktop_config.json:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"sports": {
"command": "dotnet",
"args": [
"run",
"--project",
"C:\\path\\to\\sports-mcp\\sports-mcp.csproj"
]
}
}
}Restart your MCP client after updating the configuration.
Once configured, you can ask your AI assistant natural language questions about sports:
- "What were the NBA scores yesterday?"
- "Show me today's NFL games"
- "Who won the Lakers game last night?"
- "What's the schedule for Premier League this weekend?"
- "Give me the scores for all NBA games on January 25, 2026"
Retrieves sports scores, schedules, and game information.
Parameters:
sport(required): The sport type (Football, Basketball, Soccer, Baseball, Hockey, Tennis, Golf, Racing)league(required): The specific league or competitiondate(optional): The date for results or schedule (ISO format: YYYY-MM-DD). Defaults to current date if omitted.
Returns:
- List of games/events with scores, team information, status, venue, and broadcast details
- League information
- Team records and statistics
- Game status (scheduled, in-progress, final)
- NFL: National Football League
- CollegeFootball: NCAA College Football
- NBA: National Basketball Association
- WNBA: Women's National Basketball Association
- MenCollegeBasketball: NCAA Men's College Basketball
- WomenCollegeBasketball: NCAA Women's College Basketball
- MLB: Major League Baseball
- MenCollegeBaseball: NCAA Men's College Baseball
- EPL: English Premier League
- MLS: Major League Soccer
- UEFAChampionsLeague: UEFA Champions League
- UEFAEuropaLeague: UEFA Europa League
- NHL: National Hockey League
- MenCollegeHockey: NCAA Men's College Hockey
- WomenCollegeHockey: NCAA Women's College Hockey
- ATP: Association of Tennis Professionals
- WTA: Women's Tennis Association
- PGA: PGA Tour
- LPGA: LPGA Tour
- EuropeanTour: DP World Tour (European Tour)
- NASCAR: NASCAR Cup Series
- F1: Formula 1
{
"SportsApi": {
"BaseUrl": "http://site.api.espn.com/apis/site/v2"
}
}You can override the configuration using environment variables:
Windows (PowerShell):
$env:SportsApi__BaseUrl="http://site.api.espn.com/apis/site/v2"Windows (Command Prompt):
set SportsApi__BaseUrl=http://site.api.espn.com/apis/site/v2Linux/macOS:
export SportsApi__BaseUrl="http://site.api.espn.com/apis/site/v2"dotnet builddotnet runThe project includes a comprehensive unit test suite in the sports-mcp.Tests project. Tests are written using xUnit and cover all major components of the server.
dotnet testTo run with detailed output:
dotnet test --verbosity normalThe test suite covers:
- Sports & League enums (
Models/SportsExtensionsTests.cs,Models/LeaguesExtensionsTests.cs): Verifies everySportsandLeaguesenum value maps to the correct ESPN API path segment. - Scoreboard DTO parsing (
Models/ScoreboardDtoTests.cs): Validates JSON-to-DTO deserialization for all data classes including league info, game status, venue details, team competitors, game events, and full scoreboard responses. Edge cases such as missing optional fields, empty event lists, and international venues are tested. - HTTP client extension (
Extensions/HttpClientExtTests.cs): Tests successful JSON document retrieval, HTTP error propagation, and that request URIs are constructed correctly. - GetScoreboard tool (
Tools/SportsScoreboardToolTests.cs): End-to-end tests using a mock HTTP handler that verify the correct URL is built from sport/league/date parameters, that valid responses are deserialized and serialized as indented JSON, and that HTTP or deserialization errors produce a well-formed error JSON response.
The server communicates over stdio using the MCP protocol, so its individual components are tested in isolation:
- Static tool methods (
SportsScoreboardTool.GetScoreboard) acceptHttpClientandIOptions<SportsApiOptions>as explicit parameters, making it straightforward to supply a test double without any DI container. - HTTP layer is faked using a lightweight in-process
HttpMessageHandlersubclass. This avoids network calls and third-party mock libraries. - Configuration is supplied via
Microsoft.Extensions.Options.Options.Create(), keeping tests self-contained. - Internal types (e.g.,
HttpClientExt) are exposed to the test project through[InternalsVisibleTo("sports-mcp.Tests")]in the main project.
sports-mcp.Tests/
βββ Extensions/
β βββ HttpClientExtTests.cs # HTTP client extension tests
βββ Models/
β βββ LeaguesExtensionsTests.cs # League enum mapping tests
β βββ ScoreboardDtoTests.cs # DTO JSON parsing tests
β βββ SportsExtensionsTests.cs # Sport enum mapping tests
βββ Tools/
βββ SportsScoreboardToolTests.cs # GetScoreboard tool tests
sports-mcp/
βββ Extensions/ # HTTP client extensions
βββ Models/ # Data models and enums
β βββ Sports.cs # Sport type enums
β βββ Leagues.cs # League enums
β βββ ScoreboardDto.cs # Response DTOs
βββ Options/ # Configuration options
βββ Tools/ # MCP tool implementations
β βββ SportsScoreboardTool.cs
βββ Program.cs # Application entry point
βββ appsettings.json # Configuration file
The server returns structured JSON data including:
{
"Events": [
{
"Id": "401810505",
"Name": "Sacramento Kings at Detroit Pistons",
"ShortName": "SAC @ DET",
"Date": "2026-01-25T20:00:00Z",
"Status": {
"Clock": 0,
"DisplayClock": "0:00",
"Period": 4,
"Type": {
"State": "post",
"Completed": true,
"Detail": "Final"
}
},
"Competitors": [
{
"Team": {
"DisplayName": "Detroit Pistons",
"Abbreviation": "DET",
"Logo": "https://..."
},
"Score": "139",
"Winner": true,
"HomeAway": "home",
"Records": [...]
}
],
"Venue": {
"FullName": "Little Caesars Arena",
"Address": {
"City": "Detroit",
"State": "MI"
}
}
}
],
"League": {
"Name": "National Basketball Association",
"Abbreviation": "NBA"
}
}This error can occur if the API response structure changes or contains unexpected data. The most recent fix handles cases where scheduled games don't have a winner property yet.
- Verify the path in your MCP client configuration is correct
- Ensure .NET 8.0 SDK is installed and in your PATH
- Check that
appsettings.jsonexists and is properly configured - Restart your MCP client after configuration changes
- Check client logs for startup errors
- Verify internet connectivity
- Check if ESPN API endpoint is accessible:
http://site.api.espn.com/apis/site/v2 - Ensure no firewall is blocking the connection
This server retrieves data from ESPN's public sports API endpoints. The data is provided as-is from ESPN's services.
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to submit issues or pull requests.
- Built using the Model Context Protocol
- Sports data provided by ESPN API