loading…
Search for a command to run...
loading…
A Model Context Protocol (MCP) server for interacting with the Sage Grande Testbed, enabling users to query sensor data, submit jobs, and manage Sage nodes thro
A Model Context Protocol (MCP) server for interacting with the Sage Grande Testbed, enabling users to query sensor data, submit jobs, and manage Sage nodes through natural language.
A Model Context Protocol (MCP) server for interacting with the Sage Grande Testbed, cyberinfrastructure for AI@Edge. This server provides tools, resources, and prompts for querying sensor data, submitting jobs, and managing Sage nodes.
The easiest way to use Sage MCP is through Cursor IDE with our hosted server:
Add this to your Cursor MCP configuration file (~/.cursor/mcp.json):
{
"mcpServers": {
"sage": {
"url": "https://mcp.sagecontinuum.org/mcp",
"headers": {
"Authorization": "Bearer {username}:{auth_token}"
}
}
}
}
{username} with your Sage username{auth_token} with your access tokenOnce configured, you can ask Cursor natural language questions about Sage data:
"Show me temperature readings from node W023 in the last hour"
"Find nodes in Chicago with recent camera images"
"What's the highest temperature recorded today across all nodes?"
See the Examples Guide for more query examples.
Comprehensive documentation is available in the docs/ folder:
The server supports authentication for accessing protected Sage data through HTTP headers and query parameters only.
For protected data access, use the format: username:access_token
your_username:your_access_tokenUse HTTP Authorization header with Basic auth:
# Basic Auth with username:token
curl -H "Authorization: Basic $(echo -n 'username:token' | base64)" \
"http://localhost:8000/mcp/..."
# Or Bearer token
curl -H "Authorization: Bearer username:token" \
"http://localhost:8000/mcp/..."
Use the custom X-SAGE-Token header:
curl -H "X-SAGE-Token: username:token" \
"http://localhost:8000/mcp/..."
Pass token as a query parameter:
curl "http://localhost:8000/mcp/...?token=username:token"
For protected data access, ensure you have:
your_token_hereusername:your_token_hereThe server includes an image proxy endpoint that allows authenticated access to Sage images:
GET /proxy/image?url=<encoded_sage_url>&token=<optional_token>
Environment Variables (recommended - like the Sage Python examples):
export SAGE_USER=your_username
export SAGE_PASS=your_password
Token parameter in username:password format:
curl "http://localhost:8000/proxy/image?url=...&token=username:password"
Bearer token for simple access tokens:
curl "http://localhost:8000/proxy/image?url=...&token=your_access_token"
Use the get_image_proxy_url() tool to generate proxy URLs:
# Get a proxy URL for a Sage image
proxy_url = get_image_proxy_url("https://storage.sagecontinuum.org/api/v1/data/sage/...")
pip install -r requirements.txt
# Test that all dependencies are properly installed
python test_dependencies.py
python sage_mcp.py
The server will start on http://localhost:8000/mcp by default.
MCP_HOST: Host to bind to (default: 0.0.0.0)MCP_PORT: Port to bind to (default: 8000)# Method 1: Using MCP tools (recommended)
# Start the server
python sage_mcp.py
# In your MCP client, call: set_authentication_token("username:your_access_token_here")
# Then use any data querying tool
# Method 2: Environment variable
export SAGE_USER_TOKEN="your_access_token_here"
python sage_mcp.py
# All tools will automatically use the token for protected data
set_authentication_token(username, token) - Set your Sage authentication credentials (per-session)set_authentication_token_legacy(token) - Set token in legacy format (deprecated)get_authentication_status() - Check if an authentication token is set for this sessionlist_active_sessions() - List all active authenticated sessions (admin/debug tool)get_node_all_data(node_id, time_range) - Get all sensor data for a nodeget_node_iio_data(node_id, time_range) - Get IIO sensor dataget_environmental_summary(node_id, time_range) - Get environmental data summaryget_node_temperature(node_id, sensor_type) - Get temperature dataget_temperature_summary(time_range, sensor_type) - Get temperature summarysearch_measurements(pattern, node_id, time_range) - Search for measurementslist_available_nodes(time_range) - List active Sage nodesget_node_info(node_id) - Get detailed node informationlist_all_nodes() - List all Sage nodesget_sensor_details(sensor_type) - Get sensor specificationssubmit_sage_job(job_name, nodes, plugin_image, ...) - Submit custom jobssubmit_plugin_job(plugin_type, job_name, nodes) - Submit pre-configured plugin jobscheck_job_status(job_id) - Check job statusquery_job_data(job_name, node_id, time_range) - Query job output dataget_nodes_by_location(location) - Find nodes by geographic locationget_measurement_stat_by_location(location, measurement_type, stat, ...) - Get statistics by locationfind_plugins_for_task(task_description) - Find plugins for a taskget_plugin_data(plugin_id, nodes, time_range) - Query plugin dataquery_plugin_data_nl(query) - Natural language plugin queriesget_cloud_images(time_range, node_id) - Get cloud/sky imagesget_image_data(time_range, node_id, plugin_pattern) - Get image dataget_image_proxy_url(sage_url) - Get a proxy URL for accessing Sage images with authenticationask_sage_docs(question) - Ask questions about Sage documentationsage_faq(topic) - Get FAQ answerssearch_sage_docs(query) - Search documentationquery://{plugin} - Query data for specific pluginsstats://temperature - Temperature statistics across nodesgetting_started_guide() - Interactive guide for new usersplugin_development_guide() - Guide for creating pluginsdata_analysis_guide() - Guide for data analysistroubleshooting_guide() - Troubleshooting helpSee DOCKER_DEPLOY.md for containerized deployment instructions.
The server is built using:
Want to add your own custom MCP tools to the Sage server? You can easily fork this repository and add custom endpoints:
@mcp.tool()
def my_custom_analysis(data_query: str, analysis_type: str = "basic") -> str:
"""Perform custom analysis on Sage data"""
# Your custom logic here
# Access Sage data using the existing data_service
# Return formatted results
return "Analysis results..."
For detailed instructions on forking, adding custom functions, and deploying your enhanced server, see our Custom Functions Guide.
Testing scripts are located in the tests/ folder:
# Test authentication functionality
python tests/test_auth.py
# Test dependencies
python tests/test_dependencies.py
# Test image proxy functionality
python tests/test_image_proxy.py
# Test Sage authentication
python tests/test_sage_auth.py
# Run server tests
python tests/test_server.py
The authentication test will verify all supported authentication methods (headers and query parameters) work correctly.
This project is licensed under the MIT License.
Выполни в терминале:
claude mcp add sage-mcp-server -- npx Безопасность
Низкий рискАвтоматическая эвристика по публичным данным — не гарантия безопасности.