This is a mcp server Calculate celestial object positions and rise/set times
Project description
mcp-stargazing
Calculate the altitude, rise, and set times of celestial objects (Sun, Moon, planets, stars, and deep-space objects) for any location on Earth, with optional light pollution analysis.
Features
- Altitude/Azimuth Calculation: Get elevation and compass direction for any celestial object.
- Rise/Set Times: Determine when objects appear/disappear above the horizon.
- Light Pollution Analysis: Load and analyze light pollution maps (GeoTIFF format).
- Code Execution Ready:
- Serializable Returns: All tools return JSON-serializable data (ISO strings for dates), making them directly usable by LLMs.
- Pagination:
analysis_areasupports paging (page,page_size) to handle large datasets efficiently. - Standardized Responses: Uniform response format
{ "data": ..., "_meta": ... }for better observability and error handling.
- Performance:
- Async Execution: Non-blocking celestial calculations.
- Caching: Intelligent caching for Simbad queries and regional analysis.
- Proxy Support: Native support for HTTP/HTTPS proxies (useful for downloading astronomical data).
- Time Zone Aware: Works with local or UTC times.
Installation
This project uses uv for dependency management.
-
Install
uv:pip install uv
-
Sync dependencies:
uv syncThis will create a virtual environment in
.venvand install all dependencies defined inpyproject.toml. -
Activate the environment:
source .venv/bin/activate
MCP Server Usage
Start the MCP server to expose tools to AI agents or other clients.
1. Environment Setup
Create a .env file or export variables:
# Required for weather tools
export QWEATHER_API_KEY="your_api_key"
# Optional: Proxy for downloading astronomical data (Simbad/IERS)
# Highly recommended if you are in a restricted network environment
export HTTP_PROXY="http://127.0.0.1:7890"
export HTTPS_PROXY="http://127.0.0.1:7890"
2. Start Server
Streamable HTTP (SHTTP) mode (Recommended for most agents):
# Basic start
python -m src.main --mode shttp --port 3001 --path /shttp
# With proxy explicitly passed (overrides env vars)
python -m src.main --mode shttp --port 3001 --path /shttp --proxy http://127.0.0.1:7890
SSE mode:
python -m src.main --mode sse --port 3001 --path /sse
3. Response Format
All tools return data in a standardized JSON format:
{
"data": {
// Tool-specific return data
"altitude": 45.5,
"azimuth": 180.0
},
"_meta": {
"version": "1.0.0",
"status": "success"
}
}
4. Available Tools
get_celestial_pos: Calculate altitude/azimuth.get_celestial_rise_set: Calculate rise/set times (Returns ISO strings).get_weather_by_name/get_weather_by_position: Fetch current weather.get_local_datetime_info: Get current local time information.analysis_area: Find best stargazing spots in a region.- Inputs:
top_left,bottom_right,time,page,page_size. - Returns: List of spots with viewing conditions, plus pagination metadata (
total,resource_id).
- Inputs:
Examples
-
Orchestration:
python examples/code_execution_orchestration.py- Demonstrates a full workflow: Get time -> Get Celestial Pos -> Check Weather -> Find Spots.
- Shows how to handle the standardized response format programmatically.
-
Pagination:
python examples/pagination_demo.py- Demonstrates fetching large result sets page by page using the
resource_id.
- Demonstrates fetching large result sets page by page using the
Project Structure
The project is modularized for better maintainability and code execution support:
.
├── src/
│ ├── functions/ # Tool implementations grouped by domain
│ │ ├── celestial/ # Celestial calculations (pos, rise/set)
│ │ ├── weather/ # Weather API integration
│ │ ├── places/ # Location and area analysis
│ │ └── time/ # Time utilities
│ ├── cache.py # Caching logic for analysis results
│ ├── response.py # Standardized response formatting
│ ├── server_instance.py # FastMCP server instance (avoids circular imports)
│ ├── main.py # Entry point and tool registration
│ ├── celestial.py # Core astronomy logic (Astropy wrappers)
│ ├── placefinder.py # Grid analysis logic
│ └── qweather_interaction.py # Weather API client
├── tests/ # Unified test suite
│ ├── test_celestial.py
│ ├── test_weather.py
│ ├── test_serialization.py # Validates JSON return formats
│ └── test_integration.py # End-to-end flow tests
├── examples/ # Usage examples
├── docs/ # Documentation and improvement plans
└── pyproject.toml # Project configuration and dependencies
Testing
Run the unified test suite:
pytest tests/
Key tests include:
test_serialization.py: Ensures all tools return valid JSON with the correct schema.test_integration.py: Mocks external APIs to verify the entire toolchain.
Contributing
- Follow the Code Execution with MCP best practices.
- Ensure all new tools return standard JSON responses using
src.response.format_response. - Add tests in
tests/for any new functionality.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_stargazing-0.1.6.tar.gz.
File metadata
- Download URL: mcp_stargazing-0.1.6.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0567bde87fbc403a5abe64a7b0b2de2049ef9e498d75c0af289dd0edb0e1e6a
|
|
| MD5 |
61db9cda9ef17d0ce51e2abe4a5861ad
|
|
| BLAKE2b-256 |
2fd96bc704cc715dea3b5955bd7b06e47bfbf957ed075458be3804fb44daa770
|
File details
Details for the file mcp_stargazing-0.1.6-py3-none-any.whl.
File metadata
- Download URL: mcp_stargazing-0.1.6-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06a6686e0a98327b304fefb8ddc4758b887058fe6c507daaaecd1df88aa948f6
|
|
| MD5 |
e664184273adb3c013b25ec643a3027c
|
|
| BLAKE2b-256 |
a81f1e8962c12f691c19661bf90400860364046f94d36070b7d52777a4a4c806
|