A CLI agentic system for orchestrating tools and memory using the agentic framework.
local-agent runs an agent with MCPs (Model Context Protocol tools) scoped to the root folder where it is launched, providing per-folder and per-file context, structure, and requirements.
Users can define the agent's structure, tools, and requirements specifically for each folder, enabling flexible, multi-root, and multi-file support.
local-agent also allows you to set, per scope (folder/root), the MCP tools and system prompt, providing tailored direction for editing files, remembering the project scope, and recording all changes and interactions in the session log.
npx local-agentnpm install -g local-agent
local-agent- Root Scope: When you run
local-agentin a folder, it becomes the "root" scope for that agent instance. - Per-Folder/Per-File Context: Each root can have its own configuration, tools, and requirements, defined by the user.
- Per-Scope Tools & Prompts: You can set different MCP tools and system prompts for each folder/root, giving the agent specific direction and memory for that context.
- Multi-File/Folder Access: The agent can access and operate on multiple files and subfolders within its root.
- Multiple Roots: You can run separate local-agent instances in different folders, each with its own context and configuration.
- User-Defined Structure: Users are encouraged to define the structure, requirements, and tools for each folder, making local-agent adaptable to diverse project layouts.
- Checks for required files:
system.md,local-agent.json,mcp-tools.json,keys.json - Prompts you to create any missing files (with templates or empty)
- Creates a
memory/directory for session logs - Loads default and custom MCPs (tools) from
mcp-tools.json, scoped to the current folder/root - Starts an interactive CLI session, using the system prompt and tools defined for the current scope
local-agent supports multiple AI model providers via the ai-sdk ecosystem. You can select and use different models by specifying the provider and model in your configuration.
- OpenAI (
@ai-sdk/openai) - Anthropic (
@ai-sdk/anthropic) - Google (
@ai-sdk/google) - OpenRouter (
@openrouter/ai-sdk-provider)
Note: "Custom" models are not currently supported due to SDK limitations.
Set the model field in your configuration (e.g., local-agent.json) to a string in the format:
provider/model-name
provider: The AI provider to use (e.g.,openai,anthropic,google,openrouter)model-name: The specific model for that provider
local-agent is designed to be highly extensible through Model Context Protocol (MCP) tools. MCP tools provide additional capabilities (such as file system access, memory, or custom APIs) and are loaded per project scope (the folder where you invoke the agent).
- Per-Scope Loading: When you run
local-agentin a folder, it loads MCP tools defined in that folder's configuration. Each folder/root can have its own set of tools, system prompt, and settings. - Initialization: On first run, the agent will prompt you to create missing configuration files, including
mcp-tools.json, and will initialize the folder with sensible defaults. - Isolation: Each agent instance operates only within the folder where it was started, using only the tools and context defined there.
To add or customize MCP tools for your project:
- Open (or create) the
mcp-tools.jsonfile in your project root. - Add tool definitions as objects in a JSON array.
[
{
"name": "basic-memory",
"module": "basic-memory",
"options": { "memoryDir": "memory" }
},
{
"name": "server-filesystem",
"module": "@modelcontextprotocol/server-filesystem",
"options": { "accessPath": "." }
}
]- basic-memory: Provides session memory and logging.
- server-filesystem: Allows the agent to read/write files in the current folder.
[
{
"name": "basic-memory",
"module": "basic-memory",
"options": { "memoryDir": "memory" }
},
{
"name": "server-filesystem",
"module": "@modelcontextprotocol/server-filesystem",
"options": { "accessPath": "." }
},
{
"name": "my-custom-api",
"module": "my-custom-mcp-module",
"options": { "apiKey": "YOUR_API_KEY" }
}
]- Add your own MCP tool by specifying its
name,module, and any requiredoptions.
- Scoped Context: Each agent instance is fully isolated to the folder where it is invoked. All memory, tools, and configuration are local to that folder.
- Automatic Initialization: On first run, the agent will create missing config files (
system.md,local-agent.json,mcp-tools.json,keys.json) and initialize the folder for you. - Customizable: You can tailor the agent's tools, system prompt, and settings for each project or folder independently.
- Safe by Default: The agent cannot access files or tools outside the current scope unless explicitly configured.
-
Initialize a new project folder:
mkdir my-project cd my-project npx local-agent- The agent will prompt you to create configuration files if they are missing.
-
Customize your tools:
- Edit
mcp-tools.jsonto add, remove, or configure MCP tools as needed.
- Edit
-
Run the agent:
- All actions, memory, and tools are scoped to the current folder.
For more details on available MCP tools and advanced configuration, see the ARCHITECTURE.md and AI_CLIENT_PROVIDER_REFACTOR.md documents.
{
"model": "openai/gpt-4o-mini"
}- Uses OpenAI as the provider with the
gpt-4o-minimodel.
{
"model": "anthropic/claude-3-5-sonnet-latest"
}- Uses Anthropic as the provider with the
claude-3-5-sonnet-latestmodel.
{
"model": "google/models/gemini-2.0-flash-exp"
}- Uses Google as the provider with the
gemini-2.0-flash-expmodel.
{
"model": "openrouter/meta-llama/llama-3.1-405b-instruct"
}- Uses OpenRouter as the provider with the
meta-llama/llama-3.1-405b-instructmodel.
To switch between providers or models, simply update the model field in your configuration to the desired provider/model string as shown above. No code changes are required.
-
Switching from OpenAI to Anthropic:
- Open your
local-agent.jsonconfig. - Change
"model": "openai/gpt-4o-mini"to"model": "anthropic/claude-3-5-sonnet-latest". - Save and restart the agent.
- Open your
-
Using Google Gemini:
- Set
"model": "google/models/gemini-2.0-flash-exp"in your config. - Ensure you have the correct API keys for Google in your
keys.json. - Save and restart the agent.
- Set
-
Using OpenRouter for advanced routing:
- Set
"model": "openrouter/meta-llama/llama-3.1-405b-instruct"in your config. - Add your OpenRouter API key to
keys.jsonas"openrouter": "your-openrouter-api-key-here". - Save and restart the agent.
- Set
Add the required API keys for each provider in your keys.json file:
{
"openai": "your-openai-api-key-here",
"openrouter": "your-openrouter-api-key-here",
"anthropic": "your-anthropic-api-key-here",
"google": "your-google-api-key-here"
}- Ensure the relevant provider's package is installed (see
package.json). - Add the required API keys for each provider in your
keys.jsonfile.
- If you see errors about missing modules, run
npm installto ensure all dependencies are installed. - If you see errors about missing API keys, add them to your
keys.jsonfile.
For more details, see the AI Client Provider Refactor Design Document.
- system.md: System prompt and agent instructions, specific to the folder/root.
Set the direction and behavior of the agent for this scope. - local-agent.json: Agent configuration (name, settings, etc.) for the current root.
- mcp-tools.json: List of MCP tools to load (default MCPs are injected if missing), can be tailored per folder/root. Choose which tools are available for the agent in this scope.
- keys.json: API keys for different providers (OpenAI, OpenRouter, Anthropic, Google) for the current root.
You can edit these files at any time to change agent behavior for the current folder.
Add additional MCPs by editing mcp-tools.json. Example:
[
{
"name": "basic-memory",
"module": "basic-memory",
"options": { "memoryDir": "memory" }
},
{
"name": "server-filesystem",
"module": "@modelcontextprotocol/server-filesystem",
"options": { "accessPath": "." }
}
// Add more MCPs here
]Default MCPs (basic-memory, server-filesystem) are always loaded if not present.
- To restart, simply run
npx local-agentagain in the same folder (root). - To re-initialize, delete or edit the config files and run the CLI; missing files will be recreated as needed.
- To use a different root, run
local-agentin another folder with its own configuration.
All interactions and changes are logged in the memory/ directory as markdown files, organized by session and scoped to the current root.
When you edit files or perform actions, local-agent records the context, scope, and changes, helping you track project history and agent decisions.
- Missing files? The CLI will prompt you to create them.
- API key issues? Add your keys to
keys.json. - Custom tools not loading? Check your
mcp-tools.jsonsyntax and module availability. - Multi-root confusion? Each folder/root is independent; ensure you are in the correct directory for your intended agent context.
- To publish:
npm publish - Contributions welcome! See
ARCHITECTURE.mdfor design details.