# Getting ready for secure MCP with Quarkus MCP Server

DevFeed: [Getting ready for secure MCP with Quarkus MCP Server](<https://devfeed.tech/articles/getting-ready-for-secure-mcp-with-quarkus-mcp-server-43956.md>)

Original publisher: [Read original article](<https://quarkus.io/blog/secure-mcp-sse-server/>)

Author: Sergey Beryozkin (https://twitter.com/sberyozkin)

Published: 2025-04-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [Quarkus - Supersonic Subatomic Java](<https://devfeed.tech/sources/quarkus-supersonic-subatomic-java.md>)

Topics: [Model Context Protocol](<https://devfeed.tech/topics/model-context-protocol.md>), [Quarkus](<https://devfeed.tech/topics/quarkus.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>), [Server-sent events (SSE)](<https://devfeed.tech/topics/server-sent-events-sse.md>), [Authorization](<https://devfeed.tech/topics/authorization.md>), [Security](<https://devfeed.tech/topics/security.md>), [OpenID connect (OIDC)](<https://devfeed.tech/topics/oidc.md>), [Keycloak](<https://devfeed.tech/topics/keycloak.md>), [JSON Web Tokens](<https://devfeed.tech/topics/jwt.md>), [OAuth 2.0](<https://devfeed.tech/topics/oauth2.md>), [Maven](<https://devfeed.tech/topics/maven.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [authorization](<https://devfeed.tech/tags/authorization.md>), [jwt](<https://devfeed.tech/tags/jwt.md>), [keycloak](<https://devfeed.tech/tags/keycloak.md>), [maven](<https://devfeed.tech/tags/maven.md>), [mcp](<https://devfeed.tech/tags/mcp.md>), [oauth2](<https://devfeed.tech/tags/oauth2.md>), [oidc](<https://devfeed.tech/tags/oidc.md>), [quarkus](<https://devfeed.tech/tags/quarkus.md>), [server-sent-events-sse](<https://devfeed.tech/tags/server-sent-events-sse.md>)

## AI overview

A tutorial on securing a Quarkus MCP Server that uses Server-Sent Events. It demonstrates authentication with Keycloak and OpenID Connect in development mode, then GitHub OAuth2 and access tokens in production mode.

## Source excerpt

Introduction The latest version of the Model Context Protocol (MCP) specification introduces an authorization flow. While it will take a bit of time for the new MCP specification to be widely supported, you can already add authentication to client and server following the previous MCP version. You only need an MCP client that can receive an access token and pass it to the MCP server and, obviously, an MCP server that verifies the token. In this post, we will detail how you can enforce authentication with the Quarkus MCP SSE Server. We will first use Keycloak as an OpenID Connect (OIDC) provider to login and use a Keycloak JWT access token to access the server with Quarkus MCP SSE Server Dev UI in dev mode. Secondly, we will show how to log in using GitHub OAuth2 and use a GitHub binary access token to access the server in prod mode with both MCP inspector and the curl tools. Step 1 - Create an MCP server using the SSE transport First, let's create a secure Quarkus MCP SSE server that requires authentication to establish Server-Sent Events (SSE) connection and also when invoking the tools. You can find the complete project source in the Quarkus MCP SSE Server samples. Maven dependencies Add the following dependencies: <dependency> <groupId>io.quarkiverse.mcp</groupId> <artifactId>quarkus-mcp-server-sse</artifactId> (1) <version>1.1.1</version> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-oidc</artifactId> (2) </dependency> 1 quarkus-mcp-server-sse is required to support MCP SSE transport. 2 quarkus-oidc is required to secure access to MCP SSE endpoints. Its version is defined in the Quarkus BOM. Tool Let's create a tool that can be invoked only if the current MCP request is authenticated: package org.acme; import io.quarkiverse.mcp.server.TextContent; import io.quarkiverse.mcp.server.Tool; import io.quarkus.security.Authenticated; import io.quarkus.security.identity.SecurityIdentity; import jakarta.inject.Inject; public class ServerFea