docs/mcp-setup.md

MCP Setup

Connect agent-fs to Claude Code, Cursor, Codex, and other MCP clients.

Markdown

Connect agent-fs to any MCP-compatible AI assistant (Claude Code, Cursor, Windsurf, etc.).

Claude Code

Add to your .mcp.json (project-level or ~/.claude/.mcp.json for global):

json
{
"mcpServers": {
"agent-fs": {
"command": "agent-fs",
"args": ["mcp"],
"env": {
"AGENT_FS_API_URL": "http://localhost:7433",
"AGENT_FS_API_KEY": "your-api-key"
}
}
}
}

Prerequisites: The agent-fs daemon must be running (agent-fs daemon start). The agent-fs mcp command is a stdio-to-HTTP proxy that connects to the daemon's /mcp endpoint.

With embeddings

To enable semantic search, configure an embedding provider on the daemon (via ~/.agent-fs/config.json or environment variables). The daemon initializes embeddings at startup and makes them available to both REST and MCP clients.

Supported providers: OPENAI_API_KEY (OpenAI), GEMINI_API_KEY (Google Gemini), or local llama.cpp (configured in ~/.agent-fs/config.json).

Cursor

Add to your Cursor MCP settings (Settings > MCP Servers):

json
{
"agent-fs": {
"command": "agent-fs",
"args": ["mcp"],
"env": {
"AGENT_FS_API_URL": "http://localhost:7433",
"AGENT_FS_API_KEY": "your-api-key"
}
}
}

Generic MCP Client (stdio transport)

agent-fs uses stdio transport. Spawn the process and communicate via JSON-RPC over stdin/stdout:

bash
agent-fs mcp

The server advertises tools via the standard MCP tools/list method.

Available Tools

Content Operations

ToolDescription
writeWrite or overwrite a file. Creates a new version. Use expectedVersion for optimistic concurrency.
catRead file content with optional pagination via offset/limit.
editReplace a specific string in a file (surgical find-and-replace).
appendAppend content to the end of an existing file.
tailRead the last N lines of a file.
ToolDescription
lsList immediate children of a directory. Path defaults to / (root).
statGet file metadata without reading content.
treeRecursively list all files and directories. Path defaults to / (root). Use depth to limit.
globFind files by pattern. *.md matches root only; **/*.md matches recursively.

File Management

ToolDescription
rmDelete a file. Removes from S3, cleans up FTS5 and embeddings.
mvMove or rename a file. Preserves version history.
cpCopy a file using server-side S3 copy.

Version Control

ToolDescription
logShow version history for a file.
diffShow the diff between two versions of a file.
revertRevert a file to a previous version. Creates a new version with the old content.
ToolDescription
grepRegex search across file content via FTS5 index.
ftsFull-text keyword search across all files using FTS5 tokens.
searchSemantic search using natural language (requires embedding provider).

Maintenance

ToolDescription
recentShow recent activity. Filter by path prefix and time window.
reindexRe-index files with failed or missing FTS5/embedding entries.

Comments

ToolDescription
comment-addAdd a comment to a file. Supports line ranges and threading.
comment-listList comments on a file with inline replies. Filter by path, resolved state, or parent.
comment-getGet a single comment by ID with all replies.
comment-updateUpdate a comment's body (author only).
comment-deleteSoft-delete a comment (author only).
comment-resolveResolve or reopen a root comment.

Identity & Member Management

ToolDescription
whoamiGet current user identity, org memberships, and drive roles. Lists only drives you're an explicit member of.
member-listList members of the current org, or of a drive in the current org via driveId.
member-inviteInvite an existing agent-fs user to the current org by email.
member-update-roleUpdate a member's org role, or drive role via driveId.
member-removeRemove a member from the current org (cascades to drives), or from one drive via driveId.

Member tools are admin-gated, mirroring the HTTP member routes: org-scoped calls require org admin; drive-scoped calls require drive admin or admin of the owning org. A driveId must belong to your active org — drive IDs from other orgs return "not found", and authorization runs before any email lookup, so non-admins can't probe whether an account or drive exists.

Which Search Tool Should I Use?

agent-fs has three search tools for different use cases:

ToolUse WhenExample
grepYou know the exact text or patterngrep --pattern "TODO"
ftsYou know keywords but not exact textfts --query "authentication middleware"
searchYou want to find by meaning/conceptsearch --query "how does auth work?"

`grep` is fastest — it uses regex against the FTS5 index. Use for exact strings, patterns, variable names.

`fts` is keyword-based full-text search. Use when you know relevant terms but not the exact phrasing. Supports FTS5 query syntax (AND, OR, NOT, phrases).

`search` is semantic/vector search. Use when you want to find files by meaning, not keywords. Requires an embedding provider (OpenAI, Gemini, or local llama.cpp). Best for questions like "files related to user authentication" where keyword matching would miss relevant results.

Environment Variables

VariableDescriptionRequired
AGENT_FS_API_URLServer URL (e.g., http://localhost:7433)For remote mode
AGENT_FS_API_KEYAPI key for authenticationFor remote mode
AGENT_FS_HOMEData directory (default: ~/.agent-fs)No
OPENAI_API_KEYOpenAI API key for embeddingsFor semantic search
GEMINI_API_KEYGoogle Gemini API key for embeddingsFor semantic search

Troubleshooting

"No embedding provider configured"

Semantic search (search tool) requires an embedding provider. Set OPENAI_API_KEY or GEMINI_API_KEY in your MCP config's env block, or configure a provider in ~/.agent-fs/config.json.

"Cannot connect to agent-fs"

The daemon must be running. Start it with agent-fs daemon start, or set AGENT_FS_API_URL to point to a remote server. Default port is 7433.

Tools not appearing

Restart your MCP client after updating the config. Check that agent-fs is in your PATH (which agent-fs).