MCP
Expose ApiHug services through MCP while keeping enterprise authorization and service boundaries intact.
ApiHug MCP support is an enterprise-oriented adapter layer for exposing existing services through the Model Context Protocol without abandoning the project’s existing authorization and service model.
ApiHug adds MCP-specific integration on top of the normal application stack:
Raw MCP support is useful, but enterprise systems usually need more than a bare protocol endpoint. ApiHug focuses on the missing pieces:
For older projects, enable MCP in three places.
Add or update the MCP-related entries in libs.versions.toml:
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" }Turn on MCP support in hopeStub and add the runtime dependencies:
hopeStub {
enableMcp = true
}
dependencies {
implementation(libs.apihug.spring.ai.mcp)
implementation platform(libs.spring.ai.bom)
implementation(libs.spring.ai.starter.mcp.server)
}
Extend hope.common.service.contract.ContractAdapter and describe:
moduleClassName for the runtime proto modulemcp exposure rules for services and methodscontract dependencies on third-party modulesExample service filter DSL:
return myModule.service()
.apiContext()
.orderService(
svc -> {
svc.keepAll();
svc.startsWith("add");
svc.methods(
methods -> {
methods.PlaceOrder();
methods._DeleteOrder();
});
})
.build();
spring:
ai:
mcp:
server:
enabled: true
sse-endpoint: /api/mcp/sse
sse-message-endpoint: /api/mcp/message
name: okai-app-mcp-server
stdio: false
hope:
ai:
mcp:
enabled: true
auth-key: token
That exposes two main routes:
GET /api/mcp/ssePOST /api/mcp/messageNewer project templates can include this wiring for you. Older projects need the migration steps above.