A Model Context Protocol (MCP) server built with SpringBoot and SpringAI, providing AI-powered tools and resources through a standardized protocol interface.
- MCP Protocol Compliance: Full implementation of the Model Context Protocol specification
- AI-Powered Tools: Text generation and data analysis using SpringAI
- RESTful API: HTTP-based MCP communication
- Extensible Architecture: Easy to add new tools and resources
- Production Ready: Built with SpringBoot best practices
Generate text content using AI based on prompts.
Parameters:
prompt(string, required): The text prompt to generate content frommaxTokens(integer, optional): Maximum number of tokens to generate (default: 100)
Generate optic code snippets for data transformation - inspired by Rush's many talents.
Parameters:
schema(string, optional): The schema name to use in the optic code (default: "schema")view(string, optional): The view name to use in the optic code (default: "view")
Verify optic code for syntax and logical correctness (rebellious random verification).
Parameters:
optic_code(string, required): The optic code to verify for syntax and validity
Help you out with MarkLogic documentation and guidance.
Parameters:
prompt(string, required): The user prompt describing what MarkLogic help you need
mcp://server/info: Server information and capabilitiesmcp://tools/examples: Examples of how to use the available tools
- Java 17 or higher
- Gradle 8.5 or higher
./gradlew buildTo enable AI features, you have several options for configuring your Azure OpenAI credentials:
Create a .env file in the project root directory:
# Azure OpenAI Configuration - Keep this file secret!
AZURE_OPENAI_API_KEY=your-azure-openai-api-key
AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com/
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-35-turboImportant: The .env file is automatically ignored by git and won't be committed to version control.
export AZURE_OPENAI_API_KEY=your-azure-openai-api-key
export AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com/
export AZURE_OPENAI_DEPLOYMENT_NAME=gpt-35-turboSet your credentials directly in src/main/resources/application.properties:
spring.ai.azure.openai.api-key=your-azure-openai-api-key
spring.ai.azure.openai.endpoint=https://your-resource-name.openai.azure.com/
spring.ai.azure.openai.chat.options.deployment-name=gpt-35-turbo
spring.ai.azure.openai.chat.options.model=gpt-3.5-turbo./gradlew bootRunThe server will start on http://localhost:8080
Check server health:
curl -s http://localhost:8080/mcp/health | jq .Get server capabilities:
curl -s http://localhost:8080/mcp/capabilities | jq .The MCP server can be easily containerized and deployed using Docker. The build uses Spring Boot's Cloud Native Buildpacks for optimized, production-ready images.
Build the Docker image using Gradle's bootBuildImage task:
./gradlew clean bootBuildImageThis will create a Docker image named epic-mcp-server:latest (approximately 293MB) optimized for x86_64 architecture.
Start the containerized MCP server using Docker Compose:
docker compose upOr run in the background:
docker compose up -dThe server will be available at http://localhost:8080
Once the container is running, test the MCP server with these curl commands:
curl -s http://localhost:8080/mcp/healthcurl -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' \
http://localhost:8080/mcpcurl -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"generate_text","arguments":{"prompt":"Write a haiku about Docker containers","maxTokens":50}}}' \
http://localhost:8080/mcpcurl -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"optic_code_generator","arguments":{"prompt":"Create optic code to read user profiles from the database"}}}' \
http://localhost:8080/mcpTo stop the Docker container:
docker compose downYou can also run the image directly with Docker:
# Run the container directly
docker run -p 8080:8080 epic-mcp-server:latest
# Run in the background
docker run -d -p 8080:8080 --name epic-mcp-server epic-mcp-server:latest
# Stop the container
docker stop epic-mcp-server
docker rm epic-mcp-server✅ MCP Server Working: The server implements the full MCP protocol and responds to all tool calls
✅ Mock AI Responses: Tools provide mock responses when AI is not configured
The server is fully functional for MCP protocol testing. All tools work with mock responses. MCP Tool Calls
curl -s -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "tools/list",
"params": {}
}' | jq .curl -s -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "2",
"method": "tools/call",
"params": {
"name": "generate_text",
"arguments": {
"prompt": "Write a haiku about coding",
"maxTokens": 50
}
}
}' | jq .curl -s -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "3",
"method": "resources/list",
"params": {}
}' | jq .curl -s -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "4",
"method": "resources/read",
"params": {
"uri": "mcp://tools/examples"
}
}' | jq .curl -s -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "0",
"method": "initialize",
"params": {}
}' | jq .POST /mcp
{
"jsonrpc": "2.0",
"id": "1",
"method": "initialize",
"params": {}
}POST /mcp
{
"jsonrpc": "2.0",
"id": "2",
"method": "tools/list",
"params": {}
}POST /mcp
{
"jsonrpc": "2.0",
"id": "3",
"method": "tools/call",
"params": {
"name": "generate_text",
"arguments": {
"prompt": "Write a haiku about programming",
"maxTokens": 50
}
}
}POST /mcp
{
"jsonrpc": "2.0",
"id": "4",
"method": "resources/list",
"params": {}
}POST /mcp
{
"jsonrpc": "2.0",
"id": "5",
"method": "resources/read",
"params": {
"uri": "mcp://server/info"
}
}- Update the
listTools()method inMcpServiceto include your new tool - Add a case for your tool in the
callTool()method - Implement the tool logic as a private method
- Update the
listResources()method inMcpService - Add a case for your resource in the
readResource()method - Implement the resource reading logic
./gradlew testsrc/
├── main/
│ ├── java/com/example/mcpserver/
│ │ ├── controller/ # REST API controllers
│ │ ├── model/ # MCP protocol models
│ │ ├── service/ # Business logic
│ │ └── McpServerApplication.java
│ └── resources/
│ └── application.properties
└── test/
└── java/com/example/mcpserver/
└── McpServerApplicationTests.java
Key configuration options in application.properties:
server.port: Server port (default: 8080)spring.ai.azure.openai.api-key: Azure OpenAI API key for AI featuresspring.ai.azure.openai.endpoint: Azure OpenAI service endpointspring.ai.azure.openai.chat.options.deployment-name: Your deployment namespring.ai.azure.openai.chat.options.model: AI model to use- Logging levels for debugging
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License.