tersePrompts/fastMCP4J logo

tersePrompts/fastMCP4J

Free

Java 语言构建 MCP 服务器的轻量级注解驱动框架,JSON Schema 2020-12 兼容,安全、快速、零配置。

FreeFree tier
Type
Open Source
Company
tersePrompts

About tersePrompts/fastMCP4J

fastMCP4J is an open-source Java library designed for building Model Context Protocol (MCP) servers using a lightweight, annotation-driven approach. It provides a minimal dependency footprint (12 dependencies) and enables developers to expose Java methods as AI-accessible tools with just a few annotations. The framework is JSON Schema 2020-12 compliant, supports multiple transport modes (stdio, SSE, streamable), and includes built-in modules for memory, task management, planning, and file operations. It offers fast startup times (~500ms cold start) and low memory usage (~64MB), making it suitable for integrating Java applications with AI agents.

Key Features

Annotation-driven development with @McpServer, @McpTool, @McpParam, and @McpAsync
Multiple transport support: stdio, SSE, and streamable HTTP
Built-in tools via @McpMemory, @McpTodo, @McpPlanner, @McpFileRead, @McpFileWrite – zero implementation required
Multi-class module support and package scanning for automatic tool discovery
JSON Schema 2020-12 compliant for tool parameter validation
Lightweight: only 12 dependencies, no container required
Fast cold start (~500ms) and low memory footprint (~64MB)
Secure design with minimal attack surface
Compatible with existing Java projects (Spring etc.) without framework lock-in

Pros & Cons

Pros
  • Extremely easy to use: just annotate and run with minimal boilerplate
  • Very small dependency footprint compared to similar frameworks
  • Fast startup and low memory consumption ideal for cloud/container deployments
  • Built-in high-level tools (memory, todo, planner, file I/O) reduce development effort
  • Flexible transport options (stdio, SSE, streamable HTTP)
  • Supports asynchronous tool execution with progress reporting via @McpAsync and @McpContext
  • Multi-class modular organization and package scanning for scalability
Cons
  • Currently in beta release (v0.3.1-beta), API may change
  • Limited community adoption (small number of stars and forks on GitHub)
  • Java-only solution; not usable from other JVM languages without Java interop
  • Documentation is primarily the GitHub README and may lack extensive tutorials

Best For

Exposing Java methods as tools for AI agents (e.g., Claude, Copilot)Building MCP servers rapidly with minimal code and configurationAdding MCP capabilities to existing Spring Boot applicationsCreating lightweight, standalone MCP services for integration with AI platforms

FAQ

How do I get started with fastMCP4J?
Add the Maven or Gradle dependency (groupId: io.github.terseprompts.fastmcp, artifactId: fastmcp-java, version: 0.3.1-beta), then annotate a Java class with @McpServer and tool methods with @McpTool. Call FastMCP.server(MyClass.class).stdio().run() to start the server.
What transports are supported?
fastMCP4J supports stdio, SSE (Server-Sent Events), and streamable HTTP transports. You can choose by calling .stdio(), .sse(), or .streamable() on the server builder.
Can I use fastMCP4J with Spring?
Yes, fastMCP4J can be added to existing Spring applications as a drop-in dependency without framework lock-in.
How do I add built-in tools like memory or file reading?
Annotate your @McpServer class with @McpMemory, @McpTodo, @McpPlanner, @McpFileRead, or @McpFileWrite. These built-in modules are automatically activated with zero implementation.