@antogyn/mcp-auth
v0.1.1
Published
Plug and play auth for Model Context Protocol (MCP) servers
Downloads
27
Maintainers
Readme
MCP Auth Node.js SDK
The MCP specification requires OAuth 2.1 and other RFCs for authorization. Instead of implementing all the OAuth 2.1 and OpenID Connect standards yourself, a production-ready provider and a set of libraries and tutorials can save you a lot of time and effort.
That's where MCP Auth comes in. It includes:
- An updated OAuth 2.1 and OpenID Connect provider list that meets the MCP requirements.
- A set of provider-agnostic libraries and tools to help you integrate your MCP server with any compliant provider.
- Practical tutorials and examples to get you started quickly.
And yes, it can be as simple as a few lines of code:
const server = new McpServer(/* ... */);
const mcpAuth = new MCPAuth({
server: await fetchServerConfig('<auth-server-url>', { type: 'oidc' }),
});
const app = express();
app.use(mcpAuth.bearerAuth('jwt', { requiredScopes: ['read', 'write'] }));
server.tool('whoami', ({ authInfo }) => {
// Use `authInfo` to access the auth information carried from `req.auth`
});See the documentation for the full guide.
