Filetype
Tool Name: files/filetype
Returns a file's MIME type, like file -b --mime-type, detected natively from its first 8 KiB (no file(1) needed); read-only, path must be absolute. A symlink is reported as inode/symlink (never followed); directories, devices, fifos and sockets as inode/.... Use it before files/read, which refuses binary files. For size, permissions or ownership use files/list; for contents files/read. The reply is always one plain-text line (no output_format). privileged: true (a grant, and for root a paths: entry) reads files your account cannot.
- Directories, devices, FIFOs, sockets and empty files get
file'sinode/*types; a symlink is reported asinode/symlink, not followed (asfiledoes). - ELF binaries:
application/x-executable,application/x-pie-executable,application/x-sharedlib,application/x-object,application/x-coredump. - Archives and compressors (gzip, bzip2, xz, zstd, 7z, lz4, tar, ar),
.deb,.rpm, SQLite, PDF, images, audio/video and fonts the Go standard library knows, WebAssembly;#!scripts by interpreter (text/x-shellscript,text/x-script.python,text/x-perl, ...); JSON; otherwisetext/plainorapplication/octet-stream.
file's libmagic knows far more formats (C source, makefiles, office documents, ...); for those this answers the generic text/plain or application/octet-stream. On 209 system binaries, libraries, configs and compressed docs of Ubuntu 24.04 (amd64 and arm64) the answers are identical to file's.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
path | string | yes | Absolute path to the file |
privileged | boolean | no | Run as root. Needs a grant for this tool in mcp-sudo.yaml and a paths: entry covering the path, otherwise refused |
Example
Every example below shows the equivalent linuxctl command and the raw MCP JSON-RPC call it resolves to. The raw call always follows the same two-step pattern (see MCP API overview for the full explanation): open an SSE stream to get a one-time POST endpoint, then POST the JSON-RPC request there - the result streams back on the SSE connection.
Output captured live on an Ubuntu 24.04 host - every answer below matches file -b --mime-type there.
linuxctl
linuxctl get files filetype /usr/bin/ls
Output:
application/x-pie-executable
More answers from the same host:
/etc/hosts text/plain
/usr/bin/ls application/x-pie-executable
/usr/lib/x86_64-linux-gnu/libc.so.6 application/x-sharedlib
/usr/bin/lsb_release text/x-shellscript
/usr/share/doc/bash/changelog.Debian.gz application/gzip
/etc/ssl/certs inode/directory
/usr/bin/python3 inode/symlink
curl (raw MCP JSON-RPC)
# 1. Open the SSE stream (in the background) and capture the one-time POST endpoint
curl -N -s --cacert mcpd.crt -H "Authorization: Bearer $MCP_TOKEN" https://localhost:9091/sse &
# server sends: event: endpoint / data: /message?session_id=...
# 2. POST the tools/call request to that endpoint
curl -s --cacert mcpd.crt -X POST "https://localhost:9091/message?session_id=<from step 1>" \
-H "Authorization: Bearer $MCP_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": "1", "method": "tools/call", "params": {"name": "files/filetype", "arguments": {"path": "/usr/bin/ls"}}}'
# 3. The result arrives on the SSE stream opened in step 1
Response:
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"content": [
{
"type": "text",
"text": "application/x-pie-executable\n"
}
]
}
}