carbon-factor-matcher 1.0.9__tar.gz
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.
- carbon_factor_matcher-1.0.9/.gitignore +53 -0
- carbon_factor_matcher-1.0.9/CLAUDE.md +189 -0
- carbon_factor_matcher-1.0.9/MANIFEST.in +3 -0
- carbon_factor_matcher-1.0.9/PKG-INFO +261 -0
- carbon_factor_matcher-1.0.9/PRIVACY.md +3 -0
- carbon_factor_matcher-1.0.9/README.md +238 -0
- carbon_factor_matcher-1.0.9/REFUND.md +3 -0
- carbon_factor_matcher-1.0.9/SKILL.md +92 -0
- carbon_factor_matcher-1.0.9/TERMS.md +3 -0
- carbon_factor_matcher-1.0.9/build.py +61 -0
- carbon_factor_matcher-1.0.9/build_protected.py +137 -0
- carbon_factor_matcher-1.0.9/data/factors/.gitkeep +0 -0
- carbon_factor_matcher-1.0.9/docs/superpowers/plans/2026-06-13-commercialization.md +1163 -0
- carbon_factor_matcher-1.0.9/docs/superpowers/plans/2026-06-13-fix-code-inconsistency.md +553 -0
- carbon_factor_matcher-1.0.9/docs/superpowers/specs/2026-06-13-commercialization-design.md +501 -0
- carbon_factor_matcher-1.0.9/docs/superpowers/specs/2026-06-13-fix-code-inconsistency-design.md +226 -0
- carbon_factor_matcher-1.0.9/generate_license.py +61 -0
- carbon_factor_matcher-1.0.9/index.js +47 -0
- carbon_factor_matcher-1.0.9/lemonsqueezy_integration.py +180 -0
- carbon_factor_matcher-1.0.9/package.json +48 -0
- carbon_factor_matcher-1.0.9/pyproject.toml +46 -0
- carbon_factor_matcher-1.0.9/smithery.yaml +193 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/__init__.py +3 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/__main__.py +5 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/adapters/__init__.py +6 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/adapters/base.py +22 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/adapters/ecoinvent.py +292 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/api_client.py +116 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/config.py +14 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/factor_db.py +220 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/license.py +80 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/matcher.py +795 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/models.py +72 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/server.py +343 -0
- carbon_factor_matcher-1.0.9/src/carbon_factor_matcher/usage_tracker.py +68 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.pyc
|
|
4
|
+
*.pyo
|
|
5
|
+
*.egg-info/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
.eggs/
|
|
9
|
+
*.egg
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
|
|
13
|
+
# Virtual environment
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
|
|
17
|
+
# Data files
|
|
18
|
+
*.zolca
|
|
19
|
+
*.zip
|
|
20
|
+
data/factors/*.json
|
|
21
|
+
data/factors/processes/
|
|
22
|
+
data/factors/flows/
|
|
23
|
+
data/factors/unit_groups/
|
|
24
|
+
data/factors/flow_properties/
|
|
25
|
+
data/factors/lcia_categories/
|
|
26
|
+
data/factors/locations/
|
|
27
|
+
data/factors/sources/
|
|
28
|
+
data/factors/actors/
|
|
29
|
+
data/factors/bin/
|
|
30
|
+
data/factors/currencies/
|
|
31
|
+
data/factors/dq_systems/
|
|
32
|
+
data/factors/lcia_methods/
|
|
33
|
+
!data/factors/.gitkeep
|
|
34
|
+
|
|
35
|
+
# Environment
|
|
36
|
+
.env
|
|
37
|
+
.env.local
|
|
38
|
+
|
|
39
|
+
# IDE
|
|
40
|
+
.idea/
|
|
41
|
+
.vscode/
|
|
42
|
+
*.swp
|
|
43
|
+
*.swo
|
|
44
|
+
|
|
45
|
+
# OS
|
|
46
|
+
.DS_Store
|
|
47
|
+
Thumbs.db
|
|
48
|
+
usage.db
|
|
49
|
+
|
|
50
|
+
# Workers
|
|
51
|
+
workers/.wrangler/
|
|
52
|
+
workers/factors.json
|
|
53
|
+
workers/node_modules/
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
Carbon Factor Matcher is a **commercial MCP server** that connects LLMs with carbon emission factor databases (ELCD, ecoinvent 3.10). It uses a two-stage hybrid search algorithm: embedding-based rough filtering + LLM-based fine ranking with 5-dimension data quality assessment. Licensed under a Free/Pro tier model ($5 one-time for Pro).
|
|
8
|
+
|
|
9
|
+
## Build & Run
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Install for development (editable)
|
|
13
|
+
pip install -e .
|
|
14
|
+
|
|
15
|
+
# Run the MCP server
|
|
16
|
+
python -m carbon_factor_matcher
|
|
17
|
+
# or
|
|
18
|
+
carbon-factor-matcher
|
|
19
|
+
|
|
20
|
+
# Run all tests
|
|
21
|
+
pytest
|
|
22
|
+
|
|
23
|
+
# Run a single test file
|
|
24
|
+
pytest tests/test_license.py
|
|
25
|
+
|
|
26
|
+
# Run a single test class or method
|
|
27
|
+
pytest tests/test_license.py::TestLicenseManager::test_pro_key
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Architecture
|
|
31
|
+
|
|
32
|
+
### Core Pipeline (matcher.py)
|
|
33
|
+
|
|
34
|
+
`EmissionFactorMatcher` implements the full matching pipeline:
|
|
35
|
+
|
|
36
|
+
- **Stage 0 — Unit pre-filter**: Hard constraint filtering by unit compatibility (supports Chinese/English unit aliases like `kWh` ↔ `千瓦时` ↔ `度`)
|
|
37
|
+
- **Stage 1 — Hybrid retrieval**: Keyword scoring (weight 0.3) + embedding similarity (weight 0.7). Optimization: keyword pre-filters to `keyword_top_n` candidates before computing expensive embeddings
|
|
38
|
+
- **Stage 2 — LLM fine ranking**: Sends candidates with quality ratings to DeepSeek/OpenAI for final selection. Falls back to hybrid scores on LLM failure
|
|
39
|
+
|
|
40
|
+
Embedding model: `shibing624/text2vec-base-chinese` (sentence-transformers, runs on CPU). Embeddings are lazily cached per factor index.
|
|
41
|
+
|
|
42
|
+
### Data Layer
|
|
43
|
+
|
|
44
|
+
- **`models.py`**: Core dataclasses — `Factor`, `Activity`, `MatchResult`
|
|
45
|
+
- **`factor_db.py`**: `FactorDatabase` loads factors from JSON-LD ILCD files (bundled in `data/factors/`) and compressed `.json.gz`. Supports adapter pattern via `load_adapter()`
|
|
46
|
+
- **`adapters/base.py`**: Abstract `FactorAdapter` base class
|
|
47
|
+
- **`adapters/ecoinvent.py`**: `EcoinventExcelAdapter` loads ecoinvent Database Overview Excel files (requires openpyxl)
|
|
48
|
+
|
|
49
|
+
### MCP Server (server.py)
|
|
50
|
+
|
|
51
|
+
`create_server()` wires everything together. Three MCP tools exposed:
|
|
52
|
+
- `factor_match` — Two-stage matching (Pro) or basic keyword search (Free)
|
|
53
|
+
- `factor_search` — Keyword search with category filter
|
|
54
|
+
- `factor_detail` — Full metadata for a specific factor
|
|
55
|
+
|
|
56
|
+
### Commercial Layer
|
|
57
|
+
|
|
58
|
+
- **`license.py`**: `LicenseManager` parses license key prefix (`PRO-*` → Pro tier). Free tier: 300 queries/day, no license key needed. Pro: unlimited queries + LLM matching
|
|
59
|
+
- **`usage_tracker.py`**: SQLite-based daily call tracking per user (hashed license key)
|
|
60
|
+
- **`api_client.py`**: `FactorAPIClient` queries the remote Cloudflare Worker API for factor data (no local database needed for end users)
|
|
61
|
+
|
|
62
|
+
### Configuration
|
|
63
|
+
|
|
64
|
+
All config via environment variables (resolved in `server.py:create_server()`):
|
|
65
|
+
|
|
66
|
+
| Variable | Default |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `CARBON_FACTOR_DATA_DIR` | `data/factors` (bundled) |
|
|
69
|
+
| `CARBON_FACTOR_LICENSE_KEY` | empty (Free) |
|
|
70
|
+
| `LLM_API_KEY` | — |
|
|
71
|
+
| `LLM_BASE_URL` | `https://api.deepseek.com` |
|
|
72
|
+
| `LLM_MODEL` | `deepseek-chat` |
|
|
73
|
+
| `EMBEDDING_MODEL` | `shibing624/text2vec-base-chinese` |
|
|
74
|
+
|
|
75
|
+
### npm Distribution
|
|
76
|
+
|
|
77
|
+
`index.js` is a Node.js wrapper that calls `python -m carbon_factor_matcher` via subprocess. Published to npm as `@nikeandocean/carbon-factor-matcher`. The `package.json` has no JS dependencies — it's purely a launcher.
|
|
78
|
+
|
|
79
|
+
## Commercial Infrastructure
|
|
80
|
+
|
|
81
|
+
### Cloudflare Worker (`workers/paddle-webhook.js`)
|
|
82
|
+
|
|
83
|
+
The Worker handles three responsibilities: checkout, webhook processing, and factor data API.
|
|
84
|
+
|
|
85
|
+
**Endpoints:**
|
|
86
|
+
|
|
87
|
+
| Endpoint | Method | Purpose |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| `/api/search?q=&category=&limit=` | GET | Keyword search over factors |
|
|
90
|
+
| `/api/factor/{id}` | GET | Full metadata for one factor |
|
|
91
|
+
| `/api/stats` | GET | Category breakdown + total count |
|
|
92
|
+
| `/checkout?email=` | GET | Create Paddle checkout, redirect to hosted page |
|
|
93
|
+
| `/webhook` | POST | Process Paddle events, generate license key, send email |
|
|
94
|
+
|
|
95
|
+
**Deploy:** `cd workers && npx wrangler deploy`
|
|
96
|
+
|
|
97
|
+
**Config (Cloudflare Secrets):**
|
|
98
|
+
- `PADDLE_API_KEY` — Paddle seller API key
|
|
99
|
+
- `PADDLE_WEBHOOK_SECRET` — Webhook signature verification
|
|
100
|
+
- `RESEND_API_KEY` — Email service API key
|
|
101
|
+
- `PADDLE_PRICE_ID` — Price object ID for checkout (format: `pri_xxxxx`)
|
|
102
|
+
|
|
103
|
+
**R2 Binding:** `CARBON_FACTORS` → bucket `carbon-factors`, key `factors.json`
|
|
104
|
+
|
|
105
|
+
### Data Processing (`workers/process_data.py`)
|
|
106
|
+
|
|
107
|
+
Converts raw JSON-LD files into a single `factors.json`:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
cd workers
|
|
111
|
+
python process_data.py # reads ../data/factors/processes/*.json, writes factors.json
|
|
112
|
+
# Upload to R2:
|
|
113
|
+
npx wrangler r2 object put carbon-factors/factors.json --file factors.json --remote
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Factor fields extracted: `id`, `name`, `category`, `value`, `unit`, `geography`, `source`, `year`, `applicability`, `quality_*` (5-dimension ratings).
|
|
117
|
+
|
|
118
|
+
Note: ELCD has ~600 factors, ecoinvent has ~21,000. The `process_data.py` reads from `data/factors/processes/` (ecoinvent).
|
|
119
|
+
|
|
120
|
+
### Paddle Integration Lessons
|
|
121
|
+
|
|
122
|
+
- **Paddle CDN (`cdn.paddle.com`) is blocked in China** via CloudFront. Do NOT use the Paddle JS SDK checkout popup.
|
|
123
|
+
- **Solution:** Server-side Paddle API (`POST https://api.paddle.com/transactions`) creates a checkout session, then redirect to `https://checkout.paddle.com/checkout/custom/{transaction_id}`. No client-side JS needed.
|
|
124
|
+
- **Price ID** is created in Paddle dashboard, not in code. Format: `pri_xxxxx`.
|
|
125
|
+
- **Webhook events** must verify HMAC signature using `paddle-webhook` secret.
|
|
126
|
+
- **Idempotency**: Processed transactions are stored in R2 at `processed/{txn_id}` to prevent duplicate license key generation on Paddle retries.
|
|
127
|
+
|
|
128
|
+
### GitHub Pages (public branch)
|
|
129
|
+
|
|
130
|
+
- `index.html` — Purchase page, links to Worker `/checkout` endpoint
|
|
131
|
+
- `demo.html` — Standalone demo with 30+ hardcoded ELCD factors, client-side search
|
|
132
|
+
- `TERMS.md`, `PRIVACY.md`, `REFUND.md` — Required by Paddle for compliance
|
|
133
|
+
- No Python code or data files on the public branch (`.gitignore` enforces this)
|
|
134
|
+
|
|
135
|
+
## Key Domain Concepts
|
|
136
|
+
|
|
137
|
+
- **Emission factor**: CO2-equivalent per unit activity (e.g., kgCO2e/kWh for electricity)
|
|
138
|
+
- **5-dimension quality rating**: technology representativeness (0.3), source reliability (0.4), geographic representativeness (0.1), time representativeness (0.1), factor type (0.1). Lower rating number = better quality (1=优, 2=中, 3=差)
|
|
139
|
+
- **ELCD**: European Reference Life Cycle Database — ~600 factors, source JSON-LD files in `data/factors/`. Processed to `factors.json` and hosted on Cloudflare R2
|
|
140
|
+
- **ecoinvent**: Commercial Swiss LCA database — ~21,000 factors pre-imported as JSON in `data/factors/processes/`, Pro-only. Additional data can be loaded via Excel adapter
|
|
141
|
+
|
|
142
|
+
## Testing Patterns
|
|
143
|
+
|
|
144
|
+
Tests use pytest with `asyncio_mode = "auto"`. Test files follow `test_*.py` naming. The `eval_*.py` files are evaluation scripts (not standard unit tests) for benchmarking matcher quality.
|
|
145
|
+
|
|
146
|
+
## Git Workflow — Dual Branch Strategy
|
|
147
|
+
|
|
148
|
+
This repo uses a **dual-branch** approach to keep core code private while maintaining a public GitHub page for commercial purposes.
|
|
149
|
+
|
|
150
|
+
### Branch Layout
|
|
151
|
+
|
|
152
|
+
| Branch | Content | Remote Tracking |
|
|
153
|
+
|--------|---------|-----------------|
|
|
154
|
+
| `master` | Full Python codebase (source, tests, data) | **None** — no upstream, safe from accidental push |
|
|
155
|
+
| `public` | README + policy files + LICENSE only | `origin/master` — the actual GitHub page |
|
|
156
|
+
|
|
157
|
+
### Why
|
|
158
|
+
|
|
159
|
+
GitHub serves as the product landing page for Paddle compliance (Terms, Privacy, Refund policies). Core code must not be exposed. The `master` branch has no remote tracking to prevent accidental `git push`.
|
|
160
|
+
|
|
161
|
+
### Common Operations
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Update GitHub public page
|
|
165
|
+
git checkout public
|
|
166
|
+
# edit README.md, TERMS.md, etc.
|
|
167
|
+
git add . && git commit -m "docs: ..."
|
|
168
|
+
git push public
|
|
169
|
+
|
|
170
|
+
# Switch back to development
|
|
171
|
+
git checkout master
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Important Notes
|
|
175
|
+
|
|
176
|
+
- **Never force-push `master` to origin** — it would overwrite the public page
|
|
177
|
+
- **`git push` on master will fail** (no upstream) — this is intentional
|
|
178
|
+
- The `public` branch is an orphan branch (no shared history with `master`)
|
|
179
|
+
- SSH is configured for GitHub via Clash SOCKS5 proxy on port 7897 (`~/.ssh/config`)
|
|
180
|
+
- `workers/factors.json` is not committed — lives in Cloudflare R2 only
|
|
181
|
+
- `workers/node_modules/` and `workers/.wrangler/` are gitignored
|
|
182
|
+
- The `workers/` directory must never appear on the `public` branch
|
|
183
|
+
|
|
184
|
+
## Network & Proxy
|
|
185
|
+
|
|
186
|
+
- Direct HTTPS to GitHub is blocked; use SSH with SOCKS5 proxy
|
|
187
|
+
- SSH config at `~/.ssh/config` routes `github.com` through `connect -S 127.0.0.1:7897`
|
|
188
|
+
- Clash proxy port: **7897** (not the default 7891 — verify with `netstat -an | grep 789` if connection fails)
|
|
189
|
+
- If `git push` times out, check that Clash is running and the port matches
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: carbon-factor-matcher
|
|
3
|
+
Version: 1.0.9
|
|
4
|
+
Summary: MCP server for intelligent emission factor matching using LLM-powered semantic search
|
|
5
|
+
Project-URL: Homepage, https://github.com/nikeandocean/carbon-factor-matcher
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Keywords: carbon,carbon-accounting,carbon-footprint,climate,ecoinvent,elcd,emission-factor,esg,ghg,lca,life-cycle-assessment,mcp,mcp-server,sustainability
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: Other/Proprietary License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Requires-Dist: mcp>=1.0.0
|
|
18
|
+
Requires-Dist: numpy>=1.24.0
|
|
19
|
+
Requires-Dist: openai>=1.0.0
|
|
20
|
+
Requires-Dist: openpyxl>=3.1.0
|
|
21
|
+
Requires-Dist: sentence-transformers>=3.0.0
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
[](https://smithery.ai/servers/nikeandocean/carbon-factor-matcher)
|
|
25
|
+
|
|
26
|
+
# Carbon Factor Matcher — MCP Server for Carbon Accounting
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
## What is this MCP?
|
|
31
|
+
|
|
32
|
+
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:
|
|
33
|
+
|
|
34
|
+
1. **Embedding-based rough filtering** — Semantic similarity to find candidate factors
|
|
35
|
+
2. **LLM-based fine ranking** — AI-powered selection with reasoning and confidence scores
|
|
36
|
+
|
|
37
|
+
### Supported Databases
|
|
38
|
+
|
|
39
|
+
- **ELCD** — European Reference Life Cycle Database (~600 factors, included in Free tier)
|
|
40
|
+
- **ecoinvent 3.10** — Swiss Centre for Life Cycle Inventories (~21,000 factors, Pro license required)
|
|
41
|
+
|
|
42
|
+
### Key Features
|
|
43
|
+
|
|
44
|
+
- 5-dimension data quality rating (technology, geography, source, time, factor type)
|
|
45
|
+
- Multi-language support (Chinese/English activity descriptions)
|
|
46
|
+
- MCP-compatible — works with Claude, Cursor, Windsurf, Cline, Continue, and any MCP client
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
### Claude Code
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
claude mcp add carbon-factor-matcher -- npx -y @nikeandocean/carbon-factor-matcher
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Claude Desktop
|
|
57
|
+
|
|
58
|
+
Add to `claude_desktop_config.json`:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"carbon-factor-matcher": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Config file locations:
|
|
72
|
+
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
73
|
+
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
74
|
+
|
|
75
|
+
### Cursor
|
|
76
|
+
|
|
77
|
+
Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"mcpServers": {
|
|
82
|
+
"carbon-factor-matcher": {
|
|
83
|
+
"command": "npx",
|
|
84
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Or via Cursor UI: **Settings → MCP → Add new global MCP server**.
|
|
91
|
+
|
|
92
|
+
### Windsurf
|
|
93
|
+
|
|
94
|
+
Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"mcpServers": {
|
|
99
|
+
"carbon-factor-matcher": {
|
|
100
|
+
"command": "npx",
|
|
101
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Or via Windsurf UI: **Settings → Cascade → MCP Servers → Add**.
|
|
108
|
+
|
|
109
|
+
### Cline (VS Code Extension)
|
|
110
|
+
|
|
111
|
+
Add to Cline MCP settings (click **MCP Servers** icon in Cline panel):
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"mcpServers": {
|
|
116
|
+
"carbon-factor-matcher": {
|
|
117
|
+
"command": "npx",
|
|
118
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Continue (VS Code / JetBrains)
|
|
125
|
+
|
|
126
|
+
Add to `~/.continue/config.yaml`:
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
mcpServers:
|
|
130
|
+
- name: carbon-factor-matcher
|
|
131
|
+
command: npx
|
|
132
|
+
args:
|
|
133
|
+
- "-y"
|
|
134
|
+
- "@nikeandocean/carbon-factor-matcher"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Smithery.ai (One-Click Install)
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npx -y smithery mcp add nikeandocean/carbon-factor-matcher
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Or visit [smithery.ai/server/@nikeandocean/carbon-factor-matcher](https://smithery.ai/server/@nikeandocean/carbon-factor-matcher) for hosted endpoint.
|
|
144
|
+
|
|
145
|
+
## Pro License
|
|
146
|
+
|
|
147
|
+
The Free tier works immediately after installation (300 queries/day, ELCD database, keyword search). To unlock the full experience:
|
|
148
|
+
|
|
149
|
+
| Plan | Price | Features |
|
|
150
|
+
|------|-------|----------|
|
|
151
|
+
| **Free** | $0 | ELCD database (~600 factors), keyword search, 300 queries/day |
|
|
152
|
+
| **Pro** | $5 (one-time) | ELCD + ecoinvent (~21,000 factors), LLM-powered matching, unlimited queries, data quality rating |
|
|
153
|
+
|
|
154
|
+
### Purchase License Key
|
|
155
|
+
|
|
156
|
+
👉 **[Buy Pro License](https://nikeandocean.github.io/carbon-factor-matcher)**
|
|
157
|
+
|
|
158
|
+
After purchase, you'll receive a license key via email. Set it as an environment variable in your MCP config:
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"mcpServers": {
|
|
163
|
+
"carbon-factor-matcher": {
|
|
164
|
+
"command": "npx",
|
|
165
|
+
"args": ["-y", "@nikeandocean/carbon-factor-matcher"],
|
|
166
|
+
"env": {
|
|
167
|
+
"CARBON_FACTOR_LICENSE_KEY": "PRO-xxxx-xxxx",
|
|
168
|
+
"LLM_API_KEY": "sk-xxxx",
|
|
169
|
+
"LLM_BASE_URL": "https://api.deepseek.com",
|
|
170
|
+
"LLM_MODEL": "deepseek-chat"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Configuration
|
|
178
|
+
|
|
179
|
+
| Variable | Description | Default |
|
|
180
|
+
|----------|-------------|---------|
|
|
181
|
+
| `CARBON_FACTOR_LICENSE_KEY` | Your license key (empty = Free tier) | — |
|
|
182
|
+
| `LLM_API_KEY` | LLM API key for Pro matching (DeepSeek/OpenAI) | — |
|
|
183
|
+
| `LLM_BASE_URL` | LLM endpoint URL | `https://api.deepseek.com` |
|
|
184
|
+
| `LLM_MODEL` | LLM model name | `deepseek-chat` |
|
|
185
|
+
| `CARBON_FACTOR_DATA_DIR` | Path to local factor database | `data/factors` |
|
|
186
|
+
|
|
187
|
+
## Available Tools
|
|
188
|
+
|
|
189
|
+
### `factor_match`
|
|
190
|
+
|
|
191
|
+
Match activity data to the best emission factor. Free tier uses keyword search; Pro tier uses hybrid embedding + LLM matching with quality assessment.
|
|
192
|
+
|
|
193
|
+
**Input:**
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"activity_data": "Factory in Shenzhen, 10kV industrial electricity, 2024, semiconductor fab",
|
|
197
|
+
"top_k": 10
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Output:**
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"selected_factor": {
|
|
205
|
+
"id": "elec-cn-south-10kv-2024",
|
|
206
|
+
"name": "Electricity, 10kV, South China Grid",
|
|
207
|
+
"value": 0.6101,
|
|
208
|
+
"unit": "kgCO2e/kWh"
|
|
209
|
+
},
|
|
210
|
+
"confidence": 0.92,
|
|
211
|
+
"reason": "Best match for industrial electricity in South China region",
|
|
212
|
+
"alternatives": [...]
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### `factor_search`
|
|
217
|
+
|
|
218
|
+
Search emission factors by keyword with optional filters.
|
|
219
|
+
|
|
220
|
+
**Input:**
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"query": "diesel",
|
|
224
|
+
"category": "fuel",
|
|
225
|
+
"limit": 10
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### `factor_detail`
|
|
230
|
+
|
|
231
|
+
Get full metadata for a specific factor.
|
|
232
|
+
|
|
233
|
+
**Input:**
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"factor_id": "elec-cn-south-10kv-2024"
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Demo
|
|
241
|
+
|
|
242
|
+
👉 **[Try the Live Demo](https://nikeandocean.github.io/carbon-factor-matcher/demo.html)** — Search 30+ emission factors directly in your browser (no installation needed).
|
|
243
|
+
|
|
244
|
+
## System Requirements
|
|
245
|
+
|
|
246
|
+
- Node.js 18+ (for `npx`)
|
|
247
|
+
- Python 3.11+ (auto-installed via pip)
|
|
248
|
+
- LLM API key (Pro tier only — DeepSeek recommended)
|
|
249
|
+
|
|
250
|
+
## Support
|
|
251
|
+
|
|
252
|
+
- **Email:** tao.yan@zju.edu.cn
|
|
253
|
+
- **Issues:** https://github.com/nikeandocean/carbon-factor-matcher/issues
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
This is proprietary software. See [LICENSE](LICENSE) for details.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
© 2024 Carbon Factor Matcher. All rights reserved.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Privacy Policy
|
|
2
|
+
|
|
3
|
+
We value your privacy. Carbon Factor Matcher does not collect, store, or share any personal user data or environmental query information. Your license key validation is processed securely via Paddle, and no personal identifiable information (PII) is transferred to our servers.
|