Book Library MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Book Library MCP Serverfind me books by George Orwell"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ 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: BookStack 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 |
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Abishek-0607/Library-Management-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server