Get the FREE Ultimate OpenClaw Setup Guide →

MCP_SERVER_JAVA

MCP server from cobra30299/MCP_SERVER_JAVA

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio cobra30299-mcp_server_java java -jar target/mcp-server-java-1.0.0.jar \
  --env AZURE_OPENAI_API_KEY="Your Azure OpenAI API key (set this if using ai_chat tool)"

How to use

This MCP server implements core Model Context Protocol features in Java, exposing a set of tools, resources, and prompts that can be used by clients or the MCP Inspector. Available tools include add (adds two numbers), multiply (multiplies two numbers), get_current_time (returns the server time), greet (greets a person by name), and ai_chat (interfaces with an Azure AI Foundry agent for AI-powered responses). The server also provides resources such as server-info and documentation, plus prompts like math_helper and current_time to assist with common MCP interactions. You can test the HTTP endpoints to discover, call, and experiment with these tools, or use the MCP Inspector to validate responses and JSON schemas. To start, run the HTTP server and then interact with the endpoints such as /tools, /tools/add, /tools/multiply, /tools/time, /tools/greet, and /tools/ai_chat. The AI chat endpoint supports optional parameters like max_tokens and temperature to customize responses.

How to install

Prerequisites:

  • Java 17 or higher
  • Maven 3.6+ (for building the server)
  1. Clone the repository or download the source.
  2. Build the server with Maven:
mvn clean package

This will create an executable JAR at: target/mcp-server-java-1.0.0.jar

  1. Run the HTTP server:
java -jar target/mcp-server-java-1.0.0.jar --http
  1. (Optional) Start the server without HTTP to use STDIO mode if supported by your build, or run a Java client as described in the README.

  2. If you plan to use the ai_chat tool, export your Azure OpenAI API key in your environment, for example:

PowerShell:

$env:AZURE_OPENAI_API_KEY="YOUR_KEY_HERE"

Unix/Linux:

export AZURE_OPENAI_API_KEY="YOUR_KEY_HERE"
  1. Verify the server is running by accessing http://localhost:8080/tools or by using the MCP Inspector:
npx @modelcontextprotocol/inspector java -jar target/mcp-server-java-1.0.0.jar

Additional notes

Notes and tips:

  • The server exposes HTTP endpoints for each tool under /tools and offers endpoints to query server information and documentation.
  • If you configure AZURE_OPENAI_API_KEY, the ai_chat tool can forward prompts to the Azure AI Foundry agent for dynamic responses; ensure network access and API quotas fit your environment.
  • For debugging, the project uses SLF4J for logging; logs appear in stdout/stderr.
  • If you modify or extend tools/resources/prompts, rebuild with Maven to generate the updated JAR before running.
  • The README references several example commands; adapt the host/port and path as needed for your deployment.

Related MCP Servers

Sponsor this space

Reach thousands of developers