agent에게 shell 접근 권한을 부여하는 것은 강력하지만 (샌드박스 환경 외부에서는 위험할 수 있습니다), LLM이 이를 사용하여 모든 shell 명령을 실행할 수 있습니다. 일반적인 사용 사례는 LLM이 로컬 파일 시스템과 상호작용할 수 있도록 하는 것입니다. 참고: Shell tool은 Windows OS에서 작동하지 않습니다.
pip install -qU langchain-community
from langchain_community.tools import ShellTool

shell_tool = ShellTool()
print(shell_tool.run({"commands": ["echo 'Hello World!'", "time"]}))
Hello World!

real 0m0.000s
user 0m0.000s
sys 0m0.000s
/Users/wfh/code/lc/lckg/langchain/tools/shell/tool.py:34: UserWarning: The shell tool has no safeguards by default. Use at your own risk.
  warnings.warn(

Agent와 함께 사용하기

모든 tool과 마찬가지로, 이러한 tool들은 더 복잡한 작업을 수행하기 위해 agent에게 제공될 수 있습니다. agent가 웹 페이지에서 일부 링크를 가져오도록 해봅시다.
from langchain.agents import create_agent


tools = [shell_tool]
agent = create_agent("openai:gpt-4.1-mini", tools)

input_message = {
    "role": "user",
    "content": (
        "Download the README here and identify the link for LangChain tutorials: "
        "https://raw.githubusercontent.com/langchain-ai/langchain/master/README.md"
    ),
}

for step in agent.stream(
    {"messages": [input_message]},
        stream_mode="values",
):
    step["messages"][-1].pretty_print()
================================ Human Message =================================

Download the README here and identify the link for LangChain tutorials: https://raw.githubusercontent.com/langchain-ai/langchain/master/README.md
================================== Ai Message ==================================
Tool Calls:
  terminal (call_mr86V0d6E9nQiJZT7Xw5fH0G)
 Call ID: call_mr86V0d6E9nQiJZT7Xw5fH0G
  Args:
    commands: ['curl -o README.md https://raw.githubusercontent.com/langchain-ai/langchain/master/README.md']
Executing command:
 ['curl -o README.md https://raw.githubusercontent.com/langchain-ai/langchain/master/README.md']
================================= Tool Message =================================
Name: terminal

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5169  100  5169    0     0   114k      0 --:--:-- --:--:-- --:--:--  114k
/langchain/libs/community/langchain_community/tools/shell/tool.py:33: UserWarning: The shell tool has no safeguards by default. Use at your own risk.
  warnings.warn(
================================== Ai Message ==================================
Tool Calls:
  terminal (call_LF8TGrgS84WvUvaazYnVfib8)
 Call ID: call_LF8TGrgS84WvUvaazYnVfib8
  Args:
    commands: ["grep -i 'tutorial' README.md"]
Executing command:
 ["grep -i 'tutorial' README.md"]
================================= Tool Message =================================
Name: terminal

- [Tutorials](https://python.langchain.com/docs/tutorials/): Simple walkthroughs with
/langchain/libs/community/langchain_community/tools/shell/tool.py:33: UserWarning: The shell tool has no safeguards by default. Use at your own risk.
  warnings.warn(
================================== Ai Message ==================================

The link for LangChain tutorials in the README is: https://python.langchain.com/docs/tutorials/

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I