Octopus Energy MCP Server
Enables retrieval of electricity and gas consumption data from Octopus Energy accounts through their API, with support for date range filtering, pagination, and grouping by time periods.
README
Octopus Energy MCP Server
An MCP (Model Context Protocol) server for interacting with the Octopus Energy API to retrieve electricity and gas consumption data.
Features
- Get electricity consumption data (kWh with 0.045 kWh precision)
- Get gas consumption data (kWh for SMETS1 meters, cubic meters for SMETS2 meters)
- Support for date range filtering
- Pagination support
- Group by day, week, month, or quarter
- Order by period (ascending or descending)
Prerequisites
- Node.js (v18 or higher recommended)
- An Octopus Energy API key
- Your meter details (MPAN/MPRN and serial number)
Getting Your API Key and Meter Details
- API Key: Log into your Octopus Energy account at https://octopus.energy/dashboard/new/accounts/personal-details/api-access
- Meter Details: You can find your MPAN (electricity) or MPRN (gas) and meter serial numbers:
- On your energy bill
- In your Octopus Energy account dashboard
- Via the Octopus Energy account API endpoint
Installation
- Clone or download this repository
- Install dependencies:
npm install
- Create a
.envfile from the example:
cp .env.example .env
- Edit
.envand add your Octopus Energy credentials:
OCTOPUS_API_KEY=your_api_key_here
ELECTRICITY_MPAN=1234567890123
ELECTRICITY_SERIAL_NUMBER=12A3456789
GAS_MPRN=9876543210
GAS_SERIAL_NUMBER=G4A1234567
- Build the project:
npm run build
Configuration
The server loads environment variables from a .env file in the project root. This file should contain:
- OCTOPUS_API_KEY (required): Your API key for authentication
- ELECTRICITY_MPAN (optional): Your 13-digit electricity meter point number
- ELECTRICITY_SERIAL_NUMBER (optional): Your electricity meter serial number
- GAS_MPRN (optional): Your 10-digit gas meter point reference number
- GAS_SERIAL_NUMBER (optional): Your gas meter serial number
If you configure the meter details in .env, you won't need to provide them when calling the tools. You can still override them by passing parameters to the tools if needed.
Note: The .env file is ignored by git to keep your credentials secure.
Usage with Claude Desktop
Add this to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"octopus-energy": {
"command": "node",
"args": ["/absolute/path/to/octopus-mcp-server/dist/index.js"]
}
}
}
Replace /absolute/path/to/octopus-mcp-server with the actual path to this project directory.
Note: The server will automatically load your API key from the .env file in the project directory. Alternatively, you can override it by adding an env section to the config:
{
"mcpServers": {
"octopus-energy": {
"command": "node",
"args": ["/absolute/path/to/octopus-mcp-server/dist/index.js"],
"env": {
"OCTOPUS_API_KEY": "your_api_key_here"
}
}
}
}
Available Tools
get_electricity_consumption
Retrieves electricity consumption data.
Parameters:
mpan(string, optional): The MPAN (Meter Point Administration Number). UsesELECTRICITY_MPANfrom .env if not provided.serial_number(string, optional): The meter serial number. UsesELECTRICITY_SERIAL_NUMBERfrom .env if not provided.period_from(string, optional): Start date/time in ISO 8601 format (e.g., "2024-01-01T00:00:00Z")period_to(string, optional): End date/time in ISO 8601 format (e.g., "2024-01-31T23:59:59Z")page_size(number, optional): Number of results per page (default: 100, max: 25000)order_by(string, optional): Set to "period" to return earliest records first (default: latest first)group_by(string, optional): Group results by "day", "week", "month", or "quarter"
Example with meter details in .env:
{
"period_from": "2024-01-01T00:00:00Z",
"period_to": "2024-01-31T23:59:59Z",
"group_by": "day"
}
Example with explicit parameters:
{
"mpan": "1234567890123",
"serial_number": "12A3456789",
"period_from": "2024-01-01T00:00:00Z",
"period_to": "2024-01-31T23:59:59Z",
"group_by": "day"
}
get_gas_consumption
Retrieves gas consumption data.
Parameters:
mprn(string, optional): The MPRN (Meter Point Reference Number). UsesGAS_MPRNfrom .env if not provided.serial_number(string, optional): The meter serial number. UsesGAS_SERIAL_NUMBERfrom .env if not provided.period_from(string, optional): Start date/time in ISO 8601 format (e.g., "2024-01-01T00:00:00Z")period_to(string, optional): End date/time in ISO 8601 format (e.g., "2024-01-31T23:59:59Z")page_size(number, optional): Number of results per page (default: 100, max: 25000)order_by(string, optional): Set to "period" to return earliest records first (default: latest first)group_by(string, optional): Group results by "day", "week", "month", or "quarter"
Example with meter details in .env:
{
"period_from": "2024-11-01T00:00:00Z",
"period_to": "2024-11-30T23:59:59Z",
"group_by": "week"
}
Example with explicit parameters:
{
"mprn": "9876543210",
"serial_number": "G4A1234567",
"period_from": "2024-11-01T00:00:00Z",
"period_to": "2024-11-30T23:59:59Z",
"group_by": "week"
}
Response Format
Both tools return consumption data in the following format:
{
"count": 100,
"next": "https://api.octopus.energy/v1/...",
"previous": null,
"results": [
{
"consumption": 1.234,
"interval_start": "2024-01-01T00:00:00Z",
"interval_end": "2024-01-01T00:30:00Z"
}
]
}
Development
Build the project:
npm run build
Run in development mode:
npm run dev
Watch for changes:
npm run watch
API Documentation
For more information about the Octopus Energy API:
Troubleshooting
"OCTOPUS_API_KEY environment variable is not set"
Make sure you've set the API key in your environment or in the Claude Desktop configuration.
Authentication errors (401)
Verify your API key is correct and active.
Invalid MPAN/MPRN or serial number
Double-check your meter details from your Octopus Energy account or bill.
Date format errors
Ensure dates are in ISO 8601 format with UTC indicator (Z suffix), e.g., "2024-01-01T00:00:00Z"
License
ISC
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。