跪拜 Guibai
← All articles
Frontend · Backend · Java

One Annotation to Rule AI: um-sdk Turns Java Methods into MCP Tools

By 小巫编程室 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The project offers a practical template for making existing Java business code AI-callable without learning MCP from scratch, and its lightweight framework gives Western teams a concrete alternative to Spring for memory-constrained deployments. The honest SNAPSHOT and private-repo caveats set expectations that this is a personal toolkit to adapt, not a drop-in enterprise dependency.

Summary

um-sdk, published on Gitee under Apache-2.0, collects the repetitive scaffolding every Java project needs into one dependency and adds an AI-native layer. A single @McpTool annotation exposes a business method as a callable tool for Cursor, Claude, or any MCP-compatible client, with Stdio, HTTP, and Embedded transports. The package also includes um-agent, which abstracts five LLM platforms, supports streaming, memory, and multi-model routing to cut costs by sending different task types to cheaper models.

The project is organized around two host stacks. um-spring-starter drops into existing Spring Boot apps without changing architecture, while um-ultra-starter is a zero-framework-dependency IoC/AOP container with millisecond startup and tens of megabytes of memory, designed for edge devices, CLI tools, and Serverless functions. The core modules include um-util (20+ static utility classes), um-enums (internationalized, SPI-provided dynamic enums), um-epay, um-mail, um-mcp, and um-agent. A unified cache module, um-ultra-cache, exposes one interface for memory, Redis, and MongoDB with built-in anti-cache-breakdown logic and an escape hatch to the native client.

The author, a decade-plus Java developer, explicitly lists the downsides: the version is still SNAPSHOT, artifacts live on a private Nexus repository (though the source is open), um-ultra's ecosystem is far smaller than Spring's, the community is tiny, and there is a learning curve for the Plugin SPI extension mechanism. The open code lets teams build locally if they cannot access the private Maven repo.

Takeaways
— um-sdk turns a Java method into an AI-callable MCP tool with one @McpTool annotation and required @McpParam descriptions.
— Three MCP transports are supported: Stdio for direct Cursor/Claude calls, HTTP for shared multi-agent services, and Embedded for in-process local testing.
— The um-agent module abstracts five LLM platforms, letting you switch from DeepSeek to OpenAI by changing a single line in the builder.
— Multi-model routing in um-agent can direct math questions to DeepSeek, code tasks to gpt-4o, and small talk to a mini model to reduce LLM costs.
— um-ultra provides a Spring-like IoC/AOP container with Netty HTTP, MyBatis-Plus, cache, and Nacos support, with millisecond startup and tens of MB memory, depending only on snakeyaml and asm.
— um-enums supports internationalized descriptions and SPI-driven dynamic enum values loaded at runtime from a database, so adding an order status no longer requires a code release.
— um-ultra-cache unifies memory, Redis, and MongoDB behind one UCache interface; getOrLoad prevents cache breakdown with distributed locks or Caffeine atomic operations.
— The current version is 1.3.21-SNAPSHOT and artifacts are hosted on a private Nexus repo at nexus.umnet.com.cn, so external teams should clone and build from Gitee or wait for a formal release.
— The um-ultra framework deliberately copies Spring annotation names (@Controller, @Inject, @Transactional, @Value) to minimize migration effort.
— The author recommends Spring as the primary stack for complex enterprise scenarios, positioning um-ultra as a lightweight alternative for edge, CLI, and Serverless cases.
Conclusions

The annotation-driven MCP layer shifts the burden from protocol plumbing to writing good description fields, which means the quality of AI-integrated Java systems now depends on how well developers write plain-language documentation for their own methods.

Offering both a Spring add-on and a standalone ultralight framework in the same SDK is a smart gamble: it lets teams adopt the AI bridge without committing to a full framework replacement.

A solo developer maintaining a broad toolkit (utilities, enums, payment, mail, cache, MCP, agent) will have difficulty matching the reliability guarantees that teams behind Hutool or Spring provide, regardless of how well the individual modules are designed.

The private Nexus repository is a practical obstacle for Western teams; despite being open source, the default Maven coordinates point to a non-public URL, so adoption requires either access or a self-build step.

Concepts & terms
MCP (Model Context Protocol)
An open standard that lets large language models call external tools and resources. It defines how AI clients like Cursor or Claude discover and invoke tools exposed by a server, analogous to how USB standardizes device connections.
McpTool annotation
A Java annotation in um-sdk that marks a method as an AI-callable tool. The method's name and description are passed to the LLM, and its parameters are defined with @McpParam, so the model knows when and how to call it.
Stdio transport
An MCP transport that communicates over standard input/output, used when a single AI client launches the tool server as a subprocess. It is simpler than HTTP but does not allow sharing across multiple clients.
SPI (Service Provider Interface)
A Java mechanism for runtime discovery and loading of implementations. um-enums uses SPI with an EnumProvider interface to let enums pull values from databases or config centers at runtime without code changes or redeployment.
Cache breakdown (击穿)
A cache failure scenario where a hot key expires and many requests simultaneously hit the underlying database. um-ultra-cache prevents it with getOrLoad, which uses a distributed lock on Redis or atomic operations on Caffeine to ensure only one load happens.
Plugin SPI
um-ultra's extension mechanism built on Java SPI, allowing modules like um-ultra-web, um-ultra-db, um-ultra-cache, and um-ultra-nacos to be assembled on demand into a lightweight framework without requiring a full Spring dependency.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗