A simple Model Context Protocol (MCP) stdio server implementing a calculator tool.
# Build the project
./gradlew build
# Run the server
java -jar build/libs/JaviMcp-1.0-SNAPSHOT.jarThe server implements a simple MCP protocol with a calculator tool that supports addition, subtraction, multiplication, and division operations.
On startup, the server sends an initialization message defining the available tools:
{
"type": "init",
"version": "1",
"tools": {
"calculator": {
"description": "A simple calculator tool",
"params": {
"operation": {
"type": "string",
"description": "Operation to perform: add, subtract, multiply, or divide"
},
"a": {
"type": "number",
"description": "First operand"
},
"b": {
"type": "number",
"description": "Second operand"
}
}
}
}
}To use the calculator tool, send a request in the following format:
{
"id": "request-id",
"type": "tool_call",
"params": {
"name": "calculator",
"params": {
"operation": "add",
"a": 5,
"b": 3
}
}
}The server will respond with:
{
"id": "request-id",
"type": "tool_response",
"status": "success",
"result": 8
}In case of an error:
{
"id": "request-id",
"type": "tool_response",
"status": "error",
"error": "Error message"
}echo '{"id":"123","type":"tool_call","params":{"name":"calculator","params":{"operation":"add","a":5,"b":3}}}' | java -jar build/libs/JaviMcp-1.0-SNAPSHOT.jarExpected output:
{"type":"init","version":"1","tools":{"calculator":{"description":"A simple calculator tool","params":{"operation":{"type":"string","description":"Operation to perform: add, subtract, multiply, or divide"},"a":{"type":"number","description":"First operand"},"b":{"type":"number","description":"Second operand"}}}}}
{"id":"123","type":"tool_response","status":"success","result":8.0}
This project also includes an AskGemini tool for intelligent project analysis powered by Google Gemini AI. The tool provides:
- Intelligent Code Analysis: Ask questions about project architecture, design patterns, security, and performance
- Configuration-Driven File Selection: Customize which files to analyze via
AskGemini.config - External File Integration: Include files outside the project directory (configs, logs, documentation)
- Comprehensive Logging: Track all analysis interactions with detailed context
- Flexible Analysis Modes: Source-only or comprehensive file analysis
{
"project_folder": "/path/to/your/project",
"question": "What is the main purpose of this application?",
"context": "This is a microservice for user authentication",
"extra_files": "/etc/config.yml;../deployment/docker-compose.yml"
}- Complete Guide: See ASK_GEMINI_DOCUMENTATION.md for comprehensive usage examples, configuration options, and best practices
- Example Configuration: See example-AskGemini.config for a sample configuration file with detailed comments
The AskGemini tool is perfect for:
- Code reviews and security analysis
- Understanding unfamiliar codebases
- Architecture documentation and analysis
- Performance optimization recommendations
- Migration planning and dependency analysis