Compare commits

..
6 changed files with 78 additions and 107 deletions
-4
View File
@@ -23,8 +23,6 @@ from langgraph_cli.schemas import (
GraphDef,
HttpConfig,
IndexConfig,
McpConfig,
McpTasksConfig,
SecurityConfig,
SerdeConfig,
StoreConfig,
@@ -117,8 +115,6 @@ def add_descriptions_to_schema(schema, cls):
AuthConfig,
SecurityConfig,
HttpConfig,
McpConfig,
McpTasksConfig,
CorsConfig,
CacheConfig,
ThreadTTLConfig,
+20 -3
View File
@@ -51,6 +51,7 @@ RESERVED_ENV_VARS = frozenset(
"LANGGRAPH_AUTH_TYPE",
"LANGSMITH_AUTH_ENDPOINT",
"LANGSMITH_TENANT_ID",
"LANGSMITH_WORKSPACE_ID",
"LANGSMITH_AUTH_VERIFY_TENANT_ID",
"LANGSMITH_HOST_PROJECT_ID",
"LANGSMITH_HOST_PROJECT_NAME",
@@ -1229,6 +1230,24 @@ def _run_remote_build(
# ---------------------------------------------------------------------------
def _get_tenant_id(env_vars: dict[str, str]) -> str | None:
"""Get the tenant ID from LANGSMITH_TENANT_ID or LANGSMITH_WORKSPACE_ID."""
tenant_id = env_vars.get("LANGSMITH_TENANT_ID") or os.environ.get(
"LANGSMITH_TENANT_ID"
)
fallback_tenant_id = env_vars.get("LANGSMITH_WORKSPACE_ID") or os.environ.get(
"LANGSMITH_WORKSPACE_ID"
)
if tenant_id and fallback_tenant_id:
raise click.UsageError(
"LANGSMITH_TENANT_ID and LANGSMITH_WORKSPACE_ID cannot both be set. "
"Set only one."
)
if tenant_id:
return tenant_id
return fallback_tenant_id or None
def _create_host_backend_client(
host_url: str | None,
api_key: str | None,
@@ -1236,6 +1255,7 @@ def _create_host_backend_client(
) -> HostBackendClient:
if env_vars is None:
env_vars = _parse_env_from_config({}, pathlib.Path.cwd() / DEFAULT_CONFIG)
tenant_id = _get_tenant_id(env_vars)
resolved_api_key = api_key
if not resolved_api_key:
for key_name in _API_KEY_ENV_NAMES:
@@ -1258,9 +1278,6 @@ def _create_host_backend_client(
fg="yellow",
)
resolved_api_key = click.prompt("Enter LangSmith API key", hide_input=True)
tenant_id = env_vars.get("LANGSMITH_TENANT_ID") or os.environ.get(
"LANGSMITH_TENANT_ID"
)
return HostBackendClient(host_url, resolved_api_key, tenant_id=tenant_id)
-20
View File
@@ -439,24 +439,6 @@ class ConfigurableHeaderConfig(TypedDict, total=False):
"""
class McpTasksConfig(TypedDict, total=False):
"""Settings for authenticated MCP elicitation tasks."""
poll_interval_ms: int
"""Suggested client polling interval, in milliseconds. Default 1000; range 10060000."""
ttl_minutes: int
"""Maximum task lifetime, in minutes. Default 1440; range 110080."""
completed_grace_seconds: int
"""Result retention after completion, in seconds. Default 300; range 186400."""
allow_insecure_urls: bool
"""Allow HTTP elicitation URLs for development. Defaults to False; production URLs require HTTPS."""
class McpConfig(TypedDict, total=False):
tasks: McpTasksConfig
"""Polling, retention and URL settings for the MCP Tasks extension."""
class HttpConfig(TypedDict, total=False):
"""Configuration for the built-in HTTP server that powers your deployment's routes and endpoints."""
@@ -491,8 +473,6 @@ class HttpConfig(TypedDict, total=False):
Default is False.
"""
mcp: McpConfig
"""Optional. Configure the MCP Tasks extension for elicitation over protocol 2026-07-28."""
disable_a2a: bool
"""Optional. If `True`, /a2a routes are removed, disabling default support to expose the deployment as an agent-to-agent (A2A) server.
-40
View File
@@ -1065,10 +1065,6 @@
],
"description": "Optional. Defines which headers are excluded from logging."
},
"mcp": {
"$ref": "#/$defs/McpConfig",
"description": "Optional. Configure the MCP Tasks extension for elicitation over protocol 2026-07-28."
},
"middleware_order": {
"anyOf": [
{
@@ -1174,42 +1170,6 @@
},
"required": []
},
"McpConfig": {
"title": "McpConfig",
"type": "object",
"properties": {
"tasks": {
"$ref": "#/$defs/McpTasksConfig",
"description": "Polling, retention and URL settings for the MCP Tasks extension."
}
},
"required": [],
"description": "dict() -> new empty dictionary\ndict(mapping) -> new dictionary initialized from a mapping object's\n (key, value) pairs\ndict(iterable) -> new dictionary initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] = v\ndict(**kwargs) -> new dictionary initialized with the name=value pairs\n in the keyword argument list. For example: dict(one=1, two=2)"
},
"McpTasksConfig": {
"title": "McpTasksConfig",
"description": "Settings for authenticated MCP elicitation tasks.",
"type": "object",
"properties": {
"allow_insecure_urls": {
"type": "boolean",
"description": "Allow HTTP elicitation URLs for development. Defaults to False; production URLs require HTTPS."
},
"completed_grace_seconds": {
"type": "integer",
"description": "Result retention after completion, in seconds. Default 300; range 1\u201386400."
},
"poll_interval_ms": {
"type": "integer",
"description": "Suggested client polling interval, in milliseconds. Default 1000; range 100\u201360000."
},
"ttl_minutes": {
"type": "integer",
"description": "Maximum task lifetime, in minutes. Default 1440; range 1\u201310080."
}
},
"required": []
},
"UvSource": {
"title": "UvSource",
"description": "Deployment source rooted at a uv project or workspace.",
-40
View File
@@ -1065,10 +1065,6 @@
],
"description": "Optional. Defines which headers are excluded from logging."
},
"mcp": {
"$ref": "#/$defs/McpConfig",
"description": "Optional. Configure the MCP Tasks extension for elicitation over protocol 2026-07-28."
},
"middleware_order": {
"anyOf": [
{
@@ -1174,42 +1170,6 @@
},
"required": []
},
"McpConfig": {
"title": "McpConfig",
"type": "object",
"properties": {
"tasks": {
"$ref": "#/$defs/McpTasksConfig",
"description": "Polling, retention and URL settings for the MCP Tasks extension."
}
},
"required": [],
"description": "dict() -> new empty dictionary\ndict(mapping) -> new dictionary initialized from a mapping object's\n (key, value) pairs\ndict(iterable) -> new dictionary initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] = v\ndict(**kwargs) -> new dictionary initialized with the name=value pairs\n in the keyword argument list. For example: dict(one=1, two=2)"
},
"McpTasksConfig": {
"title": "McpTasksConfig",
"description": "Settings for authenticated MCP elicitation tasks.",
"type": "object",
"properties": {
"allow_insecure_urls": {
"type": "boolean",
"description": "Allow HTTP elicitation URLs for development. Defaults to False; production URLs require HTTPS."
},
"completed_grace_seconds": {
"type": "integer",
"description": "Result retention after completion, in seconds. Default 300; range 1\u201386400."
},
"poll_interval_ms": {
"type": "integer",
"description": "Suggested client polling interval, in milliseconds. Default 1000; range 100\u201360000."
},
"ttl_minutes": {
"type": "integer",
"description": "Maximum task lifetime, in minutes. Default 1440; range 1\u201310080."
}
},
"required": []
},
"UvSource": {
"title": "UvSource",
"description": "Deployment source rooted at a uv project or workspace.",
@@ -21,6 +21,7 @@ from langgraph_cli.deploy import (
_parse_env_from_config,
_resolve_env_path,
_resolve_pushed_image_digest,
_secrets_from_env,
_smith_dashboard_base_url,
_validate_prebuilt_image,
normalize_image_tag,
@@ -540,6 +541,63 @@ class TestCreateHostBackendClientNoInput:
assert client is not None
@pytest.mark.parametrize("source", ["config", "shell"])
@pytest.mark.parametrize("name", ["LANGSMITH_TENANT_ID", "LANGSMITH_WORKSPACE_ID"])
def test_workspace_id_alias(monkeypatch, source, name):
monkeypatch.delenv("LANGSMITH_WORKSPACE_ID", raising=False)
monkeypatch.delenv("LANGSMITH_TENANT_ID", raising=False)
env_vars = {}
if source == "config":
env_vars[name] = "workspace"
else:
monkeypatch.setenv(name, "workspace")
def handler(request):
assert request.headers["X-Tenant-ID"] == "workspace"
return httpx.Response(200, json={"resources": []})
monkeypatch.setattr(
httpx, "HTTPTransport", lambda **kwargs: httpx.MockTransport(handler)
)
client = _create_host_backend_client(
"https://api.example.com", "test-key", env_vars
)
try:
client.list_deployments()
finally:
client._client.close()
@pytest.mark.parametrize("tenant_source", ["config", "shell"])
@pytest.mark.parametrize("workspace_source", ["config", "shell"])
@pytest.mark.parametrize("workspace_id", ["tenant-id", "workspace-id"])
def test_rejects_both_workspace_names(
monkeypatch, tenant_source, workspace_source, workspace_id
):
env_vars = {}
for name, source, value in [
("LANGSMITH_TENANT_ID", tenant_source, "tenant-id"),
("LANGSMITH_WORKSPACE_ID", workspace_source, workspace_id),
]:
monkeypatch.delenv(name, raising=False)
if source == "config":
env_vars[name] = value
else:
monkeypatch.setenv(name, value)
with pytest.raises(
click.UsageError,
match="LANGSMITH_TENANT_ID and LANGSMITH_WORKSPACE_ID cannot both be set",
):
_create_host_backend_client("https://api.example.com", "test-key", env_vars)
def test_workspace_id_is_not_uploaded_as_secret():
assert _secrets_from_env(
{"LANGSMITH_WORKSPACE_ID": "workspace", "APP_SETTING": "value"}
) == [{"name": "APP_SETTING", "value": "value"}]
class TestSmithDashboardBaseUrl:
def test_none_returns_default(self):
assert _smith_dashboard_base_url(None) == "https://smith.langchain.com"