langprotect-mcp-gateway 1.3.0__tar.gz → 1.3.1__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.
Files changed (17) hide show
  1. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/PKG-INFO +1 -1
  2. langprotect_mcp_gateway-1.3.1/langprotect_mcp_gateway/setup_helper.py +299 -0
  3. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/langprotect_mcp_gateway.egg-info/PKG-INFO +1 -1
  4. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/pyproject.toml +1 -1
  5. langprotect_mcp_gateway-1.3.0/langprotect_mcp_gateway/setup_helper.py +0 -182
  6. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/LICENSE +0 -0
  7. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/README.md +0 -0
  8. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/langprotect_mcp_gateway/__init__.py +0 -0
  9. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/langprotect_mcp_gateway/gateway.py +0 -0
  10. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/langprotect_mcp_gateway/response_masker.py +0 -0
  11. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/langprotect_mcp_gateway.egg-info/SOURCES.txt +0 -0
  12. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/langprotect_mcp_gateway.egg-info/dependency_links.txt +0 -0
  13. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/langprotect_mcp_gateway.egg-info/entry_points.txt +0 -0
  14. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/langprotect_mcp_gateway.egg-info/requires.txt +0 -0
  15. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/langprotect_mcp_gateway.egg-info/top_level.txt +0 -0
  16. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/setup.cfg +0 -0
  17. {langprotect_mcp_gateway-1.3.0 → langprotect_mcp_gateway-1.3.1}/tests/test_response_masker.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langprotect-mcp-gateway
3
- Version: 1.3.0
3
+ Version: 1.3.1
4
4
  Summary: Security gateway for Model Context Protocol (MCP) to protect AI tool interactions
5
5
  Author-email: LangProtect Security Team <security@langprotect.com>
6
6
  License: MIT
@@ -0,0 +1,299 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ LangProtect MCP Gateway Setup Helper
4
+ Automatically configures VS Code for global MCP gateway usage
5
+ """
6
+
7
+ import os
8
+ import json
9
+ import sys
10
+ import getpass
11
+ import urllib.request
12
+ import urllib.error
13
+ from pathlib import Path
14
+
15
+
16
+ def get_vscode_settings_path():
17
+ """Get the VS Code user settings path based on OS"""
18
+ home = Path.home()
19
+
20
+ if sys.platform == "darwin": # macOS
21
+ return home / "Library/Application Support/Code/User/settings.json"
22
+ elif sys.platform == "win32": # Windows
23
+ return home / "AppData/Roaming/Code/User/settings.json"
24
+ else: # Linux
25
+ return home / ".config/Code/User/settings.json"
26
+
27
+
28
+ def validate_credentials(url, email, password):
29
+ """Validate credentials against the backend API"""
30
+ try:
31
+ import json
32
+
33
+ # Prepare the request
34
+ data = json.dumps({"email": email, "password": password}).encode('utf-8')
35
+ req = urllib.request.Request(
36
+ f"{url}/api/auth/login/",
37
+ data=data,
38
+ headers={'Content-Type': 'application/json'}
39
+ )
40
+
41
+ # Make the request
42
+ with urllib.request.urlopen(req, timeout=10) as response:
43
+ return response.status in [200, 201]
44
+
45
+ except urllib.error.HTTPError as e:
46
+ # Parse error message if available
47
+ try:
48
+ error_body = e.read().decode('utf-8')
49
+ error_data = json.loads(error_body)
50
+ error_msg = error_data.get('detail', error_data.get('message', 'Authentication failed'))
51
+ print(f" ✗ {error_msg}")
52
+ except:
53
+ print(f" ✗ Authentication failed (HTTP {e.code})")
54
+ return False
55
+ except urllib.error.URLError as e:
56
+ print(f" ✗ Cannot connect to {url}")
57
+ print(f" Make sure the backend is running and accessible")
58
+ return False
59
+ except Exception as e:
60
+ print(f" ✗ Error: {e}")
61
+ return False
62
+
63
+
64
+ def prompt_credentials():
65
+ """Interactively prompt user for credentials with validation"""
66
+ print()
67
+ print("═" * 65)
68
+ print(" 🔐 Enter Your LangProtect Credentials")
69
+ print("═" * 65)
70
+ print()
71
+
72
+ while True:
73
+ # Prompt for URL
74
+ url = input("Backend URL [http://localhost:8000]: ").strip()
75
+ if not url:
76
+ url = "http://localhost:8000"
77
+
78
+ # Prompt for email
79
+ email = input("Email: ").strip()
80
+ if not email:
81
+ print("✗ Email cannot be empty!")
82
+ print()
83
+ continue
84
+
85
+ # Prompt for password (hidden)
86
+ password = getpass.getpass("Password: ")
87
+ if not password:
88
+ print("✗ Password cannot be empty!")
89
+ print()
90
+ continue
91
+
92
+ # Validate credentials
93
+ print(" Validating credentials...")
94
+ if validate_credentials(url, email, password):
95
+ print(" ✓ Credentials validated successfully!")
96
+ print()
97
+ return url, email, password
98
+ else:
99
+ print()
100
+ print("Please try again or press Ctrl+C to cancel.")
101
+ print()
102
+
103
+
104
+ def create_wrapper_script(url=None, email=None, password=None):
105
+ """Create the global wrapper script with credentials"""
106
+ wrapper_dir = Path.home() / ".local/bin"
107
+ wrapper_dir.mkdir(parents=True, exist_ok=True)
108
+
109
+ wrapper_path = wrapper_dir / "langprotect-mcp-wrapper.sh"
110
+
111
+ # Check if credentials provided via environment variables
112
+ if not url or not email or not password:
113
+ url = os.environ.get('LANGPROTECT_URL')
114
+ email = os.environ.get('LANGPROTECT_EMAIL')
115
+ password = os.environ.get('LANGPROTECT_PASSWORD')
116
+
117
+ # If still not provided, prompt user
118
+ if not url or not email or not password:
119
+ url, email, password = prompt_credentials()
120
+ else:
121
+ # Validate environment credentials
122
+ print(" Using credentials from environment variables...")
123
+ print(" Validating...")
124
+ if not validate_credentials(url, email, password):
125
+ print(" ✗ Environment credentials invalid. Please enter manually:")
126
+ url, email, password = prompt_credentials()
127
+ else:
128
+ print(" ✓ Environment credentials validated!")
129
+
130
+ # Create wrapper with actual credentials
131
+ wrapper_content = f"""#!/bin/bash
132
+ # LangProtect MCP Gateway Wrapper
133
+ # Auto-configured by langprotect-gateway-setup
134
+
135
+ # ============================================================
136
+ # Backend Connection
137
+ # ============================================================
138
+ export LANGPROTECT_URL="${{LANGPROTECT_URL:-{url}}}"
139
+ export LANGPROTECT_EMAIL="${{LANGPROTECT_EMAIL:-{email}}}"
140
+ export LANGPROTECT_PASSWORD="${{LANGPROTECT_PASSWORD:-{password}}}"
141
+
142
+ # ============================================================
143
+ # Security Controls (v1.3.1+)
144
+ # ============================================================
145
+ export LANGPROTECT_ENABLE_MASKING="${{LANGPROTECT_ENABLE_MASKING:-true}}"
146
+ export LANGPROTECT_FAIL_CLOSED="${{LANGPROTECT_FAIL_CLOSED:-false}}"
147
+ export LANGPROTECT_SCAN_TIMEOUT="${{LANGPROTECT_SCAN_TIMEOUT:-5.0}}"
148
+ export LANGPROTECT_ENTROPY_DETECTION="${{LANGPROTECT_ENTROPY_DETECTION:-true}}"
149
+
150
+ # ============================================================
151
+ # MCP Server Configuration
152
+ # ============================================================
153
+ export MCP_SERVER_COMMAND="${{MCP_SERVER_COMMAND:-npx}}"
154
+ export MCP_SERVER_ARGS="${{MCP_SERVER_ARGS:--y,@modelcontextprotocol/server-filesystem,.}}"
155
+
156
+ # Start the gateway
157
+ exec langprotect-gateway "$@"
158
+ """
159
+
160
+ wrapper_path.write_text(wrapper_content)
161
+ wrapper_path.chmod(0o755)
162
+
163
+ return wrapper_path
164
+
165
+
166
+ def update_vscode_settings(wrapper_path):
167
+ """Update VS Code settings to use the wrapper"""
168
+ settings_path = get_vscode_settings_path()
169
+
170
+ # Create directory if it doesn't exist
171
+ settings_path.parent.mkdir(parents=True, exist_ok=True)
172
+
173
+ # Read existing settings or create new
174
+ if settings_path.exists():
175
+ with open(settings_path, 'r') as f:
176
+ try:
177
+ settings = json.load(f)
178
+ except json.JSONDecodeError:
179
+ settings = {}
180
+ else:
181
+ settings = {}
182
+
183
+ # Add MCP configuration
184
+ if "chat.mcp.servers" not in settings:
185
+ settings["chat.mcp.servers"] = {}
186
+
187
+ settings["chat.mcp.servers"]["langprotect-gateway"] = {
188
+ "type": "stdio",
189
+ "command": str(wrapper_path),
190
+ "args": []
191
+ }
192
+
193
+ # Enable auto-start
194
+ settings["chat.mcp.autostart"] = "newAndOutdated"
195
+
196
+ # Write back
197
+ with open(settings_path, 'w') as f:
198
+ json.dump(settings, f, indent=2)
199
+
200
+ return settings_path
201
+
202
+
203
+ def get_claude_config_path():
204
+ """Get the Claude Desktop config path based on OS"""
205
+ home = Path.home()
206
+ if sys.platform == "darwin":
207
+ return home / "Library/Application Support/Claude/claude_desktop_config.json"
208
+ elif sys.platform == "win32":
209
+ return home / "AppData/Roaming/Claude/claude_desktop_config.json"
210
+ else:
211
+ return home / ".config/Claude/claude_desktop_config.json"
212
+
213
+
214
+ def update_claude_config(wrapper_path):
215
+ """Update Claude Desktop config to use the wrapper"""
216
+ config_path = get_claude_config_path()
217
+ config_path.parent.mkdir(parents=True, exist_ok=True)
218
+
219
+ if config_path.exists():
220
+ with open(config_path, 'r') as f:
221
+ try:
222
+ config = json.load(f)
223
+ except json.JSONDecodeError:
224
+ config = {}
225
+ else:
226
+ config = {}
227
+
228
+ if "mcpServers" not in config:
229
+ config["mcpServers"] = {}
230
+
231
+ config["mcpServers"]["langprotect-gateway"] = {
232
+ "command": str(wrapper_path),
233
+ "args": []
234
+ }
235
+
236
+ with open(config_path, 'w') as f:
237
+ json.dump(config, f, indent=2)
238
+
239
+ return config_path
240
+
241
+
242
+ def setup():
243
+ """Main setup function"""
244
+ print("🚀 Setting up LangProtect MCP Gateway...")
245
+ print()
246
+
247
+ # Create wrapper script (will prompt for credentials if needed)
248
+ print("📝 Creating global wrapper script...")
249
+ wrapper_path = create_wrapper_script()
250
+ print(f" ✅ Created: {wrapper_path}")
251
+ print()
252
+
253
+ # Update VS Code settings
254
+ print("⚙️ Configuring VS Code...")
255
+ try:
256
+ settings_path = update_vscode_settings(wrapper_path)
257
+ print(f" ✅ Updated: {settings_path}")
258
+ except Exception as e:
259
+ print(f" ⚠️ Could not update VS Code settings: {e}")
260
+
261
+ # Update Claude Desktop config
262
+ print("🍏 Configuring Claude Desktop...")
263
+ try:
264
+ claude_path = update_claude_config(wrapper_path)
265
+ print(f" ✅ Updated: {claude_path}")
266
+ except Exception as e:
267
+ print(f" ⚠️ Could not update Claude Desktop config: {e}")
268
+ print()
269
+
270
+ # Print next steps
271
+ print("✅ Setup complete!")
272
+ print()
273
+ print("📋 Next steps:")
274
+ print()
275
+ print("1. Reload VS Code:")
276
+ print(" Press Ctrl+Shift+P → 'Developer: Reload Window'")
277
+ print()
278
+ print("2. Verify it's working:")
279
+ print(" Press Ctrl+Shift+P → 'MCP: List Servers'")
280
+ print(" You should see 'langprotect-gateway' listed")
281
+ print()
282
+ print("3. Test the protection:")
283
+ print(" Ask AI to read a file with secrets - they'll be masked!")
284
+ print()
285
+ print("🎉 LangProtect is now protecting ALL your VS Code workspaces!")
286
+ print()
287
+ print("💡 Configuration file:", wrapper_path)
288
+ print()
289
+
290
+
291
+ if __name__ == "__main__":
292
+ try:
293
+ setup()
294
+ except KeyboardInterrupt:
295
+ print("\n\n⚠️ Setup cancelled by user.")
296
+ sys.exit(1)
297
+ except Exception as e:
298
+ print(f"\n\n❌ Setup failed: {e}")
299
+ sys.exit(1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langprotect-mcp-gateway
3
- Version: 1.3.0
3
+ Version: 1.3.1
4
4
  Summary: Security gateway for Model Context Protocol (MCP) to protect AI tool interactions
5
5
  Author-email: LangProtect Security Team <security@langprotect.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "langprotect-mcp-gateway"
7
- version = "1.3.0"
7
+ version = "1.3.1"
8
8
  description = "Security gateway for Model Context Protocol (MCP) to protect AI tool interactions"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -1,182 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- LangProtect MCP Gateway Setup Helper
4
- Automatically configures VS Code for global MCP gateway usage
5
- """
6
-
7
- import os
8
- import json
9
- import sys
10
- from pathlib import Path
11
-
12
-
13
- def get_vscode_settings_path():
14
- """Get the VS Code user settings path based on OS"""
15
- home = Path.home()
16
-
17
- if sys.platform == "darwin": # macOS
18
- return home / "Library/Application Support/Code/User/settings.json"
19
- elif sys.platform == "win32": # Windows
20
- return home / "AppData/Roaming/Code/User/settings.json"
21
- else: # Linux
22
- return home / ".config/Code/User/settings.json"
23
-
24
-
25
- def create_wrapper_script():
26
- """Create the global wrapper script"""
27
- wrapper_dir = Path.home() / ".local/bin"
28
- wrapper_dir.mkdir(parents=True, exist_ok=True)
29
-
30
- wrapper_path = wrapper_dir / "langprotect-mcp-wrapper.sh"
31
-
32
- wrapper_content = """#!/bin/bash
33
- # LangProtect MCP Gateway Wrapper
34
- # This wrapper allows global configuration for all VS Code workspaces
35
-
36
- # Configure these environment variables with your LangProtect credentials
37
- export LANGPROTECT_URL="${LANGPROTECT_URL:-http://localhost:8000}"
38
- export LANGPROTECT_EMAIL="${LANGPROTECT_EMAIL:-your.email@company.com}"
39
- export LANGPROTECT_PASSWORD="${LANGPROTECT_PASSWORD:-your-password}"
40
- export MCP_SERVER_COMMAND="${MCP_SERVER_COMMAND:-npx}"
41
- export MCP_SERVER_ARGS="${MCP_SERVER_ARGS:--y,@modelcontextprotocol/server-filesystem,.}"
42
-
43
- exec langprotect-gateway "$@"
44
- """
45
-
46
- wrapper_path.write_text(wrapper_content)
47
- wrapper_path.chmod(0o755)
48
-
49
- return wrapper_path
50
-
51
-
52
- def update_vscode_settings(wrapper_path):
53
- """Update VS Code settings to use the wrapper"""
54
- settings_path = get_vscode_settings_path()
55
-
56
- # Create directory if it doesn't exist
57
- settings_path.parent.mkdir(parents=True, exist_ok=True)
58
-
59
- # Read existing settings or create new
60
- if settings_path.exists():
61
- with open(settings_path, 'r') as f:
62
- try:
63
- settings = json.load(f)
64
- except json.JSONDecodeError:
65
- settings = {}
66
- else:
67
- settings = {}
68
-
69
- # Add MCP configuration
70
- if "chat.mcp.servers" not in settings:
71
- settings["chat.mcp.servers"] = {}
72
-
73
- settings["chat.mcp.servers"]["langprotect-gateway"] = {
74
- "type": "stdio",
75
- "command": str(wrapper_path),
76
- "args": []
77
- }
78
-
79
- # Enable auto-start
80
- settings["chat.mcp.autostart"] = "newAndOutdated"
81
-
82
- # Write back
83
- with open(settings_path, 'w') as f:
84
- json.dump(settings, f, indent=2)
85
-
86
- return settings_path
87
-
88
-
89
- def get_claude_config_path():
90
- """Get the Claude Desktop config path based on OS"""
91
- home = Path.home()
92
- if sys.platform == "darwin":
93
- return home / "Library/Application Support/Claude/claude_desktop_config.json"
94
- elif sys.platform == "win32":
95
- return home / "AppData/Roaming/Claude/claude_desktop_config.json"
96
- else:
97
- return home / ".config/Claude/claude_desktop_config.json"
98
-
99
-
100
- def update_claude_config(wrapper_path):
101
- """Update Claude Desktop config to use the wrapper"""
102
- config_path = get_claude_config_path()
103
- config_path.parent.mkdir(parents=True, exist_ok=True)
104
-
105
- if config_path.exists():
106
- with open(config_path, 'r') as f:
107
- try:
108
- config = json.load(f)
109
- except json.JSONDecodeError:
110
- config = {}
111
- else:
112
- config = {}
113
-
114
- if "mcpServers" not in config:
115
- config["mcpServers"] = {}
116
-
117
- config["mcpServers"]["langprotect-gateway"] = {
118
- "command": str(wrapper_path),
119
- "args": []
120
- }
121
-
122
- with open(config_path, 'w') as f:
123
- json.dump(config, f, indent=2)
124
-
125
- return config_path
126
-
127
-
128
- def setup():
129
- """Main setup function"""
130
- print("🚀 Setting up LangProtect MCP Gateway...")
131
- print()
132
-
133
- # Create wrapper script
134
- print("📝 Creating global wrapper script...")
135
- wrapper_path = create_wrapper_script()
136
- print(f" ✅ Created: {wrapper_path}")
137
- print()
138
-
139
- # Update VS Code settings
140
- print("⚙️ Configuring VS Code...")
141
- try:
142
- settings_path = update_vscode_settings(wrapper_path)
143
- print(f" ✅ Updated: {settings_path}")
144
- except Exception as e:
145
- print(f" ⚠️ Could not update VS Code settings: {e}")
146
-
147
- # Update Claude Desktop config
148
- print("🍏 Configuring Claude Desktop (for high compatibility)...")
149
- try:
150
- claude_path = update_claude_config(wrapper_path)
151
- print(f" ✅ Updated: {claude_path}")
152
- except Exception as e:
153
- print(f" ⚠️ Could not update Claude Desktop config: {e}")
154
- print()
155
-
156
- # Print next steps
157
- print("✅ Setup complete!")
158
- print()
159
- print("📋 Next steps:")
160
- print()
161
- print("1. Configure your credentials:")
162
- print(f" Edit: {wrapper_path}")
163
- print(" Set LANGPROTECT_URL, LANGPROTECT_EMAIL, and LANGPROTECT_PASSWORD")
164
- print()
165
- print("2. Reload VS Code:")
166
- print(" Press Ctrl+Shift+P → 'Developer: Reload Window'")
167
- print()
168
- print("3. Verify it's working:")
169
- print(" Press Ctrl+Shift+P → 'MCP: List Servers'")
170
- print(" You should see 'langprotect-gateway' listed")
171
- print()
172
- print("🎉 LangProtect will now protect ALL your VS Code workspaces!")
173
- print()
174
- print("💡 Tip: You can also set credentials via environment variables:")
175
- print(" export LANGPROTECT_URL=http://localhost:8000")
176
- print(" export LANGPROTECT_EMAIL=your.email@company.com")
177
- print(" export LANGPROTECT_PASSWORD=your-password")
178
- print()
179
-
180
-
181
- if __name__ == "__main__":
182
- setup()