Local Models with Agents
This advanced tutorial demonstrates how to use local AI models with MCP servers to handle sensitive data without sending it to external services. This is perfect for internal documents, private files, or any data you want to keep on your local machine.
Why Use Local Models with MCP?
Security Benefits
- ✅ No data leaves your machine - Everything stays local
- ✅ No API costs - Run models on your own hardware
- ✅ Complete privacy - Perfect for sensitive documents
- ✅ Offline capability - Works without internet connection
Perfect Use Cases
- Internal documents - Company files, contracts, sensitive reports
- Personal data - Private notes, passwords, personal information
- Proprietary code - Source code you don't want to share
- Local file management - Organizing files on your computer
What We're Building
We'll create a workflow that:
- Sets up a Filesystem MCP server to access your local files
- Uses Ollama with a local model (
qwen3:1.7b) for AI processing - Demonstrates secure file access by reading a "secret" file
- Shows how sensitive data stays local throughout the entire process
Prerequisites
- You understand basic MCP concepts (from Getting Started)
- You have a Mac, Windows, or Linux computer
- You're comfortable with basic file operations
Step 1: Install Ollama
Download and Install Ollama
- Go to ollama.org
- Download Ollama for your operating system
- Install Ollama following the installation instructions
- Verify installation by opening a terminal and running:
ollama --version
Download the Qwen3 Model
- Open a terminal and run:
ollama pull qwen3:1.7b - Wait for download - This may take a few minutes depending on your internet speed
- Verify the model is available:
ollama list
Why Qwen3:1.7b? This model is small enough to run on most computers while still supporting tool use, which is required for MCP integration.
Step 2: Set Up Filesystem MCP Server
The Filesystem MCP Server provides secure access to your local file system, allowing AI agents to read, write, and manage files and directories. This server is perfect for local data processing because it only accesses directories you explicitly allow, ensuring your sensitive files remain protected. The server supports common file operations like listing directories, reading files, creating new files, and organizing your local storage - all while keeping everything on your machine.
For detailed information about the filesystem server's capabilities and configuration options, see our Filesystem Server documentation.
Create the MCP Server Configuration
- Open Griptape Nodes and go to Settings → MCP Servers
- Click + New MCP Server
- Configure the server:
- Server Name/ID:
filesystem - Connection Type:
Local Process (stdio) - Configuration JSON:
- Server Name/ID:
{
"transport": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/jason/Desktop",
"/Users/jason/Downloads"
],
"env": {},
"cwd": null,
"encoding": "utf-8",
"encoding_error_handler": "strict"
}
Important: Replace
/Users/jason/Desktopand/Users/jason/Downloadswith your actual desktop and downloads folder paths. The filesystem server can only access directories you explicitly allow.
- Click Create Server
Test the Filesystem Access
- Create a test file on your desktop called
secret.txt - Add some content to the file:
The password is: CAPYBARA - Save the file
Step 3: Build the Local AI Workflow
Create the Ollama Prompt Configuration
- Drag an Ollama Prompt node to your workflow
- Configure the model:
- Model:
qwen3:1.7b - Temperature:
0.1(for consistent results) - Max Tokens:
-1(unlimited) - Stream:
True - Use Native Tools:
True(required for MCP)
- Model:
Create the Agent
- Drag an Agent node to your workflow
- Connect the Ollama Prompt's
prompt_model_configoutput to the Agent'sprompt_model_configinput - Configure the agent:
- Prompt: Leave empty for now
- Additional Context: Leave empty for now
Create the MCP Task
- Drag an MCPTask node to your workflow
- Connect the Agent's
agentoutput to the MCPTask'sagentinput - Configure the MCPTask:
- MCP Server Name:
filesystem - Prompt:
"what's the password in secret.txt? it's in the desktop folder"
- MCP Server Name:
Step 4: Run the Secure Workflow
Execute the Workflow
- Run the Ollama Prompt node first to initialize the model
- Run the Agent node to create the agent with local model access
- Run the MCPTask node to execute the file access
Expected Results
The MCPTask should return something like:
<think>
Okay, the user asked for the password in secret.txt. After checking the allowed directories and listing the contents, the secret.txt file was found. Reading the file revealed the password "CAPYBARA". Since the user requested the password, the assistant needs to provide it. The previous steps were successful, so the final answer is the password.
</think>
The password in secret.txt is **CAPYBARA**.
Why This is Secure
Data Flow Analysis
graph LR
A[Local Files] --> B[Filesystem MCP Server]
B --> C[Local Ollama Model]
C --> D[Your Computer Only]
subgraph Security ["🔒 Everything Stays Local"]
A
B
C
D
end
Security Benefits Demonstrated
- No External API Calls - The AI model runs on your machine
- No Data Transmission - Files are read locally, processed locally
- No Cloud Storage - Nothing is sent to external servers
- Complete Control - You control exactly what the AI can access
Advanced Configuration Options
Model Selection
Choose models based on your needs:
| Model | Size | Speed | Capabilities | Best For |
|---|---|---|---|---|
qwen3:1.7b |
Small | Fast | Basic tool use | Simple tasks |
qwen3:4b |
Medium | Medium | Better reasoning | Complex analysis |
llama4 |
Large | Slower | Advanced reasoning | Complex workflows |
Filesystem Security
Configure the filesystem server to only access specific directories:
{
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/jason/Documents/Work",
"/Users/jason/Documents/Projects"
]
}
Performance Optimization
- Allocate sufficient RAM (8GB+ recommended for larger models)
- Close other applications when running large models
- Use smaller models for faster responses
Troubleshooting
Common Issues
Model Not Found
# Check available models
ollama list
# Pull the model if missing
ollama pull qwen3:1.7b
Filesystem Access Denied
- Verify the directory paths in your MCP server configuration
- Check that the directories exist and are accessible
- Ensure you have read permissions for the directories
Model Performance Issues
- Try a smaller model like
qwen3:1.7b - Close other applications to free up memory
- Check your system resources (CPU, RAM usage)
Tool Use Not Working
- Ensure
use_native_toolsis set toTruein Ollama Prompt - Verify the model supports tool use (Qwen3 models do)
- Check that the MCP server is properly configured
Next Steps
Now that you've mastered local models with MCP servers, explore:
- Example MCP Servers - Set up additional servers for different capabilities
- Connection Types - Explore different ways to connect to external systems