# Connect to Calibre

> Point Library Hub at Calibre's Content Server, and decide whether it may write to your library.

Library Hub reaches your library through Calibre's own Content Server.

## Steps

1. In Calibre, select **Connect/share → Start Content server**.
2. In Obsidian, open **Settings → Library Hub**. The first time, select **Connect…**; after that it is under **Library → Calibre → Connect…**.
3. Fill in the dialog:

| Field | What to enter |
|---|---|
| **Content Server address** | Where the server listens. By default `http://localhost:8080`. |
| **User** and **Password** | Only when the server asks for a login. The password is kept in Obsidian's keychain. |
| **Library** | The library's ID on that server. Leave empty for the server's default. |
| **Library folder** | Optional. The folder of your Calibre library, the one holding `metadata.db`. With it, Library Hub can still read the library when the server is off. |

4. Select **Test**, then **Done**.

![The Calibre dialog after Test: the address, user, password, library and library folder fields, then Connected and four rows, Content Server, Login, Library and Changes, each marked Set](img/settings-calibre-dialog.png)

## The settings Calibre needs

**Test** checks each of these against the server and, for any that is set wrong, says where to set it in Calibre. The Library tab shows the same: *Connected* when all pass, *Connected, read-only* when only the last fails, with the fix in the row's description.

| Check | What it needs | Where in Calibre |
|---|---|---|
| **Content Server** | The server is running at the address above. | **Connect/share → Start Content server**. To have it start every time: **Preferences → Sharing over the net → Main → Run server automatically when calibre starts**. |
| **Login** | No login, or a user and password that the server accepts. | **Preferences → Sharing over the net → Main → Password based authentication to access the server** (off), or **User accounts** to add one and enter it in the dialog. |
| **Library** | The library in the dialog is one the server offers; empty means the server's default. | Open the library in Calibre, then stop and start the server. |
| **Changes** | The server lets this connection make changes. Needed to write metadata and covers back, and to convert a book (the conversion adds an EPUB to it). | **Preferences → Sharing over the net → Advanced → Allow un-authenticated local connections to make changes**, then **Apply** and stop and start the server. For a server on another machine: **Allow un-authenticated connections from specific IP addresses to make changes**, or log in as a user who may. |

The *Changes* check sends one `set_metadata` command that only reads field names; Calibre refuses it before doing anything when changes aren't allowed, so the check never changes your library.

Without *Changes*, everything still works except writing accepted changes back and converting books.

![The same dialog when the server refuses changes: Connected, read-only, and the Changes row marked Fix in Calibre with the setting to change](img/settings-calibre-dialog-read-only.png)

![The Library tab in the same state: the Calibre row says Connected, read-only, with the fix in its description](img/settings-library-read-only.png)

## When the server is off

With a **Library folder** set, the library is read straight from the folder, read-only: the books from `metadata.db`, and their files from the books' folders. Syncing notes, opening a book and reading its text work, for Library Hub and for plugins that use it. Converting a book to EPUB and writing to Calibre wait until the server is on. Library Hub never writes to the folder.

## Related

- [Sync notes from Calibre](sync-notes.md)
- [Changes to Calibre, and undo](changes-to-calibre.md)
