SQLite MCP: tilde (~) in --db-path is not expanded (use the full path)
Fixes the SQLite MCP server failing to open a database when --db-path contains a tilde (~). The server does not perform shell tilde expansion, so the literal ~ becomes part of the path. The fix is writing out the full home directory path. Use when the path looks right but the file cannot be opened; not for SQL errors.
TL;DR: ~ in --db-path does not mean your home directory to the SQLite MCP server. Tilde expansion is a shell feature and the server is launched without a shell, so it looks for a literal directory named ~ and fails. Write out the full path.
Error: unable to open database file(With --db-path set to something like ~/data/app.db.)
Fix it
- In your MCP client config, replace the tilde with the real home directory:
{
"args": ["mcp-server-sqlite", "--db-path", "[HOME]/..."]
} Find your home directory with echo $HOME in a terminal.
- Restart the MCP client.
Expected: the server opens the database and tools work.
When to use this
--db-pathcontains~and the server cannot open the file.- The same path works when pasted into a terminal (because your shell expands the tilde there).
When NOT to use this
- The path has no tilde and still fails. Then it is a permissions or missing-directory problem.
- The error is
no such table. The file opened; it is just the wrong or an empty one.
Compatibility
- @modelcontextprotocol/server-sqlite.
- All MCP clients, since none of them run a shell to expand the argument.
Why it happens
When you type ~/data/app.db in a terminal, your shell rewrites it to [HOME]/... before the program ever sees it. MCP clients spawn servers directly via process APIs, with no shell in between, so the server receives the literal two-character string ~/... and treats it as a relative path. There is no ~ directory, so the open fails.
Edge cases
- Environment variables like
$HOMEin args are not expanded either, for the same reason. Some clients support${HOME}in theenvblock, but not inargs. - On Windows,
%USERPROFILE%is not expanded in args either. Use the fullC:[HOME]/...path. - If you generate configs with a script, expand the path in the script before writing the JSON.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.