MCP
how the Apihug support MCP,
Support for enterprise-level MCP, leveraging existing infrastructure and authorization protection.
Since SDK version 1.4.0-RELEASE
and IDEA plugin 0.7.5
, support for generating initial project templates is available.
Only enhancements applied to the MCP server side.
The Model Context Protocol (MCP) is a standardized protocol that enables AI models to interact with external tools and resources in a structured and consistent manner. It supports multiple transport mechanisms to ensure flexibility across various environments.
Please note that MCP is currently under rapid development. Concepts and APIs may change significantly, and backward compatibility cannot be guaranteed.
As this is an experimental feature, it must be enabled manually!
Currently, MCP alone does not meet enterprise-level requirements, such as strict access control,even after breaking changes introduced in MCP Java SDK 0.8.0
⚠️. To address this, ApiHug provides key enhancements:
Based on Spring AI, ApiHug introduces the following enhancements:
libs.versions.toml
apihugVersion
to 1.4.0-RELEASE
or later.springAiVersion
to 1.0.0
or later. If missing, add it.apihug-spring-ai-mcp = { group = "com.apihug", name = "it-common-spring-ai-mcp" }
spring-ai-bom = { group = "org.springframework.ai", name = "spring-ai-bom", version.ref = "springAiVersion" }
spring-ai-starter-mcp-server = { group = "org.springframework.ai", name = "spring-ai-starter-mcp-server" }
app
ModulehopeStub
: set enableMcp = true
// For MCP — current version under review
implementation(libs.apihug.spring.ai.mcp)
implementation platform(libs.spring.ai.bom)
implementation(libs.spring.ai.starter.mcp.server)
To extend hope.common.service.contract.ContractAdapter
, you need to define:
moduleClassName
: The runtime proto module class name (self-contained).mcp
: Controls service exposure via MCP — specifies which service exposes which method (API).contract
: Defines third-party module dependencies — which service depends on which method (API).Service Filter DSL:
return myModule.service()
.apiContext()
.orderService(
svc -> {
// Keep all the methods of this service
svc.keepAll();
// All the method start with, feel free try other shortcut
svc.startsWith("add");
// Pick method one by one
svc.methods(
methods -> {
// Include this method
methods.PlaceOrder();
// Exclude this method, start with `_`
methods._DeleteOrder();
});
})
.build();
Follow the official MCP Server Boot Starter documentation to enable the MCP server.
spring:
ai:
mcp:
server:
enabled: true
# default /sse
sse-endpoint: /api/mcp/sse
# default /mcp/message
sse-message-endpoint: /api/mcp/message
name: okai-app-mcp-server
stdio: false
hope:
ai:
mcp:
enabled: true
auth-key: token
For configuration details related to spring.ai.mcp.server
, please refer to the official documentation:
MCP Server Boot Starter - Configuration Properties.
Note: Please ensure that the SSE endpoint and message endpoint are configured using paths that align with your team’s best practices and standards.
The following two routes will be implemented:
GET
/api/mcp/sse
POST
/api/mcp/message
For instructions on how to perform local MCP testing, please refer to the Spring example:
spring-ai-examples - test - ClientSse.
Everything is set! Happy coding and enjoy your development! Bon appétit🍀
Upgrade your IDEA plugin to version 0.7.5
or later. Newly generated projects will include all necessary configurations automatically, eliminating the need for manual migration steps required by legacy projects.
TBD