# Filelayer

Filelayer is an MCP server for Claude Code that checks who may read, download, or revoke files and serves them with the right headers. It issues share links with time, password, and download limits.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI
- Author: filelayer
- License: Apache-2.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/filelayer/filelayer/tree/HEAD/packages/core
- Updated: 2026-10-21
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/mcp/filelayer

## What it does

Filelayer sits between your application and your Postgres database plus object storage (S3, R2, B2 or a local directory). You pass the caller's own user id, and one authorization function decides what they can do with a file, streams the bytes with correct headers, and logs the decision in the same transaction that made it.

Share links can carry a password, an expiry and a download cap, and can be revoked afterward — access stops on the next request. For taking access back from one named person, `unshare` is the right call rather than revoking a single grant id, because `create()` is not idempotent and an earlier grant can stay live.

Filelayer does not substitute for row-level security: a direct `SELECT` against its tables passes through unfiltered, though the schema blocks cross-tenant grants and authority leaking through delegation. For public images at CDN volume or video with scrubbing, a CDN fits better, since every byte here is proxied through your own server.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `DATABASE_URL`, `FILELAYER_AS`, `FILELAYER_ORG`, `FILELAYER_DATA_DIR`, `S3_ENDPOINT`, `S3_BUCKET`, `S3_REGION`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY`, `FILELAYER_MCP_AGENT_LABEL` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add core -e DATABASE_URL=<DATABASE_URL> -e FILELAYER_AS=<FILELAYER_AS> -e FILELAYER_ORG=<FILELAYER_ORG> -e S3_ACCESS_KEY_ID=<S3_ACCESS_KEY_ID> -e S3_SECRET_ACCESS_KEY=<S3_SECRET_ACCESS_KEY> -- npx -y @filelayer/core
```
Replace <…> with your own values. 9 more environment variables are in the server README

### Codex

**Platform CLI**
```bash
codex mcp add core --env DATABASE_URL=<DATABASE_URL> --env FILELAYER_AS=<FILELAYER_AS> --env FILELAYER_ORG=<FILELAYER_ORG> --env FILELAYER_DATA_DIR=<FILELAYER_DATA_DIR> --env S3_ENDPOINT=<S3_ENDPOINT> -- npx -y @filelayer/core
```
Replace <…> with your own values. 9 more environment variables are in the server README

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "core": {
            "command": "npx",
            "args": [
                "-y",
                "@filelayer/core"
            ],
            "env": {
                "DATABASE_URL": "<DATABASE_URL>",
                "FILELAYER_AS": "<FILELAYER_AS>",
                "FILELAYER_ORG": "<FILELAYER_ORG>",
                "FILELAYER_DATA_DIR": "<FILELAYER_DATA_DIR>",
                "S3_ENDPOINT": "<S3_ENDPOINT>"
            }
        }
    }
}
```
Replace <…> with your own values. 9 more environment variables are in the server README

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "core": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "@filelayer/core"
            ],
            "env": {
                "DATABASE_URL": "<DATABASE_URL>",
                "FILELAYER_AS": "<FILELAYER_AS>",
                "FILELAYER_ORG": "<FILELAYER_ORG>",
                "FILELAYER_DATA_DIR": "<FILELAYER_DATA_DIR>",
                "S3_ENDPOINT": "<S3_ENDPOINT>"
            }
        }
    }
}
```
Replace <…> with your own values. 9 more environment variables are in the server README

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e DATABASE_URL=<DATABASE_URL> -e FILELAYER_AS=<FILELAYER_AS> -e FILELAYER_ORG=<FILELAYER_ORG> -e FILELAYER_DATA_DIR=<FILELAYER_DATA_DIR> -e S3_ENDPOINT=<S3_ENDPOINT> core npx -y @filelayer/core
```
Replace <…> with your own values. 9 more environment variables are in the server README

## When to use it
- share a private file with one user or an entire org
- issue a file link with a password, expiry and download limit
- revoke a share link already handed to someone
- log who accessed a file, including denied requests
- cap how many times a file can be downloaded

## Example prompts
- Share file `id` with user_456 for one hour, capped at three downloads
- Revoke all of user_456's access to this file using unshare
- Show who accessed file `id` and which requests were denied

## Similar
- [Willder](https://affpapa.org/en/nevibecode/mcp/willder.md) — MCP server · ★ 12 repo stars
- [sanctuary](https://affpapa.org/en/nevibecode/mcp/sanctuary.md) — MCP server · ★ 10 repo stars
- [auditing-aws-s3-bucket-permissions](https://affpapa.org/en/nevibecode/skills/auditing-aws-s3-bucket-permissions.md) — skill · 307 installs
- [januscope](https://affpapa.org/en/nevibecode/mcp/januscope.md) — MCP server · ★ 33 repo stars
- [SchemaBrain](https://affpapa.org/en/nevibecode/mcp/schemabrain.md) — MCP server · ★ 12 repo stars
- [neon-object-storage](https://affpapa.org/en/nevibecode/skills/neon-object-storage.md) — skill · 46500 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
