dtlpymcp 0.1.9__tar.gz → 0.1.10__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.
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/PKG-INFO +1 -1
- dtlpymcp-0.1.10/dtlpymcp/__init__.py +3 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp/__main__.py +9 -1
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp/proxy.py +50 -5
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp.egg-info/PKG-INFO +1 -1
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/pyproject.toml +1 -1
- dtlpymcp-0.1.9/dtlpymcp/__init__.py +0 -34
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/MANIFEST.in +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/README.md +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp/min_proxy.py +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp/utils/dtlpy_context.py +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp.egg-info/SOURCES.txt +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp.egg-info/dependency_links.txt +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp.egg-info/entry_points.txt +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp.egg-info/requires.txt +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/dtlpymcp.egg-info/top_level.txt +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/setup.cfg +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/tests/test_context.py +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/tests/test_custom_sources_file.py +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/tests/test_list_platform_tools.py +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/tests/test_proxy.py +0 -0
- {dtlpymcp-0.1.9 → dtlpymcp-0.1.10}/tests/test_run.py +0 -0
|
@@ -24,11 +24,19 @@ def main():
|
|
|
24
24
|
default=30.0,
|
|
25
25
|
help="Timeout in seconds for Dataloop context initialization (default: 30.0)",
|
|
26
26
|
)
|
|
27
|
+
start_parser.add_argument(
|
|
28
|
+
"--log-level",
|
|
29
|
+
"-l",
|
|
30
|
+
type=str,
|
|
31
|
+
default="INFO",
|
|
32
|
+
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
|
33
|
+
help="Logging level (default: INFO)",
|
|
34
|
+
)
|
|
27
35
|
|
|
28
36
|
args = parser.parse_args()
|
|
29
37
|
|
|
30
38
|
if args.command == "start":
|
|
31
|
-
sys.exit(proxy_main(sources_file=args.sources_file, init_timeout=args.init_timeout))
|
|
39
|
+
sys.exit(proxy_main(sources_file=args.sources_file, init_timeout=args.init_timeout, log_level=args.log_level))
|
|
32
40
|
else:
|
|
33
41
|
parser.print_help()
|
|
34
42
|
return 1
|
|
@@ -2,6 +2,8 @@ from mcp.server.fastmcp import FastMCP, Context
|
|
|
2
2
|
from mcp.server.fastmcp.tools.base import Tool, FuncMetadata
|
|
3
3
|
from typing import Any, Optional, List
|
|
4
4
|
import traceback
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from pathlib import Path
|
|
5
7
|
import os
|
|
6
8
|
import asyncio
|
|
7
9
|
import logging
|
|
@@ -10,7 +12,48 @@ from mcp.server.fastmcp.utilities.func_metadata import ArgModelBase
|
|
|
10
12
|
|
|
11
13
|
from dtlpymcp.utils.dtlpy_context import DataloopContext
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
|
|
16
|
+
def setup_logging(log_level: str = "INFO") -> logging.Logger:
|
|
17
|
+
"""
|
|
18
|
+
Setup logging configuration with the specified log level.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
log_level: Logging level as string (DEBUG, INFO, WARNING, ERROR, CRITICAL)
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
logging.Logger: Configured logger instance
|
|
25
|
+
"""
|
|
26
|
+
# Setup logging directory and file
|
|
27
|
+
log_dir = Path.home() / ".dataloop" / "mcplogs"
|
|
28
|
+
log_dir.mkdir(parents=True, exist_ok=True)
|
|
29
|
+
log_file = log_dir / f"{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
|
|
30
|
+
|
|
31
|
+
# Remove any existing handlers
|
|
32
|
+
for handler in logging.root.handlers[:]:
|
|
33
|
+
logging.root.removeHandler(handler)
|
|
34
|
+
|
|
35
|
+
# File handler with timestamp
|
|
36
|
+
file_handler = logging.FileHandler(log_file, mode="a", encoding="utf-8")
|
|
37
|
+
file_handler.setFormatter(
|
|
38
|
+
logging.Formatter(fmt="%(asctime)s [%(levelname)s] %(name)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# Console handler (default format)
|
|
42
|
+
console_handler = logging.StreamHandler()
|
|
43
|
+
console_handler.setFormatter(logging.Formatter(fmt="[%(levelname)s] %(name)s: %(message)s"))
|
|
44
|
+
|
|
45
|
+
# Convert string log level to logging constant
|
|
46
|
+
numeric_level = getattr(logging, log_level.upper(), logging.INFO)
|
|
47
|
+
|
|
48
|
+
# Configure root logger
|
|
49
|
+
logging.basicConfig(level=numeric_level, handlers=[file_handler, console_handler])
|
|
50
|
+
|
|
51
|
+
# Get the main logger
|
|
52
|
+
logger = logging.getLogger("dtlpymcp")
|
|
53
|
+
logger.info(f"Logging configured with level: {log_level.upper()}")
|
|
54
|
+
logger.info(f"Log file: {log_file}")
|
|
55
|
+
|
|
56
|
+
return logger
|
|
14
57
|
|
|
15
58
|
|
|
16
59
|
def run_async(coro):
|
|
@@ -29,13 +72,13 @@ async def initialize_dataloop_context(sources_file: Optional[str] = None, init_t
|
|
|
29
72
|
Initialize Dataloop context with timeout protection.
|
|
30
73
|
|
|
31
74
|
Args:
|
|
32
|
-
|
|
33
|
-
app: The FastMCP app instance to register tools with
|
|
75
|
+
sources_file: Path to sources file
|
|
34
76
|
init_timeout: Timeout in seconds for initialization
|
|
35
77
|
|
|
36
78
|
Returns:
|
|
37
79
|
List[Tool]: List of tools
|
|
38
80
|
"""
|
|
81
|
+
logger = logging.getLogger("dtlpymcp")
|
|
39
82
|
try:
|
|
40
83
|
tools = []
|
|
41
84
|
dl_context = DataloopContext(
|
|
@@ -101,8 +144,10 @@ def create_dataloop_mcp_server(sources_file: Optional[str] = None, init_timeout:
|
|
|
101
144
|
return app
|
|
102
145
|
|
|
103
146
|
|
|
104
|
-
def main(sources_file: Optional[str] = None, init_timeout: float = 30.0) -> int:
|
|
105
|
-
|
|
147
|
+
def main(sources_file: Optional[str] = None, init_timeout: float = 30.0, log_level: str = "INFO") -> int:
|
|
148
|
+
# Setup logging with the specified level
|
|
149
|
+
logger = setup_logging(log_level)
|
|
150
|
+
|
|
106
151
|
logger.info("Starting Dataloop MCP server in stdio mode")
|
|
107
152
|
|
|
108
153
|
# Validate environment variables
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
from .utils.dtlpy_context import DataloopContext, MCPSource
|
|
2
|
-
import logging
|
|
3
|
-
from datetime import datetime
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
__version__ = "0.1.9"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# Setup logging directory and file
|
|
10
|
-
log_dir = Path.home() / ".dataloop" / "mcplogs"
|
|
11
|
-
log_dir.mkdir(parents=True, exist_ok=True)
|
|
12
|
-
log_file = log_dir / f"{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
|
|
13
|
-
|
|
14
|
-
# Remove any existing handlers
|
|
15
|
-
for handler in logging.root.handlers[:]:
|
|
16
|
-
logging.root.removeHandler(handler)
|
|
17
|
-
|
|
18
|
-
# File handler with timestamp
|
|
19
|
-
file_handler = logging.FileHandler(log_file, mode="a", encoding="utf-8")
|
|
20
|
-
file_handler.setFormatter(
|
|
21
|
-
logging.Formatter(fmt="%(asctime)s [%(levelname)s] %(name)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
# Console handler (default format)
|
|
25
|
-
console_handler = logging.StreamHandler()
|
|
26
|
-
console_handler.setFormatter(logging.Formatter(fmt="[%(levelname)s] %(name)s: %(message)s"))
|
|
27
|
-
|
|
28
|
-
# Configure root logger
|
|
29
|
-
logging.basicConfig(level=logging.DEBUG, handlers=[file_handler, console_handler])
|
|
30
|
-
|
|
31
|
-
# Get the main logger
|
|
32
|
-
logger = logging.getLogger("dtlpymcp")
|
|
33
|
-
logger.info(f"Logging configured with level: DEBUG")
|
|
34
|
-
logger.info(f"Log file: {log_file}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|