kshayk/avibase-mcp-server
If you are the rightful owner of avibase-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Bird Data API Server is a RESTful API server designed for querying comprehensive bird data using JSONata, providing detailed taxonomic, conservation, and geographic information.
🦅 Bird Data API Server
A comprehensive RESTful API server for querying bird data using JSONata. This MCP (Model Context Protocol) server provides powerful querying capabilities over a comprehensive bird dataset with taxonomic, conservation, and geographic information.
📋 Table of Contents
- Features
- Installation
- Quick Start
- API Documentation
- Usage Examples
- Query Engine
- Development
- Contributing
- License
✨ Features
- Comprehensive Bird Database: Access to extensive bird data including taxonomic classifications, conservation status, and geographic ranges
- JSONata Query Engine: Powerful query capabilities using JSONata expressions
- RESTful API: Well-structured REST endpoints with consistent response formats
- Pagination Support: Built-in pagination for large result sets
- Rate Limiting: Protection against abuse with configurable rate limits
- Search Capabilities: Name-based search (exact and partial matching)
- Taxonomic Queries: Query by Order, Family, and taxonomic rank
- Conservation Status: Filter by IUCN Red List categories
- Geographic Filtering: Search by geographic range
- Custom Queries: Build complex queries with multiple filters
- Random Sampling: Get random bird samples for discovery
- Security: Helmet.js security headers and CORS support
🚀 Installation
Prerequisites
- Node.js (version 14 or higher)
- npm or yarn package manager
Setup
-
Clone the repository:
git clone <repository-url> cd mcp-server -
Install dependencies:
npm install -
Ensure data file exists: Make sure
birdIndex.jsonis present in the root directory with your bird data. -
Start the server:
npm startFor development with higher rate limits:
node server.js --dev
The server will start on port 3022 by default.
🏃♂️ Quick Start
Once the server is running, you can access:
- API Documentation: http://localhost:3022/api/docs
- Health Check: http://localhost:3022/api/health
- Dataset Statistics: http://localhost:3022/api/stats
Basic Examples
# Get dataset statistics
curl http://localhost:3022/api/stats
# Search for eagles
curl "http://localhost:3022/api/search?q=eagle"
# Get critically endangered species
curl http://localhost:3022/api/conservation/CR
# Get birds from Madagascar
curl "http://localhost:3022/api/range?region=Madagascar"
📚 API Documentation
Base URL
http://localhost:3022/api
Response Format
All API responses follow this structure:
{
"success": true,
"message": "Success message",
"timestamp": "2024-01-01T00:00:00.000Z",
"data": "response data",
"pagination": {
"currentPage": 1,
"totalItems": 100,
"itemsPerPage": 50,
"totalPages": 2,
"hasNext": true,
"hasPrev": false
}
}
Endpoints
GET /api/stats
Get comprehensive dataset statistics.
GET /api/search
Search birds by scientific or common name.
Parameters:
q(required): Search termexact(optional):truefor exact match,falsefor partial (default:false)page(optional): Page number (default: 1)limit(optional): Items per page (default: 50)
GET /api/taxonomy/:level/:value
Get birds by taxonomic classification.
Parameters:
level:Order,Family, orTaxon_rankvalue: The taxonomic value to filter bypage,limit: Pagination parameters
GET /api/conservation/:category
Get birds by IUCN Red List category.
Parameters:
category: IUCN category (e.g.,CR,EN,VU,LC,NT,DD,EX)page,limit: Pagination parameters
GET /api/range
Get birds by geographic range.
Parameters:
region(required): Geographic region to searchpage,limit: Pagination parameters
GET /api/extinct
Get all extinct or possibly extinct species.
Parameters:
page,limit: Pagination parameters
GET /api/authority
Get birds described by a specific authority.
Parameters:
name(required): Authority name to search forpage,limit: Pagination parameters
GET /api/random
Get random sample of birds.
Parameters:
count(optional): Number of birds to return (default: 10, max: 100)
GET /api/bird/:scientificName
Get detailed report for a specific bird.
Parameters:
scientificName: URL-encoded scientific name
POST /api/custom
Execute custom query with multiple filters.
Request Body:
{
"filters": {
"Field": "value",
"AnotherField": ["value1", "value2"],
"PartialField": "partial*match"
},
"page": 1,
"limit": 50
}
POST /api/query
Execute raw JSONata query.
Request Body:
{
"query": "$[Order = 'Strigiformes']",
"page": 1,
"limit": 50
}
GET /api/unique/:field
Get unique values for a specific field.
Parameters:
field: Field name to get unique values forpage,limit: Pagination parameters
💡 Usage Examples
JavaScript/Node.js
const fetch = require('node-fetch');
// Search for owls
async function searchOwls() {
const response = await fetch('http://localhost:3022/api/search?q=owl&limit=5');
const data = await response.json();
console.log(`Found ${data.pagination.totalItems} owls`);
return data.data;
}
// Get endangered species
async function getEndangeredSpecies() {
const response = await fetch('http://localhost:3022/api/conservation/EN');
const data = await response.json();
return data.data;
}
// Custom query example
async function customQuery() {
const response = await fetch('http://localhost:3022/api/custom', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
filters: {
Order: 'Passeriformes',
IUCN_Red_List_Category: ['CR', 'EN']
},
limit: 10
})
});
const data = await response.json();
return data.data;
}
Python
import requests
# Search for birds
def search_birds(query, exact=False):
params = {'q': query, 'exact': str(exact).lower()}
response = requests.get('http://localhost:3022/api/search', params=params)
return response.json()
# Get birds by family
def get_family_birds(family):
response = requests.get(f'http://localhost:3022/api/taxonomy/Family/{family}')
return response.json()
# Execute JSONata query
def execute_query(query_string):
data = {'query': query_string}
response = requests.post('http://localhost:3022/api/query', json=data)
return response.json()
curl Examples
# Get all orders
curl "http://localhost:3022/api/unique/Order"
# Get birds from a specific family
curl "http://localhost:3022/api/taxonomy/Family/Accipitridae"
# Get detailed information about a specific bird
curl "http://localhost:3022/api/bird/Aquila%20chrysaetos"
# Complex JSONata query
curl -X POST "http://localhost:3022/api/query" \
-H "Content-Type: application/json" \
-d '{"query": "$[Order=\"Strigiformes\" and IUCN_Red_List_Category=\"CR\"]"}'
🔧 Query Engine
The BirdQueryEngine class provides the core functionality:
Key Methods
searchByName(term, exact): Search by scientific or common namesgetByTaxonomy(level, value): Filter by taxonomic classificationgetByIUCNCategory(category): Filter by conservation statusgetByRange(region): Filter by geographic rangegetExtinctSpecies(): Get extinct speciesgetByAuthority(authority): Filter by naming authoritygetRandomSample(count): Get random samplecustomQuery(filters): Build complex queriesexecuteQuery(jsonataQuery): Execute raw JSONata queriesgetBirdReport(scientificName): Get comprehensive bird report
JSONata Examples
// Get all critically endangered raptors
"$[Order='Accipitriformes' and IUCN_Red_List_Category='CR']"
// Count species by family
"Family^(count($))"
// Get birds with specific characteristics
"$[Range ~> /.*Madagascar.*/ and Taxon_rank='species']"
🛠️ Development
Project Structure
mcp-server/
├── server.js # Main Express.js server
├── birdQueryEngine.js # Core query engine using JSONata
├── birdIndex.json # Bird data file
├── package.json # Dependencies and scripts
└── README.md # This file
Running in Development Mode
node server.js --dev
Development mode provides:
- Higher rate limits (1000 vs 100 requests per 15 minutes)
- Additional debugging information
Testing the Interactive CLI
node birdQueryEngine.js
This will run an interactive demonstration of the query engine capabilities.
🔒 Security Features
- Helmet.js: Security headers for protection against common vulnerabilities
- CORS: Cross-origin resource sharing configuration
- Rate Limiting: 100 requests per 15 minutes per IP (1000 in dev mode)
- Input Validation: Request parameter validation
- Error Handling: Secure error responses without sensitive information exposure
📊 Data Schema
The bird data includes fields such as:
Scientific_name: Scientific name of the birdEnglish_name_*: Common names from various sourcesOrder,Family: Taxonomic classificationTaxon_rank: Taxonomic rank (species, subspecies, etc.)IUCN_Red_List_Category: Conservation statusRange: Geographic distributionAuthority: Naming authorityExtinct_or_possibly_extinct: Extinction status- URLs for additional resources
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the ISC License - see the LICENSE file for details.
🙏 Acknowledgments
- Bird data sourced from comprehensive ornithological databases
- JSONata for powerful JSON querying capabilities
- Express.js ecosystem for robust web server framework