@nikeandocean/carbon-factor-matcher 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +236 -252
- package/index.js +47 -28
- package/package.json +1 -2
- package/src/carbon_factor_matcher/__init__.py +0 -3
- package/src/carbon_factor_matcher/__main__.py +0 -5
- package/src/carbon_factor_matcher/adapters/__init__.py +0 -6
- package/src/carbon_factor_matcher/adapters/base.py +0 -22
- package/src/carbon_factor_matcher/adapters/ecoinvent.py +0 -292
- package/src/carbon_factor_matcher/api_client.py +0 -94
- package/src/carbon_factor_matcher/config.py +0 -14
- package/src/carbon_factor_matcher/factor_db.py +0 -220
- package/src/carbon_factor_matcher/license.py +0 -80
- package/src/carbon_factor_matcher/matcher.py +0 -795
- package/src/carbon_factor_matcher/models.py +0 -71
- package/src/carbon_factor_matcher/server.py +0 -232
- package/src/carbon_factor_matcher/usage_tracker.py +0 -68
package/README.md
CHANGED
|
@@ -1,252 +1,236 @@
|
|
|
1
|
-
# Carbon Factor Matcher — MCP Server for Carbon Accounting
|
|
2
|
-
|
|
3
|
-
An MCP (Model Context Protocol) server that connects LLMs with carbon footprint databases. It provides intelligent emission factor matching for carbon accounting, LCA (Life Cycle Assessment), and ESG reporting applications.
|
|
4
|
-
|
|
5
|
-
## What is this MCP?
|
|
6
|
-
|
|
7
|
-
Carbon Factor Matcher helps AI agents and LLM-based applications find the most appropriate emission factors from standardized environmental databases. It uses a two-stage hybrid search algorithm:
|
|
8
|
-
|
|
9
|
-
1. **Embedding-based rough filtering** — Semantic similarity to find candidate factors
|
|
10
|
-
2. **LLM-based fine ranking** — AI-powered selection with reasoning and confidence scores
|
|
11
|
-
|
|
12
|
-
### Supported Databases
|
|
13
|
-
|
|
14
|
-
- **ELCD** — European Reference Life Cycle Database (~600 factors, included in Free tier)
|
|
15
|
-
- **ecoinvent 3.10** — Swiss Centre for Life Cycle Inventories (~21,000 factors, Pro license required)
|
|
16
|
-
|
|
17
|
-
### Key Features
|
|
18
|
-
|
|
19
|
-
- 5-dimension data quality rating (technology, geography, source, time, factor type)
|
|
20
|
-
- Multi-language support (Chinese/English activity descriptions)
|
|
21
|
-
- MCP-compatible — works with Claude, Cursor, Windsurf, Cline, Continue, and any MCP client
|
|
22
|
-
|
|
23
|
-
## Installation
|
|
24
|
-
|
|
25
|
-
### Claude Code
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
claude mcp add carbon-factor-matcher -- npx -y @nikeandocean/carbon-factor-matcher
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Claude Desktop
|
|
32
|
-
|
|
33
|
-
Add to `claude_desktop_config.json`:
|
|
34
|
-
|
|
35
|
-
```json
|
|
36
|
-
{
|
|
37
|
-
"mcpServers": {
|
|
38
|
-
"carbon-factor-matcher": {
|
|
39
|
-
"command": "npx",
|
|
40
|
-
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Config file locations:
|
|
47
|
-
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
48
|
-
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
49
|
-
|
|
50
|
-
### Cursor
|
|
51
|
-
|
|
52
|
-
Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
|
|
53
|
-
|
|
54
|
-
```json
|
|
55
|
-
{
|
|
56
|
-
"mcpServers": {
|
|
57
|
-
"carbon-factor-matcher": {
|
|
58
|
-
"command": "npx",
|
|
59
|
-
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Or via Cursor UI: **Settings → MCP → Add new global MCP server**.
|
|
66
|
-
|
|
67
|
-
### Windsurf
|
|
68
|
-
|
|
69
|
-
Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
70
|
-
|
|
71
|
-
```json
|
|
72
|
-
{
|
|
73
|
-
"mcpServers": {
|
|
74
|
-
"carbon-factor-matcher": {
|
|
75
|
-
"command": "npx",
|
|
76
|
-
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
Or via Windsurf UI: **Settings → Cascade → MCP Servers → Add**.
|
|
83
|
-
|
|
84
|
-
### Cline (VS Code Extension)
|
|
85
|
-
|
|
86
|
-
Add to Cline MCP settings (click **MCP Servers** icon in Cline panel):
|
|
87
|
-
|
|
88
|
-
```json
|
|
89
|
-
{
|
|
90
|
-
"mcpServers": {
|
|
91
|
-
"carbon-factor-matcher": {
|
|
92
|
-
"command": "npx",
|
|
93
|
-
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Continue (VS Code / JetBrains)
|
|
100
|
-
|
|
101
|
-
Add to `~/.continue/config.yaml`:
|
|
102
|
-
|
|
103
|
-
```yaml
|
|
104
|
-
mcpServers:
|
|
105
|
-
- name: carbon-factor-matcher
|
|
106
|
-
command: npx
|
|
107
|
-
args:
|
|
108
|
-
- "-y"
|
|
109
|
-
- "@nikeandocean/carbon-factor-matcher"
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Smithery.ai (One-Click Install)
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
npx -y smithery mcp add nikeandocean/carbon-factor-matcher
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
Or visit [smithery.ai/server/@nikeandocean/carbon-factor-matcher](https://smithery.ai/server/@nikeandocean/carbon-factor-matcher) for hosted endpoint.
|
|
119
|
-
|
|
120
|
-
## Pro License
|
|
121
|
-
|
|
122
|
-
The Free tier works immediately after installation (300 queries/day, ELCD database, keyword search). To unlock the full experience:
|
|
123
|
-
|
|
124
|
-
| Plan | Price | Features |
|
|
125
|
-
|------|-------|----------|
|
|
126
|
-
| **Free** | $0 | ELCD database (~600 factors), keyword search, 300 queries/day |
|
|
127
|
-
| **Pro** | $5 (one-time) | ELCD + ecoinvent (~21,000 factors), LLM-powered matching, unlimited queries, data quality rating |
|
|
128
|
-
|
|
129
|
-
### Purchase License Key
|
|
130
|
-
|
|
131
|
-
👉 **[Buy Pro License](https://nikeandocean.github.io/carbon-factor-matcher)**
|
|
132
|
-
|
|
133
|
-
After purchase, you'll receive a license key via email. Set it as an environment variable in your MCP config:
|
|
134
|
-
|
|
135
|
-
```json
|
|
136
|
-
{
|
|
137
|
-
"mcpServers": {
|
|
138
|
-
"carbon-factor-matcher": {
|
|
139
|
-
"command": "npx",
|
|
140
|
-
"args": ["-y", "@nikeandocean/carbon-factor-matcher"],
|
|
141
|
-
"env": {
|
|
142
|
-
"CARBON_FACTOR_LICENSE_KEY": "PRO-xxxx-xxxx",
|
|
143
|
-
"LLM_API_KEY": "sk-xxxx",
|
|
144
|
-
"LLM_BASE_URL": "https://api.deepseek.com",
|
|
145
|
-
"LLM_MODEL": "deepseek-chat"
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## Configuration
|
|
153
|
-
|
|
154
|
-
| Variable | Description | Default |
|
|
155
|
-
|----------|-------------|---------|
|
|
156
|
-
| `CARBON_FACTOR_LICENSE_KEY` | Your license key (empty = Free tier) | — |
|
|
157
|
-
| `LLM_API_KEY` | LLM API key for Pro matching (DeepSeek/OpenAI) | — |
|
|
158
|
-
| `LLM_BASE_URL` | LLM endpoint URL | `https://api.deepseek.com` |
|
|
159
|
-
| `LLM_MODEL` | LLM model name | `deepseek-chat` |
|
|
160
|
-
| `CARBON_FACTOR_DATA_DIR` | Path to local factor database | `data/factors` |
|
|
161
|
-
|
|
162
|
-
## Available Tools
|
|
163
|
-
|
|
164
|
-
### `factor_match`
|
|
165
|
-
|
|
166
|
-
Match activity data to the best emission factor. Free tier uses keyword search; Pro tier uses hybrid embedding + LLM matching with quality assessment.
|
|
167
|
-
|
|
168
|
-
**Input:**
|
|
169
|
-
```json
|
|
170
|
-
{
|
|
171
|
-
"activity_data": "Factory in Shenzhen, 10kV industrial electricity, 2024, semiconductor fab",
|
|
172
|
-
"top_k": 10
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
**Output:**
|
|
177
|
-
```json
|
|
178
|
-
{
|
|
179
|
-
"selected_factor": {
|
|
180
|
-
"id": "elec-cn-south-10kv-2024",
|
|
181
|
-
"name": "Electricity, 10kV, South China Grid",
|
|
182
|
-
"value": 0.6101,
|
|
183
|
-
"unit": "kgCO2e/kWh"
|
|
184
|
-
},
|
|
185
|
-
"confidence": 0.92,
|
|
186
|
-
"reason": "Best match for industrial electricity in South China region",
|
|
187
|
-
"alternatives": [...]
|
|
188
|
-
}
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### `factor_search`
|
|
192
|
-
|
|
193
|
-
Search emission factors by keyword with optional filters.
|
|
194
|
-
|
|
195
|
-
**Input:**
|
|
196
|
-
```json
|
|
197
|
-
{
|
|
198
|
-
"query": "diesel",
|
|
199
|
-
"category": "fuel",
|
|
200
|
-
"limit": 10
|
|
201
|
-
}
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### `factor_detail`
|
|
205
|
-
|
|
206
|
-
Get full metadata for a specific factor.
|
|
207
|
-
|
|
208
|
-
**Input:**
|
|
209
|
-
```json
|
|
210
|
-
{
|
|
211
|
-
"factor_id": "elec-cn-south-10kv-2024"
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
##
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
- **
|
|
228
|
-
- **
|
|
229
|
-
|
|
230
|
-
##
|
|
231
|
-
|
|
232
|
-
This
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
| **Smithery.ai** | [smithery.ai/server/@nikeandocean/carbon-factor-matcher](https://smithery.ai/server/@nikeandocean/carbon-factor-matcher) | Listed |
|
|
238
|
-
| **mcp.so** | [mcp.so](https://mcp.so) | Submit via site |
|
|
239
|
-
| **Glama.ai** | [glama.ai/mcp/servers](https://glama.ai/mcp/servers) | Auto-indexed from npm |
|
|
240
|
-
|
|
241
|
-
## Support
|
|
242
|
-
|
|
243
|
-
- **Email:** tao.yan@zju.edu.cn
|
|
244
|
-
- **Issues:** https://github.com/tra121vel/carbon-factor-matcher/issues
|
|
245
|
-
|
|
246
|
-
## License
|
|
247
|
-
|
|
248
|
-
This is proprietary software. See [LICENSE](LICENSE) for details.
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
© 2024 Carbon Factor Matcher. All rights reserved.
|
|
1
|
+
# Carbon Factor Matcher — MCP Server for Carbon Accounting
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that connects LLMs with carbon footprint databases. It provides intelligent emission factor matching for carbon accounting, LCA (Life Cycle Assessment), and ESG reporting applications.
|
|
4
|
+
|
|
5
|
+
## What is this MCP?
|
|
6
|
+
|
|
7
|
+
Carbon Factor Matcher helps AI agents and LLM-based applications find the most appropriate emission factors from standardized environmental databases. It uses a two-stage hybrid search algorithm:
|
|
8
|
+
|
|
9
|
+
1. **Embedding-based rough filtering** — Semantic similarity to find candidate factors
|
|
10
|
+
2. **LLM-based fine ranking** — AI-powered selection with reasoning and confidence scores
|
|
11
|
+
|
|
12
|
+
### Supported Databases
|
|
13
|
+
|
|
14
|
+
- **ELCD** — European Reference Life Cycle Database (~600 factors, included in Free tier)
|
|
15
|
+
- **ecoinvent 3.10** — Swiss Centre for Life Cycle Inventories (~21,000 factors, Pro license required)
|
|
16
|
+
|
|
17
|
+
### Key Features
|
|
18
|
+
|
|
19
|
+
- 5-dimension data quality rating (technology, geography, source, time, factor type)
|
|
20
|
+
- Multi-language support (Chinese/English activity descriptions)
|
|
21
|
+
- MCP-compatible — works with Claude, Cursor, Windsurf, Cline, Continue, and any MCP client
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
### Claude Code
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
claude mcp add carbon-factor-matcher -- npx -y @nikeandocean/carbon-factor-matcher
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Claude Desktop
|
|
32
|
+
|
|
33
|
+
Add to `claude_desktop_config.json`:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"carbon-factor-matcher": {
|
|
39
|
+
"command": "npx",
|
|
40
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Config file locations:
|
|
47
|
+
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
48
|
+
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
49
|
+
|
|
50
|
+
### Cursor
|
|
51
|
+
|
|
52
|
+
Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"carbon-factor-matcher": {
|
|
58
|
+
"command": "npx",
|
|
59
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Or via Cursor UI: **Settings → MCP → Add new global MCP server**.
|
|
66
|
+
|
|
67
|
+
### Windsurf
|
|
68
|
+
|
|
69
|
+
Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"mcpServers": {
|
|
74
|
+
"carbon-factor-matcher": {
|
|
75
|
+
"command": "npx",
|
|
76
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or via Windsurf UI: **Settings → Cascade → MCP Servers → Add**.
|
|
83
|
+
|
|
84
|
+
### Cline (VS Code Extension)
|
|
85
|
+
|
|
86
|
+
Add to Cline MCP settings (click **MCP Servers** icon in Cline panel):
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"mcpServers": {
|
|
91
|
+
"carbon-factor-matcher": {
|
|
92
|
+
"command": "npx",
|
|
93
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Continue (VS Code / JetBrains)
|
|
100
|
+
|
|
101
|
+
Add to `~/.continue/config.yaml`:
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
mcpServers:
|
|
105
|
+
- name: carbon-factor-matcher
|
|
106
|
+
command: npx
|
|
107
|
+
args:
|
|
108
|
+
- "-y"
|
|
109
|
+
- "@nikeandocean/carbon-factor-matcher"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Smithery.ai (One-Click Install)
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npx -y smithery mcp add nikeandocean/carbon-factor-matcher
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Or visit [smithery.ai/server/@nikeandocean/carbon-factor-matcher](https://smithery.ai/server/@nikeandocean/carbon-factor-matcher) for hosted endpoint.
|
|
119
|
+
|
|
120
|
+
## Pro License
|
|
121
|
+
|
|
122
|
+
The Free tier works immediately after installation (300 queries/day, ELCD database, keyword search). To unlock the full experience:
|
|
123
|
+
|
|
124
|
+
| Plan | Price | Features |
|
|
125
|
+
|------|-------|----------|
|
|
126
|
+
| **Free** | $0 | ELCD database (~600 factors), keyword search, 300 queries/day |
|
|
127
|
+
| **Pro** | $5 (one-time) | ELCD + ecoinvent (~21,000 factors), LLM-powered matching, unlimited queries, data quality rating |
|
|
128
|
+
|
|
129
|
+
### Purchase License Key
|
|
130
|
+
|
|
131
|
+
👉 **[Buy Pro License](https://nikeandocean.github.io/carbon-factor-matcher)**
|
|
132
|
+
|
|
133
|
+
After purchase, you'll receive a license key via email. Set it as an environment variable in your MCP config:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"carbon-factor-matcher": {
|
|
139
|
+
"command": "npx",
|
|
140
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"],
|
|
141
|
+
"env": {
|
|
142
|
+
"CARBON_FACTOR_LICENSE_KEY": "PRO-xxxx-xxxx",
|
|
143
|
+
"LLM_API_KEY": "sk-xxxx",
|
|
144
|
+
"LLM_BASE_URL": "https://api.deepseek.com",
|
|
145
|
+
"LLM_MODEL": "deepseek-chat"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Configuration
|
|
153
|
+
|
|
154
|
+
| Variable | Description | Default |
|
|
155
|
+
|----------|-------------|---------|
|
|
156
|
+
| `CARBON_FACTOR_LICENSE_KEY` | Your license key (empty = Free tier) | — |
|
|
157
|
+
| `LLM_API_KEY` | LLM API key for Pro matching (DeepSeek/OpenAI) | — |
|
|
158
|
+
| `LLM_BASE_URL` | LLM endpoint URL | `https://api.deepseek.com` |
|
|
159
|
+
| `LLM_MODEL` | LLM model name | `deepseek-chat` |
|
|
160
|
+
| `CARBON_FACTOR_DATA_DIR` | Path to local factor database | `data/factors` |
|
|
161
|
+
|
|
162
|
+
## Available Tools
|
|
163
|
+
|
|
164
|
+
### `factor_match`
|
|
165
|
+
|
|
166
|
+
Match activity data to the best emission factor. Free tier uses keyword search; Pro tier uses hybrid embedding + LLM matching with quality assessment.
|
|
167
|
+
|
|
168
|
+
**Input:**
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"activity_data": "Factory in Shenzhen, 10kV industrial electricity, 2024, semiconductor fab",
|
|
172
|
+
"top_k": 10
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Output:**
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"selected_factor": {
|
|
180
|
+
"id": "elec-cn-south-10kv-2024",
|
|
181
|
+
"name": "Electricity, 10kV, South China Grid",
|
|
182
|
+
"value": 0.6101,
|
|
183
|
+
"unit": "kgCO2e/kWh"
|
|
184
|
+
},
|
|
185
|
+
"confidence": 0.92,
|
|
186
|
+
"reason": "Best match for industrial electricity in South China region",
|
|
187
|
+
"alternatives": [...]
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### `factor_search`
|
|
192
|
+
|
|
193
|
+
Search emission factors by keyword with optional filters.
|
|
194
|
+
|
|
195
|
+
**Input:**
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"query": "diesel",
|
|
199
|
+
"category": "fuel",
|
|
200
|
+
"limit": 10
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### `factor_detail`
|
|
205
|
+
|
|
206
|
+
Get full metadata for a specific factor.
|
|
207
|
+
|
|
208
|
+
**Input:**
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"factor_id": "elec-cn-south-10kv-2024"
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Demo
|
|
216
|
+
|
|
217
|
+
👉 **[Try the Live Demo](https://nikeandocean.github.io/carbon-factor-matcher/demo.html)** — Search 30+ emission factors directly in your browser (no installation needed).
|
|
218
|
+
|
|
219
|
+
## System Requirements
|
|
220
|
+
|
|
221
|
+
- Node.js 18+ (for `npx`)
|
|
222
|
+
- Python 3.11+ (auto-installed via pip)
|
|
223
|
+
- LLM API key (Pro tier only — DeepSeek recommended)
|
|
224
|
+
|
|
225
|
+
## Support
|
|
226
|
+
|
|
227
|
+
- **Email:** tao.yan@zju.edu.cn
|
|
228
|
+
- **Issues:** https://github.com/tra121vel/carbon-factor-matcher/issues
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
This is proprietary software. See [LICENSE](LICENSE) for details.
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
© 2024 Carbon Factor Matcher. All rights reserved.
|
package/index.js
CHANGED
|
@@ -1,28 +1,47 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Carbon Factor Matcher - MCP Server
|
|
5
|
-
*
|
|
6
|
-
* npm wrapper that launches the Python MCP server.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const { execSync, spawn } = require('child_process');
|
|
11
|
-
|
|
12
|
-
// Check if Python is available
|
|
13
|
-
try {
|
|
14
|
-
execSync('python --version', { stdio: 'ignore' });
|
|
15
|
-
} catch (e) {
|
|
16
|
-
console.error('Error: Python 3.11+ is required to run carbon-factor-matcher');
|
|
17
|
-
console.error('Install from https://www.python.org/downloads/');
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
stdio: '
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Carbon Factor Matcher - MCP Server
|
|
5
|
+
*
|
|
6
|
+
* npm wrapper that launches the Python MCP server.
|
|
7
|
+
* Auto-installs from PyPI if not already present.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const { execSync, spawn } = require('child_process');
|
|
11
|
+
|
|
12
|
+
// Check if Python is available
|
|
13
|
+
try {
|
|
14
|
+
execSync('python --version', { stdio: 'ignore' });
|
|
15
|
+
} catch (e) {
|
|
16
|
+
console.error('Error: Python 3.11+ is required to run carbon-factor-matcher');
|
|
17
|
+
console.error('Install from https://www.python.org/downloads/');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Ensure the Python package is installed (upgrade if outdated)
|
|
22
|
+
try {
|
|
23
|
+
execSync('python -c "import carbon_factor_matcher"', { stdio: 'ignore' });
|
|
24
|
+
// Package exists, try to upgrade silently
|
|
25
|
+
try {
|
|
26
|
+
execSync('pip install --upgrade carbon-factor-matcher', { stdio: 'ignore' });
|
|
27
|
+
} catch (_) {
|
|
28
|
+
// Ignore upgrade failures (offline, permission, etc.)
|
|
29
|
+
}
|
|
30
|
+
} catch (_) {
|
|
31
|
+
console.error('Installing carbon-factor-matcher from PyPI...');
|
|
32
|
+
try {
|
|
33
|
+
execSync('pip install carbon-factor-matcher', { stdio: 'inherit' });
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error('Failed to install. Run manually: pip install carbon-factor-matcher');
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Launch the MCP server
|
|
41
|
+
const child = spawn('python', ['-m', 'carbon_factor_matcher'], {
|
|
42
|
+
stdio: 'inherit',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
child.on('exit', (code) => {
|
|
46
|
+
process.exit(code || 0);
|
|
47
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nikeandocean/carbon-factor-matcher",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "MCP server for intelligent emission factor matching — connects LLMs with carbon emission factor databases (ELCD, ecoinvent)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"index.js",
|
|
11
|
-
"src/carbon_factor_matcher/**/*.py",
|
|
12
11
|
"README.md",
|
|
13
12
|
"LICENSE"
|
|
14
13
|
],
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"""Base class for factor database adapters."""
|
|
2
|
-
|
|
3
|
-
from abc import ABC, abstractmethod
|
|
4
|
-
|
|
5
|
-
from carbon_factor_matcher.models import Factor
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class FactorAdapter(ABC):
|
|
9
|
-
"""Abstract base class for loading emission factors from different data sources.
|
|
10
|
-
|
|
11
|
-
Each adapter knows how to parse a specific format (ELCD JSON-LD,
|
|
12
|
-
ecoinvent Excel, EcoSpold2 XML, etc.) and return a list of Factor objects.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
@abstractmethod
|
|
16
|
-
def load(self) -> list[Factor]:
|
|
17
|
-
"""Load all factors from the data source.
|
|
18
|
-
|
|
19
|
-
Returns:
|
|
20
|
-
List of Factor objects ready for matching.
|
|
21
|
-
"""
|
|
22
|
-
...
|