Skip to content

Proposal: Restore file-path tools via allowlisted roots (filesystem-style) #39

@iqdoctor

Description

@iqdoctor

Hi Eugene!

I saw in the README that tools requiring direct file path access were removed because of limitations in the current MCP environment around handling file attachments and local file system paths:

  • send_file, download_media, set_profile_photo, edit_chat_photo, send_voice, send_sticker, upload_file

Proposal

Restore these tools using the same security model as the official MCP Filesystem server:

Allowed directories / roots

Support allowlisted directories in two ways:

  1. Command-line arguments (static allowlist)
  • Example: telegram-mcp /path/to/dir1 /path/to/dir2
  1. MCP Roots (recommended)
  • For MCP clients that support Roots, allow them to dynamically update allowed directories.
  • When Roots are provided by the client, they should replace any server-side allowed directories (same semantics as filesystem server).

Path security rules (suggested)

  • Accept relative paths resolved against the first allowed root
  • Reject path traversal and glob-like patterns (.., *, ?, ~, slashes in “file name only” inputs, etc.)
  • Resolve symlinks (realpath) and ensure the final path stays within an allowed root
  • Enforce read/write permissions depending on the tool
  • Optional: file-size limits and extension allowlists per tool (.jpg/.png/.webp/.ogg/.opus, etc.)

Tool behavior (suggested)

  • For “write” tools (e.g. download_media), default to a safe subfolder (e.g. <root>/downloads/) when no file path is provided and return the final saved path.
  • For “read” tools (e.g. send_file), require the file to exist under allowed roots.

Questions for maintainers

  1. Would you accept a PR that restores these tools behind a config flag (default off), or enables them when allowed roots are set?
  2. Is there a preferred approach for Roots support in this server (any existing pattern you want followed)?
  3. Any constraints you want on outputs (e.g. always save downloads under a dedicated folder)?

If you're open to it, I can prepare a PR that ports the filesystem-server style path validation and reintroduces these tools with safe defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions