# MCP and agent access

Last updated: 16 October 2026

Connect Claude, Cursor or any MCP client to Fyle with `fyle mcp`. Each agent gets an agent grant: one workspace, the paths it may touch, read or write, and an expiry. It never gets your sign-in.

## Connect a client

Claude Code: edits go to review, only docs/ and src/:
```bash
claude mcp add fyle -- fyle mcp --mode branch_only --paths 'docs/**' 'src/**'
```

Claude Desktop or Cursor (mcpServers):
```json
{
  "mcpServers": {
    "fyle": {
      "command": "fyle",
      "args": ["mcp", "--workspace", "Projects", "--mode", "branch_only"]
    }
  }
}
```

`fyle mcp` runs over stdio. For a client that needs HTTP: `fyle mcp --http 127.0.0.1:8765` (streamable HTTP at `/mcp`; bind it to localhost).

## Agent grants

Without a grant, `fyle mcp` makes one when it starts, from your sign-in. To give an agent access without your sign-in (CI, a remote machine), create a grant and pass its secret:

```bash
fyle grant create --workspace Projects --mode branch_only --paths 'docs/**' --ttl 8h
FYLE_AGENT_GRANT=fyle_agt_… fyle mcp
```

- **read:** List, read and search only.
- **branch_only (default):** New files apply; edits and deletes are kept as branches for review.
- **direct:** Edits apply unless the file moved on meanwhile (then they branch). Owners and admins only.

Grants last from 30 minutes to a day. Create, list and revoke them in the dashboard (**Agents → Access**) or with `fyle grant ls` and `fyle grant revoke ID`. Revoking stops the agent at once.

## Tools

| Tool | Does |
| --- | --- |
| `list_workspaces`, `list_folder`, `get_file_metadata` | Browse, with ids, versions and sizes |
| `read_file` | Whole file or a byte range, current or an old version |
| `search_files` | Names containing a query, under a folder |
| `create_file`, `create_folder` | New files (up to 64 MB) and folders |
| `write_file` | A new version from the version read; stale or branch-only writes become branches |
| `move_file`, `restore_version` | Direct grants only |
| `delete_file` | One file (restorable); folders are never deleted through MCP |
| `get_version_history` | Versions, branches marked |

Text read from files is treated as data, never as instructions to the agent.
