Skip to main content
Glama
infinitepi-io

Bookmark Manager MCP

add

Save web links to the Bookmark Manager MCP by providing a title, URL, and optional category for organized storage and retrieval.

Instructions

Add a new bookmark

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesBookmark title
urlYesBookmark URL
categoryNoBookmark category (default: general)

Implementation Reference

  • The handler function for the 'add' tool. It creates a bookmark object from the input parameters, adds it to the bookmarks array, persists it via saveBookmarks(), and returns a text response confirming the bookmark was added.
    async ({ title, url, category = 'general' }) => {
      const bookmark = { title, url, category }
      bookmarks.push(bookmark)
      await saveBookmarks(bookmarks)
    
      return {
        content: [{
          type: 'text',
          text: `Bookmark added: ${title} - ${url} (category: ${category})`
        }]
      }
    }
  • The input schema for the 'add' tool defined using Zod. It validates that 'title' is a string, 'url' is a valid URL string, and 'category' is an optional string (defaults to 'general').
    inputSchema: {
      title: z.string().describe('Bookmark title'),
      url: z.string().url().describe('Bookmark URL'),
      category: z.string().optional().describe('Bookmark category (default: general)')
    }
  • src/index.ts:40-62 (registration)
    Registration of the 'add' tool with the MCP server using server.registerTool(). Includes the tool name, metadata (title, description), input schema, and handler function.
    server.registerTool('add',
      {
        title: 'Add Bookmark',
        description: 'Add a new bookmark',
        inputSchema: {
          title: z.string().describe('Bookmark title'),
          url: z.string().url().describe('Bookmark URL'),
          category: z.string().optional().describe('Bookmark category (default: general)')
        }
      },
      async ({ title, url, category = 'general' }) => {
        const bookmark = { title, url, category }
        bookmarks.push(bookmark)
        await saveBookmarks(bookmarks)
    
        return {
          content: [{
            type: 'text',
            text: `Bookmark added: ${title} - ${url} (category: ${category})`
          }]
        }
      }
    )
  • Helper function 'saveBookmarks' used by the 'add' tool handler to persist the bookmarks array to a JSON file.
    async function saveBookmarks (bookmarksToSave: Bookmark[]): Promise<void> {
      let fileHandle
      try {
        fileHandle = await open(bookMarkFileName, 'w')
        await fileHandle.writeFile(JSON.stringify(bookmarksToSave, null, 2))
      } catch (error) {
        throw new Error(`Failed to save bookmarks: ${error instanceof Error ? error.message : 'Unknown error'}`)
      } finally {
        if (fileHandle) {
          await fileHandle.close()
        }
      }
    }
  • TypeScript type definition for Bookmark, defining the structure with title (string), url (string), and category (string) fields.
    type Bookmark = {
      title: string,
      url: string,
      category: string
    }
Install Server

Other Tools

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/infinitepi-io/bookmark-manager-mcp'

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