Skip to content

Commit 4d48778

Browse files
committed
samples: polish
Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
1 parent 9fe820f commit 4d48778

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

samples/integration-tests/src/test/java/org/springaicommunity/mcp/security/tests/streamable/sync/server/StreamableHttpMcpServerToolsSecured.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ List<McpServerFeatures.SyncToolSpecification> tools() {
5656
@Bean
5757
SecurityFilterChain securityFilterChain(HttpSecurity http,
5858
@Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri}") String issuerUrl) throws Exception {
59-
return http.authorizeHttpRequests(auth -> auth.anyRequest().permitAll())
59+
return http.authorizeHttpRequests(auth -> {
60+
auth.requestMatchers("/mcp").permitAll();
61+
auth.anyRequest().denyAll();
62+
})
6063
.with(mcpServerAuthorization(), (mcpAuthorization) -> {
61-
// TODO
6264
mcpAuthorization.authorizationServer(issuerUrl).resourcePath("/mcp");
6365
})
6466
// MCP inspector

samples/sample-mcp-client/src/main/java/org/springaicommunity/mcp/security/sample/client/DemoController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ String index(String query) {
9292
@GetMapping("/mcp/add")
9393
void addMcpServer(@RequestParam String url, @RequestParam String name, HttpServletResponse response)
9494
throws IOException {
95-
this.mcpClientRepo.addSseClient(url, name);
95+
this.mcpClientRepo.addClient(url, name);
9696
response.sendRedirect("/");
9797
}
9898

samples/sample-mcp-client/src/main/java/org/springaicommunity/mcp/security/sample/client/InMemoryMcpClientRepository.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public List<String> getClientNames() {
6666
return new ArrayList<>(this.clients.keySet());
6767
}
6868

69-
public void addSseClient(String url, String name) {
69+
public void addClient(String url, String name) {
7070
var transport = HttpClientStreamableHttpTransport.builder(url)
7171
.clientBuilder(HttpClient.newBuilder())
7272
.jsonMapper(new JacksonMcpJsonMapper(objectMapper))
@@ -84,11 +84,4 @@ public void addSseClient(String url, String name) {
8484
clients.put(url, client);
8585
}
8686

87-
public void removeSseClient(String url) {
88-
var client = clients.remove(url);
89-
if (client != null) {
90-
client.closeGracefully();
91-
}
92-
}
93-
9487
}

0 commit comments

Comments
 (0)