mcp-stargazing 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_stargazing-0.1.6/LICENSE +21 -0
- mcp_stargazing-0.1.6/PKG-INFO +184 -0
- mcp_stargazing-0.1.6/README.md +158 -0
- mcp_stargazing-0.1.6/mcp_stargazing.egg-info/PKG-INFO +184 -0
- mcp_stargazing-0.1.6/mcp_stargazing.egg-info/SOURCES.txt +33 -0
- mcp_stargazing-0.1.6/mcp_stargazing.egg-info/dependency_links.txt +1 -0
- mcp_stargazing-0.1.6/mcp_stargazing.egg-info/entry_points.txt +2 -0
- mcp_stargazing-0.1.6/mcp_stargazing.egg-info/requires.txt +9 -0
- mcp_stargazing-0.1.6/mcp_stargazing.egg-info/top_level.txt +1 -0
- mcp_stargazing-0.1.6/pyproject.toml +46 -0
- mcp_stargazing-0.1.6/setup.cfg +4 -0
- mcp_stargazing-0.1.6/src/__init__.py +5 -0
- mcp_stargazing-0.1.6/src/cache.py +36 -0
- mcp_stargazing-0.1.6/src/celestial.py +162 -0
- mcp_stargazing-0.1.6/src/functions/__init__.py +0 -0
- mcp_stargazing-0.1.6/src/functions/celestial/__init__.py +0 -0
- mcp_stargazing-0.1.6/src/functions/celestial/impl.py +63 -0
- mcp_stargazing-0.1.6/src/functions/places/__init__.py +0 -0
- mcp_stargazing-0.1.6/src/functions/places/impl.py +105 -0
- mcp_stargazing-0.1.6/src/functions/time/__init__.py +0 -0
- mcp_stargazing-0.1.6/src/functions/time/impl.py +19 -0
- mcp_stargazing-0.1.6/src/functions/weather/__init__.py +0 -0
- mcp_stargazing-0.1.6/src/functions/weather/impl.py +46 -0
- mcp_stargazing-0.1.6/src/main.py +44 -0
- mcp_stargazing-0.1.6/src/placefinder.py +35 -0
- mcp_stargazing-0.1.6/src/qweather_interaction.py +121 -0
- mcp_stargazing-0.1.6/src/response.py +48 -0
- mcp_stargazing-0.1.6/src/server_instance.py +4 -0
- mcp_stargazing-0.1.6/src/utils.py +114 -0
- mcp_stargazing-0.1.6/tests/test_celestial.py +76 -0
- mcp_stargazing-0.1.6/tests/test_integration.py +35 -0
- mcp_stargazing-0.1.6/tests/test_placefinder.py +56 -0
- mcp_stargazing-0.1.6/tests/test_serialization.py +120 -0
- mcp_stargazing-0.1.6/tests/test_utils.py +40 -0
- mcp_stargazing-0.1.6/tests/test_weather.py +34 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 stargazer95
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-stargazing
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: This is a mcp server Calculate celestial object positions and rise/set times
|
|
5
|
+
Author-email: Henry Gong <zhao.gong@outlook.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/StarGazer1995/mcp-stargazing
|
|
7
|
+
Project-URL: Issues, https://github.com/StarGazer1995/mcp-stargazing/issues
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: fastmcp
|
|
17
|
+
Requires-Dist: astropy>=5.0
|
|
18
|
+
Requires-Dist: pytz
|
|
19
|
+
Requires-Dist: numpy
|
|
20
|
+
Requires-Dist: astroquery
|
|
21
|
+
Requires-Dist: rasterio
|
|
22
|
+
Requires-Dist: tzlocal
|
|
23
|
+
Requires-Dist: geopy
|
|
24
|
+
Requires-Dist: stargazing-place-finder>=0.3.0
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# mcp-stargazing
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- **Altitude/Azimuth Calculation**: Get elevation and compass direction for any celestial object.
|
|
34
|
+
- **Rise/Set Times**: Determine when objects appear/disappear above the horizon.
|
|
35
|
+
- **Light Pollution Analysis**: Load and analyze light pollution maps (GeoTIFF format).
|
|
36
|
+
- **Code Execution Ready**:
|
|
37
|
+
- **Serializable Returns**: All tools return JSON-serializable data (ISO strings for dates), making them directly usable by LLMs.
|
|
38
|
+
- **Pagination**: `analysis_area` supports paging (`page`, `page_size`) to handle large datasets efficiently.
|
|
39
|
+
- **Standardized Responses**: Uniform response format `{ "data": ..., "_meta": ... }` for better observability and error handling.
|
|
40
|
+
- **Performance**:
|
|
41
|
+
- **Async Execution**: Non-blocking celestial calculations.
|
|
42
|
+
- **Caching**: Intelligent caching for Simbad queries and regional analysis.
|
|
43
|
+
- **Proxy Support**: Native support for HTTP/HTTPS proxies (useful for downloading astronomical data).
|
|
44
|
+
- **Time Zone Aware**: Works with local or UTC times.
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
This project uses [uv](https://github.com/astral-sh/uv) for dependency management.
|
|
49
|
+
|
|
50
|
+
1. **Install `uv`**:
|
|
51
|
+
```bash
|
|
52
|
+
pip install uv
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. **Sync dependencies**:
|
|
56
|
+
```bash
|
|
57
|
+
uv sync
|
|
58
|
+
```
|
|
59
|
+
This will create a virtual environment in `.venv` and install all dependencies defined in `pyproject.toml`.
|
|
60
|
+
|
|
61
|
+
3. **Activate the environment**:
|
|
62
|
+
```bash
|
|
63
|
+
source .venv/bin/activate
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## MCP Server Usage
|
|
67
|
+
|
|
68
|
+
Start the MCP server to expose tools to AI agents or other clients.
|
|
69
|
+
|
|
70
|
+
### 1. Environment Setup
|
|
71
|
+
|
|
72
|
+
Create a `.env` file or export variables:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Required for weather tools
|
|
76
|
+
export QWEATHER_API_KEY="your_api_key"
|
|
77
|
+
|
|
78
|
+
# Optional: Proxy for downloading astronomical data (Simbad/IERS)
|
|
79
|
+
# Highly recommended if you are in a restricted network environment
|
|
80
|
+
export HTTP_PROXY="http://127.0.0.1:7890"
|
|
81
|
+
export HTTPS_PROXY="http://127.0.0.1:7890"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Start Server
|
|
85
|
+
|
|
86
|
+
**Streamable HTTP (SHTTP) mode** (Recommended for most agents):
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Basic start
|
|
90
|
+
python -m src.main --mode shttp --port 3001 --path /shttp
|
|
91
|
+
|
|
92
|
+
# With proxy explicitly passed (overrides env vars)
|
|
93
|
+
python -m src.main --mode shttp --port 3001 --path /shttp --proxy http://127.0.0.1:7890
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**SSE mode**:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
python -m src.main --mode sse --port 3001 --path /sse
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 3. Response Format
|
|
103
|
+
|
|
104
|
+
All tools return data in a standardized JSON format:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"data": {
|
|
109
|
+
// Tool-specific return data
|
|
110
|
+
"altitude": 45.5,
|
|
111
|
+
"azimuth": 180.0
|
|
112
|
+
},
|
|
113
|
+
"_meta": {
|
|
114
|
+
"version": "1.0.0",
|
|
115
|
+
"status": "success"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 4. Available Tools
|
|
121
|
+
|
|
122
|
+
- **`get_celestial_pos`**: Calculate altitude/azimuth.
|
|
123
|
+
- **`get_celestial_rise_set`**: Calculate rise/set times (Returns ISO strings).
|
|
124
|
+
- **`get_weather_by_name` / `get_weather_by_position`**: Fetch current weather.
|
|
125
|
+
- **`get_local_datetime_info`**: Get current local time information.
|
|
126
|
+
- **`analysis_area`**: Find best stargazing spots in a region.
|
|
127
|
+
- **Inputs**: `top_left`, `bottom_right`, `time`, `page`, `page_size`.
|
|
128
|
+
- **Returns**: List of spots with viewing conditions, plus pagination metadata (`total`, `resource_id`).
|
|
129
|
+
|
|
130
|
+
## Examples
|
|
131
|
+
|
|
132
|
+
- **Orchestration**: `python examples/code_execution_orchestration.py`
|
|
133
|
+
- Demonstrates a full workflow: Get time -> Get Celestial Pos -> Check Weather -> Find Spots.
|
|
134
|
+
- Shows how to handle the standardized response format programmatically.
|
|
135
|
+
|
|
136
|
+
- **Pagination**: `python examples/pagination_demo.py`
|
|
137
|
+
- Demonstrates fetching large result sets page by page using the `resource_id`.
|
|
138
|
+
|
|
139
|
+
## Project Structure
|
|
140
|
+
|
|
141
|
+
The project is modularized for better maintainability and code execution support:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
.
|
|
145
|
+
├── src/
|
|
146
|
+
│ ├── functions/ # Tool implementations grouped by domain
|
|
147
|
+
│ │ ├── celestial/ # Celestial calculations (pos, rise/set)
|
|
148
|
+
│ │ ├── weather/ # Weather API integration
|
|
149
|
+
│ │ ├── places/ # Location and area analysis
|
|
150
|
+
│ │ └── time/ # Time utilities
|
|
151
|
+
│ ├── cache.py # Caching logic for analysis results
|
|
152
|
+
│ ├── response.py # Standardized response formatting
|
|
153
|
+
│ ├── server_instance.py # FastMCP server instance (avoids circular imports)
|
|
154
|
+
│ ├── main.py # Entry point and tool registration
|
|
155
|
+
│ ├── celestial.py # Core astronomy logic (Astropy wrappers)
|
|
156
|
+
│ ├── placefinder.py # Grid analysis logic
|
|
157
|
+
│ └── qweather_interaction.py # Weather API client
|
|
158
|
+
├── tests/ # Unified test suite
|
|
159
|
+
│ ├── test_celestial.py
|
|
160
|
+
│ ├── test_weather.py
|
|
161
|
+
│ ├── test_serialization.py # Validates JSON return formats
|
|
162
|
+
│ └── test_integration.py # End-to-end flow tests
|
|
163
|
+
├── examples/ # Usage examples
|
|
164
|
+
├── docs/ # Documentation and improvement plans
|
|
165
|
+
└── pyproject.toml # Project configuration and dependencies
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Testing
|
|
169
|
+
|
|
170
|
+
Run the unified test suite:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
pytest tests/
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Key tests include:
|
|
177
|
+
- `test_serialization.py`: Ensures all tools return valid JSON with the correct schema.
|
|
178
|
+
- `test_integration.py`: Mocks external APIs to verify the entire toolchain.
|
|
179
|
+
|
|
180
|
+
## Contributing
|
|
181
|
+
|
|
182
|
+
1. Follow the [Code Execution with MCP](https://www.anthropic.com/engineering/code-execution-with-mcp) best practices.
|
|
183
|
+
2. Ensure all new tools return standard JSON responses using `src.response.format_response`.
|
|
184
|
+
3. Add tests in `tests/` for any new functionality.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# mcp-stargazing
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Altitude/Azimuth Calculation**: Get elevation and compass direction for any celestial object.
|
|
8
|
+
- **Rise/Set Times**: Determine when objects appear/disappear above the horizon.
|
|
9
|
+
- **Light Pollution Analysis**: Load and analyze light pollution maps (GeoTIFF format).
|
|
10
|
+
- **Code Execution Ready**:
|
|
11
|
+
- **Serializable Returns**: All tools return JSON-serializable data (ISO strings for dates), making them directly usable by LLMs.
|
|
12
|
+
- **Pagination**: `analysis_area` supports paging (`page`, `page_size`) to handle large datasets efficiently.
|
|
13
|
+
- **Standardized Responses**: Uniform response format `{ "data": ..., "_meta": ... }` for better observability and error handling.
|
|
14
|
+
- **Performance**:
|
|
15
|
+
- **Async Execution**: Non-blocking celestial calculations.
|
|
16
|
+
- **Caching**: Intelligent caching for Simbad queries and regional analysis.
|
|
17
|
+
- **Proxy Support**: Native support for HTTP/HTTPS proxies (useful for downloading astronomical data).
|
|
18
|
+
- **Time Zone Aware**: Works with local or UTC times.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
This project uses [uv](https://github.com/astral-sh/uv) for dependency management.
|
|
23
|
+
|
|
24
|
+
1. **Install `uv`**:
|
|
25
|
+
```bash
|
|
26
|
+
pip install uv
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. **Sync dependencies**:
|
|
30
|
+
```bash
|
|
31
|
+
uv sync
|
|
32
|
+
```
|
|
33
|
+
This will create a virtual environment in `.venv` and install all dependencies defined in `pyproject.toml`.
|
|
34
|
+
|
|
35
|
+
3. **Activate the environment**:
|
|
36
|
+
```bash
|
|
37
|
+
source .venv/bin/activate
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## MCP Server Usage
|
|
41
|
+
|
|
42
|
+
Start the MCP server to expose tools to AI agents or other clients.
|
|
43
|
+
|
|
44
|
+
### 1. Environment Setup
|
|
45
|
+
|
|
46
|
+
Create a `.env` file or export variables:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Required for weather tools
|
|
50
|
+
export QWEATHER_API_KEY="your_api_key"
|
|
51
|
+
|
|
52
|
+
# Optional: Proxy for downloading astronomical data (Simbad/IERS)
|
|
53
|
+
# Highly recommended if you are in a restricted network environment
|
|
54
|
+
export HTTP_PROXY="http://127.0.0.1:7890"
|
|
55
|
+
export HTTPS_PROXY="http://127.0.0.1:7890"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. Start Server
|
|
59
|
+
|
|
60
|
+
**Streamable HTTP (SHTTP) mode** (Recommended for most agents):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Basic start
|
|
64
|
+
python -m src.main --mode shttp --port 3001 --path /shttp
|
|
65
|
+
|
|
66
|
+
# With proxy explicitly passed (overrides env vars)
|
|
67
|
+
python -m src.main --mode shttp --port 3001 --path /shttp --proxy http://127.0.0.1:7890
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**SSE mode**:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
python -m src.main --mode sse --port 3001 --path /sse
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. Response Format
|
|
77
|
+
|
|
78
|
+
All tools return data in a standardized JSON format:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"data": {
|
|
83
|
+
// Tool-specific return data
|
|
84
|
+
"altitude": 45.5,
|
|
85
|
+
"azimuth": 180.0
|
|
86
|
+
},
|
|
87
|
+
"_meta": {
|
|
88
|
+
"version": "1.0.0",
|
|
89
|
+
"status": "success"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 4. Available Tools
|
|
95
|
+
|
|
96
|
+
- **`get_celestial_pos`**: Calculate altitude/azimuth.
|
|
97
|
+
- **`get_celestial_rise_set`**: Calculate rise/set times (Returns ISO strings).
|
|
98
|
+
- **`get_weather_by_name` / `get_weather_by_position`**: Fetch current weather.
|
|
99
|
+
- **`get_local_datetime_info`**: Get current local time information.
|
|
100
|
+
- **`analysis_area`**: Find best stargazing spots in a region.
|
|
101
|
+
- **Inputs**: `top_left`, `bottom_right`, `time`, `page`, `page_size`.
|
|
102
|
+
- **Returns**: List of spots with viewing conditions, plus pagination metadata (`total`, `resource_id`).
|
|
103
|
+
|
|
104
|
+
## Examples
|
|
105
|
+
|
|
106
|
+
- **Orchestration**: `python examples/code_execution_orchestration.py`
|
|
107
|
+
- Demonstrates a full workflow: Get time -> Get Celestial Pos -> Check Weather -> Find Spots.
|
|
108
|
+
- Shows how to handle the standardized response format programmatically.
|
|
109
|
+
|
|
110
|
+
- **Pagination**: `python examples/pagination_demo.py`
|
|
111
|
+
- Demonstrates fetching large result sets page by page using the `resource_id`.
|
|
112
|
+
|
|
113
|
+
## Project Structure
|
|
114
|
+
|
|
115
|
+
The project is modularized for better maintainability and code execution support:
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
.
|
|
119
|
+
├── src/
|
|
120
|
+
│ ├── functions/ # Tool implementations grouped by domain
|
|
121
|
+
│ │ ├── celestial/ # Celestial calculations (pos, rise/set)
|
|
122
|
+
│ │ ├── weather/ # Weather API integration
|
|
123
|
+
│ │ ├── places/ # Location and area analysis
|
|
124
|
+
│ │ └── time/ # Time utilities
|
|
125
|
+
│ ├── cache.py # Caching logic for analysis results
|
|
126
|
+
│ ├── response.py # Standardized response formatting
|
|
127
|
+
│ ├── server_instance.py # FastMCP server instance (avoids circular imports)
|
|
128
|
+
│ ├── main.py # Entry point and tool registration
|
|
129
|
+
│ ├── celestial.py # Core astronomy logic (Astropy wrappers)
|
|
130
|
+
│ ├── placefinder.py # Grid analysis logic
|
|
131
|
+
│ └── qweather_interaction.py # Weather API client
|
|
132
|
+
├── tests/ # Unified test suite
|
|
133
|
+
│ ├── test_celestial.py
|
|
134
|
+
│ ├── test_weather.py
|
|
135
|
+
│ ├── test_serialization.py # Validates JSON return formats
|
|
136
|
+
│ └── test_integration.py # End-to-end flow tests
|
|
137
|
+
├── examples/ # Usage examples
|
|
138
|
+
├── docs/ # Documentation and improvement plans
|
|
139
|
+
└── pyproject.toml # Project configuration and dependencies
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Testing
|
|
143
|
+
|
|
144
|
+
Run the unified test suite:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pytest tests/
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Key tests include:
|
|
151
|
+
- `test_serialization.py`: Ensures all tools return valid JSON with the correct schema.
|
|
152
|
+
- `test_integration.py`: Mocks external APIs to verify the entire toolchain.
|
|
153
|
+
|
|
154
|
+
## Contributing
|
|
155
|
+
|
|
156
|
+
1. Follow the [Code Execution with MCP](https://www.anthropic.com/engineering/code-execution-with-mcp) best practices.
|
|
157
|
+
2. Ensure all new tools return standard JSON responses using `src.response.format_response`.
|
|
158
|
+
3. Add tests in `tests/` for any new functionality.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-stargazing
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: This is a mcp server Calculate celestial object positions and rise/set times
|
|
5
|
+
Author-email: Henry Gong <zhao.gong@outlook.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/StarGazer1995/mcp-stargazing
|
|
7
|
+
Project-URL: Issues, https://github.com/StarGazer1995/mcp-stargazing/issues
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: fastmcp
|
|
17
|
+
Requires-Dist: astropy>=5.0
|
|
18
|
+
Requires-Dist: pytz
|
|
19
|
+
Requires-Dist: numpy
|
|
20
|
+
Requires-Dist: astroquery
|
|
21
|
+
Requires-Dist: rasterio
|
|
22
|
+
Requires-Dist: tzlocal
|
|
23
|
+
Requires-Dist: geopy
|
|
24
|
+
Requires-Dist: stargazing-place-finder>=0.3.0
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# mcp-stargazing
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- **Altitude/Azimuth Calculation**: Get elevation and compass direction for any celestial object.
|
|
34
|
+
- **Rise/Set Times**: Determine when objects appear/disappear above the horizon.
|
|
35
|
+
- **Light Pollution Analysis**: Load and analyze light pollution maps (GeoTIFF format).
|
|
36
|
+
- **Code Execution Ready**:
|
|
37
|
+
- **Serializable Returns**: All tools return JSON-serializable data (ISO strings for dates), making them directly usable by LLMs.
|
|
38
|
+
- **Pagination**: `analysis_area` supports paging (`page`, `page_size`) to handle large datasets efficiently.
|
|
39
|
+
- **Standardized Responses**: Uniform response format `{ "data": ..., "_meta": ... }` for better observability and error handling.
|
|
40
|
+
- **Performance**:
|
|
41
|
+
- **Async Execution**: Non-blocking celestial calculations.
|
|
42
|
+
- **Caching**: Intelligent caching for Simbad queries and regional analysis.
|
|
43
|
+
- **Proxy Support**: Native support for HTTP/HTTPS proxies (useful for downloading astronomical data).
|
|
44
|
+
- **Time Zone Aware**: Works with local or UTC times.
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
This project uses [uv](https://github.com/astral-sh/uv) for dependency management.
|
|
49
|
+
|
|
50
|
+
1. **Install `uv`**:
|
|
51
|
+
```bash
|
|
52
|
+
pip install uv
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
2. **Sync dependencies**:
|
|
56
|
+
```bash
|
|
57
|
+
uv sync
|
|
58
|
+
```
|
|
59
|
+
This will create a virtual environment in `.venv` and install all dependencies defined in `pyproject.toml`.
|
|
60
|
+
|
|
61
|
+
3. **Activate the environment**:
|
|
62
|
+
```bash
|
|
63
|
+
source .venv/bin/activate
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## MCP Server Usage
|
|
67
|
+
|
|
68
|
+
Start the MCP server to expose tools to AI agents or other clients.
|
|
69
|
+
|
|
70
|
+
### 1. Environment Setup
|
|
71
|
+
|
|
72
|
+
Create a `.env` file or export variables:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Required for weather tools
|
|
76
|
+
export QWEATHER_API_KEY="your_api_key"
|
|
77
|
+
|
|
78
|
+
# Optional: Proxy for downloading astronomical data (Simbad/IERS)
|
|
79
|
+
# Highly recommended if you are in a restricted network environment
|
|
80
|
+
export HTTP_PROXY="http://127.0.0.1:7890"
|
|
81
|
+
export HTTPS_PROXY="http://127.0.0.1:7890"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Start Server
|
|
85
|
+
|
|
86
|
+
**Streamable HTTP (SHTTP) mode** (Recommended for most agents):
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Basic start
|
|
90
|
+
python -m src.main --mode shttp --port 3001 --path /shttp
|
|
91
|
+
|
|
92
|
+
# With proxy explicitly passed (overrides env vars)
|
|
93
|
+
python -m src.main --mode shttp --port 3001 --path /shttp --proxy http://127.0.0.1:7890
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**SSE mode**:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
python -m src.main --mode sse --port 3001 --path /sse
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 3. Response Format
|
|
103
|
+
|
|
104
|
+
All tools return data in a standardized JSON format:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"data": {
|
|
109
|
+
// Tool-specific return data
|
|
110
|
+
"altitude": 45.5,
|
|
111
|
+
"azimuth": 180.0
|
|
112
|
+
},
|
|
113
|
+
"_meta": {
|
|
114
|
+
"version": "1.0.0",
|
|
115
|
+
"status": "success"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 4. Available Tools
|
|
121
|
+
|
|
122
|
+
- **`get_celestial_pos`**: Calculate altitude/azimuth.
|
|
123
|
+
- **`get_celestial_rise_set`**: Calculate rise/set times (Returns ISO strings).
|
|
124
|
+
- **`get_weather_by_name` / `get_weather_by_position`**: Fetch current weather.
|
|
125
|
+
- **`get_local_datetime_info`**: Get current local time information.
|
|
126
|
+
- **`analysis_area`**: Find best stargazing spots in a region.
|
|
127
|
+
- **Inputs**: `top_left`, `bottom_right`, `time`, `page`, `page_size`.
|
|
128
|
+
- **Returns**: List of spots with viewing conditions, plus pagination metadata (`total`, `resource_id`).
|
|
129
|
+
|
|
130
|
+
## Examples
|
|
131
|
+
|
|
132
|
+
- **Orchestration**: `python examples/code_execution_orchestration.py`
|
|
133
|
+
- Demonstrates a full workflow: Get time -> Get Celestial Pos -> Check Weather -> Find Spots.
|
|
134
|
+
- Shows how to handle the standardized response format programmatically.
|
|
135
|
+
|
|
136
|
+
- **Pagination**: `python examples/pagination_demo.py`
|
|
137
|
+
- Demonstrates fetching large result sets page by page using the `resource_id`.
|
|
138
|
+
|
|
139
|
+
## Project Structure
|
|
140
|
+
|
|
141
|
+
The project is modularized for better maintainability and code execution support:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
.
|
|
145
|
+
├── src/
|
|
146
|
+
│ ├── functions/ # Tool implementations grouped by domain
|
|
147
|
+
│ │ ├── celestial/ # Celestial calculations (pos, rise/set)
|
|
148
|
+
│ │ ├── weather/ # Weather API integration
|
|
149
|
+
│ │ ├── places/ # Location and area analysis
|
|
150
|
+
│ │ └── time/ # Time utilities
|
|
151
|
+
│ ├── cache.py # Caching logic for analysis results
|
|
152
|
+
│ ├── response.py # Standardized response formatting
|
|
153
|
+
│ ├── server_instance.py # FastMCP server instance (avoids circular imports)
|
|
154
|
+
│ ├── main.py # Entry point and tool registration
|
|
155
|
+
│ ├── celestial.py # Core astronomy logic (Astropy wrappers)
|
|
156
|
+
│ ├── placefinder.py # Grid analysis logic
|
|
157
|
+
│ └── qweather_interaction.py # Weather API client
|
|
158
|
+
├── tests/ # Unified test suite
|
|
159
|
+
│ ├── test_celestial.py
|
|
160
|
+
│ ├── test_weather.py
|
|
161
|
+
│ ├── test_serialization.py # Validates JSON return formats
|
|
162
|
+
│ └── test_integration.py # End-to-end flow tests
|
|
163
|
+
├── examples/ # Usage examples
|
|
164
|
+
├── docs/ # Documentation and improvement plans
|
|
165
|
+
└── pyproject.toml # Project configuration and dependencies
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Testing
|
|
169
|
+
|
|
170
|
+
Run the unified test suite:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
pytest tests/
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Key tests include:
|
|
177
|
+
- `test_serialization.py`: Ensures all tools return valid JSON with the correct schema.
|
|
178
|
+
- `test_integration.py`: Mocks external APIs to verify the entire toolchain.
|
|
179
|
+
|
|
180
|
+
## Contributing
|
|
181
|
+
|
|
182
|
+
1. Follow the [Code Execution with MCP](https://www.anthropic.com/engineering/code-execution-with-mcp) best practices.
|
|
183
|
+
2. Ensure all new tools return standard JSON responses using `src.response.format_response`.
|
|
184
|
+
3. Add tests in `tests/` for any new functionality.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
mcp_stargazing.egg-info/PKG-INFO
|
|
5
|
+
mcp_stargazing.egg-info/SOURCES.txt
|
|
6
|
+
mcp_stargazing.egg-info/dependency_links.txt
|
|
7
|
+
mcp_stargazing.egg-info/entry_points.txt
|
|
8
|
+
mcp_stargazing.egg-info/requires.txt
|
|
9
|
+
mcp_stargazing.egg-info/top_level.txt
|
|
10
|
+
src/__init__.py
|
|
11
|
+
src/cache.py
|
|
12
|
+
src/celestial.py
|
|
13
|
+
src/main.py
|
|
14
|
+
src/placefinder.py
|
|
15
|
+
src/qweather_interaction.py
|
|
16
|
+
src/response.py
|
|
17
|
+
src/server_instance.py
|
|
18
|
+
src/utils.py
|
|
19
|
+
src/functions/__init__.py
|
|
20
|
+
src/functions/celestial/__init__.py
|
|
21
|
+
src/functions/celestial/impl.py
|
|
22
|
+
src/functions/places/__init__.py
|
|
23
|
+
src/functions/places/impl.py
|
|
24
|
+
src/functions/time/__init__.py
|
|
25
|
+
src/functions/time/impl.py
|
|
26
|
+
src/functions/weather/__init__.py
|
|
27
|
+
src/functions/weather/impl.py
|
|
28
|
+
tests/test_celestial.py
|
|
29
|
+
tests/test_integration.py
|
|
30
|
+
tests/test_placefinder.py
|
|
31
|
+
tests/test_serialization.py
|
|
32
|
+
tests/test_utils.py
|
|
33
|
+
tests/test_weather.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=42", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mcp-stargazing"
|
|
7
|
+
version = "0.1.6"
|
|
8
|
+
description = "This is a mcp server Calculate celestial object positions and rise/set times"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Henry Gong", email = "zhao.gong@outlook.com" },
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Science/Research",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Topic :: Scientific/Engineering :: Astronomy",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"fastmcp",
|
|
23
|
+
"astropy>=5.0",
|
|
24
|
+
"pytz",
|
|
25
|
+
"numpy",
|
|
26
|
+
"astroquery",
|
|
27
|
+
"rasterio",
|
|
28
|
+
"tzlocal",
|
|
29
|
+
"geopy",
|
|
30
|
+
"stargazing-place-finder>=0.3.0"
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
mcp-stargazing = "src.main:main"
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/StarGazer1995/mcp-stargazing"
|
|
38
|
+
Issues = "https://github.com/StarGazer1995/mcp-stargazing/issues"
|
|
39
|
+
|
|
40
|
+
[tool.setuptools.packages.find]
|
|
41
|
+
include = ["src*"]
|
|
42
|
+
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
dev = [
|
|
45
|
+
"pytest>=9.0.2",
|
|
46
|
+
]
|