a month ago
I am trying to setup the MCP in my IDE.
From what i read, the token should start with rly and should be at the account level not the project level. However, i only see the option to create a token at project level and i none of the tokens i can generate start with 'rly_'
All attempts to access the MCP always return something like this:
" Railway CLI Status Check FailedError: Invalid or expired Railway token. Please run 'railway login' to refresh your authenticationNext Steps:• If Railway CLI is not installed: Install it from https://docs.railway.com/guides/cli• If not logged in: Run railway login to authenticate • If token is expired: Run railway login to refresh your authentication"
Pinned Solution
a month ago
Hello sofortune81,
your issue is that the official @railway/mcp-server does not use a railway_api_token env variable at all , that's why it keeps failing , you need to remove the entire env block from your config
the correct config is this:
{"mcpServers": {"railway": {"command": "npx", "args": ["-y", "@railway/mcp-server"]}}}
then make sure the railway cli is installed on your machine, and run "railway login" once to authenticate , the mcp server uses your cli session directly, no token needed in the config
Hope this help you :)
6 Replies
a month ago
The MCP server requires the Railway CLI to be installed and authenticated, not an API token. You can authenticate by running railway login in your terminal. If you want to use a token instead, create an account token (not a project token) from the tokens page by selecting "No workspace" in the workspace dropdown, then set it via railway login --token before starting the MCP server.
Status changed to Awaiting User Response Railway • about 1 month ago
Railway
The MCP server requires the Railway CLI to be installed and authenticated, not an API token. You can authenticate by running `railway login` in your terminal. If you want to use a token instead, create an **account token** (not a project token) from the [tokens page](https://railway.com/account/tokens) by selecting "No workspace" in the workspace dropdown, then set it via `railway login --token ` before starting the MCP server.
a month ago
Do you mean i need to run railway login every single time?
Status changed to Awaiting Railway Response Railway • about 1 month ago
a month ago
No, you only need to run railway login once. The CLI persists your session, so it stays authenticated until you explicitly log out or the session is revoked. Alternatively, you can create an account-level token at railway.com/account/tokens by selecting "No workspace" in the dropdown, then set RAILWAY_API_TOKEN as an environment variable in your MCP server config so it authenticates automatically without needing the CLI login at all.
Status changed to Awaiting User Response Railway • about 1 month ago
Railway
No, you only need to run `railway login` once. The CLI persists your session, so it stays authenticated until you explicitly log out or the session is revoked. Alternatively, you can create an account-level token at [railway.com/account/tokens](https://railway.com/account/tokens) by selecting "No workspace" in the dropdown, then set `RAILWAY_API_TOKEN` as an environment variable in your MCP server config so it authenticates automatically without needing the CLI login at all.
a month ago
{
"mcpServers": {
"railway": {
"command": "npx",
"args": [
"-y",
"@railway/mcp-server"
],
"env": {
"RAILWAY_API_TOKEN": "[MY_TOKEN]"
}
}
}
}I have setup the MCP like this, but it still always returns the Railway CLI Status Check Failed Error: Invalid or expired Railway token
Status changed to Awaiting Railway Response Railway • about 1 month ago
Status changed to Open Railway • about 1 month ago
sofortune81
```json { "mcpServers": { "railway": { "command": "npx", "args": [ "-y", "@railway/mcp-server" ], "env": { "RAILWAY_API_TOKEN": "[MY_TOKEN]" } } } } ``` I have setup the MCP like this, but it still always returns the Railway CLI Status Check Failed **Error:** Invalid or expired Railway token
a month ago
Are you using a project scoped token?
As mentioned above, you must create an account-level token to use RAILWAY_API_TOKEN.
a month ago
Hello sofortune81,
your issue is that the official @railway/mcp-server does not use a railway_api_token env variable at all , that's why it keeps failing , you need to remove the entire env block from your config
the correct config is this:
{"mcpServers": {"railway": {"command": "npx", "args": ["-y", "@railway/mcp-server"]}}}
then make sure the railway cli is installed on your machine, and run "railway login" once to authenticate , the mcp server uses your cli session directly, no token needed in the config
Hope this help you :)
Status changed to Solved 0x5b62656e5d • 16 days ago
