SA

spring-ai-community/mcp-security

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

124 stars 38 forks 质量 67 趋势 20Apache-2.0

spring-ai-community/mcp-security 是从 https://github.com/spring-ai-community/mcp-security. 导入的 MCP 服务器候选

概览

spring-ai-community/mcp-security 是从 https://github.com/spring-ai-community/mcp-security. 导入的 MCP 服务器候选

概述(AI 翻译)

Spring AI 中对模型上下文协议的安全性与授权支持。

⚠️ mcp-security 的 0.1.x 版本仅支持 Spring AI 的 2.0.x 分支。对于 Spring AI 1.1.x,请使用版本 0.0.6。

目录

  • 概述
  • MCP服务器安全
  • MCP 客户端安全
  • 授权服务器
  • 采样
  • 集成(Cursor、Claude Desktop 等)
  • 许可证

概述

该仓库提供 授权支持 Spring AI 与模型上下文协议(MCP)的集成。它涵盖 MCP 客户端、MCP 服务器和 Spring 授权服务器。

该项目使开发者能够:

  • 支持 OAuth 2.0 认证的安全 MCP 服务器
  • 配置带有OAuth 2.0授权流的MCP客户端
  • 建立专门为MCP工作流设计的授权服务器
  • 为MCP工具和资源实现细粒度访问控制

MCP服务器安全

提供OAuth 2.0资源服务器功能 用于 Spring AI 的 MCP 服务器。 它还为基于API密钥的服务器提供基本支持。 OAuth2 和 API 密钥认证仅兼容基于 Spring WebMVC 的服务器。 Origin验证还支持Spring WebFlux。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Security

Security and Authorization support for Model Context Protocol in Spring AI.

⚠️ Versions 0.1.x of mcp-security only work Spring AI’s 2.0.x branch. For Spring AI 1.1.x, use version 0.0.6.

Table of Contents

Overview

This repository provides Authorization support for Spring AI integrations with the Model Context Protocol (MCP). It covers both MCP Clients, MCP Servers, and Spring Authorization Server.

The project enables developers to:

  • Secure MCP servers with OAuth 2.0 authentication
  • Configure MCP clients with OAuth 2.0 authorization flows
  • Set up authorization servers specifically designed for MCP workflows
  • Implement fine-grained access control for MCP tools and resources

MCP Server Security

Provides OAuth 2.0 resource server capabilities for Spring AI’s MCP servers. It also provides basic support for API-key based servers. OAuth2 and API-key authentication are compatible with Spring WebMVC-based servers only. Origin validation additionally supports Spring WebFlux.

Quick start with mcp-server-security-spring-boot (recommended)

The easiest way to add OAuth2 security to your MCP server is with the Boot auto-configuration module. It provides a default SecurityFilterChain that secures all endpoints, with no additional configuration required beyond setting the issuer URI.

Maven


    
        org.springaicommunity
        mcp-server-security-spring-boot
        0.1.14
    

Gradle

implementation("org.springaicommunity:mcp-server-security-spring-boot:0.1.14")

Then configure your application.properties:

spring.ai.mcp.server.name=my-cool-mcp-server
spring.ai.mcp.server.protocol=STREAMABLE

# The issuer URI of the authorization server
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:9000

That’s it. When spring.security.oauth2.resourceserver.jwt.issuer-uri is set, the auto-configuration creates a SecurityFilterChain that secures all endpoints using the McpServerOAuth2Configurer.

For a complete working example, see the

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →