- Home
- MCP servers
- Cost Explorer
Cost Explorer
- python
0
GitHub Stars
python
Language
6 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
You deploy and run a Python-based MCP server that exposes Cost Explorer data through the Model Context Protocol using streamable HTTP. It is designed for local development and for deploying to Agentcore Runtime, enabling you to test queries locally and then operate the server in a managed runtime environment.
How to use
You will run the local MCP server and then interact with it using an MCP client to retrieve cost and usage data, perform comparisons, and forecast costs. Start the server in one terminal and run client tests in another to verify end-to-end operation. The server uses streamable HTTP transport on port 8000.
How to install
Prerequisites you need before getting started:
pip install bedrock-agentcore-starter-toolkit
pip install mcp[cli]
aws configure
Additional setup steps
Install dependencies and start the local MCP server to verify everything is working before attempting deployment.
pip install -r requirements.txt
python mcp_server.py
Deployment and testing workflow
When you are ready to deploy to Agentcore Runtime, run the deployment automation script to configure and launch the server in the managed runtime.
python deploy.py
Authentication and security notes
Choose an authentication method that fits your security posture. You can configure OAuth or Cognito and supply the necessary tokens or credentials during deployment and testing.
Testing
For local testing, start the server and run the local test client in a separate terminal to verify responses.
# Start server
python mcp_server.py
# In another terminal
python test_mcp_client.py
Troubleshooting
If you encounter issues, check port availability, review server logs, and verify your credentials and configuration are correct for the environment you are using (local or Agentcore Runtime).
lsof -i :8000
python mcp_server.py
Notes
The server includes provisions to minimize calls to AWS Cost Explorer, helping to manage costs while you explore data. Keep track of usage since each Cost Explorer API call has an associated price.
Available tools
get_today_date
Retrieve the current date to support date-based queries.
get_dimension_values
Fetch available values for dimensions such as SERVICE and REGION to build dynamic queries.
get_tag_values
Retrieve tag value options for filtering and aggregation.
get_cost_and_usage
Obtain cost and usage data with filters and groupings.
get_cost_and_usage_comparisons
Compare costs across different time periods.
get_cost_comparison_drivers
Analyze drivers behind cost changes across dimensions.
get_cost_forecast
Generate forecasts for future costs based on historical data.