imc-accident-mcp-server

dbbaskette/imc-accident-mcp-server

3.2

If you are the rightful owner of imc-accident-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The IMC Accident MCP Server is a Model Context Protocol server designed to manage accident and customer data within the IMC ecosystem, utilizing Spring AI and Spring Boot.

Tools
2
Resources
0
Prompts
0

IMC Accident MCP Server

A Model Context Protocol (MCP) server for managing accident and customer data within the IMC ecosystem, built with Spring AI and Spring Boot.

License: MIT Java 21+ Maven 3.6+

This server provides a foundation for building MCP-enabled applications that interact with accident and customer-related functionalities. It supports both STDIO transport (for Claude Desktop integration) and SSE transport (for web-based clients).

For more information on the underlying framework, see the MCP Server Boot Starter reference documentation.

๐Ÿ“œ Table of Contents

โœจ Overview

This IMC Accident MCP server demonstrates:

  • Integration with spring-ai-mcp-server-webflux-spring-boot-starter for MCP capabilities.
  • Dual transport support: STDIO (for CLI/desktop clients like Claude Desktop) and SSE (Server-Sent Events for web-based clients).
  • Automatic tool registration using Spring AI's @Tool annotation, enabling AI models to interact with accident and customer data.
  • Clean separation of concerns with a dedicated ToolsService for business logic.
  • Production-ready logging configuration.
  • Comprehensive test coverage.

๐Ÿ› ๏ธ Available Tools

This server exposes tools that can be invoked by an AI model to query customer and accident information:

๐Ÿ‘ค queryCustomer

  • Description: Query customer information by customer ID. Returns customer contact details and address.
  • Parameters:
    • customerId (Integer): The customer ID to search for.
  • Example: queryCustomer(123)

๐Ÿ’ฅ queryAccidents

  • Description: Query accident information by customer ID. Returns all accidents where the customer was the driver.
  • Parameters:
    • customerId (Integer): The customer ID (driver ID) to search accidents for.
  • Example: queryAccidents(123)

๐Ÿš€ Quick Start

Prerequisites

  • Java 21+
  • Maven 3.6+

Building the Project

./mvnw clean install

Running the Server

For Claude Desktop (STDIO Mode)
java -Dspring.profiles.active=stdio -jar target/mcp-server-0.0.1-SNAPSHOT.jar
For Web Clients (SSE Mode - Default)
java -jar target/mcp-server-0.0.1-SNAPSHOT.jar

Server will be available at http://localhost:8080/mcp/message

Testing the Server

Use the included test script:

# Test STDIO mode
./test-mcp.sh --stdio --test-tools

# Test SSE mode
./test-mcp.sh --sse --test-tools

# Build and test both modes
./test-mcp.sh --build --both --test-tools

๐Ÿค– Claude Desktop Integration

1. Add to Claude Desktop Configuration

Add this to your Claude Desktop claude_desktop_config.json:

{
  "mcpServers": {
    "mcp-server": {
      "command": "java",
      "args": [
        "-Dspring.profiles.active=stdio",
        "-jar",
        "/absolute/path/to/mcp-server/target/mcp-server-0.0.1-SNAPSHOT.jar"
      ]
    }
  }
}

2. Restart Claude Desktop

The tools capitalizeText and calculate will be available for use.

3. Test the Tools

Try asking Claude Desktop:

  • "Query customer with ID 1"
  • "Find accidents for customer ID 2"

โš™๏ธ Configuration

The server uses profile-based configuration:

STDIO Profile (application-stdio.properties)

# STDIO Transport for Claude Desktop
spring.ai.mcp.server.stdio=true
spring.main.web-application-type=none
spring.main.banner-mode=off

# Logging to file only (console interferes with MCP protocol)
logging.level.root=OFF
logging.config=classpath:logback-stdio.xml

SSE Profile (application-sse.properties)

# SSE Transport for Web Clients
spring.ai.mcp.server.stdio=false
server.port=8080

# MCP endpoint
spring.ai.mcp.server.sse-message-endpoint=/mcp/message

๐Ÿ—๏ธ Architecture

Core Components

  • McpServerApplication: Main Spring Boot application with tool registration.
  • ToolsService: Service containing MCP tools with @Tool annotations, where accident and customer-related business logic would reside.
  • Transport Layer: Automatic Spring AI MCP transport configuration.
  • Configuration: Profile-based setup for different deployment modes.

Project Structure

src/
โ”œโ”€โ”€ main/java/com/baskettecase/mcpserver/
โ”‚   โ”œโ”€โ”€ McpServerApplication.java      # Main application
โ”‚   โ”œโ”€โ”€ ToolsService.java              # MCP tools implementation (e.g., for accident/customer data)
โ”‚   โ””โ”€โ”€ model/
โ”‚       โ”œโ”€โ”€ Accident.java              # Data model for Accident entity
โ”‚       โ””โ”€โ”€ Customer.java              # Data model for Customer entity
โ”œโ”€โ”€ main/resources/
โ”‚   โ”œโ”€โ”€ application.properties         # Base configuration
โ”‚   โ”œโ”€โ”€ application-stdio.properties   # STDIO transport config
โ”‚   โ”œโ”€โ”€ application-sse.properties   # SSE transport config
โ”‚   โ””โ”€โ”€ logback-stdio.xml              # STDIO logging config
โ””โ”€โ”€ test/java/
    โ”œโ”€โ”€ ToolsServiceTest.java          # Comprehensive tool tests
    โ””โ”€โ”€ org/springframework/ai/mcp/sample/client/
        โ”œโ”€โ”€ SampleClient.java          # Example MCP client
        โ”œโ”€โ”€ ClientStdio.java           # STDIO client example
        โ””โ”€โ”€ ClientSse.java             # SSE client example

๐Ÿ› ๏ธ Development

Adding New Tools

Add methods to ToolsService with the @Tool annotation to expose new functionalities to the AI model:

@Tool(description = "Your tool description")
public String yourTool(String parameter) {
    // Your implementation for accident/customer data interaction
    return "result";
}

Running Tests

./mvnw test

Viewing Logs

  • STDIO mode: Logs go to /tmp/mcp-server-stdio.log
  • SSE mode: Logs go to console and ./target/mcp-server-sse.log

๐Ÿงช Client Examples

Manual MCP Client (STDIO)

var stdioParams = ServerParameters.builder("java")
    .args("-Dspring.profiles.active=stdio", "-jar", "target/mcp-server-0.0.1-SNAPSHOT.jar")
    .build();

var transport = new StdioClientTransport(stdioParams);
var client = McpClient.sync(transport).build();

Manual MCP Client (SSE)

var transport = new WebFluxSseClientTransport(
    WebClient.builder().baseUrl("http://localhost:8080"));
var client = McpClient.sync(transport).build();

๐Ÿ“ฆ Dependencies

Key dependencies include:

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-mcp-server-webflux-spring-boot-starter</artifactId>
    <version>1.1.0-SNAPSHOT</version>
</dependency>

This starter provides:

  • Reactive and STDIO transport support
  • Auto-configured MCP endpoints
  • Tool callback registration
  • Spring WebFlux integration

๐Ÿค Contributing

This project serves as a foundation for the IMC Accident MCP server. Feel free to:

  • Add new tools to ToolsService for accident and customer management.
  • Extend transport configurations.
  • Improve test coverage.
  • Add new MCP capabilities.

๐Ÿ“š Additional Resources

License

This project is provided as-is for educational and development purposes.