Cars MCP Server
Basic MCP server example with Spring AI
amarpreetbhatia
README
Cars MCP Server
This is an MCP (Model Context Protocol) server built using Spring AI. The project demonstrates the use of Spring AI's ToolCallback
API to expose tools for interacting with a list of cars, which represents Amarpreet's wishlist.
Demo
Project Structure
The project is organized as follows:
-
src/main/java/com/amarpreet/carsmcpserver/
CarsmcpserverApplication.java
: The main entry point of the Spring Boot application. It initializes the application and registers theToolCallback
beans using theCarService
class.Car.java
: A simplerecord
class representing a car with two fields:modelName
andbuildYear
.CarService.java
: A service class that provides methods to interact with the list of cars. These methods are exposed as tools using theToolCallback
API.
-
src/main/resources/application.properties
: Contains configuration properties for the Spring Boot application. -
src/test/java/com/amarpreet/carsmcpserver/
CarsmcpserverApplicationTests.java
: Contains a basic test to ensure the application context loads correctly.
ToolCallback API
The ToolCallback
API is used to expose methods from the CarService
class as tools. These tools can be invoked programmatically or through an AI-driven interface. The CarsmcpserverApplication
class registers these tools using the ToolCallbacks.from()
method.
Tool Registration
In CarsmcpserverApplication.java
:
@Bean
public List<ToolCallback> amarpreetTools(CarService carService) {
return List.of(ToolCallbacks.from(carService));
}
This registers all methods annotated with @Tool
in the CarService
class as ToolCallback
instances.
CarService
The CarService
class is the core of this application. It manages a list of cars and provides the following methods:
Methods in CarService
getCars()
- Tool Name:
get_cars
- Description: Retrieves the list of cars in Amarpreet's wishlist.
- Return Type:
List<Car>
getCar(String name)
- Tool Name:
get_car_by_name
- Description: Finds a car by its model name.
- Parameters:
name
- The model name to search for.
- Return Type:
Car
(ornull
if not found)
getCarByYear(Integer year)
- Tool Name:
get_car_by_years
- Description: Finds a car by its build year.
- Parameters:
year
- The build year to search for.
- Return Type:
Car
(ornull
if not found)
Initialization
The CarService
class initializes a list of cars during application startup using the @PostConstruct
annotation:
public void init() {
log.info("Initializing cars MCP server...");
cars.addAll(List.of(
new Car("BMW Neue Klasse", 2025),
new Car("Ferrari EV", 2025),
new Car("Mercedes AMG 4dr EV", 2025),
new Car("Porsche 718 Boxster", 2025)
));
}
How to Run
Build the project using Maven:
mvn clean install
Run the application:
java -jar target/carsmcpserver-0.0.1-SNAPSHOT.jar
Configuration
The application can be configured using the application.properties
file located in src/main/resources
. Key properties include:
spring.application.name
: The name of the application.spring.main.web-application-type
: Set tonone
for a non-web application.spring.ai.mcp.server
: The name of the MCP server.spring.ai.mcp.version
: The version of the MCP server.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor

Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.