Skip to main content
Glama
srgsanky

Personal Library MCP Server

by srgsanky

search_books

Search for books by title or ISBN to find and manage reading materials in your personal library database.

Instructions

Searches for books by name or ISBN.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The `search_books` tool handler implements a database search functionality using SQL 'LIKE' queries on both the book 'name' and 'isbn' columns. It is decorated with `@mcp.tool()` which handles the registration with the MCP framework.
    @mcp.tool()
    def search_books(query: str) -> str:
        """Searches for books by name or ISBN."""
        conn = get_db_connection()
        cursor = conn.cursor()
        cursor.execute("SELECT isbn, name FROM books WHERE name LIKE ? OR isbn LIKE ?", (f"%{query}%", f"%{query}%"))
        results = [dict(row) for row in cursor.fetchall()]
        conn.close()
        
        if results:
            return json.dumps(results, indent=2)
        return "No matches found."

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