A starter template for building MCP Servers that implement the MCP Authorization flow.
The fastest way to try out Remote MCP servers with built-in authentication is by deploying on Railway with the template below:
For the deployment you need the following:
- Create a New GitHub App, required for user authentication
- For the "Authorization callback URL" add the placeholder
http://localhost:3000/auth/callbackand create the app, you will update it at step 5.
- For the "Authorization callback URL" add the placeholder
- Add the GitHub Client ID and Client Secret in the Deploy panel on Railway, and click "Deploy"
- After the app is deployed, the Custom Domain is available in the railway deployment settings page.
- Update the "Authorization callback URL" of the GitHub app to the custom domain with the postfix as shown here:
https://<custom-domain>.up.railway.app/auth/callback.
And you are ready to roll!
Open MCP Inspector at https://<custom-domain>.up.railway.app/mcp to see the available resources and tools.
Clone the repository and install dependencies:
git clone https://github.com/rekog-labs/mcp-nest-auth-starter.git
cd mcp-nest-auth-starter
npm installSet the environment variables in a .env file at the root of the project. You can use the provided .env.example as a template.
SERVER_URL=http://localhost:3000
GITHUB_CLIENT_ID=<your_github_client_id>
GITHUB_CLIENT_SECRET=<your_github_client_secret>
JWT_SECRET=<your_jwt_secret>
SERVER_URL- The base URL of your application.GITHUB_CLIENT_ID- Your GitHub OAuth client ID.GITHUB_CLIENT_SECRET- Your GitHub OAuth client secret.JWT_SECRET- Your JSON Web Token secret.
npm run start:devnpm run build
npm run start:prod