diff --git a/docs-site/content/docs/cli/index.en.mdx b/docs-site/content/docs/cli/index.en.mdx
index ff69e9a16..d8a6ec8b2 100644
--- a/docs-site/content/docs/cli/index.en.mdx
+++ b/docs-site/content/docs/cli/index.en.mdx
@@ -92,7 +92,7 @@ agentengine config set OPENAI_MODEL_NAME=my-model
agentengine config model
```
-`config set` writes to the current project's `.env`. `--global` only applies to configuration groups that support shared global values. Project-scoped capabilities such as Tunnel are still written only to the project even when `--global` is present, and a notice is displayed. The interactive wizard for ADK projects supports optional on-prem MCP Tunnel configuration; see [On-prem MCP Tunnel](../framework/guides/tunnel.mdx).
+`config set` writes to the current project's `.env`. `--global` only applies to configuration groups that support shared global values. Project-scoped capabilities such as Tunnel are still written only to the project even when `--global` is present, and a notice is displayed. The interactive wizard for ADK and LangGraph projects supports optional on-prem MCP Tunnel configuration; LangGraph also requires explicit integration in a custom StateGraph. See [On-prem MCP Tunnel](../framework/guides/tunnel.mdx).
### `agentengine run`
diff --git a/docs-site/content/docs/cli/index.mdx b/docs-site/content/docs/cli/index.mdx
index ce5655c65..d380e5671 100644
--- a/docs-site/content/docs/cli/index.mdx
+++ b/docs-site/content/docs/cli/index.mdx
@@ -91,7 +91,7 @@ agentengine config set OPENAI_MODEL_NAME=my-model
agentengine config model
```
-`config set` 写入当前项目的 `.env`。`--global` 只适用于支持全局共享的配置组;Tunnel 等项目级能力即使搭配 `--global` 也只写入项目,并会显示提示。ADK 项目的交互向导支持可选的内网 MCP Tunnel 配置,详见[内网 MCP Tunnel](../framework/guides/tunnel.mdx)。
+`config set` 写入当前项目的 `.env`。`--global` 只适用于支持全局共享的配置组;Tunnel 等项目级能力即使搭配 `--global` 也只写入项目,并会显示提示。ADK 和 LangGraph 项目的交互向导支持可选的内网 MCP Tunnel 配置;LangGraph 还需在自定义 StateGraph 中显式接入,详见[内网 MCP Tunnel](../framework/guides/tunnel.mdx)。
### `agentengine run`
diff --git a/docs-site/content/docs/framework/guides/frameworks.en.mdx b/docs-site/content/docs/framework/guides/frameworks.en.mdx
index eb780c0c9..85c572e0e 100644
--- a/docs-site/content/docs/framework/guides/frameworks.en.mdx
+++ b/docs-site/content/docs/framework/guides/frameworks.en.mdx
@@ -150,6 +150,8 @@ entry_point: agent.py
agent_variable: root_agent
```
+A custom LangGraph StateGraph can explicitly call on-prem MCP tools with `LangGraphTunnelTools`. Fetch current tools in both the model node and the ToolNode execution node instead of relying on Runner auto-injection as used by ADK. See [On-prem MCP Tunnel](./tunnel.mdx) for the complete integration.
+
## LangChain
```python title="agent.py"
diff --git a/docs-site/content/docs/framework/guides/frameworks.mdx b/docs-site/content/docs/framework/guides/frameworks.mdx
index bc395b144..bf78e66f6 100644
--- a/docs-site/content/docs/framework/guides/frameworks.mdx
+++ b/docs-site/content/docs/framework/guides/frameworks.mdx
@@ -132,6 +132,8 @@ entry_point: agent.py
agent_variable: root_agent
```
+自定义 LangGraph StateGraph 可以通过 `LangGraphTunnelTools` 显式调用内网 MCP 工具。工具需要在 model 节点和 ToolNode 执行节点中动态获取,不能像 ADK 一样依赖 Runner 自动注入;完整示例见[内网 MCP Tunnel](./tunnel.mdx)。
+
## LangChain
```python title="agent.py"
diff --git a/docs-site/content/docs/framework/guides/tools-and-skill-runtime.en.mdx b/docs-site/content/docs/framework/guides/tools-and-skill-runtime.en.mdx
index 49f3ebbda..d504f7331 100644
--- a/docs-site/content/docs/framework/guides/tools-and-skill-runtime.en.mdx
+++ b/docs-site/content/docs/framework/guides/tools-and-skill-runtime.en.mdx
@@ -33,6 +33,8 @@ human confirms.
| Common AgentEngine built-ins | the `ksadk.toolsets` focused profile |
| Infrequent or higher-risk built-ins | `agentengine_tool_dispatcher` list/describe/call |
+Tunnel automatically injects tools into a top-level ADK Agent. A custom LangGraph StateGraph explicitly calls `LangGraphTunnelTools.get_tools()` in both its model and tools nodes. See [On-prem MCP Tunnel](/en/docs/framework/guides/tunnel) for the complete integration and migration examples.
+
Use the simplest path that gives the agent enough capability. Do not route a plain deterministic helper through a remote runtime just to make it look like a tool.
diff --git a/docs-site/content/docs/framework/guides/tools-and-skill-runtime.mdx b/docs-site/content/docs/framework/guides/tools-and-skill-runtime.mdx
index 8ef99577b..96483a720 100644
--- a/docs-site/content/docs/framework/guides/tools-and-skill-runtime.mdx
+++ b/docs-site/content/docs/framework/guides/tools-and-skill-runtime.mdx
@@ -33,6 +33,8 @@ KsADK 可以通过框架原生工具、MCP/A2A 集成和可选的 Skill Runtime
| AgentEngine 常用内置能力 | `ksadk.toolsets` 的 focused profile |
| 低频或高风险内置能力 | `agentengine_tool_dispatcher` 按需列出、描述和调用 |
+Tunnel 对顶层 ADK Agent 使用自动注入;自定义 LangGraph StateGraph 需要在 model/tools 节点中显式调用 `LangGraphTunnelTools.get_tools()`。完整接入代码和现有图改造方式见[内网 MCP Tunnel](/cn/docs/framework/guides/tunnel)。
+
## AgentEngine 内置工具

diff --git a/docs-site/content/docs/framework/guides/tunnel.en.mdx b/docs-site/content/docs/framework/guides/tunnel.en.mdx
index 222026deb..072625447 100644
--- a/docs-site/content/docs/framework/guides/tunnel.en.mdx
+++ b/docs-site/content/docs/framework/guides/tunnel.en.mdx
@@ -1,13 +1,13 @@
---
title: "On-prem MCP Tunnel"
-description: "Let a cloud ADK Agent call on-prem Streamable HTTP MCP tools through an outbound WebSocket tunnel established by the enterprise side."
+description: "Let a cloud ADK Agent or custom LangGraph StateGraph call on-prem Streamable HTTP MCP tools through an outbound WebSocket tunnel established by the enterprise side."
status: new
---
-KsADK Tunnel connects MCP Servers inside an enterprise network to a cloud ADK Agent through an **outbound** WebSocket. The enterprise side does not need to open an inbound port, and the Agent can discover and call tunneled tools on subsequent turns.
+KsADK Tunnel connects MCP Servers inside an enterprise network to a cloud ADK Agent or custom LangGraph StateGraph through an **outbound** WebSocket. The enterprise side does not need to open an inbound port, and the Agent can discover and call tunneled tools according to the services online during execution.
-The first version supports only the root ADK Agent and Streamable HTTP MCP. The registry lives in one Runtime process, so deployment requires one worker and one replica, or a verified sticky-routing topology. WS/WSS forwarding through the actual gateway requires separate acceptance testing.
+The first version supports automatic injection into the root ADK Agent and explicit integration with a custom LangGraph StateGraph; the only supported protocol is Streamable HTTP MCP. The registry lives in one Runtime process, so deployment requires one worker and one replica, or a verified sticky-routing topology. WS/WSS forwarding through the actual gateway requires separate acceptance testing.
## How it works
@@ -22,7 +22,7 @@ flowchart LR
subgraph cloud["Cloud Runtime: one process"]
W["/tunnel/connect"]
R["Per-app TunnelRegistry"]
- T["ADKRunner + TunnelToolset"]
+ T["ADKRunner / LangGraphTunnelTools"]
P["/tunnel/mcp/*"]
W --> R --> T --> P
end
@@ -30,15 +30,15 @@ flowchart LR
P -- "Forwarded over WebSocket" --> C
```
-1. The cloud ADK Runtime mounts Tunnel routes from environment configuration.
+1. The cloud KsADK Runtime mounts Tunnel routes from environment configuration.
2. The enterprise connector registers one or more MCP Servers, sending only names, protocols, and tool filters.
-3. ADKRunner injects `TunnelToolset` when it first loads the root Agent, without importing the user's `root_agent` during app bootstrap.
-4. Each subsequent tool enumeration reads the currently online services. New services appear on the next turn, and offline services are removed.
+3. ADKRunner automatically injects `TunnelToolset` when it first loads the root ADK Agent, without importing the user's `root_agent` during app bootstrap. A custom LangGraph StateGraph instead calls `LangGraphTunnelTools` explicitly from its nodes.
+4. ADK reads the currently online services during each subsequent tool enumeration; LangGraph reads them when its model and tool nodes execute. New services subsequently appear, and offline services are removed.
5. MCP requests travel through the in-process proxy and WebSocket to the connector, which calls the real on-prem service.
## Enable the cloud side
-Tunnel is disabled by default, and the first version only supports the ADK Runtime. `KSADK_TUNNEL_TOKEN` is required when Tunnel is enabled; other Runtimes must not set the enable flag.
+Tunnel is disabled by default. The first version supports the ADK Runtime and explicit custom StateGraph integration in the LangGraph Runtime. `KSADK_TUNNEL_TOKEN` is required when Tunnel is enabled; other Runtimes must not set the enable flag.
### Project-scoped configuration
@@ -52,7 +52,7 @@ agentengine config set \
agentengine run . --port 8080
```
-For an ADK project, you can also run `agentengine config` and enable Tunnel in the interactive wizard. The wizard reads the token through a password prompt and does not generate `KSADK_TUNNEL_SELF_URL`. Tunnel is project-scoped and cannot be saved to the global configuration. Even with `--global`, these variables are only written to the current project and a notice is displayed.
+For an ADK or LangGraph project, you can also run `agentengine config` and enable Tunnel in the interactive wizard. The wizard reads the token through a password prompt and does not generate `KSADK_TUNNEL_SELF_URL`; for LangGraph, it also reminds you to integrate explicitly in a custom StateGraph. Tunnel is project-scoped and cannot be saved to the global configuration. Even with `--global`, these variables are only written to the current project and a notice is displayed.
For temporary local debugging, you can still use the shell directly:
@@ -97,7 +97,7 @@ This must be the loopback HTTP(S) base URL of the FastAPI app in the same proces
### Ingress gateway and connection URL
-For cloud deployment, the outer ingress gateway must forward `/tunnel/connect` to the FastAPI instance running the ADK Runtime and allow WebSocket Upgrade. Allowing ordinary Agent HTTP requests is not sufficient for Tunnel. If this path is not configured, is rejected by the gateway, or is handled as ordinary HTTP, the connector cannot reach the Agent and complete registration.
+For cloud deployment, the outer ingress gateway must forward `/tunnel/connect` to the FastAPI instance running the KsADK Runtime and allow WebSocket Upgrade. Allowing ordinary Agent HTTP requests is not sufficient for Tunnel. If this path is not configured, is rejected by the gateway, or is handled as ordinary HTTP, the connector cannot reach the Agent and complete registration.
Without a path prefix, the complete cloud connection URL is:
@@ -133,10 +133,103 @@ The `agent` value used during connector registration is the Agent name detected
- Prefer `name` from `agentengine.yaml` when explicitly configured.
- Otherwise, use the name shown in detection output.
-- It can differ from `root_agent.name` in code; use the CLI detection result as the reference.
+- It can differ from `root_agent.name` in ADK code; use the CLI detection result as the reference.
+- In a custom LangGraph StateGraph, `LangGraphTunnelTools(agent_name=...)` must match the name detected for the current app.
The cloud side only allows registration to an Agent name allowed for the current app.
+## Explicit integration for custom LangGraph StateGraphs
+
+The public import is `from ksadk.tunnel.langgraph import LangGraphTunnelTools`; `from ksadk.tunnel import LangGraphTunnelTools` is also supported. During graph execution, the standard KsADK Runtime automatically supplies the current app's registry, self URL, and internal proxy credential. You do not need to call `mount_tunnel`, create a registry, or handle the proxy token yourself.
+
+`await tunnel.get_tools(tools=BUSINESS_TOOLS)` returns the business tools plus the currently online Tunnel tools. When Tunnel is disabled and no registry was explicitly supplied, it returns only the business tools. Tools are discovered independently for each online server; a discovery failure for one server does not hide tools from the others. Model-visible tool names are stable as `__`, such as `calculator__add`. `LocalServer.tool_filter` always uses original MCP tool names, such as `add`, rather than names with the namespace prefix.
+
+
+This phase supports only explicit integration from nodes in a custom `StateGraph`. It does not support `create_agent`, DeepAgents, or the legacy `create_react_agent`, and it does not automatically inject tools into arbitrary compiled graphs. `create_agent` and DeepAgents integration is left for a later phase; ADK retains automatic injection.
+
+
+### Complete example
+
+The following example can serve as the entry module for a custom LangGraph project. Configure the environment variables required by your model provider and replace `BUSINESS_TOOLS` with your existing business tools. The example contains no real credentials.
+
+```python title="agent.py"
+import os
+
+from langchain_openai import ChatOpenAI
+from langgraph.graph import MessagesState, StateGraph, START
+from langgraph.prebuilt import ToolNode, tools_condition
+
+from ksadk.tunnel.langgraph import LangGraphTunnelTools
+
+
+# Replace with your existing LangChain business tools.
+BUSINESS_TOOLS = []
+
+model = ChatOpenAI(
+ model=os.environ.get("OPENAI_MODEL_NAME", "my-model"),
+ base_url=os.environ.get("OPENAI_BASE_URL"),
+ api_key=os.environ.get("OPENAI_API_KEY"),
+)
+tunnel = LangGraphTunnelTools(agent_name="ops_agent")
+
+
+async def current_tools():
+ return await tunnel.get_tools(tools=BUSINESS_TOOLS)
+
+
+async def model_node(state: MessagesState, config):
+ reply = await model.bind_tools(await current_tools()).ainvoke(
+ state["messages"], config=config
+ )
+ return {"messages": [reply]}
+
+
+async def tools_node(state: MessagesState, config):
+ return await ToolNode(await current_tools()).ainvoke(state, config=config)
+
+
+def build_graph(*, checkpointer=None):
+ graph = StateGraph(MessagesState)
+ graph.add_node("model", model_node)
+ graph.add_node("tools", tools_node)
+ graph.add_edge(START, "model")
+ graph.add_conditional_edges("model", tools_condition)
+ graph.add_edge("tools", "model")
+ return graph.compile(checkpointer=checkpointer)
+
+
+def ksadk_graph_factory(*, checkpointer):
+ return build_graph(checkpointer=checkpointer)
+
+
+root_agent = build_graph()
+```
+
+Keep `agent_name` consistent with `name` in `agentengine.yaml`:
+
+```yaml title="agentengine.yaml"
+name: ops_agent
+framework: langgraph
+entry_point: agent.py
+agent_variable: root_agent
+```
+
+Both the model node and the tool node call the same `current_tools()`: the model obtains the tools currently available for model binding through `model.bind_tools(await current_tools())`, and the tool node obtains the currently executable tools through `ToolNode(await current_tools())`. Both nodes are async. The graph's nodes and edges keep a fixed topology; Tunnel tools are not expanded statically when the graph is compiled.
+
+Do not run `get_tools()` during module import or inside `build_graph()`, and do not cache the tool list across executions. The standard Runtime provides the app-owned binding only in the graph execution context. Calling too early would lack that context and would freeze a tool catalog that is meant to reflect online changes.
+
+### Configuration and startup order
+
+1. Install `ksadk[langgraph]` and `langchain-openai`; the `langgraph` extra already includes the required `langchain-mcp-adapters`. Configure the model provider environment variables and create the `agent.py` and `agentengine.yaml` files above.
+2. Enable Tunnel and configure its token as described in “Project-scoped configuration” or “Code/Container deployment”, then start or restart the Runtime. The standard entrypoint mounts the routes and provides the binding during graph execution; deployment must still follow the single-worker, single-replica, or sticky-routing limits at the end of this guide.
+3. After the Runtime is ready, start the connector and confirm that the required servers have registered. The first-version connector does not promise automatic reconnection. Restart the connector and register again after a Runtime restart or a disconnected connection.
+4. Send a request that needs Tunnel tools. Each node execution enumerates the currently online services again without recompiling the graph. If no servers have registered when the model request starts, the model sees only the business tools available at that time.
+
+### Migrate an existing LangGraph graph
+
+- **Existing custom ReAct StateGraph**: preserve the graph topology and replace static model tool binding and `ToolNode` construction with the async `model_node` and `tools_node` wrappers from the example. Both nodes call the same `current_tools()`, and existing business tools are passed through `BUSINESS_TOOLS`.
+- **Chat-node-only graph**: the current LangGraph project template has only a `chat` node and no `ToolNode`. Adding `bind_tools` to `chat` alone is insufficient. Follow the complete example to add an async tool node, a `tools_condition` conditional edge, and an edge from `tools` back to `model`, forming a complete tool-calling loop.
+
## Enterprise connector
Run the following example inside the enterprise network. `TUNNEL_TOKEN` is only the local environment variable read by this connector process, and its value must match the cloud `KSADK_TUNNEL_TOKEN`.
@@ -178,7 +271,7 @@ The first-version `start()` does not promise automatic reconnection. When the pr
| Credential | Purpose | Location |
| --- | --- | --- |
| Tunnel token | Authenticate connector registration at `/tunnel/connect` | Cloud Secret and connector configuration |
-| Internal proxy credential | Authenticate `TunnelToolset` calls to `/tunnel/mcp/*` in the same process | Randomly generated by Runtime and held only in per-app tunnel state |
+| Internal proxy credential | Authenticate `TunnelToolset` or `LangGraphTunnelTools` calls to `/tunnel/mcp/*` in the same process | Randomly generated by Runtime and held only in per-app tunnel state |
| Local MCP credential | Authenticate the connector to the real on-prem MCP Server | Only `LocalServer.headers` or `query` on the enterprise side |
The internal proxy credential requires no user configuration. The cloud side removes it after verification and never sends it to the connector or the on-prem MCP Server.
@@ -213,14 +306,22 @@ Never put real credentials in source code, documentation, logs, or deployment ar
- `/tunnel/mcp/*` and `/tunnel/servers` are authenticated and cannot be used as anonymous public proxies.
- A response-head timeout returns 504, a disconnected server returns 503, and a connector-side local request failure returns 502 if the response has not started.
- Cancellation and connector disconnects clean up pending requests. A mid-stream failure is not treated as a successful EOF.
+- The `content` of ordinary tool results continues through the existing event stream; the first version does not promise complete projection of MCP `structuredContent`.
+- The first version does not promise cold recovery of executions containing unfinished Tunnel ToolCalls. Ordinary MCP calls proxied through Tunnel do not guarantee exactly-once semantics. Reconcile external side effects before retrying or recovering, and make business tools idempotent or deduplicated as required.
+
+## MCP cleanup logging
+
+Some MCP SDK versions log `anyio.ClosedResourceError` from `standalone_sse_writer` when a Session or standalone SSE stream closes. LangGraph uses short-lived Sessions for tool discovery and invocation, so this cleanup message may appear repeatedly.
+
+When the Agent has received the correct result and the MCP Server has the corresponding actual tool-call log, this message usually does not indicate a tool execution failure. If the Agent did not receive a result, timed out, or lost the Connector connection, investigate the interrupted response instead. Do not use this exception alone to decide whether the whole call succeeded or failed, and do not disable all `mcp.server.streamable_http` logging merely to hide it.
## Deployment limits
1. **One process**: the process owning the WebSocket and the process executing the Agent must share the same per-app registry.
2. **One replica or sticky routing**: randomly load-balanced multi-replica deployment is unsupported.
3. **WebSocket gateway**: production acceptance must cover WS/WSS, custom headers, idle timeouts, and maximum frame sizes.
-4. **Dynamic behavior**: tool changes apply to subsequent turns and do not modify a turn that has already started.
-5. **Protocol scope**: stdio MCP, generic non-MCP binary proxying, and automatic tool injection for other Runtimes are unsupported.
+4. **Dynamic behavior**: ADK tool changes apply to subsequent turns and do not modify a turn that has already started. LangGraph enumerates again whenever a node calls `current_tools()` and does not rewrite a model response that has already been generated.
+5. **Protocol and integration scope**: stdio MCP, generic non-MCP binary proxying, and automatic tool injection other than into the root ADK Agent are unsupported. LangGraph supports only the explicit custom StateGraph integration described above.
6. **State recovery**: the registry does not survive process restart, so connectors must register again.
Passing a local MCP smoke test is not proof of cloud E2E success. Before release, use an isolated environment to verify the actual gateway, WSS, both authentication layers, tool invocation, and disconnect behavior.
diff --git a/docs-site/content/docs/framework/guides/tunnel.mdx b/docs-site/content/docs/framework/guides/tunnel.mdx
index e26993b8e..41a4200df 100644
--- a/docs-site/content/docs/framework/guides/tunnel.mdx
+++ b/docs-site/content/docs/framework/guides/tunnel.mdx
@@ -1,13 +1,13 @@
---
title: "内网 MCP Tunnel"
-description: "通过企业侧主动建立的 WebSocket 隧道,让云端 ADK Agent 调用内网 Streamable HTTP MCP 工具。"
+description: "通过企业侧主动建立的 WebSocket 隧道,让云端 ADK Agent 或自定义 LangGraph StateGraph 调用内网 Streamable HTTP MCP 工具。"
status: new
---
-KsADK Tunnel 让企业内网的 MCP Server 通过**出站** WebSocket 连接到云端 ADK Agent。企业侧无需开放入站端口,Agent 可以在后续轮次发现 Tunnel 中的工具并发起调用。
+KsADK Tunnel 让企业内网的 MCP Server 通过**出站** WebSocket 连接到云端 ADK Agent 或自定义 LangGraph StateGraph。企业侧无需开放入站端口,Agent 可以按执行时的在线状态发现 Tunnel 中的工具并发起调用。
-首版仅支持根 ADK Agent 和 Streamable HTTP MCP。Registry 位于单个 Runtime 进程内,因此部署必须使用单 worker、单副本,或经过验证的 sticky 路由。真实网关的 WS/WSS 转发能力需要单独验收。
+首版支持根 ADK Agent 自动注入和自定义 LangGraph StateGraph 显式接入,协议仅支持 Streamable HTTP MCP。Registry 位于单个 Runtime 进程内,因此部署必须使用单 worker、单副本,或经过验证的 sticky 路由。真实网关的 WS/WSS 转发能力需要单独验收。
## 工作原理
@@ -22,7 +22,7 @@ flowchart LR
subgraph cloud["云端单进程 Runtime"]
W["/tunnel/connect"]
R["Per-app TunnelRegistry"]
- T["ADKRunner + TunnelToolset"]
+ T["ADKRunner / LangGraphTunnelTools"]
P["/tunnel/mcp/*"]
W --> R --> T --> P
end
@@ -30,15 +30,15 @@ flowchart LR
P -- "WebSocket 转发" --> C
```
-1. 云端 ADK Runtime 根据环境变量挂载 Tunnel 路由。
+1. 云端 KsADK Runtime 根据环境变量挂载 Tunnel 路由。
2. 企业侧 connector 注册一个或多个 MCP Server,只发送名称、协议和工具过滤条件。
-3. ADKRunner 首次加载根 Agent 时注入 `TunnelToolset`,不提前导入用户的 `root_agent`。
-4. 后续每轮工具枚举读取当前在线服务;新服务在下一轮出现,离线服务在下一轮移除。
+3. ADKRunner 首次加载根 ADK Agent 时自动注入 `TunnelToolset`,不提前导入用户的 `root_agent`;自定义 LangGraph StateGraph 则在节点中显式调用 `LangGraphTunnelTools`。
+4. ADK 在后续每轮工具枚举时读取当前在线服务;LangGraph 在模型和工具节点执行时读取。新服务随后出现,离线服务随后移除。
5. MCP 请求经本进程代理和 WebSocket 到达 connector,再由 connector 调用真实内网服务。
## 云端开启
-Tunnel 默认关闭,首版仅支持 ADK Runtime。开启时必须提供 `KSADK_TUNNEL_TOKEN`,其他 Runtime 不应设置开启开关。
+Tunnel 默认关闭,首版支持 ADK Runtime,以及 LangGraph Runtime 中的自定义 StateGraph 显式接入。开启时必须提供 `KSADK_TUNNEL_TOKEN`,其他 Runtime 不应设置开启开关。
### 项目级配置
@@ -52,7 +52,7 @@ agentengine config set \
agentengine run . --port 8080
```
-ADK 项目也可以运行 `agentengine config`,在交互向导中启用 Tunnel。向导使用密码输入读取 token,不会生成 `KSADK_TUNNEL_SELF_URL`。Tunnel 是项目级能力,不支持保存到全局配置;即使搭配 `--global`,这些变量也只写入当前项目并显示提示。
+ADK 和 LangGraph 项目也可以运行 `agentengine config`,在交互向导中启用 Tunnel。向导使用密码输入读取 token,不会生成 `KSADK_TUNNEL_SELF_URL`;选择 LangGraph 时会提示还需在自定义 StateGraph 中显式接入。Tunnel 是项目级能力,不支持保存到全局配置;即使搭配 `--global`,这些变量也只写入当前项目并显示提示。
临时本地调试仍可直接使用 shell:
@@ -97,7 +97,7 @@ export KSADK_TUNNEL_SELF_URL=http://127.0.0.1:8080
### 外层入口网关与建联 URL
-云端部署时,外层入口网关必须把 `/tunnel/connect` 转发到运行 ADK Runtime 的 FastAPI 实例,并允许 WebSocket Upgrade。只放行普通 Agent HTTP 请求并不代表 Tunnel 可用;该路径未配置、被网关拒绝或被当作普通 HTTP 处理时,connector 无法连接到 Agent 并完成注册。
+云端部署时,外层入口网关必须把 `/tunnel/connect` 转发到运行 KsADK Runtime 的 FastAPI 实例,并允许 WebSocket Upgrade。只放行普通 Agent HTTP 请求并不代表 Tunnel 可用;该路径未配置、被网关拒绝或被当作普通 HTTP 处理时,connector 无法连接到 Agent 并完成注册。
无路径前缀时,完整云端建联 URL 为:
@@ -133,10 +133,103 @@ connector 注册时使用的 `agent` 是 KsADK 检测到的 Agent 名称:
- 优先使用 `agentengine.yaml` 中的 `name`。
- 没有显式配置时,使用检测结果显示的名称。
-- 它可能与代码中的 `root_agent.name` 不同,以 CLI 的检测结果为准。
+- 它可能与 ADK 代码中的 `root_agent.name` 不同,以 CLI 的检测结果为准。
+- 自定义 LangGraph StateGraph 中,`LangGraphTunnelTools(agent_name=...)` 必须与当前应用检测到的名称一致。
云端只允许 connector 注册到当前应用允许的 Agent 名称。
+## 自定义 LangGraph StateGraph 显式接入
+
+公开入口为 `from ksadk.tunnel.langgraph import LangGraphTunnelTools`,也可以使用 `from ksadk.tunnel import LangGraphTunnelTools`。标准 KsADK Runtime 会在图执行期间自动提供当前应用的 registry、self URL 和内部代理凭证;用户不需要手动调用 `mount_tunnel`、创建 registry 或处理 proxy token。
+
+`await tunnel.get_tools(tools=BUSINESS_TOOLS)` 返回业务工具和当前在线的 Tunnel 工具。Tunnel 未开启且没有显式传入 registry 时,只返回业务工具。每个在线 server 独立发现工具;一个 server 发现失败不会隐藏其他 server 的工具。模型看到的工具名稳定为 `__`,例如 `calculator__add`;`LocalServer.tool_filter` 始终使用原始 MCP 工具名,例如 `add`,而不是命名空间后的名称。
+
+
+本阶段只支持自定义 `StateGraph` 在节点中显式接入;不支持 `create_agent`、DeepAgents 或旧 `create_react_agent`,也不支持向任意 compiled graph 自动注入。`create_agent` 与 DeepAgents 的接入留待后续,ADK 保持自动注入。
+
+
+### 完整示例
+
+以下示例可作为自定义 LangGraph 项目的入口。按模型供应商的要求配置环境变量,并将 `BUSINESS_TOOLS` 替换为现有业务工具;示例不包含真实凭证。
+
+```python title="agent.py"
+import os
+
+from langchain_openai import ChatOpenAI
+from langgraph.graph import MessagesState, StateGraph, START
+from langgraph.prebuilt import ToolNode, tools_condition
+
+from ksadk.tunnel.langgraph import LangGraphTunnelTools
+
+
+# Replace with your existing LangChain business tools.
+BUSINESS_TOOLS = []
+
+model = ChatOpenAI(
+ model=os.environ.get("OPENAI_MODEL_NAME", "my-model"),
+ base_url=os.environ.get("OPENAI_BASE_URL"),
+ api_key=os.environ.get("OPENAI_API_KEY"),
+)
+tunnel = LangGraphTunnelTools(agent_name="ops_agent")
+
+
+async def current_tools():
+ return await tunnel.get_tools(tools=BUSINESS_TOOLS)
+
+
+async def model_node(state: MessagesState, config):
+ reply = await model.bind_tools(await current_tools()).ainvoke(
+ state["messages"], config=config
+ )
+ return {"messages": [reply]}
+
+
+async def tools_node(state: MessagesState, config):
+ return await ToolNode(await current_tools()).ainvoke(state, config=config)
+
+
+def build_graph(*, checkpointer=None):
+ graph = StateGraph(MessagesState)
+ graph.add_node("model", model_node)
+ graph.add_node("tools", tools_node)
+ graph.add_edge(START, "model")
+ graph.add_conditional_edges("model", tools_condition)
+ graph.add_edge("tools", "model")
+ return graph.compile(checkpointer=checkpointer)
+
+
+def ksadk_graph_factory(*, checkpointer):
+ return build_graph(checkpointer=checkpointer)
+
+
+root_agent = build_graph()
+```
+
+`agent_name` 与 `agentengine.yaml` 的 `name` 保持一致:
+
+```yaml title="agentengine.yaml"
+name: ops_agent
+framework: langgraph
+entry_point: agent.py
+agent_variable: root_agent
+```
+
+模型节点和工具节点都调用同一个 `current_tools()`:模型通过 `model.bind_tools(await current_tools())` 获取当前可提供给模型的工具,工具节点通过 `ToolNode(await current_tools())` 获取当前可执行的工具。两个节点均为 async,图节点和边的拓扑保持固定,不在编译图时静态展开 Tunnel 工具。
+
+不要在模块导入或 `build_graph()` 中提前执行 `get_tools()`,也不要跨执行缓存工具列表。标准 Runtime 只在图执行上下文提供 app-owned 绑定,提前调用既不能获得该上下文,也会冻结本可动态变化的在线工具目录。
+
+### 配置与启动顺序
+
+1. 安装 `ksadk[langgraph]` 和 `langchain-openai`;`langgraph` extra 已包含所需的 `langchain-mcp-adapters`。配置模型供应商环境变量,并完成上述 `agent.py` 与 `agentengine.yaml`。
+2. 按“项目级配置”或“Code/Container 部署”开启 Tunnel 并配置 token,然后启动或重新启动 Runtime。标准入口会挂载路由,并在图执行时提供绑定;部署仍须遵守文末的单 worker、单副本或 sticky 路由限制。
+3. Runtime 就绪后再启动 connector,确认所需 server 已注册。首版 connector 不承诺断线自动重连;Runtime 重启或连接断开后,需要重新启动 connector 并注册。
+4. 发起需要 Tunnel 工具的请求。每次节点执行都会重新枚举当前在线服务,无需重新编译图;如果发起模型请求时尚未注册,模型只能看到当时的业务工具。
+
+### 从现有 LangGraph 图迁移
+
+- **已有自定义 ReAct StateGraph**:保留现有图拓扑,将静态的模型工具绑定和 `ToolNode` 改为示例中的异步 `model_node`、`tools_node` 包装。两处都调用同一个 `current_tools()`,现有业务工具通过 `BUSINESS_TOOLS` 传入。
+- **只有 chat 节点**:当前 LangGraph 项目模板只有 `chat` 节点,没有 `ToolNode`。不能只给 `chat` 增加 `bind_tools`;应按完整示例增加异步工具节点、`tools_condition` 条件边和 `tools` 回到 `model` 的边,形成完整的工具调用循环。
+
## 企业侧 connector
以下示例在内网运行。`TUNNEL_TOKEN` 只是 connector 进程读取的本地环境变量名称,凭证必须与云端 `KSADK_TUNNEL_TOKEN` 一致。
@@ -178,7 +271,7 @@ asyncio.run(main())
| 凭证 | 用途 | 保存位置 |
| --- | --- | --- |
| Tunnel token | connector 注册到 `/tunnel/connect` | 云端 Secret 和 connector 配置 |
-| 内部代理凭证 | `TunnelToolset` 调用本进程 `/tunnel/mcp/*` | 由 Runtime 随机生成,仅保存在 per-app tunnel state |
+| 内部代理凭证 | `TunnelToolset` 或 `LangGraphTunnelTools` 调用本进程 `/tunnel/mcp/*` | 由 Runtime 随机生成,仅保存在 per-app tunnel state |
| 本地 MCP 凭证 | connector 调用真实内网 MCP Server | 仅企业侧 `LocalServer.headers` 或 `query` |
内部代理凭证不需要用户配置。云端验证后会将其从转发请求中移除,不会发送给 connector 或内网 MCP Server。
@@ -213,14 +306,22 @@ connector = TunnelConnector(
- `/tunnel/mcp/*` 和 `/tunnel/servers` 都有鉴权,不能作为匿名公网代理使用。
- 等待响应头超时返回 504;服务未连接返回 503;connector 本地请求失败在未开始响应时返回 502。
- 请求取消和 connector 断开会清理 pending 请求。流式响应中途失败不会被当作成功结束。
+- 普通工具结果的 `content` 继续通过现有事件流传递;首版不承诺完整投影 MCP `structuredContent`。
+- 首版不承诺对包含未完成 Tunnel ToolCall 的执行进行冷恢复。Tunnel 代理的普通 MCP 调用不保证 exactly-once;重试或恢复前应核对外部副作用,业务工具需要提供所需的幂等或去重。
+
+## MCP 清理日志
+
+部分 MCP SDK 版本在 Session 或 standalone SSE 关闭时,会在 `standalone_sse_writer` 中记录 `anyio.ClosedResourceError`。LangGraph 使用短生命周期 Session 进行工具发现和调用,因此这类清理日志可能重复出现。
+
+如果 Agent 已收到正确结果,且 MCP 有对应的实际工具调用日志,这通常不是工具执行失败。若 Agent 没有收到结果、发生超时或 Connector 断连,则仍需排查响应中断,不能仅凭该异常判断整个调用成功或失败,也不应为了掩盖问题而关闭整个 `mcp.server.streamable_http` 日志。
## 部署限制
1. **单进程**:WebSocket 所属进程和 Agent 执行进程必须共享同一个 per-app registry。
2. **单副本或 sticky 路由**:普通随机负载均衡的多副本部署不受支持。
3. **WebSocket 网关**:生产环境必须验证 WS/WSS、自定义 header、idle timeout 和最大帧大小。
-4. **动态生效**:工具变化在后续轮次生效,不会修改已经开始的当前轮次。
-5. **协议范围**:不支持 stdio MCP、非 MCP 通用二进制代理或其他 Runtime 的自动工具注入。
+4. **动态生效**:ADK 的工具变化在后续轮次生效,不会修改已经开始的当前轮次;LangGraph 在节点每次调用 `current_tools()` 时重新枚举,不会改写已经生成的模型响应。
+5. **协议与接入范围**:不支持 stdio MCP、非 MCP 通用二进制代理,或除根 ADK Agent 之外的自动工具注入;LangGraph 仅支持上述自定义 StateGraph 显式接入。
6. **状态恢复**:进程重启后 registry 不保留,connector 需要重新注册。
本地 MCP smoke 通过不等同于真实云端 E2E 通过。发布前还需在隔离环境验证实际网关、WSS、双层鉴权、工具调用和断连行为。
diff --git a/docs-site/content/docs/framework/tutorials/langgraph-agent.en.mdx b/docs-site/content/docs/framework/tutorials/langgraph-agent.en.mdx
index e4e7f10e6..e79ea9043 100644
--- a/docs-site/content/docs/framework/tutorials/langgraph-agent.en.mdx
+++ b/docs-site/content/docs/framework/tutorials/langgraph-agent.en.mdx
@@ -209,8 +209,22 @@ dist/
build/
```
+## 8. Connect To On-prem MCP With Tunnel (Optional)
+
+Use Tunnel when a cloud Agent needs to call a Streamable HTTP MCP Server inside an enterprise network. ADKRunner injects Tunnel tools automatically; LangGraph requires explicit integration in the business graph, so setting `KSADK_ENABLE_TUNNEL=1` alone is not enough.
+
+The tutorial above has only a synchronous `chat` node and no ToolNode. To add Tunnel tools:
+
+1. Make the model node async and add a `ToolNode`, `tools_condition`, and a tools→model edge to form the tool-calling loop.
+2. Create `LangGraphTunnelTools(agent_name="weather-agent")`, matching `name` in `agentengine.yaml`.
+3. Use `model.bind_tools(await tunnel.get_tools(tools=BUSINESS_TOOLS))` in the model node and pass the same current tool set to `ToolNode` in the tools node.
+4. Configure the Tunnel token, start the Runtime, and run the enterprise Connector as usual. Do not manually create a registry, call `mount_tunnel`, or handle the internal proxy credential.
+
+See [On-prem MCP Tunnel](../guides/tunnel.mdx) for a complete `agent.py`, the smaller migration for an existing ReAct graph, and the checkpoint, disconnect, and deployment limits. New `create_agent`, DeepAgents, and immutable compiled-graph auto-injection are outside the current explicit LangGraph integration scope.
+
## Next Steps
+- Follow the complete example in [On-prem MCP Tunnel](../guides/tunnel.mdx).
- Add framework-specific patterns from [Frameworks](../guides/frameworks.mdx).
- Add session or file handling from [Runtime Sessions And Files](/en/docs/references/runtime-sessions-files).
- Package the project with [Build And Package](../guides/build-and-package.mdx).
diff --git a/docs-site/content/docs/framework/tutorials/langgraph-agent.mdx b/docs-site/content/docs/framework/tutorials/langgraph-agent.mdx
index 9178fed41..14c662d54 100644
--- a/docs-site/content/docs/framework/tutorials/langgraph-agent.mdx
+++ b/docs-site/content/docs/framework/tutorials/langgraph-agent.mdx
@@ -203,8 +203,22 @@ dist/
build/
```
+## 8. 接入内网 MCP Tunnel(可选)
+
+如果云端 Agent 需要调用企业内网的 Streamable HTTP MCP,可以使用 Tunnel。ADKRunner 会自动注入 Tunnel 工具,LangGraph 则需要在业务图中显式接入,不能只设置 `KSADK_ENABLE_TUNNEL=1`。
+
+本教程的示例只有一个同步 `chat` 节点,没有 ToolNode。接入时需要:
+
+1. 把模型节点改为异步调用,并增加 `ToolNode`、`tools_condition` 和 tools→model 回边,形成工具调用循环。
+2. 创建 `LangGraphTunnelTools(agent_name="weather-agent")`,其中名称与 `agentengine.yaml` 的 `name` 一致。
+3. 在 model 节点使用 `model.bind_tools(await tunnel.get_tools(tools=BUSINESS_TOOLS))`,在 tools 节点把同一动态工具集合交给 `ToolNode`。
+4. 按标准方式配置 Tunnel token、启动 Runtime 和企业侧 Connector;不需要手工创建 registry、调用 `mount_tunnel` 或处理内部代理凭证。
+
+完整的 `agent.py`、已有 ReAct 图的简化改法,以及 checkpoint、断连和部署限制见[内网 MCP Tunnel](../guides/tunnel.mdx)。新版 `create_agent`、DeepAgents 和不可修改的 compiled graph 不属于当前 LangGraph 显式接入范围。
+
## 后续阅读
+- 阅读 [内网 MCP Tunnel](../guides/tunnel.mdx),获取完整的 LangGraph Tunnel 接入示例。
- 阅读 [框架接入](../guides/frameworks.mdx),了解框架适配和 runner 加载边界。
- 阅读 [会话与文件](/cn/docs/references/runtime-sessions-files),了解 session、上传和工作区文件。
- 阅读 [构建与打包](../guides/build-and-package.mdx),了解本地构建和公开 artifact 规则。
diff --git a/docs-site/content/docs/references/environment-variables.en.mdx b/docs-site/content/docs/references/environment-variables.en.mdx
index 21ceefa1a..de5f1bfb1 100644
--- a/docs-site/content/docs/references/environment-variables.en.mdx
+++ b/docs-site/content/docs/references/environment-variables.en.mdx
@@ -312,12 +312,14 @@ KSADK_MCP_SERVERS='[{"name":"docs","url":"http://127.0.0.1:9000/mcp"}]'
| Variable | Purpose |
| --- | --- |
-| `KSADK_ENABLE_TUNNEL` | enable the on-prem MCP Tunnel for the ADK Runtime; defaults to `0` |
+| `KSADK_ENABLE_TUNNEL` | enable the on-prem MCP Tunnel for ADK or an explicit custom LangGraph StateGraph; defaults to `0` |
| `KSADK_TUNNEL_TOKEN` | connector registration token; required when Tunnel is enabled and sensitive |
-| `KSADK_TUNNEL_SELF_URL` | loopback base URL through which TunnelToolset reaches the in-process proxy; standard entrypoints derive it from the actual port |
+| `KSADK_TUNNEL_SELF_URL` | loopback base URL through which Tunnel tools reach the in-process proxy; standard entrypoints derive it from the actual port |
These variables are project-scoped Runtime configuration and cannot be saved to the global configuration with `agentengine config set --global`. Generate `KSADK_TUNNEL_TOKEN` independently for each project or environment. `KSADK_TUNNEL_SELF_URL` is an optional override for special deployments and normally should not be written to a project or deployment environment file; standard entrypoints derive it from the actual port.
+ADKRunner injects Tunnel tools automatically. A custom LangGraph StateGraph must explicitly use `LangGraphTunnelTools` in both its model and tools nodes; setting the flag alone does not expose tools to the graph. See [On-prem MCP Tunnel](/en/docs/framework/guides/tunnel) for the complete integration and its limits.
+
```bash title="bash"
KSADK_ENABLE_TUNNEL=1
KSADK_TUNNEL_TOKEN=
diff --git a/docs-site/content/docs/references/environment-variables.mdx b/docs-site/content/docs/references/environment-variables.mdx
index 4e5f941ac..5db22307b 100644
--- a/docs-site/content/docs/references/environment-variables.mdx
+++ b/docs-site/content/docs/references/environment-variables.mdx
@@ -309,12 +309,14 @@ KSADK_MCP_SERVERS='[{"name":"docs","url":"http://127.0.0.1:9000/mcp"}]'
| 变量 | 用途 |
| --- | --- |
-| `KSADK_ENABLE_TUNNEL` | 为 ADK Runtime 开启内网 MCP Tunnel,默认 `0` |
+| `KSADK_ENABLE_TUNNEL` | 为 ADK 或自定义 LangGraph StateGraph 开启内网 MCP Tunnel,默认 `0` |
| `KSADK_TUNNEL_TOKEN` | connector 注册鉴权 token;开启 Tunnel 时必传且属于敏感信息 |
-| `KSADK_TUNNEL_SELF_URL` | TunnelToolset 访问本进程代理的 loopback base URL;标准入口按实际端口生成 |
+| `KSADK_TUNNEL_SELF_URL` | Tunnel 工具访问本进程代理的 loopback base URL;标准入口按实际端口生成 |
这些变量是项目级 Runtime 配置,不支持通过 `agentengine config set --global` 保存到全局配置。`KSADK_TUNNEL_TOKEN` 应按项目或环境独立生成。`KSADK_TUNNEL_SELF_URL` 是特殊部署使用的可选覆盖项,通常不要写入项目或部署环境文件;标准启动入口会按实际端口推导。
+ADKRunner 会自动注入 Tunnel 工具;自定义 LangGraph StateGraph 还需要在 model/tools 节点中显式使用 `LangGraphTunnelTools`,不能只设置开启开关。完整接入示例和限制见[内网 MCP Tunnel](/cn/docs/framework/guides/tunnel)。
+
```bash title="bash"
KSADK_ENABLE_TUNNEL=1
KSADK_TUNNEL_TOKEN=
diff --git "a/docs/reference/ksadk\347\216\257\345\242\203\345\217\230\351\207\217\345\217\202\350\200\203.md" "b/docs/reference/ksadk\347\216\257\345\242\203\345\217\230\351\207\217\345\217\202\350\200\203.md"
index 9252412a1..5e7f63579 100644
--- "a/docs/reference/ksadk\347\216\257\345\242\203\345\217\230\351\207\217\345\217\202\350\200\203.md"
+++ "b/docs/reference/ksadk\347\216\257\345\242\203\345\217\230\351\207\217\345\217\202\350\200\203.md"
@@ -73,15 +73,15 @@ A2A 内部控制面和云评测数据集客户端。知识库和记忆库通过
| `KSADK_MCP_KEY` | 否 | 无 | 是 | 开发者 / 平台 Secret | MCP 服务 API key;ksyun web search provider 未配 `KSADK_WEB_SEARCH_API_KEY` 时也回退到此。 |
| `KSADK_MCP_SERVERS` | 条件必传 | 无 | 是 | 开发者 / 平台 Secret | JSON 数组,配置 MCP server url、api_key、tool_filter、tool_name_prefix。可能包含 token。 |
-#### 2.3.1 ADK 内网 MCP Tunnel
+#### 2.3.1 ADK / LangGraph 内网 MCP Tunnel
| 变量 | 是否必传 | 别名/兼容 | 敏感 | 配置方/来源 | 说明 |
| --- | --- | --- | --- | --- | --- |
-| `KSADK_ENABLE_TUNNEL` | 否 | 无 | 否 | 开发者 / 平台 | 默认 `0`。设为 `1/true/yes/on` 时为 ADK Runtime 开启内网 MCP Tunnel;其他 Runtime 不支持。 |
+| `KSADK_ENABLE_TUNNEL` | 否 | 无 | 否 | 开发者 / 平台 | 默认 `0`。设为 `1/true/yes/on` 时为 ADK 或自定义 LangGraph StateGraph 开启内网 MCP Tunnel;其他 Runtime 不支持。 |
| `KSADK_TUNNEL_TOKEN` | 开启 Tunnel 时必传 | 无 | 是 | 开发者 / 平台 Secret | connector 注册到 `/tunnel/connect` 时使用的共享 token。不得写入源码或日志。 |
-| `KSADK_TUNNEL_SELF_URL` | 否 | 无 | 否 | 开发者 / Runtime | `TunnelToolset` 访问本进程代理的 loopback base URL。标准启动入口按实际端口生成,仅特殊部署需要显式覆盖。 |
+| `KSADK_TUNNEL_SELF_URL` | 否 | 无 | 否 | 开发者 / Runtime | Tunnel 工具访问本进程代理的 loopback base URL。标准启动入口按实际端口生成,仅特殊部署需要显式覆盖。 |
-上述变量均为项目级 Runtime 配置,不支持通过 `agentengine config set --global` 保存到全局配置。Tunnel token 应按项目或环境独立生成。标准部署只需要开启开关和 token;`KSADK_TUNNEL_SELF_URL` 通常不要写入项目或部署环境文件,由标准启动入口按实际端口推导。
+上述变量均为项目级 Runtime 配置,不支持通过 `agentengine config set --global` 保存到全局配置。Tunnel token 应按项目或环境独立生成。标准部署只需要开启开关和 token;`KSADK_TUNNEL_SELF_URL` 通常不要写入项目或部署环境文件,由标准启动入口按实际端口推导。ADKRunner 自动注入 Tunnel 工具;自定义 LangGraph StateGraph 还需要在 model/tools 节点中显式使用 `LangGraphTunnelTools`。
### 2.4 Skill Runtime 本地模式
diff --git a/ksadk/builders/code_builder.py b/ksadk/builders/code_builder.py
index 55acdb7ef..af5bf02c6 100644
--- a/ksadk/builders/code_builder.py
+++ b/ksadk/builders/code_builder.py
@@ -329,7 +329,7 @@ class CodeBuilder(BaseBuilder):
)
BUNDLED_KSADK_MCP_RUNTIME_REQUIREMENTS = (
"mcp>=1.1.0",
- "langchain-mcp-adapters>=0.0.1",
+ "langchain-mcp-adapters>=0.3.2",
)
BUNDLED_KSADK_POSTGRES_SESSION_REQUIREMENTS = (
"asyncpg>=0.30.0,<1.0.0",
diff --git a/ksadk/builders/framework_requirements.py b/ksadk/builders/framework_requirements.py
index 7c1d69ef4..36b4e77b3 100644
--- a/ksadk/builders/framework_requirements.py
+++ b/ksadk/builders/framework_requirements.py
@@ -26,8 +26,9 @@
DEEPAGENTS_REQUIREMENTS = ("deepagents>=0.6.2,<1.0.0",)
-# Runtime-only dependency used by ADK Tunnel's Streamable HTTP MCP handler.
+# Runtime-only dependencies used by Tunnel's Streamable HTTP MCP handlers.
TUNNEL_MCP_REQUIREMENT = "mcp>=1.26.0,<2.0.0"
+TUNNEL_LANGGRAPH_REQUIREMENT = "langchain-mcp-adapters>=0.3.2"
# codex runtime:openai-codex SDK(自带 codex CLI 二进制,见 PyPI cli-bin wheel)。
# 版本必须与 pyproject.toml 的 ksadk[codex] extra 保持一致:适配层
diff --git a/ksadk/cli/cmd_config.py b/ksadk/cli/cmd_config.py
index 59accf7c9..0157fa655 100644
--- a/ksadk/cli/cmd_config.py
+++ b/ksadk/cli/cmd_config.py
@@ -386,7 +386,7 @@ def run_config_wizard(config_file: str | None, set_items: tuple, is_global: bool
1. 配置 Agent 基础信息 (名称、框架等)
2. 配置 模型服务 (API Key, Base URL)
3. 配置 云厂商凭证 (KSYUN AK/SK)
- 4. 为 ADK 项目配置可选的内网 MCP Tunnel
+ 4. 为 ADK / LangGraph 项目配置可选的内网 MCP Tunnel
参数:
--set: 非交互式设置配置项 (如 --set name=MyAgent --set KSYUN_REGION=cn-beijing-6)
@@ -657,10 +657,15 @@ def _ask_or_exit(question):
print_info("企业版 KCR 和第三方镜像仓库必须配置 KCR_USERNAME + KCR_PASSWORD")
print_info("KCR 访问凭证获取: https://kcr.console.ksyun.com/ → 访问凭证")
- if new_config["framework"] == "adk":
+ if new_config["framework"] in {"adk", "langgraph"}:
print_rule()
print_rule("内网 MCP Tunnel (可选)")
print_info("Tunnel 仅保存到当前项目;标准入口会自动推导 self URL。")
+ if new_config["framework"] == "langgraph":
+ print_info(
+ "LangGraph 还需在自定义 StateGraph 的 model/tools 节点中显式使用 "
+ "LangGraphTunnelTools。"
+ )
enable_tunnel = _ask_or_exit(
questionary.confirm(
"是否启用内网 MCP Tunnel?",
diff --git a/ksadk/configs/env_registry.py b/ksadk/configs/env_registry.py
index 16eaf05b4..fd1653626 100644
--- a/ksadk/configs/env_registry.py
+++ b/ksadk/configs/env_registry.py
@@ -262,7 +262,12 @@
"Internal bundled core requirement constant.",
),
EnvVarSpec("KSADK_ENABLE_MCP_TOOLS", "mcp_runtime", "Enable ADK MCP tool injection.", "1"),
- EnvVarSpec("KSADK_ENABLE_TUNNEL", "tunnel", "Enable ADK on-prem MCP Tunnel.", "0"),
+ EnvVarSpec(
+ "KSADK_ENABLE_TUNNEL",
+ "tunnel",
+ "Enable on-prem MCP Tunnel for ADK or explicit LangGraph StateGraph tools.",
+ "0",
+ ),
EnvVarSpec("KSADK_EVENTS_TABLE", "sessions", "Internal SQLite events table constant."),
EnvVarSpec("KSADK_FEISHU_APP_ID", "cli", "Feishu helper app id used by OpenClaw diagnostics."),
EnvVarSpec("KSADK_FEISHU_RESULT_PATH", "cli", "Feishu helper result file path."),
diff --git a/ksadk/deployment/manager.py b/ksadk/deployment/manager.py
index 87641c36a..b05455e25 100644
--- a/ksadk/deployment/manager.py
+++ b/ksadk/deployment/manager.py
@@ -8,6 +8,7 @@
from ksadk.builders.framework_requirements import (
FASTAPI_REQUIREMENT,
+ TUNNEL_LANGGRAPH_REQUIREMENT,
TUNNEL_MCP_REQUIREMENT,
minimal_requirements_for_framework,
)
@@ -156,6 +157,8 @@ def _generate_requirements(self, detection_result: Any) -> str:
base_deps += minimal_requirements_for_framework(framework)
if tunnel_enabled():
base_deps.append(TUNNEL_MCP_REQUIREMENT)
+ if framework == "langgraph":
+ base_deps.append(TUNNEL_LANGGRAPH_REQUIREMENT)
return "\n".join(merge_requirement_lists(base_deps))
diff --git a/ksadk/mcp_runtime/__init__.py b/ksadk/mcp_runtime/__init__.py
index 06544a011..e07e4dc1e 100644
--- a/ksadk/mcp_runtime/__init__.py
+++ b/ksadk/mcp_runtime/__init__.py
@@ -91,6 +91,18 @@ def build_connection_params(
return _RedactedStreamableHTTPConnectionParams(**kwargs)
+def build_langchain_connection(config: MCPServerConfig) -> dict[str, Any]:
+ """Build the equivalent Streamable HTTP connection for LangChain MCP tools."""
+ if config.auth_mode == "oauth":
+ raise ValueError("OAuth MCP requires the explicit LangGraph call_mcp_tool helper")
+ return {
+ "transport": "streamable_http",
+ "url": config.url,
+ "headers": config.headers,
+ "httpx_client_factory": _default_httpx_client_factory(config.url),
+ }
+
+
def build_mcp_toolset(
config: MCPServerConfig,
*,
@@ -253,6 +265,7 @@ def _validate_mcp_url(url: str) -> str:
"MCPServerConfig",
"MCP_TOOLSET_KEY_ATTR",
"build_connection_params",
+ "build_langchain_connection",
"build_mcp_toolset",
"load_mcp_server_configs",
"load_mcp_toolsets_from_env",
diff --git a/ksadk/runtime/factory.py b/ksadk/runtime/factory.py
index 037aa1653..85751af38 100644
--- a/ksadk/runtime/factory.py
+++ b/ksadk/runtime/factory.py
@@ -194,7 +194,16 @@ def _create_adk(context: RuntimeLaunchContext) -> RuntimeAdapter:
def _create_langgraph(context: RuntimeLaunchContext) -> RuntimeAdapter:
- return LangGraphRuntimeAdapter(_create_framework_runner(context, "langgraph"))
+ runner = _create_framework_runner(context, "langgraph")
+ from ksadk.tunnel.config import tunnel_config_from_context
+
+ tunnel = tunnel_config_from_context(context)
+ if tunnel is not None:
+ # The graph resolves these process-only dependencies only during execution.
+ runner._tunnel_config = tunnel
+ runner._tunnel_registry = context.services.tunnel_registry
+ runner._owns_tunnel_registry = False
+ return LangGraphRuntimeAdapter(runner)
def build_default_runtime_registry(
diff --git a/ksadk/runtime/langgraph_checkpoint_view.py b/ksadk/runtime/langgraph_checkpoint_view.py
index 28634ee5e..72e6e7cfb 100644
--- a/ksadk/runtime/langgraph_checkpoint_view.py
+++ b/ksadk/runtime/langgraph_checkpoint_view.py
@@ -8,6 +8,8 @@
from functools import wraps
from typing import Any
+from ksadk.tunnel.langgraph import langgraph_tunnel_execution
+
# This applies only to the first latest-root checkpoint read of a new input.
# Explicit checkpoint/approval resumes and ordinary history reads see the exact
# original checkpoint. Context variables isolate concurrent sessions and tasks.
@@ -32,29 +34,32 @@ async def generate(self, input_data):
while True:
# Some adapters drive each anext in a different Task.
# Never carry a ContextVar token across a public yield.
+ with langgraph_tunnel_execution(self):
+ token = _FRESH_READ.set(context)
+ try:
+ item = await results.__anext__()
+ except StopAsyncIteration:
+ return
+ finally:
+ _FRESH_READ.reset(token)
+ yield item
+ finally:
+ with langgraph_tunnel_execution(self):
token = _FRESH_READ.set(context)
try:
- item = await results.__anext__()
- except StopAsyncIteration:
- return
+ await results.aclose()
finally:
_FRESH_READ.reset(token)
- yield item
- finally:
- token = _FRESH_READ.set(context)
- try:
- await results.aclose()
- finally:
- _FRESH_READ.reset(token)
return generate
@wraps(function)
async def invoke(self, input_data):
- token = _FRESH_READ.set({"used": False} if fresh(input_data) else None)
- try:
- return await function(self, input_data)
- finally:
- _FRESH_READ.reset(token)
+ with langgraph_tunnel_execution(self):
+ token = _FRESH_READ.set({"used": False} if fresh(input_data) else None)
+ try:
+ return await function(self, input_data)
+ finally:
+ _FRESH_READ.reset(token)
return invoke
diff --git a/ksadk/tunnel/__init__.py b/ksadk/tunnel/__init__.py
index f946b837c..f96cf9734 100644
--- a/ksadk/tunnel/__init__.py
+++ b/ksadk/tunnel/__init__.py
@@ -15,6 +15,7 @@
"ServerDescriptor": "ksadk.tunnel.registry",
"TunnelRegistry": "ksadk.tunnel.registry",
"get_registry": "ksadk.tunnel.registry",
+ "LangGraphTunnelTools": "ksadk.tunnel.langgraph",
"mount_tunnel": "ksadk.tunnel.server",
"TunnelToolset": "ksadk.tunnel.toolset",
}
diff --git a/ksadk/tunnel/config.py b/ksadk/tunnel/config.py
index d12a4d8c5..813878a4b 100644
--- a/ksadk/tunnel/config.py
+++ b/ksadk/tunnel/config.py
@@ -1,4 +1,4 @@
-"""Environment and composition helpers for the optional ADK Tunnel."""
+"""Environment and composition helpers for the optional MCP Tunnel."""
from __future__ import annotations
@@ -56,8 +56,14 @@ def tunnel_config_for_detection(
detection_type = getattr(getattr(detection, "type", None), "value", None)
selected_runtime = str(runtime_type or detection_type or "").strip().lower()
- if selected_runtime != "adk":
- raise ValueError("KSADK_ENABLE_TUNNEL currently requires the ADK runtime")
+ supported_types = {"adk", "langgraph"}
+ if selected_runtime not in supported_types or (
+ detection_type and detection_type not in supported_types
+ ):
+ raise ValueError(
+ "KSADK_ENABLE_TUNNEL currently supports only ADK and custom LangGraph "
+ "StateGraph runtimes"
+ )
agent_name = str(getattr(detection, "name", "") or "").strip()
if not agent_name:
diff --git a/ksadk/tunnel/langgraph.py b/ksadk/tunnel/langgraph.py
new file mode 100644
index 000000000..cbb3f218b
--- /dev/null
+++ b/ksadk/tunnel/langgraph.py
@@ -0,0 +1,183 @@
+"""Explicit LangChain tools backed by the current application's Tunnel registry."""
+
+from __future__ import annotations
+
+import hashlib
+import logging
+import re
+from contextlib import contextmanager
+from contextvars import ContextVar
+from dataclasses import dataclass
+from typing import TYPE_CHECKING, Any, Iterator, Sequence
+from urllib.parse import quote
+
+from ksadk.mcp_runtime import MCPServerConfig, build_langchain_connection
+from ksadk.tunnel.config import TunnelConfig, default_tunnel_self_url, tunnel_enabled
+from ksadk.tunnel.registry import TunnelRegistry
+
+if TYPE_CHECKING:
+ from langchain_core.tools import BaseTool
+
+logger = logging.getLogger(__name__)
+
+
+@dataclass(frozen=True)
+class _Binding:
+ agent_name: str
+ registry: TunnelRegistry
+
+
+_binding: ContextVar[_Binding | None] = ContextVar("ksadk_langgraph_tunnel", default=None)
+
+
+@contextmanager
+def bind_langgraph_tunnel(config: TunnelConfig, registry: TunnelRegistry) -> Iterator[None]:
+ """Bind trusted process-only dependencies for one complete graph execution."""
+ token = _binding.set(_Binding(config.agent_name, registry))
+ try:
+ yield
+ finally:
+ _binding.reset(token)
+
+
+@contextmanager
+def langgraph_tunnel_execution(runner: Any) -> Iterator[None]:
+ """Bind the current runner's app-owned dependencies for one native operation."""
+ config = getattr(runner, "_tunnel_config", None)
+ if config is None:
+ yield
+ return
+ registry = getattr(runner, "_tunnel_registry", None)
+ if registry is None:
+ raise RuntimeError("LangGraph Tunnel requires an app-owned registry")
+ with bind_langgraph_tunnel(config, registry):
+ yield
+
+
+def _load_mcp_tools():
+ try:
+ from langchain_mcp_adapters.tools import load_mcp_tools
+ except ImportError as exc:
+ raise ImportError(
+ "LangGraph Tunnel requires langchain-mcp-adapters>=0.3.2; "
+ "install the documented KsADK LangGraph dependencies"
+ ) from exc
+ return load_mcp_tools
+
+
+def _model_name(value: str) -> str:
+ """Keep ordinary names legible and bound unusual names for model APIs."""
+ if re.fullmatch(r"[a-zA-Z0-9_-]{1,24}", value) and "__" not in value:
+ return value
+ slug = re.sub(r"[^a-zA-Z0-9-]", "_", value)[:12].strip("_") or "tool"
+ return slug + "_" + hashlib.sha256(value.encode()).hexdigest()[:10]
+
+
+def _tool_name(tool: Any) -> str:
+ return str(getattr(tool, "name", None) or getattr(tool, "__name__", ""))
+
+
+def _append_unique(tools: list[Any], seen: set[str], tool: Any) -> None:
+ name = _tool_name(tool)
+ if not name:
+ raise ValueError("LangGraph Tunnel tools must have non-empty names")
+ if name in seen:
+ raise ValueError(f"Duplicate LangGraph tool name after Tunnel merging: {name!r}")
+ seen.add(name)
+ tools.append(tool)
+
+
+def _namespaced_tool(tool: BaseTool, server_name: str) -> BaseTool:
+ name = f"{_model_name(server_name)}__{_model_name(tool.name)}"
+ if tool.name == name:
+ return tool
+ return tool.model_copy(update={"name": name})
+
+
+class LangGraphTunnelTools:
+ """Resolve current Tunnel routes into LangChain tools without mutating a graph."""
+
+ def __init__(
+ self,
+ agent_name: str,
+ registry: TunnelRegistry | None = None,
+ self_url: str | None = None,
+ ) -> None:
+ if not isinstance(agent_name, str) or not agent_name.strip():
+ raise ValueError("LangGraphTunnelTools requires a non-empty agent_name")
+ self.agent_name = agent_name.strip()
+ self._registry = registry
+ self._self_url = self_url.rstrip("/") if self_url else None
+
+ def _resolve(self) -> tuple[TunnelRegistry, str] | None:
+ binding = _binding.get()
+ if binding is not None and binding.agent_name != self.agent_name:
+ raise ValueError(
+ f"LangGraph Tunnel Agent mismatch: helper={self.agent_name!r}, "
+ f"runtime={binding.agent_name!r}"
+ )
+ if self._registry is not None:
+ if binding is not None and binding.registry is not self._registry:
+ raise ValueError("Manual and app-owned Tunnel registries must not be mixed")
+ self_url = self._self_url or self._registry.self_url
+ return self._registry, self_url or default_tunnel_self_url()
+ if binding is None:
+ if tunnel_enabled():
+ raise RuntimeError(
+ "LangGraph Tunnel requires an active KsADK runtime execution context"
+ )
+ return None
+ self_url = self._self_url or binding.registry.self_url
+ return binding.registry, self_url or default_tunnel_self_url()
+
+ async def get_tools(self, *, tools: Sequence[BaseTool] = ()) -> list[BaseTool]:
+ """Return existing tools plus the currently discoverable Tunnel tools."""
+ merged: list[BaseTool] = []
+ seen: set[str] = set()
+ for tool in tools:
+ _append_unique(merged, seen, tool)
+
+ resolved = self._resolve()
+ if resolved is None:
+ return merged
+ registry, self_url = resolved
+ routes = registry.list_server_routes(self.agent_name)
+ if not routes:
+ return merged
+
+ load_mcp_tools = _load_mcp_tools()
+ for _owner_id, server in routes:
+ proxy_url = (
+ f"{self_url.rstrip('/')}/tunnel/mcp/"
+ f"{quote(self.agent_name, safe='')}/{quote(server.name, safe='')}"
+ )
+ try:
+ config = MCPServerConfig(
+ name=server.name,
+ url=proxy_url,
+ api_key=registry.proxy_token,
+ tool_filter=tuple(server.tool_filter or ()),
+ )
+ discovered = await load_mcp_tools(
+ None,
+ connection=build_langchain_connection(config),
+ server_name=server.name,
+ )
+ except Exception as exc:
+ logger.warning(
+ "Could not load LangGraph tunnel tools for agent %s server %s (%s)",
+ self.agent_name,
+ server.name,
+ type(exc).__name__,
+ )
+ continue
+
+ allowed = set(server.tool_filter or ())
+ for tool in discovered:
+ if allowed and tool.name not in allowed:
+ continue
+ _append_unique(merged, seen, _namespaced_tool(tool, server.name))
+ return merged
+
+
+__all__ = ["LangGraphTunnelTools"]
diff --git a/pyproject.toml b/pyproject.toml
index 6936b31a3..ba9dd6495 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -121,6 +121,7 @@ langgraph = [
"psycopg-pool>=3.2,<4.0",
"langchain>=1.3.14,<2.0.0",
"langchain-openai>=1.4.0,<2.0.0",
+ "langchain-mcp-adapters>=0.3.2",
"protobuf>=6.32.1",
]
# DeepAgents 支持(基于 LangGraph)
diff --git a/scripts/prepare_ksadk_python_export.py b/scripts/prepare_ksadk_python_export.py
index 47f78ac7c..2f64a4a8a 100644
--- a/scripts/prepare_ksadk_python_export.py
+++ b/scripts/prepare_ksadk_python_export.py
@@ -383,6 +383,7 @@
"tests/tunnel/__init__.py",
"tests/tunnel/conftest.py",
"tests/tunnel/test_connector.py",
+ "tests/tunnel/test_langgraph.py",
"tests/tunnel/test_registry.py",
"tests/tunnel/test_server.py",
"tests/tunnel/test_toolset.py",
diff --git a/tests/cli/test_cmd_config_tunnel.py b/tests/cli/test_cmd_config_tunnel.py
index 168030444..8581cc379 100644
--- a/tests/cli/test_cmd_config_tunnel.py
+++ b/tests/cli/test_cmd_config_tunnel.py
@@ -170,7 +170,7 @@ def test_adk_wizard_disable_preserves_token_and_self_url(monkeypatch, tmp_path):
def test_non_adk_wizard_does_not_touch_tunnel_env(monkeypatch, tmp_path):
(tmp_path / "agentengine.yaml").write_text(
- "name: fixture_agent\nframework: langgraph\n",
+ "name: fixture_agent\nframework: langchain\n",
encoding="utf-8",
)
(tmp_path / ".env").write_text(
@@ -180,7 +180,7 @@ def test_non_adk_wizard_does_not_touch_tunnel_env(monkeypatch, tmp_path):
questions, _ = _install_wizard_answers(
monkeypatch,
tmp_path,
- framework="langgraph",
+ framework="langchain",
)
_run_wizard(tmp_path)
@@ -191,6 +191,24 @@ def test_non_adk_wizard_does_not_touch_tunnel_env(monkeypatch, tmp_path):
assert not any("Tunnel" in message for _, message in questions)
+def test_langgraph_wizard_enables_tunnel_and_requires_explicit_helper(monkeypatch, tmp_path):
+ questions, _ = _install_wizard_answers(
+ monkeypatch,
+ tmp_path,
+ framework="langgraph",
+ )
+ messages: list[str] = []
+ monkeypatch.setattr(cmd_config, "print_info", messages.append)
+
+ _run_wizard(tmp_path)
+
+ env = _project_env(tmp_path)
+ assert env["KSADK_ENABLE_TUNNEL"] == "1"
+ assert env["KSADK_TUNNEL_TOKEN"] == _FAKE_TUNNEL_TOKEN
+ assert any(kind == "confirm" and "Tunnel" in message for kind, message in questions)
+ assert any("LangGraphTunnelTools" in message for message in messages)
+
+
def test_adk_wizard_requires_non_empty_tunnel_token(monkeypatch, tmp_path):
_install_wizard_answers(monkeypatch, tmp_path, tunnel_token=" ")
diff --git a/tests/test_mcp_runtime.py b/tests/test_mcp_runtime.py
index d0b81e046..9806acf2e 100644
--- a/tests/test_mcp_runtime.py
+++ b/tests/test_mcp_runtime.py
@@ -147,6 +147,27 @@ def test_build_connection_params_disables_proxy_for_loopback_urls(monkeypatch):
anyio.run(client.aclose)
+@pytest.mark.asyncio
+async def test_build_langchain_connection_preserves_loopback_auth_and_proxy_boundary():
+ from ksadk.mcp_runtime import MCPServerConfig, build_langchain_connection
+
+ descriptor = MCPServerConfig(
+ name="local",
+ url="http://127.0.0.1:8899/mcp",
+ api_key="fixture-proxy-token",
+ )
+
+ connection = build_langchain_connection(descriptor)
+ assert connection["transport"] == "streamable_http"
+ assert connection["url"] == descriptor.url
+ assert connection["headers"] == {"Authorization": "Bearer fixture-proxy-token"}
+ client = connection["httpx_client_factory"]()
+ try:
+ assert client._trust_env is False
+ finally:
+ await client.aclose()
+
+
@pytest.mark.asyncio
async def test_build_mcp_toolset_roundtrip_lists_and_calls_remote_tools(weather_mcp_server):
from ksadk.mcp_runtime import MCPServerConfig, build_mcp_toolset
diff --git a/tests/test_prepare_ksadk_python_export.py b/tests/test_prepare_ksadk_python_export.py
index 1f67d8290..a2051b14d 100644
--- a/tests/test_prepare_ksadk_python_export.py
+++ b/tests/test_prepare_ksadk_python_export.py
@@ -83,6 +83,7 @@ def test_export_plan_includes_public_preflight_contract_files():
"tests/studio/test_style_system.py",
"tests/test_config_env_registry.py",
"tests/cli/test_cmd_config_tunnel.py",
+ "tests/tunnel/test_langgraph.py",
"tests/runners/test_adapter_contract.py",
"ksadk/studio/react-ui/package.json",
"ksadk/studio/react-ui/package-lock.json",
diff --git a/tests/test_runtime_common_packaging.py b/tests/test_runtime_common_packaging.py
index bbcee03cf..e197af28a 100644
--- a/tests/test_runtime_common_packaging.py
+++ b/tests/test_runtime_common_packaging.py
@@ -369,6 +369,7 @@ def test_pyproject_declares_validated_framework_dependency_windows():
assert "langgraph==1.2.15" in dependencies
for extra in ("langgraph", "deepagents"):
assert "langgraph==1.2.15" in optional_dependencies[extra]
+ assert "langchain-mcp-adapters>=0.3.2" in optional_dependencies["langgraph"]
assert (
"deepagents>=0.6.2,<1.0.0; python_version >= '3.11'" in optional_dependencies["deepagents"]
)
diff --git a/tests/test_tunnel_e2e.py b/tests/test_tunnel_e2e.py
index 09de65081..3b834be3c 100644
--- a/tests/test_tunnel_e2e.py
+++ b/tests/test_tunnel_e2e.py
@@ -6,8 +6,14 @@
import httpx
import pytest
from fastapi import FastAPI
+from langchain_core.language_models.fake_chat_models import FakeMessagesListChatModel
+from langchain_core.messages import AIMessage
+from langgraph.graph import START, MessagesState, StateGraph
+from langgraph.prebuilt import ToolNode, tools_condition
+from pydantic import PrivateAttr
from ksadk.tunnel import (
+ LangGraphTunnelTools,
LocalServer,
TunnelConnector,
TunnelRegistry,
@@ -20,6 +26,14 @@
_FAKE_LOCAL_MCP_TOKEN = "fixture-local-mcp-token"
+class _ScriptedModel(FakeMessagesListChatModel):
+ _bound_tools: list = PrivateAttr(default_factory=list)
+
+ def bind_tools(self, tools, **kwargs):
+ self._bound_tools.append(tools)
+ return self
+
+
async def _wait_for_server_count(
registry: TunnelRegistry,
expected: int,
@@ -111,3 +125,150 @@ async def test_local_mcp_tunnel_list_call_and_disconnect():
with suppress(asyncio.CancelledError):
await connector_task
await toolset.close()
+
+
+@pytest.mark.asyncio
+@pytest.mark.local_process_heavy
+@pytest.mark.parametrize("execution_mode", ["invoke", "legacy", "canonical"])
+async def test_local_mcp_tunnel_langgraph_toolnode_list_call_and_disconnect(
+ monkeypatch, tmp_path, execution_mode
+):
+ registry = TunnelRegistry()
+ app = FastAPI()
+ mount_tunnel(
+ app,
+ token=_FAKE_TUNNEL_TOKEN,
+ allowed_agents=["demo_agent"],
+ registry=registry,
+ )
+
+ with (
+ run_fixture_mcp_server(
+ label="tunnel_langgraph_fixture",
+ required_token=_FAKE_LOCAL_MCP_TOKEN,
+ ) as local_mcp,
+ run_http_app(app) as cloud_url,
+ ):
+ monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
+ monkeypatch.setenv("KSADK_TUNNEL_TOKEN", _FAKE_TUNNEL_TOKEN)
+ registry.self_url = cloud_url
+ connector = TunnelConnector(
+ cloud_url=cloud_url,
+ agent="demo_agent",
+ token=_FAKE_TUNNEL_TOKEN,
+ servers=[
+ LocalServer(
+ name="fixture",
+ address=local_mcp.url,
+ tool_filter=["lookup"],
+ headers={"Authorization": f"Bearer {_FAKE_LOCAL_MCP_TOKEN}"},
+ )
+ ],
+ )
+ connector_task = asyncio.create_task(connector.start())
+ provider = LangGraphTunnelTools("demo_agent")
+ try:
+ await _wait_for_server_count(registry, 1, connector_task)
+
+ model = _ScriptedModel(
+ responses=[
+ AIMessage(
+ content="",
+ tool_calls=[
+ {
+ "name": "fixture__lookup",
+ "args": {"value": "hello"},
+ "id": "langgraph-call-1",
+ "type": "tool_call",
+ }
+ ],
+ ),
+ AIMessage(content="done"),
+ ]
+ )
+
+ async def current_tools():
+ return await provider.get_tools()
+
+ async def model_node(state, config):
+ reply = await model.bind_tools(await current_tools()).ainvoke(
+ state["messages"], config=config
+ )
+ return {"messages": [reply]}
+
+ async def tools_node(state, config):
+ return await ToolNode(await current_tools()).ainvoke(state, config=config)
+
+ workflow = StateGraph(MessagesState)
+ workflow.add_node("model", model_node)
+ workflow.add_node("tools", tools_node)
+ workflow.add_edge(START, "model")
+ workflow.add_conditional_edges("model", tools_condition)
+ workflow.add_edge("tools", "model")
+ graph = workflow.compile()
+
+ from types import SimpleNamespace
+
+ from ksadk.detection.detector import DetectionResult, FrameworkType
+ from ksadk.runners.langgraph_runner import LangGraphRunner
+ from ksadk.runtime.factory import build_default_runtime_registry
+ from ksadk.runtime.launch import RuntimeLaunchContext, RuntimeServices
+
+ detection = DetectionResult(
+ type=FrameworkType.LANGGRAPH,
+ name="demo_agent",
+ entry_point="agent.py",
+ package_path=str(tmp_path),
+ )
+ runner = LangGraphRunner(detection, str(tmp_path))
+ context = RuntimeLaunchContext(
+ runtime_type="langgraph",
+ project_dir=tmp_path,
+ detection=detection,
+ services=RuntimeServices(
+ tunnel_registry=registry,
+ runner_factory=lambda *_: runner,
+ ),
+ )
+ build_default_runtime_registry().create(context)
+ monkeypatch.setattr(
+ "ksadk.runners.langgraph_runner.load_agent_module",
+ lambda *args, **kwargs: (graph, SimpleNamespace()),
+ )
+ runner.load_agent()
+ request = {
+ "input": "lookup hello",
+ "session_id": "langgraph-e2e",
+ "run_id": "langgraph-e2e-run",
+ }
+ if execution_mode == "invoke":
+ result = await runner.invoke({**request, "_ksadk_force_graph_invoke": True})
+ assert result["output"] == "done"
+ elif execution_mode == "legacy":
+ chunks = [chunk async for chunk in runner.stream(request)]
+ assert chunks
+ else:
+ events = [event async for event in runner.stream_canonical_events(request)]
+ assert events
+
+ assert [tool.name for tool in model._bound_tools[0]] == ["fixture__lookup"]
+ assert len(model._bound_tools) == 2
+ assert ("lookup", "hello") in local_mcp.log.calls
+ assert local_mcp.log.authorization
+ assert set(local_mcp.log.authorization) == {f"Bearer {_FAKE_LOCAL_MCP_TOKEN}"}
+ assert registry.proxy_token not in str(local_mcp.log.authorization)
+ assert _FAKE_TUNNEL_TOKEN not in str(local_mcp.log.authorization)
+
+ connector_task.cancel()
+ with suppress(asyncio.CancelledError):
+ await connector_task
+ await _wait_for_server_count(registry, 0, connector_task)
+ offline_provider = LangGraphTunnelTools(
+ "demo_agent", registry=registry, self_url=cloud_url
+ )
+ assert await offline_provider.get_tools() == []
+ finally:
+ connector_task.cancel()
+ with suppress(asyncio.CancelledError):
+ await connector_task
+ await registry.close()
diff --git a/tests/test_tunnel_runtime.py b/tests/test_tunnel_runtime.py
index cf6382a22..8efac17f6 100644
--- a/tests/test_tunnel_runtime.py
+++ b/tests/test_tunnel_runtime.py
@@ -61,19 +61,35 @@ def test_tunnel_enabled_requires_token(monkeypatch, tmp_path):
)
-def test_tunnel_enabled_rejects_non_adk_runtime(monkeypatch, tmp_path):
+@pytest.mark.parametrize("runtime_type", ["codex", "langchain", "deepagents"])
+def test_tunnel_enabled_rejects_unsupported_runtime(monkeypatch, tmp_path, runtime_type):
_clear_tunnel_env(monkeypatch)
monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
monkeypatch.setenv("KSADK_TUNNEL_TOKEN", "fake-tunnel-token")
- with pytest.raises(ValueError, match="requires the ADK runtime"):
+ with pytest.raises(ValueError, match="only ADK and custom LangGraph"):
RuntimeLaunchContext(
- runtime_type="langgraph",
+ runtime_type=runtime_type,
project_dir=tmp_path,
- detection=_detection("langgraph"),
+ detection=_detection(runtime_type),
)
+def test_tunnel_enabled_accepts_langgraph_runtime(monkeypatch, tmp_path):
+ _clear_tunnel_env(monkeypatch)
+ monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
+ monkeypatch.setenv("KSADK_TUNNEL_TOKEN", "fake-tunnel-token")
+
+ context = RuntimeLaunchContext(
+ runtime_type="langgraph",
+ project_dir=tmp_path,
+ detection=_detection("langgraph"),
+ )
+
+ assert context.services.tunnel_registry is not None
+ assert context.services.tunnel_registry.self_url == "http://127.0.0.1:8000"
+
+
def test_tunnel_registry_is_shared_and_start_port_refines_same_instance(monkeypatch, tmp_path):
_clear_tunnel_env(monkeypatch)
monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "true")
@@ -263,7 +279,47 @@ async def test_early_adapter_shares_registry_with_later_app_port(monkeypatch, tm
await registry.close()
-def test_runtime_web_app_uses_actual_cli_port(monkeypatch, tmp_path):
+@pytest.mark.asyncio
+async def test_early_langgraph_adapter_shares_registry_and_latest_self_url(monkeypatch, tmp_path):
+ _clear_tunnel_env(monkeypatch)
+ monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
+ monkeypatch.setenv("KSADK_TUNNEL_TOKEN", "fake-tunnel-token")
+
+ from ksadk.runners._langgraph_fresh_turn import fresh_user_checkpoint
+ from ksadk.runners.langgraph_runner import LangGraphRunner
+ from ksadk.runtime.factory import build_default_runtime_registry
+ from ksadk.runtime.launch import RuntimeServices
+ from ksadk.tunnel.langgraph import LangGraphTunnelTools
+
+ detection = _detection("langgraph")
+ runner = LangGraphRunner(detection, str(tmp_path))
+ context = RuntimeLaunchContext(
+ runtime_type="langgraph",
+ project_dir=tmp_path,
+ detection=detection,
+ services=RuntimeServices(runner_factory=lambda *_: runner),
+ )
+ build_default_runtime_registry().create(context)
+ registry = context.services.tunnel_registry
+ assert runner._tunnel_registry is registry
+
+ prepare_tunnel_context(context, self_url="http://127.0.0.1:18080")
+
+ class BoundRunner:
+ _tunnel_config = runner._tunnel_config
+ _tunnel_registry = runner._tunnel_registry
+
+ @fresh_user_checkpoint
+ async def invoke(self, input_data):
+ return LangGraphTunnelTools("demo_agent")._resolve()
+
+ _, self_url = await BoundRunner().invoke({})
+ assert self_url == "http://127.0.0.1:18080"
+ await registry.close()
+
+
+@pytest.mark.parametrize("framework_type", ["adk", "langgraph"])
+def test_runtime_web_app_uses_actual_cli_port(monkeypatch, tmp_path, framework_type):
_clear_tunnel_env(monkeypatch)
monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
monkeypatch.setenv("KSADK_TUNNEL_TOKEN", "fake-tunnel-token")
@@ -274,7 +330,7 @@ def test_runtime_web_app_uses_actual_cli_port(monkeypatch, tmp_path):
from ksadk.detection.detector import DetectionResult, FrameworkType
detection = DetectionResult(
- type=FrameworkType.ADK,
+ type=FrameworkType(framework_type),
name="demo_agent",
entry_point="agent.py",
package_path=str(tmp_path),
@@ -286,7 +342,8 @@ def test_runtime_web_app_uses_actual_cli_port(monkeypatch, tmp_path):
assert state.launch_context.services.tunnel_registry.self_url == state.tunnel.self_url
-def test_tunnel_routes_precede_hosted_ui_catchall(monkeypatch, tmp_path):
+@pytest.mark.parametrize("runtime_type", ["adk", "langgraph"])
+def test_tunnel_routes_precede_hosted_ui_catchall(monkeypatch, tmp_path, runtime_type):
_clear_tunnel_env(monkeypatch)
monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
monkeypatch.setenv("KSADK_TUNNEL_TOKEN", "fake-tunnel-token")
@@ -295,9 +352,9 @@ def test_tunnel_routes_precede_hosted_ui_catchall(monkeypatch, tmp_path):
from ksadk.server.factory import create_runtime_app
context = RuntimeLaunchContext(
- runtime_type="adk",
+ runtime_type=runtime_type,
project_dir=tmp_path,
- detection=_detection(),
+ detection=_detection(runtime_type),
)
app = create_runtime_app(
RuntimeAppConfig(
@@ -338,9 +395,9 @@ def test_code_builder_tunnel_enables_mcp_runtime_requirements(monkeypatch, tmp_p
builder = CodeBuilder(tmp_path)
assert builder._mcp_runtime_enabled() is True
- assert any(
- requirement.startswith("mcp") for requirement in builder._bundled_runtime_requirements()
- )
+ requirements = builder._bundled_runtime_requirements()
+ assert any(requirement.startswith("mcp") for requirement in requirements)
+ assert "langchain-mcp-adapters>=0.3.2" in requirements
def test_code_builder_detects_embedded_tunnel_import(monkeypatch, tmp_path):
@@ -364,3 +421,15 @@ def test_deployment_manager_adds_tunnel_mcp_requirement(monkeypatch, tmp_path):
requirements = K8sDeployer()._generate_requirements(_detection())
assert "mcp>=1.26.0,<2.0.0" in requirements
+ assert "langchain-mcp-adapters" not in requirements
+
+
+def test_deployment_manager_adds_langgraph_tunnel_requirements(monkeypatch, tmp_path):
+ _clear_tunnel_env(monkeypatch)
+ monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
+
+ from ksadk.deployment.manager import K8sDeployer
+
+ requirements = K8sDeployer()._generate_requirements(_detection("langgraph"))
+ assert "mcp>=1.26.0,<2.0.0" in requirements
+ assert "langchain-mcp-adapters>=0.3.2" in requirements
diff --git a/tests/tunnel/test_connector.py b/tests/tunnel/test_connector.py
index 469d14555..ecbe81952 100644
--- a/tests/tunnel/test_connector.py
+++ b/tests/tunnel/test_connector.py
@@ -18,15 +18,19 @@ def test_public_package_import_is_lazy() -> None:
import ksadk.tunnel as tunnel
assert set(tunnel.__all__) == {
'LocalServer', 'TunnelConnector', 'ServerDescriptor', 'TunnelRegistry',
- 'TunnelToolset', 'mount_tunnel', 'get_registry'
+ 'TunnelToolset', 'LangGraphTunnelTools', 'mount_tunnel', 'get_registry'
}
assert 'ksadk.tunnel.connector' not in sys.modules
assert 'ksadk.tunnel.toolset' not in sys.modules
+assert 'ksadk.tunnel.langgraph' not in sys.modules
assert not any(name == 'google.adk' or name.startswith('google.adk.') for name in sys.modules)
import ksadk.tunnel.config
assert not any(name == 'google.adk' or name.startswith('google.adk.') for name in sys.modules)
from ksadk.tunnel import TunnelRegistry
assert TunnelRegistry().self_url is None
+from ksadk.tunnel import LangGraphTunnelTools
+assert LangGraphTunnelTools.__name__ == 'LangGraphTunnelTools'
+assert 'langchain_mcp_adapters' not in sys.modules
assert not any(name == 'google.adk' or name.startswith('google.adk.') for name in sys.modules)
"""
result = subprocess.run(
diff --git a/tests/tunnel/test_langgraph.py b/tests/tunnel/test_langgraph.py
new file mode 100644
index 000000000..9899453d5
--- /dev/null
+++ b/tests/tunnel/test_langgraph.py
@@ -0,0 +1,285 @@
+from __future__ import annotations
+
+import asyncio
+import logging
+from typing import Any
+
+import pytest
+from langchain_core.tools import tool
+
+from ksadk.runners._langgraph_fresh_turn import _FRESH_READ, fresh_user_checkpoint
+from ksadk.tunnel.config import TunnelConfig
+from ksadk.tunnel.langgraph import LangGraphTunnelTools, _binding, bind_langgraph_tunnel
+from ksadk.tunnel.registry import ServerDescriptor, TunnelRegistry
+
+from .conftest import add_connection
+
+
+def _tool(name: str):
+ @tool(name)
+ def fake_tool(value: str) -> str:
+ """Return the tool name and input."""
+ return f"{name}:{value}"
+
+ return fake_tool
+
+
+def _config(registry: TunnelRegistry, agent: str = "agent") -> TunnelConfig:
+ return TunnelConfig(
+ agent_name=agent,
+ token="fixture-tunnel-token",
+ self_url=registry.self_url or "http://127.0.0.1:8000",
+ )
+
+
+def _install_loader(monkeypatch: pytest.MonkeyPatch, discovered: dict[str, list[Any]]):
+ calls = []
+
+ async def load(session, *, connection, server_name, **kwargs):
+ assert session is None
+ calls.append({"connection": connection, "server_name": server_name, **kwargs})
+ return discovered.get(server_name, [])
+
+ monkeypatch.setattr("ksadk.tunnel.langgraph._load_mcp_tools", lambda: load)
+ return calls
+
+
+@pytest.mark.asyncio
+async def test_dynamic_tools_filter_namespace_and_disconnect(monkeypatch):
+ registry = TunnelRegistry()
+ registry.self_url = "http://127.0.0.1:9000/"
+ calls = _install_loader(
+ monkeypatch,
+ {"docs": [_tool("search"), _tool("admin")]},
+ )
+ provider = LangGraphTunnelTools("agent", registry)
+ business = _tool("local")
+
+ assert await provider.get_tools(tools=[business]) == [business]
+ assert calls == []
+
+ connection, _ = add_connection(
+ registry,
+ descriptors=[ServerDescriptor(name="docs", tool_filter=["search"])],
+ )
+ tools = await provider.get_tools(tools=[business])
+
+ assert [item.name for item in tools] == ["local", "docs__search"]
+ assert calls[0]["server_name"] == "docs"
+ connection_config = calls[0]["connection"]
+ assert connection_config["transport"] == "streamable_http"
+ assert connection_config["url"] == "http://127.0.0.1:9000/tunnel/mcp/agent/docs"
+ assert connection_config["headers"] == {"Authorization": f"Bearer {registry.proxy_token}"}
+ assert callable(connection_config["httpx_client_factory"])
+
+ registry.remove_connection(connection.connector_id, connection)
+ add_connection(
+ registry,
+ connector_id="replacement",
+ descriptors=[ServerDescriptor(name="docs", tool_filter=["admin"])],
+ )
+ assert [item.name for item in await provider.get_tools(tools=[business])] == [
+ "local",
+ "docs__admin",
+ ]
+
+ registry.remove_connection("replacement")
+ assert await provider.get_tools(tools=[business]) == [business]
+
+
+@pytest.mark.asyncio
+async def test_same_mcp_name_on_multiple_servers_uses_server_namespace(monkeypatch):
+ registry = TunnelRegistry()
+ provider = LangGraphTunnelTools("agent", registry)
+ add_connection(
+ registry,
+ descriptors=[ServerDescriptor(name="docs"), ServerDescriptor(name="inventory")],
+ )
+ _install_loader(
+ monkeypatch,
+ {"docs": [_tool("search")], "inventory": [_tool("search")]},
+ )
+
+ assert [item.name for item in await provider.get_tools()] == [
+ "docs__search",
+ "inventory__search",
+ ]
+
+
+@pytest.mark.asyncio
+async def test_single_server_failure_does_not_hide_other_servers(monkeypatch, caplog):
+ registry = TunnelRegistry()
+ provider = LangGraphTunnelTools("agent", registry)
+ add_connection(
+ registry,
+ descriptors=[ServerDescriptor(name="broken"), ServerDescriptor(name="docs")],
+ )
+
+ async def load(session, *, connection, server_name, **kwargs):
+ if server_name == "broken":
+ raise RuntimeError("fixture discovery failure")
+ return [_tool("search")]
+
+ monkeypatch.setattr("ksadk.tunnel.langgraph._load_mcp_tools", lambda: load)
+ with caplog.at_level(logging.WARNING):
+ tools = await provider.get_tools()
+
+ assert [item.name for item in tools] == ["docs__search"]
+ assert "broken" in caplog.text
+ assert "RuntimeError" in caplog.text
+ assert registry.proxy_token not in caplog.text
+
+
+@pytest.mark.asyncio
+async def test_final_tool_name_conflict_fails_closed(monkeypatch):
+ registry = TunnelRegistry()
+ provider = LangGraphTunnelTools("agent", registry)
+ add_connection(registry)
+ _install_loader(monkeypatch, {"docs": [_tool("search")]})
+
+ with pytest.raises(ValueError, match="Duplicate LangGraph tool name"):
+ await provider.get_tools(tools=[_tool("docs__search")])
+
+
+@pytest.mark.asyncio
+async def test_disabled_tunnel_preserves_business_tools_without_loader(monkeypatch):
+ monkeypatch.delenv("KSADK_ENABLE_TUNNEL", raising=False)
+ provider = LangGraphTunnelTools("agent")
+ business = _tool("local")
+
+ def fail_loader():
+ raise AssertionError("disabled Tunnel must not load the MCP adapter")
+
+ monkeypatch.setattr("ksadk.tunnel.langgraph._load_mcp_tools", fail_loader)
+ assert await provider.get_tools(tools=[business]) == [business]
+
+
+@pytest.mark.asyncio
+async def test_enabled_tunnel_requires_runtime_binding(monkeypatch):
+ monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
+ provider = LangGraphTunnelTools("agent")
+
+ with pytest.raises(RuntimeError, match="runtime execution context"):
+ await provider.get_tools()
+
+
+@pytest.mark.asyncio
+async def test_runtime_binding_supplies_registry_and_self_url(monkeypatch):
+ monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
+ registry = TunnelRegistry()
+ registry.self_url = "http://127.0.0.1:9100"
+ add_connection(registry)
+ calls = _install_loader(monkeypatch, {"docs": [_tool("search")]})
+ provider = LangGraphTunnelTools("agent")
+
+ with bind_langgraph_tunnel(_config(registry), registry):
+ assert [item.name for item in await provider.get_tools()] == ["docs__search"]
+
+ assert calls[0]["connection"]["url"] == "http://127.0.0.1:9100/tunnel/mcp/agent/docs"
+
+
+@pytest.mark.asyncio
+async def test_runtime_binding_rejects_agent_and_registry_mismatch(monkeypatch):
+ monkeypatch.setenv("KSADK_ENABLE_TUNNEL", "1")
+ registry = TunnelRegistry()
+ other = TunnelRegistry()
+
+ with bind_langgraph_tunnel(_config(registry), registry):
+ with pytest.raises(ValueError, match="Agent mismatch"):
+ await LangGraphTunnelTools("other-agent").get_tools()
+ with pytest.raises(ValueError, match="must not be mixed"):
+ await LangGraphTunnelTools("agent", other).get_tools()
+
+
+@pytest.mark.asyncio
+async def test_unusual_public_names_have_stable_bounded_aliases(monkeypatch):
+ registry = TunnelRegistry()
+ provider = LangGraphTunnelTools("agent", registry)
+ add_connection(registry, descriptors=[ServerDescriptor(name="docs space")])
+ _install_loader(monkeypatch, {"docs space": [_tool("search/docs")]})
+
+ first = await provider.get_tools()
+ second = await provider.get_tools()
+
+ assert first[0].name == second[0].name
+ assert first[0].name.startswith("docs_space_")
+ assert "__" in first[0].name
+ assert len(first[0].name) <= 50
+ assert first[0].name != "search/docs"
+
+
+def test_agent_name_is_required():
+ with pytest.raises(ValueError, match="non-empty agent_name"):
+ LangGraphTunnelTools(" ")
+
+
+class _BoundRunner:
+ def __init__(self, registry: TunnelRegistry) -> None:
+ self._tunnel_config = _config(registry)
+ self._tunnel_registry = registry
+
+ @fresh_user_checkpoint
+ async def invoke(self, input_data):
+ return _binding.get()
+
+ @fresh_user_checkpoint
+ async def stream(self, input_data):
+ yield _binding.get()
+ yield _binding.get()
+
+
+@pytest.mark.asyncio
+async def test_execution_binding_covers_invoke_and_stream_without_yield_leak():
+ registry = TunnelRegistry()
+ runner = _BoundRunner(registry)
+
+ assert (await runner.invoke({})).registry is registry
+ assert _binding.get() is None
+ async for current in runner.stream({}):
+ assert current.registry is registry
+ assert _binding.get() is None
+ assert _binding.get() is None
+
+
+@pytest.mark.asyncio
+async def test_interleaved_app_streams_do_not_share_bindings():
+ first = _BoundRunner(TunnelRegistry()).stream({})
+ second = _BoundRunner(TunnelRegistry()).stream({})
+
+ first_binding = await anext(first)
+ assert _binding.get() is None
+ second_binding = await anext(second)
+ assert _binding.get() is None
+ assert first_binding.registry is not second_binding.registry
+
+ await first.aclose()
+ await second.aclose()
+ assert _binding.get() is None
+
+
+@pytest.mark.asyncio
+async def test_cancellation_restores_execution_and_fresh_checkpoint_contexts():
+ registry = TunnelRegistry()
+ runner = _BoundRunner(registry)
+ started = asyncio.Event()
+
+ @fresh_user_checkpoint
+ async def blocking_stream(self, input_data):
+ started.set()
+ await asyncio.Event().wait()
+ yield _binding.get()
+
+ runner.stream = blocking_stream.__get__(runner)
+
+ async def consume():
+ async for _ in runner.stream({"input": "blocking"}):
+ pass
+
+ task = asyncio.create_task(consume())
+ await started.wait()
+ task.cancel()
+ with pytest.raises(asyncio.CancelledError):
+ await task
+
+ assert _binding.get() is None
+ assert _FRESH_READ.get() is None
diff --git a/uv.lock b/uv.lock
index 54082d14a..5cd350041 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1933,6 +1933,7 @@ langchain = [
]
langgraph = [
{ name = "langchain" },
+ { name = "langchain-mcp-adapters" },
{ name = "langchain-openai" },
{ name = "langgraph" },
{ name = "langgraph-checkpoint-postgres" },
@@ -1986,6 +1987,7 @@ requires-dist = [
{ name = "langchain", marker = "extra == 'langgraph'", specifier = ">=1.3.14,<2.0.0" },
{ name = "langchain-core", marker = "extra == 'langchain'", specifier = ">=1.5.0,<2.0.0" },
{ name = "langchain-mcp-adapters", marker = "extra == 'langchain'", specifier = ">=0.3.2" },
+ { name = "langchain-mcp-adapters", marker = "extra == 'langgraph'", specifier = ">=0.3.2" },
{ name = "langchain-openai", marker = "extra == 'deepagents'", specifier = ">=1.4.0,<2.0.0" },
{ name = "langchain-openai", marker = "extra == 'langchain'", specifier = ">=1.4.0,<2.0.0" },
{ name = "langchain-openai", marker = "extra == 'langgraph'", specifier = ">=1.4.0,<2.0.0" },