Book Library MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
π Book Library β MCP Server Demo
A production-ready reference implementation showing how Claude (or any LLM) connects to a real REST API through an MCP Server.
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOU / CLAUDE β
β (natural language: "find me Python books") β
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β MCP Protocol (JSON-RPC 2.0)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP SERVER :9000 β
β (book_mcp β FastMCP) β
β β
β Tools exposed: β
β book_list book_search book_get β
β book_create book_update book_delete β
β β
β Responsibilities: β
β β
Translate MCP tool calls β HTTP requests β
β β
Validate inputs with Pydantic β
β β
Format API responses as Markdown or JSON β
β β
Handle and surface errors cleanly β
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β REST API (HTTP/JSON)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BOOK LIBRARY API :8000 β
β (FastAPI) β
β β
β Endpoints: β
β GET /api/v1/books/ List + filter + paginate β
β GET /api/v1/books/search Full-text search β
β GET /api/v1/books/{id} Get single book β
β POST /api/v1/books/ Create book β
β PATCH /api/v1/books/{id} Update book β
β DELETE /api/v1/books/{id} Delete book β
β GET /health Health probe β
β GET /docs Swagger UI β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββRelated MCP server: Books API MCP Server
π Folder Structure
book-mcp-demo/
β
βββ api/ # FastAPI REST API
β βββ core/
β β βββ config.py # Settings from env vars
β βββ exceptions/
β β βββ __init__.py # Custom exception classes
β βββ models/
β β βββ book.py # Domain model + in-memory store
β βββ routers/
β β βββ books.py # All CRUD route handlers
β βββ schemas/
β β βββ book.py # Pydantic request/response schemas
β βββ main.py # FastAPI app entry point
β βββ requirements.txt
β
βββ mcp_server/
β βββ server.py # FastMCP server with 6 tools
β βββ requirements.txt
β
βββ mcp_client/
β βββ client.py # Demo client (shows MCP wire protocol)
β βββ requirements.txt
β
βββ tests/
β βββ test_books_api.py # API integration tests
β
βββ Dockerfile.api # Multi-stage Docker build for API
βββ Dockerfile.mcp # Multi-stage Docker build for MCP server
βββ Dockerfile.client # Docker build for demo client
βββ docker-compose.yml # Orchestrates all 3 services
βββ requirements.txt # Root deps for local dev
βββ .env # Environment variablesπ Quick Start
Option 1 β Docker Compose (Recommended)
# Clone and enter the project
cd book-mcp-demo
# Start all 3 services (API + MCP Server + Client demo)
docker compose up --build
# You'll see:
# book_api β ready on port 8000
# book_mcp β ready on port 9000
# book_mcp_client β runs all demo scenarios, then exitsOption 2 β Local Development
# Install all dependencies
pip install -r requirements.txt
# Terminal 1: Start the API
uvicorn api.main:app --reload --port 8000
# Terminal 2: Start the MCP server
python mcp_server/server.py
# Terminal 3: Run the client demo
python mcp_client/client.pyπ§ͺ Running Tests
# Install test deps
pip install -r requirements.txt
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ -v --cov=apiπ API Documentation
Once the API is running, open:
URL | Description |
Swagger UI (interactive) | |
ReDoc UI | |
Health check |
π§ MCP Tools Reference
Tool | Description | Read-only |
| List all books with filters and pagination | β Yes |
| Search by title or author | β Yes |
| Get a single book by ID | β Yes |
| Add a new book (ISBN must be unique) | β No |
| Partially update a book | β No |
| Permanently delete a book | β No |
π How MCP Works (Step by Step)
Step 1 β Handshake
Client β Server: initialize (announce capabilities)
Server β Client: serverInfo + available tools list
Step 2 β Tool Discovery
Client β Server: tools/list
Server β Client: [{name, description, inputSchema}, ...]
Step 3 β Tool Call
Client β Server: tools/call {name: "book_search", arguments: {query: "python"}}
Server: validates input β calls Book API β formats response
Server β Client: {content: [{type: "text", text: "### Search results..."}]}π‘οΈ Error Handling Strategy
API Layer (FastAPI)
Custom exceptions (
BookNotFoundError,DuplicateISBNError) β raised in business logicException handlers in routers convert them to proper HTTP status codes
Global handler catches anything unexpected β always returns clean JSON
MCP Layer (FastMCP)
_handle_api_error()β single shared function maps all error types:httpx.HTTPStatusErrorβ maps HTTP codes to user-friendly messageshttpx.TimeoutExceptionβ timeout messagehttpx.ConnectErrorβ connectivity message
Never exposes raw stack traces to the LLM client
Structured logging to stderr (stdout is reserved for MCP protocol)
π³ Container Design Decisions
Decision | Reason |
Multi-stage builds | Smaller final images (no build tools in runtime) |
Non-root user | Security best practice |
Health checks | Docker and orchestrators (K8s) need these for readiness |
| MCP won't start until API is truly ready |
| Logs appear immediately in Docker |
Per-service | Only installs what each container needs |
βοΈ Environment Variables
Variable | Default | Description |
|
| API base URL seen by MCP server |
|
| HTTP timeout in seconds |
|
| MCP server bind host |
|
| MCP server port |
|
| MCP URL seen by client |
|
| Enable debug logging |
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Persistent memory layer for AI tools. Save and recall notes across Claude and other MCP clients.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables management of Micro.blog book collections through natural language, allowing users to organize bookshelves, add/move books, and track reading goals. Built with FastMCP for reliable integration with Claude Desktop.11MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that exposes book management tools for AI assistants, enabling CRUD operations on book collections through a .NET Books API backend.-
- AlicenseNot gradedqualityBmaintenanceEnables conversational management of a Calibre ebook library via MCP, including search, metadata editing, adding, converting, deduplicating, removing, and emailing books with human-in-the-loop safety.1MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI agents with a persistent, searchable knowledge library via MCP tools, allowing them to create books, manage pages, perform semantic search, and retrieve usage guides.5MIT