system32miro/api-into-mcp
If you are the rightful owner of api-into-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project is a dual-purpose REST API that serves both traditional REST clients and AI agents through MCP integration, providing European football data.
ā½ Football API + MCP Server
Dual-Purpose REST API built from scratch for querying European football data - serves both traditional REST clients and AI agents through MCP integration.
šÆ Unique Dual Architecture
This project demonstrates a groundbreaking approach: a single FastAPI application that simultaneously serves as:
- š Traditional REST API - For web applications, mobile apps, and standard HTTP clients
- š¤ MCP Server - For AI agents (Claude, Cursor, Windsurf) with intelligent semantic tools
- š Real-time SSE - Server-Sent Events for seamless AI agent connectivity
Built from scratch with production-ready architecture, this API showcases how modern applications can bridge traditional web development with AI agent ecosystems.
š Revolutionary Use Cases
For Traditional Development
# Standard REST API calls
curl http://localhost:8000/api/v1/teams?search=manchester
curl http://localhost:8000/api/v1/matches?league_id=1
For AI Agents
"Show me Manchester City's latest matches"
"What's the current Premier League standings?"
"How many goals did Barcelona score this season?"
Same data, same API - different interaction paradigms!
š¤ MCP Functionality
This API includes an integrated MCP server that allows AI agents (like Claude, Cursor, etc.) to directly access football data through intelligent semantic tools.
⨠MCP Capabilities
- š Intelligent search for teams, players and matches
- š Automated statistics queries
- š Real-time standings analysis
- šÆ Automatic filters by league, team, matchday
- š Complex data aggregation
- š¤ Native integration with IDEs and AI agents
š MCP Endpoint
- MCP URL:
http://localhost:8000/mcp
- Protocol: Server-Sent Events (SSE)
- Tools: 6 automatic tools generated from API endpoints
š Available Data
- 5 Main Leagues: Premier League, La Liga, Serie A, Bundesliga, Ligue 1
- 96 Teams with complete information
- 3150 Players with personal data and positions
- 1752 Matches with results and statistics
- Updated standings for all leagues
- Stadiums, Coaches and Referees
š How to Run
Method 1: Directly with Python
# Install dependencies (includes fastapi-mcp)
pip install -r requirements.txt
# Configure environment variables (optional)
cp .env.example .env
# Run API with integrated MCP
uvicorn app.main:app --reload
# Access API at: http://localhost:8000
# Access MCP at: http://localhost:8000/mcp
Method 2: With Docker (Development)
# Build and run
docker-compose up --build
# Access API at: http://localhost:8000
# Access MCP at: http://localhost:8000/mcp
Method 3: Production Deploy
# Configure variables for production
export ENVIRONMENT=production
export ALLOWED_ORIGINS=https://yourdomain.com
export LOG_LEVEL=WARNING
export ENABLE_DOCS=false
# Deploy with production docker-compose
docker-compose -f docker-compose.prod.yml up -d
# Monitor logs
docker-compose -f docker-compose.prod.yml logs -f
š¤ MCP Configuration for IDEs
Cursor / Windsurf
Add to ~/.cursor/mcp.json
or ~/.windsurf/mcp.json
:
{
"mcpServers": {
"football-api-mcp": {
"url": "http://localhost:8000/mcp"
}
}
}
Claude Desktop
Add to Claude configuration file:
{
"mcpServers": {
"football-api-mcp": {
"url": "http://localhost:8000/mcp"
}
}
}
Other MCP Clients
For clients that don't support SSE directly, use mcp-remote
:
{
"mcpServers": {
"football-api-mcp": {
"command": "npx",
"args": [
"mcp-remote",
"http://localhost:8000/mcp"
]
}
}
}
š ļø Available MCP Tools
1. health_check
Check API status and database connectivity
2. get_leagues_api_v1_leagues__get
Get all available European leagues
3. get_teams_api_v1_teams__get
Search teams with filters and pagination
- Parameters:
search
,league_id
,page
,size
4. get_team_api_v1_teams__team_id__get
Get complete details of a specific team
5. get_matches_api_v1_matches__get
Query matches with advanced filters
- Parameters:
league_id
,team_id
,matchday
,winner
,page
,size
Each tool includes complete documentation and JSON schemas to facilitate AI agent understanding.
š§ Production Configuration
Environment Variables
Copy .env.example
to .env
and configure:
ENVIRONMENT=production
ALLOWED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com
DATABASE_PATH=sports_league.sqlite
LOG_LEVEL=WARNING
API_VERSION=1.0.0
ENABLE_DOCS=false # Disable in production
MAX_PAGE_SIZE=100
DEFAULT_PAGE_SIZE=20
Deploy Checklist
- Configure CORS for specific domains
- Disable documentation in production (
ENABLE_DOCS=false
) - Configure appropriate logging (
LOG_LEVEL=WARNING
) - Configure SSL/HTTPS
- Implement reverse proxy (Nginx)
- Configure database backup
- Configure monitoring
- Test MCP connectivity in production
š API Documentation
- Swagger UI: http://localhost:8000/docs (development only)
- ReDoc: http://localhost:8000/redoc (development only)
- Health Check: http://localhost:8000/api/v1/health
- MCP Server: http://localhost:8000/mcp
š Main Endpoints
Leagues
GET /api/v1/leagues
- List all leaguesGET /api/v1/leagues/{id}
- League detailsGET /api/v1/leagues/{id}/teams
- Teams in a leagueGET /api/v1/leagues/{id}/standings
- League standings
Teams
GET /api/v1/teams
- List teams (with pagination and search)GET /api/v1/teams/{id}
- Team detailsGET /api/v1/teams/{id}/players
- Team playersGET /api/v1/teams/{id}/matches
- Team matchesGET /api/v1/teams/{id}/statistics
- Team statistics
Matches
GET /api/v1/matches
- List matches (with filters and pagination)GET /api/v1/matches/{id}
- Match detailsGET /api/v1/matches/upcoming
- Upcoming matches
š Filters and Search
Pagination
?page=1&size=20
Filter by League
?league_id=1
Search by Name
?search=manchester
Match Filters
?team_id=65&winner=HOME_TEAM&matchday=1
š Usage Examples
Traditional REST API
# Get all leagues
curl http://localhost:8000/api/v1/leagues
# Search Manchester teams
curl "http://localhost:8000/api/v1/teams?search=manchester"
# Premier League standings
curl http://localhost:8000/api/v1/leagues/1/standings
# Manchester City matches
curl http://localhost:8000/api/v1/teams/65/matches
Through MCP Agent (Cursor/Claude)
"How many teams are in the Premier League?"
"Show me Manchester City's details"
"What's the current La Liga standings?"
"How many goals did Barcelona score this season?"
The agent will automatically use MCP tools to answer the questions!
š ļø Technologies
- FastAPI - Modern and fast web framework
- FastAPI-MCP - Native MCP integration
- Pydantic - Data validation
- SQLite - Lightweight and portable database
- Uvicorn - ASGI server
- Docker - Containerization
- MCP Protocol - Model Context Protocol for AI agents
š Project Structure
api/
āāā app/
ā āāā main.py # Main application + MCP Server
ā āāā config.py # Configuration and environment variables
ā āāā logging_config.py # Logging configuration
ā āāā database.py # SQLite connection
ā āāā models.py # Pydantic models
ā āāā utils.py # Utilities (pagination, filters)
ā āāā routers/ # Organized endpoints
ā āāā leagues.py
ā āāā matches.py
ā āāā teams.py
āāā requirements.txt # Python dependencies (includes fastapi-mcp)
āāā Dockerfile # Docker configuration
āāā docker-compose.yml # Development
āāā docker-compose.prod.yml # Production
āāā .env.example # Configuration example
āāā README.md # This file
āāā sports_league.sqlite # Database
šÆ Features
ā
Complete REST API with automatic documentation
ā
Integrated MCP server for AI agents
ā
6 MCP tools automatically generated
ā
Complete MCP documentation with JSON schemas
ā
SSE support for real-time connectivity
ā
Pagination for large datasets
ā
Advanced filters by league, team, matchday
ā
Text search in team names
ā
Detailed statistics for teams
ā
Data relationships (teams ā players ā matches)
ā
Configured CORS for web access
ā
Health checks for monitoring
ā
Docker ready for easy deployment
ā
Structured logging for production
ā
Environment configurations (dev/prod)
ā
Robust error handling
ā
Security with non-root user
š Security
- API is read-only (GET queries only)
- MCP Server exposed locally by default
- Data validation with Pydantic
- Consistent error handling
- Pagination limits to prevent overload
- Restricted CORS to specific domains in production
- Audit logs for all requests
- Container with non-root user
š Monitoring
- Health check endpoint:
/api/v1/health
- MCP connectivity check through health check
- Structured logs in file and stdout
- Performance metrics in logs
- Configured Docker health checks
- MCP usage tracking in logs
š¤ MCP Use Cases
For Developers
- Quick data search during development
- Statistics analysis without leaving the IDE
- Ad-hoc queries through Cursor chat
For Sports Analysts
- Automated comparative analyses
- Data-driven report generation
- Pattern identification through AI
For Journalists
- Quick fact verification
- Statistics gathering for articles
- Contextual queries about teams and players
š Sample Data
The API contains real data from the 2023-2024 season of the five main European leagues, including:
- Premier League: 20 teams, ~380 matches
- La Liga: 20 teams, ~380 matches
- Serie A: 20 teams, ~380 matches
- Bundesliga: 18 teams, ~306 matches
- Ligue 1: 18 teams, ~306 matches
š Next Steps
- Add more MCP tools (advanced statistics)
- Implement cache for better performance
- Add historical data from previous seasons
- Create optional web dashboard
- Implement webhooks for real-time updates
š¤ Contributions
This project demonstrates the perfect integration between FastAPI and MCP. Feel free to fork and improve!
š License
MIT License - See LICENSE file for details.
Data Source: Kaggle - Football Data European Top 5 Leagues
Powered by: FastAPI + FastAPI-MCP