Skip to content

Commit d05aa44

Browse files
committed
Auto-refresh gists every hour
1 parent f7b9664 commit d05aa44

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 📆 v0.4.6 (06/16/2025)
2+
3+
- The server's gist cache is now automatically refreshed every hour
4+
15
## 📆 v0.4.5 (06/16/2025)
26

37
- Added the `refresh_gists` tool

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,4 @@ The `gistpad-mcp` CLI accepts the following optional flags:
150150

151151
## 🧰 Troubleshooting
152152

153-
- <u>Not seeing a gist in your list?</u> Rhe GistPad MCP server caches your gist list during the lifetime of its server process (for performance reasons), and so if you add/edit/delete a gist externally, you may need to tell GistPad MCP to refresh itself. You can do this by triggering the `refresh_gists` tool (e.g. running `#refresh_gists` in VS Code Copilot chat).
153+
- <u>Not seeing a gist in your list?</u> The GistPad MCP server caches your gist list and updates it 1) anytime you make a change through the MCP server, or 2) every hour. However, if you add/edit/delete a gist using an external client, you may need to tell GistPad MCP to refresh itself (assuming it hasn't performed its hourly refresh yet). You can do this by triggering the `refresh_gists` tool (e.g. running `#refresh_gists` in VS Code Copilot chat).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gistpad-mcp",
3-
"version": "0.4.5",
3+
"version": "0.4.6",
44
"description": "An MCP server for managing your personal knowledge, daily notes, and reusable prompts via GitHub Gists.",
55
"type": "module",
66
"bin": {

src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class GistpadServer {
4747
this.server = new Server(
4848
{
4949
name: "gistpad",
50-
version: "0.4.5",
50+
version: "0.4.6",
5151
},
5252
{
5353
capabilities: {
@@ -102,6 +102,16 @@ To read gists, notes, and gist comments, prefer using the available resources vs
102102
await this.server.close();
103103
process.exit(0);
104104
});
105+
106+
// Schedule an hourly background refresh
107+
setInterval(async () => {
108+
console.error("Refreshing gist cache...");
109+
110+
await Promise.all([
111+
this.gistStore.refresh(),
112+
this.starredGistStore.refresh(),
113+
]);
114+
}, 1000 * 60 * 60);
105115
}
106116

107117
private createRequestContext(): RequestContext {

src/store.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ export abstract class GistStore {
4040
}
4141
}
4242

43-
private notifyPromptListChanged(): void {
43+
private notifyPromptListChanged() {
4444
if (this.triggerNotifications) {
4545
this.server.sendPromptListChanged();
4646
}
4747
}
4848

49-
async getAll(): Promise<Gist[]> {
50-
if (this.cache === null) {
49+
async getAll(forceRefresh: boolean = false): Promise<Gist[]> {
50+
if (this.cache === null || forceRefresh) {
5151
const gists = await this.fetchGists();
5252
this.cache = this.markdownOnly ? filterGists(gists) : gists;
5353
}
@@ -66,7 +66,7 @@ export abstract class GistStore {
6666
}
6767
}
6868

69-
remove(gistId: string): void {
69+
remove(gistId: string) {
7070
if (this.cache) {
7171
this.cache = this.cache.filter((g) => g.id !== gistId);
7272
this.notifyResourceListChanged();
@@ -94,15 +94,16 @@ export abstract class GistStore {
9494
}
9595
}
9696

97-
invalidate(): void {
98-
this.cache = null;
97+
async refresh() {
98+
await this.getAll(true);
99+
this.notifyResourceListChanged();
99100
}
100101

101-
subscribe(gistId: string): void {
102+
subscribe(gistId: string) {
102103
this.subscribedGists.add(gistId);
103104
}
104105

105-
unsubscribe(gistId: string): void {
106+
unsubscribe(gistId: string) {
106107
this.subscribedGists.delete(gistId);
107108
}
108109

src/tools/refresh.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
{
66
name: "refresh_gists",
77
description:
8-
"Reload the gist and starred gist stores, bypassing the cache",
8+
"Refresh the server's cache of gists, to ensure it picks up any changes made by external clients.",
99
inputSchema: {
1010
type: "object",
1111
properties: {},
@@ -16,15 +16,11 @@ export default {
1616

1717
handlers: {
1818
refresh_gists: async (_, context) => {
19-
context.gistStore.invalidate();
20-
context.starredGistStore.invalidate();
21-
2219
await Promise.all([
23-
context.gistStore.getAll(),
24-
context.starredGistStore.getAll(),
20+
context.gistStore.refresh(),
21+
context.starredGistStore.refresh(),
2522
]);
2623

27-
await context.server.sendResourceListChanged();
2824
return "Gists refreshed!";
2925
},
3026
},

0 commit comments

Comments
 (0)