J

mcp-fireproof-todos

...
Created 12/7/2024byjimpick

Language:

JavaScript

Stars:

4

Forks:

1

Model Context Protocol and Fireproof Demo: To Do List

This is a simple example of how to use a Fireproof database in a Model Context Protocol server (used for plugging code and data into A.I. systems such as Claude Desktop).

This demo server implements a simple "To Do List", using the same fields as in the demo on the Fireproof Homepage Codepen.

Fireproof Homepage Demo Screenshot

Once installed, this MCP server exposes a "todos" service. If you are using Claude Desktop, you can interact with it via the chatbot to create "To Do List" items, mark them as done, delete them, and even summarize the list.

Here's an example chat where I've asked Claude to "add butter to my todo list":

Claude Desktop Screenshot - Add Butter to To Do List

Where it really gets interesting is when you combine it with knowledge that Claude already has, or with other tools.

If I ask Claude for a cookie recipe:

Claude Desktop Screenshot - Ask for a cookie recipe

I can add all the ingredients to the todo list with a natural language request...

Claude Desktop Screenshot - Add Items 1/2

Claude Desktop Screenshot - Add Items 2/2

You can do other fun things, like mark todos as done, as well as delete them.

Claude Desktop Screenshot - Add Meaning of Life to list and mark as done

Installation

First, make sure you have Node.js installed.

Clone the repo:

git clone https://github.com/jimpick/mcp-fireproof-todos.git

Change directory:

cd mcp-fireproof-todos

Install dependencies:

npm install

Build the server:

npm run build

To use with Claude Desktop, add the server config:

            On MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`

On Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "todos": {
      "command": "/path/to/todos/build/index.js"
    }
  }
}

Development Notes

Mostly, this was developed following the tutorial here:

Fireproof support was added:

import { fireproof } from "use-fireproof";

const db = fireproof("mcp_todo", { public: true });

The fields were defined:

/**
 * Type alias for a todo object.
 */
type Todo = {
  _id: string,
  done: boolean,
  text: string,
  created: Number,
  updated: Number
};

I'm keeping an in-memory list of items, which is kept updated with a .subscribe() method. It might have been simpler to just query the items in the "list_todos" tool.

const todos: { [id: string]: Todo } = {}

await db.ready()

const onDbEvent = async function () {
  const run = Math.random()
  const fpTodos = await db.query("created", {
    includeDocs: true,
    descending: true,
    limit: 10,
  });
  for (let id in todos) {
    delete todos[id]
  }
  for (const row of fpTodos.rows) {
    let todo = row.doc;
    todos[todo!._id] = todo as Todo
  }
};
onDbEvent();
db.subscribe(onDbEvent);

We register the following tools using server.setRequestHandler() with ListToolsRequestSchema:

  • create_todo
  • list_todos
  • mark_todo_as_done
  • delete_todo

And there are simple implementations for each using server.setRequestHandler() with CallToolRequestSchema.

License

Apache 2 or MIT

Last updated: 1/20/2025

Publisher info

jimpick's avatar

Jim Pick

Freelance developer

Hex.Camp
Victoria, BC, Canada
408
followers
182
following
413
repos

More MCP servers built with JavaScript

emergency-medicare-planner-mcp-server

emergency-medicare-planner-mcp-server

By manolaz1
mcp-warpcast-server

MCP Server for Warpcast integration

By zhangzhongnan9281
mcp-tavily-server

Tavily MCP Server for Cline

By dkmaker1