{"id":26641103,"url":"https://github.com/dreamcenter/springboot-mcpserver-junit","last_synced_at":"2026-04-17T12:33:57.863Z","repository":{"id":283788129,"uuid":"952443955","full_name":"dreamcenter/springboot-MCPserver-JUnit","owner":"dreamcenter","description":"A template idea project by springboot、mcp、junit. Available for both stdio and sse mode.","archived":false,"fork":false,"pushed_at":"2025-03-22T06:41:59.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T07:27:05.679Z","etag":null,"topics":["junit","mcp","spring-boot","sse","stdio"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dreamcenter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-21T09:39:05.000Z","updated_at":"2025-03-22T06:53:00.000Z","dependencies_parsed_at":"2025-03-22T07:27:13.418Z","dependency_job_id":"2eb19fef-4b03-46eb-9c0e-4581bef076dd","html_url":"https://github.com/dreamcenter/springboot-MCPserver-JUnit","commit_stats":null,"previous_names":["dreamcenter/springboot-mcpserver-junit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dreamcenter/springboot-MCPserver-JUnit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamcenter%2Fspringboot-MCPserver-JUnit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamcenter%2Fspringboot-MCPserver-JUnit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamcenter%2Fspringboot-MCPserver-JUnit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamcenter%2Fspringboot-MCPserver-JUnit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dreamcenter","download_url":"https://codeload.github.com/dreamcenter/springboot-MCPserver-JUnit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamcenter%2Fspringboot-MCPserver-JUnit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268625009,"owners_count":24280188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["junit","mcp","spring-boot","sse","stdio"],"created_at":"2025-03-24T18:19:45.152Z","updated_at":"2026-04-17T12:33:57.832Z","avatar_url":"https://github.com/dreamcenter.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Springboot + MCP + JUnit 模板项目\n\n\u003chr/\u003e\n\n\u003e使用springboot快速构建一个mcp项目，项目支持 JUNIT单元测试。\n\u003e \n\u003e模式支持： **STDIO** 和 **SSE**\n\n\n\u003e **解说视频：**\n\u003e * 全网首发：从零搭建 Springboot+MCP+JUnit 项目 【搭配CherryStudio】[BV1qUXkYRE6C](https://www.bilibili.com/video/BV1qUXkYRE6C)\n\u003e * 全网首发：Springboot+MCP(SSE)+JUnit 从搭建到上线  [BV1rSXWYGEVz](https://www.bilibili.com/video/BV1rSXWYGEVz)\n\n\u003chr/\u003e\n\n### 开发环境\n\n- 开发IDE: IDEA\n- java版本: JAVA17 (Spring官方要求必须java17+)\n- maven版本: 3.8.1 (太高引入项目时可能报错，请选择适当版本)\n\n### 参考文档资料\n1. [MCP官网-协议](https://spec.modelcontextprotocol.io) (必读文档)\n2. [MCP官网-编码指南](https://modelcontextprotocol.io/quickstart/server)\n3. [Spring官网](https://docs.spring.io/spring-ai/reference/api/mcp/mcp-server-boot-starter-docs.html)\n\n\n### 客户端测试方案\n\n#### 1. 对于STDIO客户端配置方式：\n```text\n命令(Command)：\n    java\n参数(Arguments)：\n    -jar\n    -Dfile.encoding=UTF-8\n    -Dspring.ai.mcp.server.stdio=true\n    AbsolutePath/**/xxx.jar\n环境(Environments)：\n    env1=xxx\n    env2=yyy\n```\n指令是java（如果本地主环境不是17+，注意切换）；\n\n参数file.encoding指定System.in和System.out为UTF-8编码，避免编码问题；\n\n参数spring.ai.mcp.server.stdio表示以stdio的方式启用该服务；\n\n环境配置，是将配置写入当前系统环境，以供当前程序调取。\n\n\u003cbr/\u003e\n\n#### 2. 对于SSE客户端配置方式：\n```text\nSSE地址填写如下链接即可\nhttp://主机地址:端口/sse\n```\n\n\n\u003chr/\u003e\n\n### 额外可选功能的探索\n#### 1. 修改消息端点\n配置文件参见：McpServerProperties\n```yaml\nspring.ai.mcp.server.sseMessageEndpoint=/mcp/message\n```\n#### 2. 修改sse端点\n原始的sse端点在/sse，而配置文件没有提供sse端点的配置方式，所以需要重新注入 **ServerMcpTransport** 来换掉原来的。\n\n注意下面两个Bean配置都要加，因为自动注入文件 **MpcWebMvcServerAutoConfiguration** 中，对整个注册的注入条件是\n@ConditionalOnMissingBean(ServerMcpTransport.class)，导致下面两个bean都不会注入\n\n\n```java\nprivate final String SSE_ENDPOINT = \"/sse\";\n\n@Bean\n@ConditionalOnMissingBean\npublic WebMvcSseServerTransport webMvcSseServerTransport(ObjectMapper objectMapper,\n        McpServerProperties serverProperties) {\n    return new WebMvcSseServerTransport(objectMapper, serverProperties.getSseMessageEndpoint(), SSE_ENDPOINT);\n}\n\n@Bean\npublic RouterFunction\u003cServerResponse\u003e mvcMcpRouterFunction(WebMvcSseServerTransport transport) {\n    return transport.getRouterFunction();\n}\n```\n\n#### 3. 一服务多端点？\n需要重新注入多个 **McpSyncServer** ，详见类 **MpcServerAutoConfiguration** 。\n\n因为多端点可能会涉及到的东西非常多，感兴趣的可以自己研究，我就只提供这样的指引啦！\n\n#### 4. SSE授权？\n在2025.03.26 的MCP官方协议文档中，更新了鉴权方案，\n期待Spring的更新。\n\n\n\u003cbr/\u003e\n\u003chr/\u003e\n\nBye.ヾ(•ω•`)o","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamcenter%2Fspringboot-mcpserver-junit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdreamcenter%2Fspringboot-mcpserver-junit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamcenter%2Fspringboot-mcpserver-junit/lists"}