shell_exec
Execute whitelisted shell commands with literal arguments and path validation. Kernel-enforced confinement restricts file access to a configured root, enabling targeted reads and reducing context usage.
Instructions
Execute a whitelisted shell command (grep/cat/ls/find/sed/awk/…). No shell interpreter — args are passed literally. Path args validated against root.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | Yes | ||
| command | Yes |
Implementation Reference
- The handler function 'chisel_shell_exec' which delegates to the underlying chisel tool by calling _chisel_call with tool name 'shell_exec'.
async def chisel_shell_exec(command: str, args: list[str]) -> str: return await _chisel_call("shell_exec", command=command, args=args) - Helper function '_chisel_call' that opens a streaming HTTP MCP session to chisel and calls the specified tool; used by shell_exec handler.
async def _chisel_call(tool: str, **kwargs) -> str: """Open a session to chisel, call one tool, return the text result.""" async with streamablehttp_client(CHISEL_URL, headers=_HEADERS) as (read, write, _): async with ClientSession(read, write) as session: await session.initialize() result = await session.call_tool(tool, kwargs) return result.content[0].text - The 'run_lint' MCP tool handler that uses 'chisel_shell_exec' to run 'rg' (ripgrep) for counting TODO markers.
@mcp.tool() async def run_lint(path: str) -> str: """ Run rg (ripgrep) over a file to count TODO markers. Delegates to chisel's shell_exec — path is validated server-side. Args: path: Absolute path to the file to inspect """ result = await chisel_shell_exec("rg", ["--count", "TODO", path]) return result or "No TODO markers found." - examples/python-mcp-server/server.py:58-58 (registration)Registration of the FastMCP server instance named 'my-project-server' which hosts the MCP tools including run_lint that uses shell_exec.
mcp = FastMCP("my-project-server")