Pure Java 21 MCP server

Pure Java 21 MCP server

mcp-server-example-aliaksandr-haurylau-godel•byaliaksandr-haurylau-godel

A from-scratch Model Context Protocol server written in Java 21 that communicates over STDIO using JSON-RPC 2.0 and exposes a basic echo tool.

License: Not specified•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Handles MCP core lifecycle requests including initialize, initialized, shutdown, and exit over a STDIO transport.
  • •Parses and serializes JSON-RPC 2.0 messages with Content-Length framing.
  • •Provides an echoTool that takes a message string and returns it prefixed with Echo.
  • •Logs server activity to a log file and to the console.

BEST FOR

  • •Developers wanting a minimal reference implementation of an MCP server without MCP-specific SDKs.
  • •Learning how MCP initialize, tool/call, and shutdown flows work over STDIO.
  • •Java developers experimenting with a simple echo-based tool server.

ABOUT MCP-SERVER-EXAMPLE-ALIAKSANDR-HAURYLAU-GODEL

Pure Java 21 MCP server is cataloged as an MCP server attributed to aliaksandr-haurylau-godel. A from-scratch Model Context Protocol server written in Java 21 that communicates over STDIO using JSON-RPC 2.0 and exposes a basic echo tool. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Pure Java 21 MCP server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

What MCP features does the server implement?

It implements STDIO transport, JSON-RPC 2.0, MCP core lifecycle requests (initialize, initialized, shutdown, exit), and a basic tool capability with the echoTool.

What does the echoTool do?

It takes a message string and returns it prefixed with Echo: in a response string.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 0330d670a294 · 采集于 2026-11-13 12:47:59 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

Pure Java 21 MCP Server

This project is an implementation of a Model Context Protocol (MCP) server in pure Java 21, strictly adhering to the (conceptual) 2025-03-26 MCP specification. It is built from scratch without external MCP-specific SDKs.

Prerequisites

  • Java 21 SDK: Ensure you have Java 21 (or later) installed and configured.
  • Gson Library: This server uses the Gson library for JSON parsing and serialization. You will need to download the Gson JAR file.
    • You can typically download it from Maven Central. Search for "Gson" or com.google.code.gson:gson. Download the JAR (e.g., gson-2.10.1.jar or a later version).
    • Place the downloaded Gson JAR (e.g., gson-2.10.1.jar) in a known location, for example, a lib directory within this project (lib/gson-2.10.1.jar). The compilation and run commands below assume this location.

Project Structure

  • src/: Contains the Java source code.
    • main/java/io/modelcontextprotocol/server/: Root package.
      • jsonrpc/: Classes for JSON-RPC message structures, parsing, and error handling.
      • messages/: Classes for MCP-specific message payloads (initialize, tool definitions, etc.).
      • tools/: Implementation of tools (e.g., EchoTool).
      • transport/: Transport layer handling (e.g., StdioTransport).
      • McpServer.java: Core server logic.
      • Main.java: Application entry point.
  • lib/: (Recommended) Create this directory to store the Gson JAR.
  • mcp-server.log: Log file generated by the server during operation.
  • .gitignore: Specifies intentionally untracked files that Git should ignore.
  • README.md: This file.

Compilation

  1. Create Directories:

    • Ensure you have a lib directory in the project root and place the Gson JAR file (e.g., gson-2.10.1.jar) there.
    • Create a bin directory in the project root to store the compiled class files:
      mkdir lib
      mkdir bin
      # Download Gson JAR and place it in lib/
      # For example: wget https://repo1.maven.org/maven2/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar -P lib/
      
  2. Compile the Server: Open a terminal or command prompt in the project's root directory. Adjust lib/gson-2.10.1.jar if you are using a different version or path for Gson.

    Nix (Linux/macOS):

    javac -d bin -cp "lib/gson-2.10.1.jar:src/main/java" $(find src/main/java -name "*.java")
    

    Windows (Command Prompt):

    javac -d bin -cp "lib\gson-2.10.1.jar;src\main\java" $(powershell -Command "(Get-ChildItem -Recurse -Filter *.java src\main\java | Select-Object -ExpandProperty FullName) -join ';' ")
    

    If the $(powershell ...) command doesn't work directly in cmd.exe, you might need to list the files manually or use a different approach:

    javac -d bin -cp "lib\gson-2.10.1.jar;src\main\java" src\main\java\io\modelcontextprotocol\server\*.java src\main\java\io\modelcontextprotocol\server\jsonrpc\*.java src\main\java\io\modelcontextprotocol\server\messages\*.java src\main\java\io\modelcontextprotocol\server	ools\*.java src\main\java\io\modelcontextprotocol\server	ransport\*.java
    

    (Ensure all package paths are included if manually listing files).

Running the Server

After successful compilation, run the server from the project's root directory:

Nix (Linux/macOS):

java -cp "bin:lib/gson-2.10.1.jar" io.modelcontextprotocol.server.Main

Windows (Command Prompt):

java -cp "bin;lib\gson-2.10.1.jar" io.modelcontextprotocol.server.Main

The server will start and listen for JSON-RPC messages on standard input (STDIO).

Implemented Features

  • Transport: STDIO (Content-Length header framed messages).
  • JSON-RPC: Version 2.0 message parsing and serialization.
  • MCP Core:
    • initialize request: Server responds with its capabilities.
    • initialized notification: Client confirms initialization.
    • shutdown request: Server acknowledges and prepares to exit.
    • exit notification: Server terminates.
  • Tools:
    • Basic "Tool" capability.
    • tool/call request for the echoTool.
    • echoTool: A simple tool that echoes a message.
      • Input schema: { "type": "object", "properties": { "message": { "type": "string" } } }
      • Output schema: { "type": "object", "properties": { "response": { "type": "string" } } }
  • Logging: Server activity is logged to mcp-server.log (FINE level and above) and to the console (INFO level and above).

Example Interaction (via STDIO)

Messages are framed with Content-Length and \r\n\r\n before the JSON body.

1. Client -> Server: initialize Request

Content-Length: 123

{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"processId":1234,"capabilities":{}}}

(Note: params content like processId and capabilities are illustrative for initialize but are currently ignored by this server.)

2. Server -> Client: initialize Response

Content-Length: 297

{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"tools":[{"name":"echoTool","description":"A simple tool that takes a 'message' string and returns it prefixed with 'Echo: '.","inputSchema":{"type":"object","properties":{"message":"string"}},"outputSchema":{"type":"object","properties":{"response":"string"}}}]}}}

(Actual Content-Length will vary based on exact formatting. The server calculates this.)

3. Client -> Server: initialized Notification

Content-Length: 40

{"jsonrpc":"2.0","method":"initialized"}

(No id for notifications. Server does not respond.)

4. Client -> Server: tool/call for echoTool

Content-Length: 107

{"jsonrpc":"2.0","id":2,"method":"tool/call","params":{"toolName":"echoTool","params":{"message":"Hello MCP!"}}}

5. Server -> Client: tool/result Response

Content-Length: 74

{"jsonrpc":"2.0","id":2,"result":{"response":"Echo: Hello MCP!"}}

6. Client -> Server: shutdown Request

Content-Length: 49

{"jsonrpc":"2.0","id":3,"method":"shutdown","params":{}}

7. Server -> Client: shutdown Response

Content-Length: 34

{"jsonrpc":"2.0","id":3,"result":null}

8. Client -> Server: exit Notification

Content-Length: 36

{"jsonrpc":"2.0","method":"exit","params":{}}

(Server then terminates. No response.)

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Pure Java 21 MCP server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-server-example-aliaksandr-haurylau-godel)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools