A gravitational wave signal detection and optimization system using the Model Context Protocol (MCP) for efficient parameter space exploration.
This project provides tools for analyzing gravitational wave signals, specifically focusing on the GW150914 event. It uses MCP to create a client-server architecture where:
- GW Analysis Server (
mcp-server/gw_analysis_server.py
): Provides gravitational wave analysis tools via MCP - GW Optimization Client (
mcp-client/gw_optimization_client.py
): Uses AI to optimize signal detection parameters
- Python 3.9 or higher
- UV package manager
Install UV if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
- Clone and setup the project:
git clone <repository-url>
cd gw150914-mcp-signal-search
make setup
- Configure environment variables:
cp env.template .env
# Edit .env with your OpenAI API key
- Install dependencies:
make install-dev
- Start the analysis server andthe optimization client:
make run-client SERVER_PATH=mcp-server/gw_analysis_server.py
- Or run a complete demo (includes both server and client):
make demo
Run make help
to see all available commands:
make install
- Install production dependenciesmake install-dev
- Install with development dependenciesmake setup
- Complete development setupmake update
- Update all dependencies
make format
- Format code with black and isortmake lint
- Run linting checksmake check
- Run all code quality checksmake test
- Run tests
make run-server
- Start the GW analysis servermake run-client SERVER_PATH=<path>
- Start the optimization clientmake demo
- Run complete demo
make notebook
- Start Jupyter notebookmake dev-shell
- Enter development shellmake clean
- Clean temporary files
make data-info
- Show information about data filesmake clean-data
- Clean temporary data files (keeps strain data)make backup-data
- Create backup of analysis results and logs
gw150914-mcp-signal-search/
βββ data/ # Gravitational wave data and analysis results
β βββ H1-1126259446-1126259478.txt # LIGO Hanford strain data (GW150914)
β βββ L1-1126259446-1126259478.txt # LIGO Livingston strain data (GW150914)
β βββ matched_filter_records.jsonl # Analysis results and optimization history
β βββ logs/ # Application logs (auto-generated)
β βββ server_YYYYMMDD_HHMMSS.log # Server execution logs
β βββ client_YYYYMMDD_HHMMSS.log # Client execution logs
β βββ demo_YYYYMMDD_HHMMSS.log # Combined demo logs
βββ mcp-client/
β βββ gw_optimization_client.py # AI-powered optimization client
βββ mcp-server/
β βββ gw_analysis_server.py # GW analysis MCP server
βββ pyproject.toml # Project configuration
βββ Makefile # Build and deployment commands
βββ env.template # Environment variables template
βββ README.md # This file
The data/
directory contains gravitational wave strain data and analysis results for the GW150914 event:
-
H1-1126259446-1126259478.txt
: LIGO Hanford (H1) detector strain data- GPS time range: 1126259446 to 1126259478 (32 seconds around GW150914)
- Format: Two columns - GPS time (seconds) and strain amplitude
- Sample rate: 4096 Hz
- Data points: ~131,072 samples per detector
-
L1-1126259446-1126259478.txt
: LIGO Livingston (L1) detector strain data- Same format and time range as H1 data
- Contains the gravitational wave signal from the binary black hole merger
matched_filter_records.jsonl
: JSON Lines file containing optimization results- Each line represents one matched filter analysis result
- Contains SNR values, template parameters, detector responses
- Tracks optimization history and parameter exploration
- Used by the AI client to learn from previous attempts
logs/
: Directory containing timestamped execution logs (auto-generated)server_YYYYMMDD_HHMMSS.log
: Server execution logs with timestampsclient_YYYYMMDD_HHMMSS.log
: Client optimization logs and AI interactionsdemo_YYYYMMDD_HHMMSS.log
: Combined logs from demo runs- All stdout and stderr output is captured with timestamps
- Logs are automatically created when running
make run-server
,make run-client
, ormake demo
Strain Data Format:
GPS_TIME STRAIN_AMPLITUDE
1.126259446000000000e+09 2.177040281448404468e-19
1.126259446000244141e+09 2.087638998822567751e-19
...
Analysis Results Format:
{
"timestamp": "010725",
"max_network_snr": 7.3055496414353565,
"max_snr_time": 1126259462.4360352,
"template_parameters": {
"mass1": 17.0,
"mass2": 9.5,
"ra": 0.94,
"dec": -0.31
},
"detector_snrs_at_max": {
"H1": {"snr_abs": 5.064289109514169},
"L1": {"snr_abs": 5.2653614670535624}
}
}
- The strain data is automatically loaded by the MCP server for analysis
- Results are cached to
/tmp/gw-mcp/
during processing - The optimization client uses historical results to guide parameter searches
- Data can be visualized using the server's plotting tools
- All execution logs are automatically saved to
data/logs/
with timestamps for debugging and analysis
- Data Fetching: Download and preprocess GW data from GWOSC
- Matched Filter Search: Perform template-based signal detection
- Network Analysis: Multi-detector coherent analysis
- Visualization: Generate plots and analysis results
- AI-Powered Search: Uses OpenAI GPT for intelligent parameter exploration
- 4D Parameter Space: Optimizes mass1, mass2, right ascension, declination
- Convergence Detection: Automatically stops when optimal SNR is found
- Progress Tracking: Visual feedback during optimization
This project focuses on the GW150914 event, the first direct detection of gravitational waves:
- Event Time: GPS 1126259462.427
- Source: Binary black hole merger (~36 + 29 solar masses)
- Detectors: LIGO Hanford (H1) and LIGO Livingston (L1)
- Peak SNR: ~24 in the network
This project was developed and validated at the AI for Science Hackathon (Beijing) with promising results demonstrating the effectiveness of LLM-agent powered gravitational wave detection.
Project presentation at AI for Science Hackathon (Beijing) - LLM-agent powered gravitational wave detection and scientific discovery
The system demonstrates consistent convergence behavior across different initial conditions:
Parameter evolution and convergence analysis showing gradual convergence to true values during exploration. The system shows consistent performance under different initial conditions with average iterations of 13.3 Β± 3.5 to reach maximum SNR of 19.56.
The automated system successfully detects and analyzes gravitational wave signals:
Network SNR time series showing successful detection of GW150914 signal. The system achieves peak network SNR of 19.6 at GPS time 1126259462.428, demonstrating automated GW data detection with LLM-agent validation on real GW data.
- Convergence: Parameters gradually converge to true values during exploration
- Consistency: Model shows consistent performance under different initial conditions
- Accuracy: Successfully achieves maximum SNR of ~19.6, matching theoretical expectations
- Automation: Fully automated detection pipeline validated on real LIGO data
For detailed methodology, results, and analysis, see: docs/Hackathon.pdf
Presented by He Wang (ICTP-AP, UCAS) and Yiming Dong (PKU) at AI for Science Hackathon (Beijing), August 24, 2025
# Complete development setup
make setup
# Install pre-commit hooks
make pre-commit-install
# Run tests
make test
# Check code quality
make check
Core dependencies:
mcp
: Model Context Protocol frameworknumpy
,scipy
: Scientific computinggwpy
,pycbc
: Gravitational wave analysisopenai
: AI integrationmatplotlib
: Visualization
# The client will automatically optimize parameters for GW150914
python mcp-client/gw_optimization_client.py mcp-server/gw_analysis_server.py
Edit the optimization query in the client to specify different:
- Mass ranges (currently 10-80 solar masses)
- Sky location ranges (RA: 0-2Ο, Dec: -Ο/2 to Ο/2)
- Convergence criteria
- Fork the repository
- Create a feature branch
- Make your changes
- Run
make check
to ensure code quality - Submit a pull request
MIT License - see LICENSE file for details.
- Official MCP Documentation - Complete getting started guide and API reference
- DeepLearning.AI MCP Course - "MCP: Build Rich-Context AI Apps with Anthropic" - comprehensive hands-on course by Elie Schoppik
- Tutorial on Building AI Scientist Agents with Model Context Protocol - Comprehensive tutorial on building AI scientist agents using MCP framework
- MCP.Science Repository - Open source MCP servers for scientific research with 65+ stars
- How to Build Your Own MCP Server - Step-by-step tutorial for creating custom MCP servers
- Integrate MCP Server Guide - Complete integration guide for MCP servers with AI applications
- AI4Science Events - Stanford Quantum Science Hackathon and other AI for science events
- AI-4-Science Organization - Community and resources for AI applications in scientific research
- Project Technical Report - Detailed methodology and results from AI for Science Hackathon (Beijing) validation
This project demonstrates practical applications of MCP in scientific computing, specifically for gravitational wave analysis. The resources above provide:
- Foundation Knowledge: Understanding MCP architecture and implementation
- Hands-on Learning: Building and deploying MCP servers and clients
- Scientific Context: Real-world applications of AI in physics and astronomy
- Community: Connect with researchers and developers working on similar projects
- Start with the official MCP documentation for core concepts
- Take the DeepLearning.AI course for practical implementation
- Explore the MCP.Science repository for scientific use cases
- Use this project as a template for your own gravitational wave or scientific analysis applications
- LIGO Scientific Collaboration for gravitational wave data
- PyCBC and GWpy communities for analysis tools
- Anthropic for MCP framework and protocol development
- Path Integral Institute for MCP.Science open source servers
- DeepLearning.AI and Elie Schoppik for educational resources