This MCP server exposes CodeCarbon API capabilities to LLM clients through MCP tools and allow AI agents to run measurements locally thanks to CodeCarbon's library.
It is designed for a setup where the server runs with valid credentials and queries experiment records directly from the official API.
- Read organizations, projects, and experiments from CodeCarbon API.
- Compute experiment consumption from run summaries.
- Recommend the least emitting experiment with an optional minimum accuracy.
- Provide demo prompt scenarios for Friday's presentation.
- Create
- Python 3.12
- pip
- uv
- Clone the repository:
git clone <repository-url>
cd mcp-cc- Install dependencies:
pip install -r requirements.txtBefore running the server, at the root of the project, execute the command "codecarbon login" then login to your codecarbon account, a credential file will be generated at the root.
From repository root:
uv run server.pyThe server will start and be ready to receive MCP client connections.
API tools:
check_authlist_organizationslist_projectslist_experimentsget_experiment_consumptionget_experiment_consumption_by_namerecommend_lowest_emission_experimentdemo_prompt_scenarioscreate_exprimentLocal tools:start_trackingstop_trackingget_statusget_current_metrics
The recommend_lowest_emission_experiment tool can enforce min_accuracy, but the API
does not expose a dedicated accuracy field today. The server infers accuracy from
experiment name or description when formatted like:
accuracy=92.4accuracy: 92.4%