Librechat + Obsidian = Life Coach

For as long as I can remember, I’ve been making notes, journalling and having those feed into planning.

Since 2023, I’ve become a pretty heavy ChatGPT user, using it for therapy, coding, research and all kinds of other weird things to see how I can push it’s limits. Naturally, I’ve started to wonder how I can better merge these two worlds of journalling and LLMs to create an even more potent ideas.

Here’s the idea. Have the LLM:

  1. Read my journal/notes
  2. Summarize what’s been going on in my life
  3. Reflect it back to me and give me an “objective” perspective and some growth ideas.

Privacy Concerns

LLMs work by training on real text content on the internet to improve their output. A great way for them to improve their responses is training on the actual conversations that people are having with their LLMs. Do we really want our private conversations be part of a new model that other people interact with? Not really…

To prevent that, I could spin up a local LLM like Deepseek, but that requires a decent GPU or dedicated Macbook which ain’t cheap. However, the Terms and Conditions of most providers won’t build profiles or train the LLMs using data via the API. The middleground I’ve found is this: using an open client (LibreChat) that allows me to use the APIs. I’ve only recently migrated to using LibreChat instead of the ChatGPT web client.

Architecture

Overall

Ultimately we want to connect the Librechat instance in docker on my laptop, to my obsidian instance also running on my machine.

  • There is a really nice existing obsidian mcp out there. I wrote PR to allow it to pull from recent Obsidian notes
  • That MCP uses the Obsidian REST api plugin to access the data.

Since LibreChat conveniently is already deployed by Docker-compose, we can override it to deploy the ObsidianMCP as a new service to keep everything all nicely contained together.

In Docker Compose

The main complicating factor is that most MCPs use stdio to communicate with the client. Since we have the MCP sitting in a container, we need to communicate over a network. Thankfully, there is this cool project called Supergateway that will proxy MCPs to Server Side Events when they only speak stdio. So we deploy both the original Obisidian MCP, with SuperGateway as the proxy within the same container.

Getting Started

Steps in Obsidian:

  1. In your Obsidian instance, install the Obsidian Local Rest API using the Obsidian Plugin manager and turn it on.

Steps in Librechat:

  1. First get Librechat repo setup using the instructions on their site using Docker Compose. Including adding your API keys to .env and getting your docker-compose.override.yml setup to use librechat.yaml.
  2. Copy the code below and add it into the example docker-compose.override.yml file. This will create the obsidian-mcp next to the Librechat container so they can talk to each other:

  supergateway-obsidian:
    image: python:3.12-alpine
    container_name: supergateway-obsidian
    command: >
      sh -c "
        apk add --no-cache nodejs npm git socat &&
        socat TCP4-LISTEN:27124,fork TCP4:host.docker.internal:27124 &
        pip install git+https://github.com/jevy/mcp-obsidian.git@period-tools &&
        npm install -g supergateway &&
        supergateway --stdio 'mcp-obsidian' --port 8001 --ssePath /sse --messagePath /message --cors --logLevel info
      "
    ports:
      - "8001:8001"
    restart: unless-stopped
    environment:
      - OBSIDIAN_API_KEY=${OBSIDIAN_API_KEY}
    extra_hosts:
      - "host.docker.internal:host-gateway"
  1. Add this to your librechat.yaml so Librechat knows about the obsidian-mcp.

mcpServers:
  perplexity:
    url: http://supergateway-perplexity:8000/sse
  1. Then docker-compose restart and everything should be working great! Add a new “Agent” and add the obsidian tools you want to be available to said agent.

I now have super powerful suggestions and reflection based on my own journal entries and additional context from my Obsidian notes:

2 Likes

Thanks for providing this overview! Great to connect Librechat and Obsidian via a containerized MCP server.

Just confirming that in Step 3 the mcpServers: information is correct (to be added to librechat.yaml)? Not sure where Perplexity is used, so perhaps the server name should be mcp-obsidian?

If so, what is the URL that Librechat is expecting as the SSE endpoint? Have tried e.g. 'localhost:8001/sse" but Librechat doesn’t see it (I’ve confirmed that the Docker container super gateway-obsidian is running and that port 8001 is exposed). Any further pointers much appreciated!

Took me a while to get this one work. I had issue where git wasn’t getting installed properly on the image, so I created a Dockerfile.supergateway file with:

FROM python:3.12-alpine

# Install git along with nodejs, npm, and socat
RUN apk update && apk add --no-cache nodejs npm git socat

# Now run the pip install (which requires git)
RUN pip install git+https://github.com/jevy/mcp-obsidian.git@period-tools

# Install the npm package globally
RUN npm install -g supergateway

EXPOSE 8001

CMD sh -c "socat TCP4-LISTEN:27124,fork TCP4:host.docker.internal:27124 & \
           supergateway --stdio 'mcp-obsidian' --port 8001 --ssePath /sse \
           --messagePath /message --cors --logLevel info"

then added this under service: in the docker-compose.override.yml

  supergateway-obsidian:
    build:
      context: .
      dockerfile: Dockerfile.supergateway  # or use dockerfile: dockerfile.multi if that’s appropriate
    container_name: supergateway-obsidian
    ports:
      - "8001:8001"
    restart: unless-stopped
    environment:
      - OBSIDIAN_API_KEY=${OBSIDIAN_API_KEY}
    extra_hosts:
      - "host.docker.internal:host-gateway"

lastly I added this to my librechat.yml file

# Example MCP Servers Object Structure
mcpServers:
  # everything:
  #   # type: sse # type can optionally be omitted
  #   url: http://localhost:3001/sse
  #   timeout: 60000  # 1 minute timeout for this server, this is the default timeout for MCP servers.
  supergateway:
    url: http://host.docker.internal:8001/sse

i used http://host.docker.internal:8001/sse instead of http://localhost:8001/sse as mac seem to have this issue with docker containers talking to each other. However you can go to http://localhost:8001/sse in the browser to verify the mcpserver is working

Hope this helps someone :slight_smile:
big thanks to Jevy for idea! also, I note the repo is private, is there a way for us to verify this code? hope I’m not asking for too much