universal-mcp 0.1.18rc2__tar.gz → 0.1.18rc3__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.
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/PKG-INFO +1 -1
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/pyproject.toml +1 -1
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/applications/__init__.py +6 -1
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/applications/application.py +105 -15
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/cli.py +44 -4
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/config.py +3 -1
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/installation.py +1 -1
- universal_mcp-0.1.18rc3/src/universal_mcp/utils/openapi/api_splitter.py +400 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/openapi/openapi.py +292 -114
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/.gitignore +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/LICENSE +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/README.md +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/__init__.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/conftest.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/test_api_generator.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/test_api_integration.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/test_applications.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/test_localserver.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/test_stores.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/test_tool.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/test_tool_manager.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/tests/test_zenquotes.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/__init__.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/analytics.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/applications/README.md +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/exceptions.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/integrations/README.md +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/integrations/__init__.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/integrations/integration.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/logger.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/py.typed +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/servers/README.md +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/servers/__init__.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/servers/server.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/stores/README.md +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/stores/__init__.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/stores/store.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/tools/README.md +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/tools/__init__.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/tools/adapters.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/tools/func_metadata.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/tools/manager.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/tools/tools.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/__init__.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/agentr.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/common.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/docstring_parser.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/openapi/__inti__.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/openapi/api_generator.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/openapi/docgen.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/openapi/preprocessor.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/openapi/readme.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/singleton.py +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/templates/README.md.j2 +0 -0
- {universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/utils/templates/api_client.py.j2 +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: universal-mcp
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.18rc3
|
4
4
|
Summary: Universal MCP acts as a middle ware for your API applications. It can store your credentials, authorize, enable disable apps on the fly and much more.
|
5
5
|
Author-email: Manoj Bajaj <manojbajaj95@gmail.com>
|
6
6
|
License: MIT
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "universal-mcp"
|
7
|
-
version = "0.1.18-
|
7
|
+
version = "0.1.18-rc3"
|
8
8
|
description = "Universal MCP acts as a middle ware for your API applications. It can store your credentials, authorize, enable disable apps on the fly and much more."
|
9
9
|
readme = "README.md"
|
10
10
|
authors = [
|
{universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/applications/__init__.py
RENAMED
@@ -1,4 +1,5 @@
|
|
1
1
|
import importlib
|
2
|
+
import os
|
2
3
|
import subprocess
|
3
4
|
import sys
|
4
5
|
from pathlib import Path
|
@@ -34,8 +35,12 @@ def _install_or_upgrade_package(package_name: str, repository_path: str):
|
|
34
35
|
"""
|
35
36
|
Helper to install a package via pip from the universal-mcp GitHub repository.
|
36
37
|
"""
|
38
|
+
|
39
|
+
uv_path = os.getenv("UV_PATH")
|
40
|
+
uv_executable = str(Path(uv_path) / "uv") if uv_path else "uv"
|
41
|
+
logger.info(f"Using uv executable: {uv_executable}")
|
37
42
|
cmd = [
|
38
|
-
|
43
|
+
uv_executable,
|
39
44
|
"pip",
|
40
45
|
"install",
|
41
46
|
"--upgrade",
|
{universal_mcp-0.1.18rc2 → universal_mcp-0.1.18rc3}/src/universal_mcp/applications/application.py
RENAMED
@@ -169,14 +169,28 @@ class APIApplication(BaseApplication):
|
|
169
169
|
logger.debug(f"GET request successful with status code: {response.status_code}")
|
170
170
|
return response
|
171
171
|
|
172
|
-
def _post(
|
172
|
+
def _post(
|
173
|
+
self,
|
174
|
+
url: str,
|
175
|
+
data: Any,
|
176
|
+
params: dict[str, Any] | None = None,
|
177
|
+
content_type: str = "application/json",
|
178
|
+
files: dict[str, Any] | None = None,
|
179
|
+
) -> httpx.Response:
|
173
180
|
"""
|
174
181
|
Make a POST request to the specified URL.
|
175
182
|
|
176
183
|
Args:
|
177
184
|
url: The URL to send the request to
|
178
|
-
data: The data to send
|
185
|
+
data: The data to send. For 'application/json', this is JSON-serializable.
|
186
|
+
For 'application/x-www-form-urlencoded' or 'multipart/form-data', this is a dict of form fields.
|
187
|
+
For other content types, this is raw bytes or string.
|
179
188
|
params: Optional query parameters
|
189
|
+
content_type: The Content-Type of the request body.
|
190
|
+
Examples: 'application/json', 'application/x-www-form-urlencoded',
|
191
|
+
'multipart/form-data', 'application/octet-stream', 'text/plain'.
|
192
|
+
files: Optional dictionary of files to upload for 'multipart/form-data'.
|
193
|
+
Example: {'file_field_name': ('filename.txt', open('file.txt', 'rb'), 'text/plain')}
|
180
194
|
|
181
195
|
Returns:
|
182
196
|
httpx.Response: The response from the server
|
@@ -184,25 +198,69 @@ class APIApplication(BaseApplication):
|
|
184
198
|
Raises:
|
185
199
|
httpx.HTTPError: If the request fails
|
186
200
|
"""
|
187
|
-
logger.debug(
|
188
|
-
|
189
|
-
url,
|
190
|
-
headers=self._get_headers(),
|
191
|
-
json=data,
|
192
|
-
params=params,
|
201
|
+
logger.debug(
|
202
|
+
f"Making POST request to {url} with params: {params}, data type: {type(data)}, content_type={content_type}, files: {'yes' if files else 'no'}"
|
193
203
|
)
|
204
|
+
headers = self._get_headers().copy()
|
205
|
+
|
206
|
+
if content_type != "multipart/form-data":
|
207
|
+
headers["Content-Type"] = content_type
|
208
|
+
|
209
|
+
if content_type == "multipart/form-data":
|
210
|
+
response = self.client.post(
|
211
|
+
url,
|
212
|
+
headers=headers,
|
213
|
+
data=data, # For regular form fields
|
214
|
+
files=files, # For file parts
|
215
|
+
params=params,
|
216
|
+
)
|
217
|
+
elif content_type == "application/x-www-form-urlencoded":
|
218
|
+
response = self.client.post(
|
219
|
+
url,
|
220
|
+
headers=headers,
|
221
|
+
data=data,
|
222
|
+
params=params,
|
223
|
+
)
|
224
|
+
elif content_type == "application/json":
|
225
|
+
response = self.client.post(
|
226
|
+
url,
|
227
|
+
headers=headers,
|
228
|
+
json=data,
|
229
|
+
params=params,
|
230
|
+
)
|
231
|
+
else: # Handles 'application/octet-stream', 'text/plain', 'image/jpeg', etc.
|
232
|
+
response = self.client.post(
|
233
|
+
url,
|
234
|
+
headers=headers,
|
235
|
+
content=data, # Expect data to be bytes or str
|
236
|
+
params=params,
|
237
|
+
)
|
194
238
|
response.raise_for_status()
|
195
239
|
logger.debug(f"POST request successful with status code: {response.status_code}")
|
196
240
|
return response
|
197
241
|
|
198
|
-
def _put(
|
242
|
+
def _put(
|
243
|
+
self,
|
244
|
+
url: str,
|
245
|
+
data: Any,
|
246
|
+
params: dict[str, Any] | None = None,
|
247
|
+
content_type: str = "application/json",
|
248
|
+
files: dict[str, Any] | None = None,
|
249
|
+
) -> httpx.Response:
|
199
250
|
"""
|
200
251
|
Make a PUT request to the specified URL.
|
201
252
|
|
202
253
|
Args:
|
203
254
|
url: The URL to send the request to
|
204
|
-
data: The data to send
|
255
|
+
data: The data to send. For 'application/json', this is JSON-serializable.
|
256
|
+
For 'application/x-www-form-urlencoded' or 'multipart/form-data', this is a dict of form fields.
|
257
|
+
For other content types, this is raw bytes or string.
|
205
258
|
params: Optional query parameters
|
259
|
+
content_type: The Content-Type of the request body.
|
260
|
+
Examples: 'application/json', 'application/x-www-form-urlencoded',
|
261
|
+
'multipart/form-data', 'application/octet-stream', 'text/plain'.
|
262
|
+
files: Optional dictionary of files to upload for 'multipart/form-data'.
|
263
|
+
Example: {'file_field_name': ('filename.txt', open('file.txt', 'rb'), 'text/plain')}
|
206
264
|
|
207
265
|
Returns:
|
208
266
|
httpx.Response: The response from the server
|
@@ -210,12 +268,44 @@ class APIApplication(BaseApplication):
|
|
210
268
|
Raises:
|
211
269
|
httpx.HTTPError: If the request fails
|
212
270
|
"""
|
213
|
-
logger.debug(
|
214
|
-
|
215
|
-
url,
|
216
|
-
json=data,
|
217
|
-
params=params,
|
271
|
+
logger.debug(
|
272
|
+
f"Making PUT request to {url} with params: {params}, data type: {type(data)}, content_type={content_type}, files: {'yes' if files else 'no'}"
|
218
273
|
)
|
274
|
+
headers = self._get_headers().copy()
|
275
|
+
# For multipart/form-data, httpx handles the Content-Type header (with boundary)
|
276
|
+
# For other content types, we set it explicitly.
|
277
|
+
if content_type != "multipart/form-data":
|
278
|
+
headers["Content-Type"] = content_type
|
279
|
+
|
280
|
+
if content_type == "multipart/form-data":
|
281
|
+
response = self.client.put(
|
282
|
+
url,
|
283
|
+
headers=headers,
|
284
|
+
data=data, # For regular form fields
|
285
|
+
files=files, # For file parts
|
286
|
+
params=params,
|
287
|
+
)
|
288
|
+
elif content_type == "application/x-www-form-urlencoded":
|
289
|
+
response = self.client.put(
|
290
|
+
url,
|
291
|
+
headers=headers,
|
292
|
+
data=data,
|
293
|
+
params=params,
|
294
|
+
)
|
295
|
+
elif content_type == "application/json":
|
296
|
+
response = self.client.put(
|
297
|
+
url,
|
298
|
+
headers=headers,
|
299
|
+
json=data,
|
300
|
+
params=params,
|
301
|
+
)
|
302
|
+
else: # Handles 'application/octet-stream', 'text/plain', 'image/jpeg', etc.
|
303
|
+
response = self.client.put(
|
304
|
+
url,
|
305
|
+
headers=headers,
|
306
|
+
content=data, # Expect data to be bytes or str
|
307
|
+
params=params,
|
308
|
+
)
|
219
309
|
response.raise_for_status()
|
220
310
|
logger.debug(f"PUT request successful with status code: {response.status_code}")
|
221
311
|
return response
|
@@ -45,14 +45,26 @@ def generate(
|
|
45
45
|
raise typer.Exit(1)
|
46
46
|
|
47
47
|
try:
|
48
|
-
|
49
|
-
app_file = generate_api_from_schema(
|
48
|
+
app_file_data = generate_api_from_schema(
|
50
49
|
schema_path=schema_path,
|
51
50
|
output_path=output_path,
|
52
51
|
class_name=class_name,
|
53
52
|
)
|
54
|
-
|
55
|
-
|
53
|
+
if isinstance(app_file_data, dict) and "code" in app_file_data:
|
54
|
+
console.print("[yellow]No output path specified, printing generated code to console:[/yellow]")
|
55
|
+
console.print(app_file_data["code"])
|
56
|
+
elif isinstance(app_file_data, Path):
|
57
|
+
console.print("[green]API client successfully generated and installed.[/green]")
|
58
|
+
console.print(f"[blue]Application file: {app_file_data}[/blue]")
|
59
|
+
else:
|
60
|
+
# Handle the error case from api_generator if validation fails
|
61
|
+
if isinstance(app_file_data, dict) and "error" in app_file_data:
|
62
|
+
console.print(f"[red]{app_file_data['error']}[/red]")
|
63
|
+
raise typer.Exit(1)
|
64
|
+
else:
|
65
|
+
console.print("[red]Unexpected return value from API generator.[/red]")
|
66
|
+
raise typer.Exit(1)
|
67
|
+
|
56
68
|
except Exception as e:
|
57
69
|
console.print(f"[red]Error generating API client: {e}[/red]")
|
58
70
|
raise typer.Exit(1) from e
|
@@ -255,5 +267,33 @@ def preprocess(
|
|
255
267
|
run_preprocessing(schema_path, output_path)
|
256
268
|
|
257
269
|
|
270
|
+
@app.command()
|
271
|
+
def split_api(
|
272
|
+
input_app_file: Path = typer.Argument(..., help="Path to the generated app.py file to split"),
|
273
|
+
output_dir: Path = typer.Option(..., "--output-dir", "-o", help="Directory to save the split files"),
|
274
|
+
):
|
275
|
+
"""Splits a single generated API client file into multiple files based on path groups."""
|
276
|
+
from universal_mcp.utils.openapi.api_splitter import split_generated_app_file
|
277
|
+
|
278
|
+
if not input_app_file.exists() or not input_app_file.is_file():
|
279
|
+
console.print(f"[red]Error: Input file {input_app_file} does not exist or is not a file.[/red]")
|
280
|
+
raise typer.Exit(1)
|
281
|
+
|
282
|
+
if not output_dir.exists():
|
283
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
284
|
+
console.print(f"[green]Created output directory: {output_dir}[/green]")
|
285
|
+
elif not output_dir.is_dir():
|
286
|
+
console.print(f"[red]Error: Output path {output_dir} is not a directory.[/red]")
|
287
|
+
raise typer.Exit(1)
|
288
|
+
|
289
|
+
try:
|
290
|
+
split_generated_app_file(input_app_file, output_dir)
|
291
|
+
console.print(f"[green]Successfully split {input_app_file} into {output_dir}[/green]")
|
292
|
+
except Exception as e:
|
293
|
+
console.print(f"[red]Error splitting API client: {e}[/red]")
|
294
|
+
|
295
|
+
raise typer.Exit(1) from e
|
296
|
+
|
297
|
+
|
258
298
|
if __name__ == "__main__":
|
259
299
|
app()
|
@@ -49,7 +49,9 @@ class ServerConfig(BaseSettings):
|
|
49
49
|
description: str = Field(default="Universal MCP", description="Description of the MCP server")
|
50
50
|
api_key: SecretStr | None = Field(default=None, description="API key for authentication")
|
51
51
|
type: Literal["local", "agentr"] = Field(default="agentr", description="Type of server deployment")
|
52
|
-
transport: Literal["stdio", "sse", "http"] = Field(
|
52
|
+
transport: Literal["stdio", "sse", "streamable-http"] = Field(
|
53
|
+
default="stdio", description="Transport protocol to use"
|
54
|
+
)
|
53
55
|
port: int = Field(default=8005, description="Port to run the server on (if applicable)")
|
54
56
|
host: str = Field(default="localhost", description="Host to bind the server to (if applicable)")
|
55
57
|
apps: list[AppConfig] | None = Field(default=None, description="List of configured applications")
|