Skip to main content
LESSON 3 of 5//Agentic CLI & MCP

Exposing local directories to agents

The filesystem MCP server gives AI agents the ability to read, search, and modify files in specified directories. This is what enables agents to understand your codebase and make changes.

Scoped directory accesszsh // interactive
# Expose a single project directory (recommended)
~npx @modelcontextprotocol/server-filesystem ~/projects/my-app
[READY] Filesystem server listening on stdio
[INFO] Allowed directory: /Users/dev/projects/my-app
# Expose multiple directories
~npx @modelcontextprotocol/server-filesystem ~/projects/api ~/projects/frontend
!

Principle of least privilege

Always expose the minimum directory scope needed. An agent with access to ~/ can read your SSH keys, environment files, and other sensitive data. Limit access to specific project folders.

Once connected, the AI agent can use tools like read_file, write_file, list_directory, and search_files to interact with your codebase — all through the command-line server you launched.

PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: