open-edison 0.1.34__tar.gz → 0.1.37__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.
- {open_edison-0.1.34 → open_edison-0.1.37}/PKG-INFO +48 -6
- {open_edison-0.1.34 → open_edison-0.1.37}/README.md +47 -1
- {open_edison-0.1.34 → open_edison-0.1.37}/config.json +21 -18
- {open_edison-0.1.34 → open_edison-0.1.37}/desktop_ext/README.md +9 -11
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/development/contributing.md +2 -1
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/development/development_guide.md +1 -1
- {open_edison-0.1.34 → open_edison-0.1.37}/hatch_build.py +0 -2
- open_edison-0.1.37/installation_test/README.md +18 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/pyproject.toml +13 -7
- open_edison-0.1.37/src/__init__.py +8 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/cli.py +0 -14
- {open_edison-0.1.34 → open_edison-0.1.37}/src/config.py +6 -1
- open_edison-0.1.37/src/config.pyi +80 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/events.py +0 -2
- open_edison-0.1.37/src/mcp_importer/__init__.py +15 -0
- open_edison-0.1.37/src/mcp_importer/__main__.py +19 -0
- open_edison-0.1.37/src/mcp_importer/api.py +106 -0
- open_edison-0.1.37/src/mcp_importer/cli.py +113 -0
- open_edison-0.1.37/src/mcp_importer/export_cli.py +201 -0
- open_edison-0.1.37/src/mcp_importer/exporters.py +393 -0
- open_edison-0.1.37/src/mcp_importer/import_api.py +3 -0
- open_edison-0.1.37/src/mcp_importer/importers.py +63 -0
- open_edison-0.1.37/src/mcp_importer/merge.py +47 -0
- open_edison-0.1.37/src/mcp_importer/parsers.py +148 -0
- open_edison-0.1.37/src/mcp_importer/paths.py +92 -0
- open_edison-0.1.37/src/mcp_importer/quick_cli.py +65 -0
- open_edison-0.1.37/src/mcp_importer/types.py +5 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/server.py +2 -2
- open_edison-0.1.34/src/__init__.py +0 -11
- {open_edison-0.1.34 → open_edison-0.1.37}/.gitignore +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/LICENSE +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/README.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/architecture/single_user_design.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/core/configuration.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/core/project_structure.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/core/proxy_usage.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/deployment/docker.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/deployment/local.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/development/testing.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/quick-reference/api_reference.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/docs/quick-reference/config_quick_start.md +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/prompt_permissions.json +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/resource_permissions.json +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/__main__.py +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/frontend_dist/assets/index-BUUcUfTt.js +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/frontend_dist/assets/index-o6_8mdM8.css +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/frontend_dist/index.html +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/frontend_dist/sw.js +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/middleware/data_access_tracker.py +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/middleware/session_tracking.py +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/oauth_manager.py +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/permissions.py +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/single_user_mcp.py +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/src/telemetry.py +0 -0
- {open_edison-0.1.34 → open_edison-0.1.37}/tool_permissions.json +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: open-edison
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.37
|
4
4
|
Summary: Open-source MCP security, aggregation, and monitoring. Single-user, self-hosted MCP proxy.
|
5
5
|
Author-email: Hugo Berg <hugo@edison.watch>
|
6
6
|
License-File: LICENSE
|
@@ -20,17 +20,13 @@ Requires-Dist: pyyaml>=6.0.2
|
|
20
20
|
Requires-Dist: sqlalchemy>=2.0.41
|
21
21
|
Requires-Dist: starlette>=0.47.1
|
22
22
|
Requires-Dist: uvicorn>=0.35.0
|
23
|
-
Provides-Extra: dev
|
24
|
-
Requires-Dist: pytest-asyncio>=1.0.0; extra == 'dev'
|
25
|
-
Requires-Dist: pytest>=8.3.3; extra == 'dev'
|
26
|
-
Requires-Dist: ruff>=0.12.3; extra == 'dev'
|
27
23
|
Description-Content-Type: text/markdown
|
28
24
|
|
29
25
|
# OpenEdison 🔒⚡️
|
30
26
|
|
31
27
|
> The Secure MCP Control Panel
|
32
28
|
|
33
|
-
Connect AI to your data/software securely without risk of data exfiltration. Gain visibility, block threats, and get alerts on the data your agent is reading/writing.
|
29
|
+
Connect AI to your data/software securely without risk of data exfiltration. Gain visibility, block threats, and get alerts on the data your agent is reading/writing.
|
34
30
|
|
35
31
|
OpenEdison solves the [lethal trifecta problem](https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/), which can cause agent hijacking & data exfiltration by malicious actors.
|
36
32
|
|
@@ -76,6 +72,13 @@ curl -fsSL https://raw.githubusercontent.com/Edison-Watch/open-edison/main/curl_
|
|
76
72
|
|
77
73
|
Run locally with uvx: `uvx open-edison`
|
78
74
|
|
75
|
+
Optionally, import your existing MCP configs from Cursor, VS Code, or Claude Code with:
|
76
|
+
|
77
|
+
```bash
|
78
|
+
# From source (no install) — quick one-liner (add --dry-run to preview)
|
79
|
+
uv run python -m mcp_importer.quick_cli --yes
|
80
|
+
```
|
81
|
+
|
79
82
|
<details>
|
80
83
|
<summary>⬇️ Install Node.js/npm (optional for MCP tools)</summary>
|
81
84
|
|
@@ -125,6 +128,45 @@ OPEN_EDISON_CONFIG_DIR=~/edison-config open-edison run
|
|
125
128
|
|
126
129
|
</details>
|
127
130
|
|
131
|
+
<details>
|
132
|
+
<summary>🔄 Import from Cursor/VS Code/Claude Code</summary>
|
133
|
+
|
134
|
+
### Import from Cursor/VS Code/Claude Code
|
135
|
+
|
136
|
+
- **CLI**
|
137
|
+
|
138
|
+
- Import & configure to use edison as your MCP server:
|
139
|
+
|
140
|
+
```bash
|
141
|
+
# From source (no install)
|
142
|
+
uv run python -m mcp_importer.quick_cli --yes
|
143
|
+
# After install: mcp-importer-quick --yes
|
144
|
+
```
|
145
|
+
|
146
|
+
- Preview what will be imported (no writes):
|
147
|
+
|
148
|
+
```bash
|
149
|
+
uv run python -m mcp_importer --source cursor --dry-run
|
150
|
+
```
|
151
|
+
|
152
|
+
- Import servers into Open Edison `config.json` (merge policy defaults to `skip`):
|
153
|
+
|
154
|
+
```bash
|
155
|
+
uv run python -m mcp_importer --source cursor
|
156
|
+
uv run python -m mcp_importer --source vscode
|
157
|
+
uv run python -m mcp_importer --source claude-code
|
158
|
+
```
|
159
|
+
|
160
|
+
- Point your editor to Open Edison (backup original config and replace with a single Open Edison server):
|
161
|
+
|
162
|
+
```bash
|
163
|
+
uv run python -m mcp_importer export --target cursor --yes
|
164
|
+
uv run python -m mcp_importer export --target vscode --yes
|
165
|
+
uv run python -m mcp_importer export --target claude-code --yes
|
166
|
+
```
|
167
|
+
|
168
|
+
</details>
|
169
|
+
|
128
170
|
<details>
|
129
171
|
<summary><img src="https://img.shields.io/badge/Docker-2CA5E0?style=for-the-badge&logo=docker&logoColor=white" alt="Docker"> Run with Docker</summary>
|
130
172
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
> The Secure MCP Control Panel
|
4
4
|
|
5
|
-
Connect AI to your data/software securely without risk of data exfiltration. Gain visibility, block threats, and get alerts on the data your agent is reading/writing.
|
5
|
+
Connect AI to your data/software securely without risk of data exfiltration. Gain visibility, block threats, and get alerts on the data your agent is reading/writing.
|
6
6
|
|
7
7
|
OpenEdison solves the [lethal trifecta problem](https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/), which can cause agent hijacking & data exfiltration by malicious actors.
|
8
8
|
|
@@ -48,6 +48,13 @@ curl -fsSL https://raw.githubusercontent.com/Edison-Watch/open-edison/main/curl_
|
|
48
48
|
|
49
49
|
Run locally with uvx: `uvx open-edison`
|
50
50
|
|
51
|
+
Optionally, import your existing MCP configs from Cursor, VS Code, or Claude Code with:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
# From source (no install) — quick one-liner (add --dry-run to preview)
|
55
|
+
uv run python -m mcp_importer.quick_cli --yes
|
56
|
+
```
|
57
|
+
|
51
58
|
<details>
|
52
59
|
<summary>⬇️ Install Node.js/npm (optional for MCP tools)</summary>
|
53
60
|
|
@@ -97,6 +104,45 @@ OPEN_EDISON_CONFIG_DIR=~/edison-config open-edison run
|
|
97
104
|
|
98
105
|
</details>
|
99
106
|
|
107
|
+
<details>
|
108
|
+
<summary>🔄 Import from Cursor/VS Code/Claude Code</summary>
|
109
|
+
|
110
|
+
### Import from Cursor/VS Code/Claude Code
|
111
|
+
|
112
|
+
- **CLI**
|
113
|
+
|
114
|
+
- Import & configure to use edison as your MCP server:
|
115
|
+
|
116
|
+
```bash
|
117
|
+
# From source (no install)
|
118
|
+
uv run python -m mcp_importer.quick_cli --yes
|
119
|
+
# After install: mcp-importer-quick --yes
|
120
|
+
```
|
121
|
+
|
122
|
+
- Preview what will be imported (no writes):
|
123
|
+
|
124
|
+
```bash
|
125
|
+
uv run python -m mcp_importer --source cursor --dry-run
|
126
|
+
```
|
127
|
+
|
128
|
+
- Import servers into Open Edison `config.json` (merge policy defaults to `skip`):
|
129
|
+
|
130
|
+
```bash
|
131
|
+
uv run python -m mcp_importer --source cursor
|
132
|
+
uv run python -m mcp_importer --source vscode
|
133
|
+
uv run python -m mcp_importer --source claude-code
|
134
|
+
```
|
135
|
+
|
136
|
+
- Point your editor to Open Edison (backup original config and replace with a single Open Edison server):
|
137
|
+
|
138
|
+
```bash
|
139
|
+
uv run python -m mcp_importer export --target cursor --yes
|
140
|
+
uv run python -m mcp_importer export --target vscode --yes
|
141
|
+
uv run python -m mcp_importer export --target claude-code --yes
|
142
|
+
```
|
143
|
+
|
144
|
+
</details>
|
145
|
+
|
100
146
|
<details>
|
101
147
|
<summary><img src="https://img.shields.io/badge/Docker-2CA5E0?style=for-the-badge&logo=docker&logoColor=white" alt="Docker"> Run with Docker</summary>
|
102
148
|
|
@@ -59,26 +59,14 @@
|
|
59
59
|
},
|
60
60
|
{
|
61
61
|
"name": "supabase",
|
62
|
-
"command": "",
|
63
|
-
"args": [],
|
64
|
-
"env": {
|
65
|
-
"SUPABASE_URL": "https://your-supabase-url.supabase.co",
|
66
|
-
"SUPABASE_API_KEY": "your-supabase-api-key",
|
67
|
-
"SUPABASE_DATABASE": "your-database-name"
|
68
|
-
},
|
69
|
-
"enabled": false
|
70
|
-
},
|
71
|
-
{
|
72
|
-
"name": "google_drive",
|
73
62
|
"command": "npx",
|
74
63
|
"args": [
|
75
64
|
"-y",
|
76
|
-
"@
|
65
|
+
"@supabase/mcp-server"
|
77
66
|
],
|
78
67
|
"env": {
|
79
|
-
"
|
80
|
-
"
|
81
|
-
"GOOGLE_REFRESH_TOKEN": "your-refresh-token"
|
68
|
+
"SUPABASE_URL": "https://YOUR_PROJECT.supabase.co",
|
69
|
+
"SUPABASE_ANON_KEY": "your-supabase-anon-key"
|
82
70
|
},
|
83
71
|
"enabled": false
|
84
72
|
},
|
@@ -93,17 +81,32 @@
|
|
93
81
|
"env": {},
|
94
82
|
"enabled": false
|
95
83
|
},
|
84
|
+
{
|
85
|
+
"name": "google_drive",
|
86
|
+
"command": "npx",
|
87
|
+
"args": [
|
88
|
+
"-y",
|
89
|
+
"@modelcontextprotocol/server-gdrive"
|
90
|
+
],
|
91
|
+
"env": {
|
92
|
+
"GOOGLE_CLIENT_ID": "your-client-id",
|
93
|
+
"GOOGLE_CLIENT_SECRET": "your-client-secret",
|
94
|
+
"GOOGLE_REFRESH_TOKEN": "your-refresh-token"
|
95
|
+
},
|
96
|
+
"enabled": false
|
97
|
+
},
|
96
98
|
{
|
97
99
|
"name": "zapier",
|
98
100
|
"command": "npx",
|
99
101
|
"args": [
|
100
102
|
"-y",
|
101
103
|
"mcp-remote",
|
102
|
-
"https://mcp.zapier.com/api/mcp/s/
|
104
|
+
"https://mcp.zapier.com/api/mcp/s/REPLACE_WITH_ACCESS_TOKEN/mcp",
|
105
|
+
"--header",
|
106
|
+
"Accept: application/json, text/event-stream"
|
103
107
|
],
|
104
108
|
"env": {},
|
105
|
-
"enabled": false
|
106
|
-
"roots": []
|
109
|
+
"enabled": false
|
107
110
|
}
|
108
111
|
]
|
109
112
|
}
|
@@ -45,23 +45,21 @@ Access to all tools from MCP servers you've configured in Open Edison, such as:
|
|
45
45
|
3. **Go to Settings** → Extensions
|
46
46
|
4. **Click "Install Extension"** or drag the `.dxt` file into the window
|
47
47
|
5. **Configure your connection**:
|
48
|
-
- **Server URL**: Your Open Edison server MCP
|
49
|
-
- **API Key**: Your Open Edison API key
|
48
|
+
- **Server URL**: Your Open Edison server MCP endpoint (e.g., `http://localhost:3000/mcp/`)
|
49
|
+
- **API Key**: Your Open Edison API key (default for local dev: `dev-api-key-change-me`)
|
50
50
|
6. **Click "Install"** when prompted
|
51
51
|
7. **Done!** All your Open Edison tools are now available in Claude Desktop
|
52
52
|
|
53
|
-
### Server URL
|
53
|
+
### Server URL
|
54
54
|
|
55
|
-
-
|
56
|
-
- **Remote server**: `https://your-server.com:3001/mcp/call`
|
57
|
-
- **Docker deployment**: `http://your-docker-host:3001/mcp/call`
|
55
|
+
- `http://localhost:3000/mcp/`
|
58
56
|
|
59
57
|
## Configuration
|
60
58
|
|
61
59
|
### Required Settings
|
62
60
|
|
63
|
-
- **Server URL**: The full URL to your Open Edison MCP
|
64
|
-
- **API Key**: Your authentication key for the Open Edison server (configured in `config.json`)
|
61
|
+
- **Server URL**: The full URL to your Open Edison MCP endpoint (`http://localhost:3000/mcp/`)
|
62
|
+
- **API Key**: Your authentication key for the Open Edison server (configured in `config.json`; local default `dev-api-key-change-me`)
|
65
63
|
|
66
64
|
### Open Edison Server Setup
|
67
65
|
|
@@ -71,7 +69,7 @@ Make sure your Open Edison server is running and accessible:
|
|
71
69
|
2. **Configure MCP servers**: Edit `config.json` to add your MCP servers
|
72
70
|
3. **Set API key**: Ensure `server.api_key` is set in your `config.json`
|
73
71
|
|
74
|
-
Your server should be accessible at `http://localhost:
|
72
|
+
Your server should be accessible at `http://localhost:3000`.
|
75
73
|
|
76
74
|
## How It Works
|
77
75
|
|
@@ -129,10 +127,10 @@ This extension operates securely:
|
|
129
127
|
|
130
128
|
### Debug Steps
|
131
129
|
|
132
|
-
1. **Check server accessibility**: Try accessing `http://localhost:3001/health` in a browser
|
130
|
+
1. **Check server accessibility**: Try accessing `http://localhost:3001/health` (management API) in a browser
|
133
131
|
2. **Verify API key**: Check the `server.api_key` value in your Open Edison `config.json`
|
134
132
|
3. **Check logs**: Look at Claude Desktop logs for connection errors
|
135
|
-
4. **Test MCP endpoint**: Use curl to test the `/mcp
|
133
|
+
4. **Test MCP endpoint**: Use curl to test the `/mcp/` endpoint
|
136
134
|
|
137
135
|
### Log Locations
|
138
136
|
|
@@ -111,7 +111,8 @@ make test
|
|
111
111
|
|
112
112
|
**Standards**:
|
113
113
|
|
114
|
-
- **
|
114
|
+
- **uv** for formatting (`make format`)
|
115
|
+
- **Ruff** for linting (`make lint`)
|
115
116
|
- **Type hints** for all function signatures
|
116
117
|
- **Docstrings** for public functions and classes
|
117
118
|
|
@@ -413,7 +413,7 @@ from src.proxy import MCPProxy
|
|
413
413
|
|
414
414
|
### Code Style
|
415
415
|
|
416
|
-
- Use
|
416
|
+
- Use uv for formatting (`make format`) and Ruff for linting (`make lint`)
|
417
417
|
- Type hints for all function signatures
|
418
418
|
- Docstrings for all public functions/classes
|
419
419
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Installation Test (Ubuntu)
|
2
|
+
|
3
|
+
This directory contains a Dockerfile that validates the README curl | bash installer on a clean Ubuntu environment.
|
4
|
+
|
5
|
+
How it works:
|
6
|
+
|
7
|
+
- Uses `ubuntu:24.04`
|
8
|
+
- Installs minimal prerequisites (`curl`, `ca-certificates`, etc.)
|
9
|
+
- Runs the documented installer: `curl -fsSL https://raw.githubusercontent.com/Edison-Watch/open-edison/main/curl_pipe_bash.sh | bash -s -- -h`
|
10
|
+
- The `-h` flag is forwarded to `open-edison`, so the installer prints help and exits 0, making the Docker build fast and non-interactive.
|
11
|
+
|
12
|
+
Build locally:
|
13
|
+
|
14
|
+
```bash
|
15
|
+
make install_curl_test
|
16
|
+
```
|
17
|
+
|
18
|
+
If the build completes successfully, the installer path is healthy. If it fails, the build will error and show logs with the failing step (e.g., uv install, Python 3.12, or `uvx open-edison`).
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "open-edison"
|
3
|
-
version = "0.1.
|
3
|
+
version = "0.1.37"
|
4
4
|
description = "Open-source MCP security, aggregation, and monitoring. Single-user, self-hosted MCP proxy."
|
5
5
|
readme = "README.md"
|
6
6
|
authors = [
|
@@ -28,6 +28,8 @@ requires-python = ">= 3.12"
|
|
28
28
|
[project.scripts]
|
29
29
|
open-edison = "src.cli:main"
|
30
30
|
open_edison = "src.cli:main"
|
31
|
+
mcp-importer = "mcp_importer.__main__:main"
|
32
|
+
mcp-importer-quick = "mcp_importer.quick_cli:main"
|
31
33
|
|
32
34
|
[build-system]
|
33
35
|
requires = ["hatchling"]
|
@@ -42,14 +44,11 @@ dev-dependencies = [
|
|
42
44
|
"pytest-asyncio>=1.0.0",
|
43
45
|
"vulture>=2.11",
|
44
46
|
"twine>=5.1.1",
|
47
|
+
"ty>=0.0.1a19",
|
45
48
|
]
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
"ruff>=0.12.3",
|
50
|
-
"pytest>=8.3.3",
|
51
|
-
"pytest-asyncio>=1.0.0",
|
52
|
-
]
|
50
|
+
|
51
|
+
|
53
52
|
|
54
53
|
[tool.hatch.metadata]
|
55
54
|
allow-direct-references = true
|
@@ -119,5 +118,12 @@ reportUnusedFunction = false # Disable unused function warnings since we have m
|
|
119
118
|
venvPath = ".venv"
|
120
119
|
extraPaths = ["src"]
|
121
120
|
|
121
|
+
[tool.ty.rules]
|
122
|
+
possibly-unresolved-reference = "error"
|
123
|
+
index-out-of-bounds = "error"
|
124
|
+
|
125
|
+
[tool.ty.src]
|
126
|
+
exclude = ["tests/**"]
|
127
|
+
|
122
128
|
[tool.vulture]
|
123
129
|
exclude = ["tests", "src/frontend_dist"]
|
@@ -4,8 +4,6 @@ CLI entrypoint for Open Edison.
|
|
4
4
|
Provides `open-edison` executable when installed via pip/uvx/pipx.
|
5
5
|
"""
|
6
6
|
|
7
|
-
from __future__ import annotations
|
8
|
-
|
9
7
|
import argparse
|
10
8
|
import asyncio
|
11
9
|
import os
|
@@ -69,11 +67,6 @@ def _parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
|
69
67
|
default="interactive",
|
70
68
|
help="Source application to import from",
|
71
69
|
)
|
72
|
-
sp_import.add_argument(
|
73
|
-
"--project-dir",
|
74
|
-
type=Path,
|
75
|
-
help="When --source=cursor, path to the project containing .cursor/mcp.json",
|
76
|
-
)
|
77
70
|
sp_import.add_argument(
|
78
71
|
"--config-dir",
|
79
72
|
type=Path,
|
@@ -250,11 +243,6 @@ def main(argv: list[str] | None = None) -> NoReturn: # noqa: C901
|
|
250
243
|
importer_argv: list[str] = []
|
251
244
|
if args.source:
|
252
245
|
importer_argv += ["--source", str(args.source)]
|
253
|
-
if getattr(args, "project_dir", None):
|
254
|
-
importer_argv += [
|
255
|
-
"--project-dir",
|
256
|
-
str(Path(args.project_dir).expanduser().resolve()),
|
257
|
-
]
|
258
246
|
if getattr(args, "config_dir", None):
|
259
247
|
importer_argv += [
|
260
248
|
"--config-dir",
|
@@ -262,8 +250,6 @@ def main(argv: list[str] | None = None) -> NoReturn: # noqa: C901
|
|
262
250
|
]
|
263
251
|
if args.merge:
|
264
252
|
importer_argv += ["--merge", str(args.merge)]
|
265
|
-
if bool(getattr(args, "enable_imported", False)):
|
266
|
-
importer_argv += ["--enable-imported"]
|
267
253
|
if bool(getattr(args, "dry_run", False)):
|
268
254
|
importer_argv += ["--dry-run"]
|
269
255
|
|
@@ -142,11 +142,16 @@ class TelemetryConfig:
|
|
142
142
|
def load_json_file(path: Path) -> dict[str, Any]:
|
143
143
|
"""Load a JSON file from the given path.
|
144
144
|
Kept as a separate function because we want to manually clear cache sometimes (update in config)"""
|
145
|
-
log.
|
145
|
+
log.trace(f"Loading configuration from {path}")
|
146
146
|
with open(path) as f:
|
147
147
|
return json.load(f)
|
148
148
|
|
149
149
|
|
150
|
+
def clear_json_file_cache() -> None:
|
151
|
+
"""Clear the cache for the given JSON file path"""
|
152
|
+
load_json_file.cache_clear()
|
153
|
+
|
154
|
+
|
150
155
|
@dataclass
|
151
156
|
class Config:
|
152
157
|
"""Main configuration class"""
|
@@ -0,0 +1,80 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from typing import Any, overload
|
3
|
+
|
4
|
+
# Module constants
|
5
|
+
DEFAULT_OTLP_METRICS_ENDPOINT: str
|
6
|
+
root_dir: Path
|
7
|
+
|
8
|
+
def get_config_dir() -> Path: ...
|
9
|
+
def get_config_json_path() -> Path: ...
|
10
|
+
|
11
|
+
class ServerConfig:
|
12
|
+
host: str
|
13
|
+
port: int
|
14
|
+
api_key: str
|
15
|
+
|
16
|
+
class LoggingConfig:
|
17
|
+
level: str
|
18
|
+
database_path: str
|
19
|
+
|
20
|
+
class MCPServerConfig:
|
21
|
+
name: str
|
22
|
+
command: str
|
23
|
+
args: list[str]
|
24
|
+
env: dict[str, str] | None
|
25
|
+
enabled: bool
|
26
|
+
roots: list[str] | None
|
27
|
+
oauth_scopes: list[str] | None
|
28
|
+
oauth_client_name: str | None
|
29
|
+
|
30
|
+
def __init__(
|
31
|
+
self,
|
32
|
+
*,
|
33
|
+
name: str,
|
34
|
+
command: str,
|
35
|
+
args: list[str],
|
36
|
+
env: dict[str, str] | None = None,
|
37
|
+
enabled: bool = True,
|
38
|
+
roots: list[str] | None = None,
|
39
|
+
oauth_scopes: list[str] | None = None,
|
40
|
+
oauth_client_name: str | None = None,
|
41
|
+
) -> None: ...
|
42
|
+
def is_remote_server(self) -> bool: ...
|
43
|
+
def get_remote_url(self) -> str | None: ...
|
44
|
+
|
45
|
+
class TelemetryConfig:
|
46
|
+
enabled: bool
|
47
|
+
otlp_endpoint: str | None
|
48
|
+
headers: dict[str, str] | None
|
49
|
+
export_interval_ms: int
|
50
|
+
def __init__(
|
51
|
+
self,
|
52
|
+
*,
|
53
|
+
enabled: bool = True,
|
54
|
+
otlp_endpoint: str | None = None,
|
55
|
+
headers: dict[str, str] | None = None,
|
56
|
+
export_interval_ms: int = 60000,
|
57
|
+
) -> None: ...
|
58
|
+
|
59
|
+
def load_json_file(path: Path) -> dict[str, Any]: ...
|
60
|
+
def clear_json_file_cache() -> None: ...
|
61
|
+
|
62
|
+
class Config:
|
63
|
+
@property
|
64
|
+
def version(self) -> str: ...
|
65
|
+
server: ServerConfig
|
66
|
+
logging: LoggingConfig
|
67
|
+
mcp_servers: list[MCPServerConfig]
|
68
|
+
telemetry: TelemetryConfig | None
|
69
|
+
@overload
|
70
|
+
def __init__(self, config_path: Path | None = None) -> None: ...
|
71
|
+
@overload
|
72
|
+
def __init__(
|
73
|
+
self,
|
74
|
+
server: ServerConfig,
|
75
|
+
logging: LoggingConfig,
|
76
|
+
mcp_servers: list[MCPServerConfig],
|
77
|
+
telemetry: TelemetryConfig | None = None,
|
78
|
+
) -> None: ...
|
79
|
+
def save(self, config_path: Path | None = None) -> None: ...
|
80
|
+
def create_default(self) -> None: ...
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"""MCP importer package for Open Edison scripts.
|
2
|
+
|
3
|
+
Import submodules explicitly as needed, e.g. `from mcp_importer import cli`.
|
4
|
+
"""
|
5
|
+
|
6
|
+
# pyright: reportUnsupportedDunderAll=false
|
7
|
+
|
8
|
+
__all__ = [
|
9
|
+
"paths",
|
10
|
+
"parsers",
|
11
|
+
"importers",
|
12
|
+
"merge",
|
13
|
+
"cli",
|
14
|
+
"api",
|
15
|
+
]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import sys
|
4
|
+
|
5
|
+
from mcp_importer.cli import run_cli as import_run_cli
|
6
|
+
from mcp_importer.export_cli import run_cli as export_run_cli
|
7
|
+
|
8
|
+
|
9
|
+
def main() -> int:
|
10
|
+
# Usage:
|
11
|
+
# python -m mcp_importer -> import CLI
|
12
|
+
# python -m mcp_importer export ... -> export CLI
|
13
|
+
if len(sys.argv) > 1 and sys.argv[1] == "export":
|
14
|
+
return export_run_cli(sys.argv[2:])
|
15
|
+
return import_run_cli(sys.argv[1:])
|
16
|
+
|
17
|
+
|
18
|
+
if __name__ == "__main__":
|
19
|
+
raise SystemExit(main())
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# pyright: reportMissingImports=false, reportUnknownVariableType=false, reportUnknownMemberType=false, reportUnknownArgumentType=false, reportUnknownParameterType=false
|
2
|
+
from enum import Enum
|
3
|
+
from pathlib import Path
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
import mcp_importer.paths as _paths
|
7
|
+
from mcp_importer.exporters import export_to_claude_code, export_to_cursor, export_to_vscode
|
8
|
+
from mcp_importer.importers import (
|
9
|
+
import_from_claude_code as _import_from_claude_code,
|
10
|
+
)
|
11
|
+
from mcp_importer.importers import (
|
12
|
+
import_from_cursor as _import_from_cursor,
|
13
|
+
)
|
14
|
+
from mcp_importer.importers import (
|
15
|
+
import_from_vscode as _import_from_vscode,
|
16
|
+
)
|
17
|
+
from mcp_importer.merge import MergePolicy, merge_servers
|
18
|
+
from src.config import Config, MCPServerConfig, get_config_json_path
|
19
|
+
|
20
|
+
|
21
|
+
class CLIENT(str, Enum):
|
22
|
+
CURSOR = "cursor"
|
23
|
+
VSCODE = "vscode"
|
24
|
+
CLAUDE_CODE = "claude-code"
|
25
|
+
|
26
|
+
|
27
|
+
def detect_clients() -> set[CLIENT]:
|
28
|
+
detected: set[CLIENT] = set()
|
29
|
+
if _paths.detect_cursor_config_path() is not None:
|
30
|
+
detected.add(CLIENT.CURSOR)
|
31
|
+
if _paths.detect_vscode_config_path() is not None:
|
32
|
+
detected.add(CLIENT.VSCODE)
|
33
|
+
if _paths.detect_claude_code_config_path() is not None:
|
34
|
+
detected.add(CLIENT.CLAUDE_CODE)
|
35
|
+
return detected
|
36
|
+
|
37
|
+
|
38
|
+
import_cursor = _import_from_cursor
|
39
|
+
import_vscode = _import_from_vscode
|
40
|
+
import_claude_code = _import_from_claude_code
|
41
|
+
|
42
|
+
|
43
|
+
def import_from(client: CLIENT) -> list[MCPServerConfig]:
|
44
|
+
if client == CLIENT.CURSOR:
|
45
|
+
return import_cursor()
|
46
|
+
if client == CLIENT.VSCODE:
|
47
|
+
return import_vscode()
|
48
|
+
if client == CLIENT.CLAUDE_CODE:
|
49
|
+
return import_claude_code()
|
50
|
+
raise ValueError(f"Unsupported client: {client}")
|
51
|
+
|
52
|
+
|
53
|
+
def save_imported_servers(
|
54
|
+
servers: list[MCPServerConfig],
|
55
|
+
*,
|
56
|
+
merge_policy: str = MergePolicy.SKIP,
|
57
|
+
config_dir: Path | None = None,
|
58
|
+
) -> Path:
|
59
|
+
target_path: Path = (
|
60
|
+
get_config_json_path() if config_dir is None else (Path(config_dir) / "config.json")
|
61
|
+
)
|
62
|
+
cfg: Config = Config(target_path)
|
63
|
+
merged = merge_servers(existing=cfg.mcp_servers, imported=servers, policy=merge_policy)
|
64
|
+
cfg.mcp_servers = merged
|
65
|
+
cfg.save(target_path)
|
66
|
+
return target_path
|
67
|
+
|
68
|
+
|
69
|
+
def export_edison_to(
|
70
|
+
client: CLIENT,
|
71
|
+
*,
|
72
|
+
url: str = "http://localhost:3000/mcp/",
|
73
|
+
api_key: str = "dev-api-key-change-me",
|
74
|
+
server_name: str = "open-edison",
|
75
|
+
dry_run: bool = False,
|
76
|
+
force: bool = False,
|
77
|
+
create_if_missing: bool = False,
|
78
|
+
) -> Any:
|
79
|
+
match client:
|
80
|
+
case CLIENT.CURSOR:
|
81
|
+
return export_to_cursor(
|
82
|
+
url=url,
|
83
|
+
api_key=api_key,
|
84
|
+
server_name=server_name,
|
85
|
+
dry_run=dry_run,
|
86
|
+
force=force,
|
87
|
+
create_if_missing=create_if_missing,
|
88
|
+
)
|
89
|
+
case CLIENT.VSCODE:
|
90
|
+
return export_to_vscode(
|
91
|
+
url=url,
|
92
|
+
api_key=api_key,
|
93
|
+
server_name=server_name,
|
94
|
+
dry_run=dry_run,
|
95
|
+
force=force,
|
96
|
+
create_if_missing=create_if_missing,
|
97
|
+
)
|
98
|
+
case CLIENT.CLAUDE_CODE:
|
99
|
+
return export_to_claude_code(
|
100
|
+
url=url,
|
101
|
+
api_key=api_key,
|
102
|
+
server_name=server_name,
|
103
|
+
dry_run=dry_run,
|
104
|
+
force=force,
|
105
|
+
create_if_missing=create_if_missing,
|
106
|
+
)
|