furkanozer1/LibraryMcp
If you are the rightful owner of LibraryMcp 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 Book Tracker Backend is a Spring Boot application that provides REST API and MCP server functionality for managing books, integrated with a PostgreSQL database.
Book Tracker Backend
A Spring Boot application that provides both REST API and MCP (Model Context Protocol) server functionality for managing books.
Features
- REST API: Traditional HTTP endpoints for book management
- MCP Server: Protocol-compliant server for AI tool integration
- PostgreSQL Database: Persistent storage for book data
- CRUD Operations: Complete book management functionality
Prerequisites
- Java 21+
- PostgreSQL database running on localhost:5432
- Database named
library_db
- PostgreSQL user:
postgres
with password:password
Running the Application
# Using Maven wrapper
./mvnw.cmd spring-boot:run
# Or if Maven is installed
mvn spring-boot:run
The application will start on http://localhost:8080
REST API Endpoints
Books Management
GET /api/books
- Get all booksGET /api/books/{id}
- Get book by IDPOST /api/books
- Create new bookPUT /api/books/{id}
- Update existing bookDELETE /api/books/{id}
- Delete book
Example Book JSON
{
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"isbn": "978-0-7432-7356-5"
}
MCP Server Endpoints
The MCP server provides the same functionality as REST API but follows the MCP protocol specification.
MCP Protocol Endpoints
POST /mcp/initialize
- Initialize MCP server connectionPOST /mcp/tools/list
- List available toolsPOST /mcp/tools/call
- Execute tool calls
Available MCP Tools
- getAllBooks - Get all books from database
- getBookById - Get book by ID
- Parameters:
id
(number)
- Parameters:
- createBook - Create new book
- Parameters:
title
(string),author
(string),isbn
(string)
- Parameters:
- updateBook - Update existing book
- Parameters:
id
(number),title
(string),author
(string),isbn
(string)
- Parameters:
- deleteBook - Delete book by ID
- Parameters:
id
(number)
- Parameters:
- findBookByTitle - Find books by title
- Parameters:
title
(string)
- Parameters:
- findBookByAuthor - Find books by author
- Parameters:
author
(string)
- Parameters:
MCP Tool Call Example
{
"name": "createBook",
"arguments": {
"title": "1984",
"author": "George Orwell",
"isbn": "978-0-452-28423-4"
}
}
Database Setup
Create PostgreSQL database:
CREATE DATABASE library_db;
The application will automatically create the book
table with the following structure:
id
(BIGINT, Primary Key, Auto-increment)title
(VARCHAR)author
(VARCHAR)isbn
(VARCHAR)
Configuration
Database configuration in src/main/resources/application.properties
:
spring.datasource.url=jdbc:postgresql://localhost:5432/library_db
spring.datasource.username=postgres
spring.datasource.password=password
API Documentation
When running, visit http://localhost:8080/swagger-ui.html
for interactive API documentation.
Architecture
- Controller Layer: REST endpoints (
BookController
) and MCP endpoints (McpServerController
) - Service Layer: Business logic (
BookTools
) - Repository Layer: Data access (
BookRepository
) - Model Layer: Entity definitions (
Book
)
Error Handling
The application includes basic error handling:
- Invalid book IDs return
null
- MCP tool errors are wrapped in error responses
- Database connection issues are logged
Development
The application uses Spring Boot DevTools for hot reloading during development.
config file for claude:
{
"mcpServers": {
"booktracker": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://127.0.0.1:8080/mcp"
]
}
}
}
Important Notice
All related files and detailed information about MCP and MCP servers can be found under booktracker_backend
directory.