mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-21 15:54:28 +01:00
Use 120 characters instead of 88 (#856)
This commit is contained in:
committed by
GitHub
parent
f7265f7b91
commit
543961968c
@@ -21,9 +21,7 @@ def get_claude_config_path() -> Path | None:
|
||||
elif sys.platform == "darwin":
|
||||
path = Path(Path.home(), "Library", "Application Support", "Claude")
|
||||
elif sys.platform.startswith("linux"):
|
||||
path = Path(
|
||||
os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config"), "Claude"
|
||||
)
|
||||
path = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config"), "Claude")
|
||||
else:
|
||||
return None
|
||||
|
||||
@@ -37,8 +35,7 @@ def get_uv_path() -> str:
|
||||
uv_path = shutil.which("uv")
|
||||
if not uv_path:
|
||||
logger.error(
|
||||
"uv executable not found in PATH, falling back to 'uv'. "
|
||||
"Please ensure uv is installed and in your PATH"
|
||||
"uv executable not found in PATH, falling back to 'uv'. " "Please ensure uv is installed and in your PATH"
|
||||
)
|
||||
return "uv" # Fall back to just "uv" if not found
|
||||
return uv_path
|
||||
@@ -94,10 +91,7 @@ def update_claude_config(
|
||||
config["mcpServers"] = {}
|
||||
|
||||
# Always preserve existing env vars and merge with new ones
|
||||
if (
|
||||
server_name in config["mcpServers"]
|
||||
and "env" in config["mcpServers"][server_name]
|
||||
):
|
||||
if server_name in config["mcpServers"] and "env" in config["mcpServers"][server_name]:
|
||||
existing_env = config["mcpServers"][server_name]["env"]
|
||||
if env_vars:
|
||||
# New vars take precedence over existing ones
|
||||
|
||||
@@ -45,9 +45,7 @@ def _get_npx_command():
|
||||
# Try both npx.cmd and npx.exe on Windows
|
||||
for cmd in ["npx.cmd", "npx.exe", "npx"]:
|
||||
try:
|
||||
subprocess.run(
|
||||
[cmd, "--version"], check=True, capture_output=True, shell=True
|
||||
)
|
||||
subprocess.run([cmd, "--version"], check=True, capture_output=True, shell=True)
|
||||
return cmd
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
@@ -58,9 +56,7 @@ def _get_npx_command():
|
||||
def _parse_env_var(env_var: str) -> tuple[str, str]:
|
||||
"""Parse environment variable string in format KEY=VALUE."""
|
||||
if "=" not in env_var:
|
||||
logger.error(
|
||||
f"Invalid environment variable format: {env_var}. Must be KEY=VALUE"
|
||||
)
|
||||
logger.error(f"Invalid environment variable format: {env_var}. Must be KEY=VALUE")
|
||||
sys.exit(1)
|
||||
key, value = env_var.split("=", 1)
|
||||
return key.strip(), value.strip()
|
||||
@@ -154,14 +150,10 @@ def _import_server(file: Path, server_object: str | None = None):
|
||||
True if it's supported.
|
||||
"""
|
||||
if not isinstance(server_object, FastMCP):
|
||||
logger.error(
|
||||
f"The server object {object_name} is of type "
|
||||
f"{type(server_object)} (expecting {FastMCP})."
|
||||
)
|
||||
logger.error(f"The server object {object_name} is of type " f"{type(server_object)} (expecting {FastMCP}).")
|
||||
if isinstance(server_object, LowLevelServer):
|
||||
logger.warning(
|
||||
"Note that only FastMCP server is supported. Low level "
|
||||
"Server class is not yet supported."
|
||||
"Note that only FastMCP server is supported. Low level " "Server class is not yet supported."
|
||||
)
|
||||
return False
|
||||
return True
|
||||
@@ -172,10 +164,7 @@ def _import_server(file: Path, server_object: str | None = None):
|
||||
for name in ["mcp", "server", "app"]:
|
||||
if hasattr(module, name):
|
||||
if not _check_server_object(getattr(module, name), f"{file}:{name}"):
|
||||
logger.error(
|
||||
f"Ignoring object '{file}:{name}' as it's not a valid "
|
||||
"server object"
|
||||
)
|
||||
logger.error(f"Ignoring object '{file}:{name}' as it's not a valid " "server object")
|
||||
continue
|
||||
return getattr(module, name)
|
||||
|
||||
@@ -280,8 +269,7 @@ def dev(
|
||||
npx_cmd = _get_npx_command()
|
||||
if not npx_cmd:
|
||||
logger.error(
|
||||
"npx not found. Please ensure Node.js and npm are properly installed "
|
||||
"and added to your system PATH."
|
||||
"npx not found. Please ensure Node.js and npm are properly installed " "and added to your system PATH."
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -383,8 +371,7 @@ def install(
|
||||
typer.Option(
|
||||
"--name",
|
||||
"-n",
|
||||
help="Custom name for the server (defaults to server's name attribute or"
|
||||
" file name)",
|
||||
help="Custom name for the server (defaults to server's name attribute or" " file name)",
|
||||
),
|
||||
] = None,
|
||||
with_editable: Annotated[
|
||||
@@ -458,8 +445,7 @@ def install(
|
||||
name = server.name
|
||||
except (ImportError, ModuleNotFoundError) as e:
|
||||
logger.debug(
|
||||
"Could not import server (likely missing dependencies), using file"
|
||||
" name",
|
||||
"Could not import server (likely missing dependencies), using file" " name",
|
||||
extra={"error": str(e)},
|
||||
)
|
||||
name = file.stem
|
||||
@@ -477,11 +463,7 @@ def install(
|
||||
if env_file:
|
||||
if dotenv:
|
||||
try:
|
||||
env_dict |= {
|
||||
k: v
|
||||
for k, v in dotenv.dotenv_values(env_file).items()
|
||||
if v is not None
|
||||
}
|
||||
env_dict |= {k: v for k, v in dotenv.dotenv_values(env_file).items() if v is not None}
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to load .env file: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user