Skip to main content
Glama
srgsanky

Personal Library MCP Server

by srgsanky

add_book

Adds new books to your personal library by entering ISBN, title, author, genre, and publication year. Track ownership and reading status to manage your collection.

Instructions

Adds a new book to the library.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
isbnYes
nameYes
authorYes
genreYes
yearYes
ownedNo
readNo

Implementation Reference

  • server.py:68-84 (handler)
    The handler function for the `add_book` tool, which inserts a new book record into the SQLite database.
    @mcp.tool()
    def add_book(isbn: str, name: str, author: str, genre: str, year: int, owned: bool = False, read: bool = False) -> str:
        """Adds a new book to the library."""
        metadata = json.dumps({"author": author, "genre": genre, "year": year})
        conn = get_db_connection()
        cursor = conn.cursor()
        try:
            cursor.execute("""
            INSERT INTO books (isbn, name, metadata, owned, read)
            VALUES (?, ?, ?, ?, ?)
            """, (isbn, name, metadata, int(owned), int(read)))
            conn.commit()
            return f"Success: Book '{name}' added with ISBN {isbn}."
        except sqlite3.IntegrityError:
            return f"Error: Book with ISBN {isbn} already exists."
        finally:
            conn.close()

Latest Blog Posts

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/srgsanky/mcp-demo'

If you have feedback or need assistance with the MCP directory API, please join our Discord server