@fredrika/mcp-mochi 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,14 +1,11 @@
1
1
  # Mochi MCP Server
2
2
 
3
- This MCP server provides integration with the Mochi flashcard system, allowing you to manage and review your flashcards through the Model Context Protocol.
3
+ This MCP server provides integration with the Mochi flashcard system, allowing you to manage your flashcards through the Model Context Protocol.
4
4
 
5
5
  ## Features
6
6
 
7
7
  - Create, update, and delete flashcards
8
- - Get flashcards due for review
9
- - Review flashcards and track progress
10
- - View study statistics
11
- - Tag-based organization
8
+ - List flashcards, decks, and templates
12
9
 
13
10
  ## Setup
14
11
 
@@ -33,40 +30,38 @@ This MCP server provides integration with the Mochi flashcard system, allowing y
33
30
 
34
31
  ## Available Tools
35
32
 
36
- ### `createFlashcard`
37
- Create a new flashcard.
33
+ ### `mochi_create_card`
34
+ Create a new flashcard in Mochi.
38
35
  - Parameters:
39
- - `front`: string (front side content)
40
- - `back`: string (back side content)
41
- - `tags`: string[] (optional tags)
42
-
43
- ### `updateFlashcard`
44
- Update an existing flashcard.
36
+ - `content`: string (Markdown content of the card. Separate front and back using a horizontal rule `---`)
37
+ - `deck-id`: string (ID of the deck to create the card in)
38
+ - `template-id`: string (optional, template to use for the card)
39
+ - `manual-tags`: string[] (optional, tags to add to the card)
40
+ - `fields`: object (map of field IDs to field values, required if using a template)
41
+
42
+ ### `mochi_update_card`
43
+ Update or delete an existing flashcard in Mochi. To delete, set `trashed` to true.
45
44
  - Parameters:
46
- - `id`: string (flashcard ID)
47
- - `front`: string (optional)
48
- - `back`: string (optional)
49
- - `tags`: string[] (optional)
45
+ - `card-id`: string (ID of the card to update)
46
+ - Any updatable card fields (see code for all options)
47
+ - To delete: set `trashed?` to `'true'` (string)
50
48
 
51
- ### `deleteFlashcard`
52
- Delete a flashcard.
49
+ ### `mochi_list_cards`
50
+ List cards (paginated).
53
51
  - Parameters:
54
- - `id`: string (flashcard ID)
55
-
56
- ### `getDueFlashcards`
57
- Get a list of flashcards that are due for review.
58
- - No parameters required
52
+ - `deck-id`: string (optional, filter by deck)
53
+ - `limit`: number (optional, 1-100)
54
+ - `bookmark`: string (optional, for pagination)
59
55
 
60
- ### `reviewFlashcard`
61
- Submit a review for a flashcard.
56
+ ### `mochi_list_decks`
57
+ List all decks.
62
58
  - Parameters:
63
- - `id`: string (flashcard ID)
64
- - `success`: boolean (whether the review was successful)
65
- - `timeSpentMs`: number (time spent reviewing in milliseconds)
59
+ - `bookmark`: string (optional, for pagination)
66
60
 
67
- ### `getStats`
68
- Get study statistics.
69
- - No parameters required
61
+ ### `mochi_list_templates`
62
+ List all templates.
63
+ - Parameters:
64
+ - `bookmark`: string (optional, for pagination)
70
65
 
71
66
  ## Example Usage
72
67
 
@@ -85,29 +80,34 @@ Here's how to use the MCP server with the MCP Inspector:
85
80
  3. Create a new flashcard:
86
81
  ```json
87
82
  {
88
- "tool": "createFlashcard",
83
+ "tool": "mochi_create_card",
89
84
  "params": {
90
- "front": "What is MCP?",
91
- "back": "Model Context Protocol - a protocol for providing context to LLMs",
92
- "tags": ["tech", "protocols"]
85
+ "content": "What is MCP?\n---\nModel Context Protocol - a protocol for providing context to LLMs",
86
+ "deck-id": "<YOUR_DECK_ID>"
93
87
  }
94
88
  }
95
89
  ```
96
90
 
97
- 4. Get flashcards due for review:
91
+ 4. List all decks:
98
92
  ```json
99
93
  {
100
- "tool": "getDueFlashcards"
94
+ "tool": "mochi_list_decks",
95
+ "params": {}
101
96
  }
102
97
  ```
103
98
 
99
+ 5. Delete a flashcard (set `trashed` to true via update):
100
+ ```json
101
+ {
102
+ "tool": "mochi_update_card",
103
+ "params": {
104
+ "card-id": "<CARD_ID>",
105
+ "trashed?": "true"
106
+ }
107
+ }
108
+ ```
104
109
 
105
- ## Setup
106
-
107
- ### Personal Access Token
108
- TODO
109
-
110
- ### Usage with Claude Desktop
110
+ ## Usage with Claude Desktop
111
111
  To use this with Claude Desktop, add the following to your `claude_desktop_config.json`:
112
112
 
113
113
  #### Docker
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@ import { z } from "zod";
3
3
  declare const CreateCardRequestSchema: z.ZodObject<{
4
4
  content: z.ZodString;
5
5
  "deck-id": z.ZodString;
6
- "template-id": z.ZodOptional<z.ZodString>;
6
+ "template-id": z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
7
7
  "manual-tags": z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
8
- fields: z.ZodRecord<z.ZodString, z.ZodObject<{
8
+ fields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
9
9
  id: z.ZodString;
10
10
  value: z.ZodString;
11
11
  }, "strip", z.ZodTypeAny, {
@@ -14,25 +14,25 @@ declare const CreateCardRequestSchema: z.ZodObject<{
14
14
  }, {
15
15
  id: string;
16
16
  value: string;
17
- }>>;
17
+ }>>>;
18
18
  }, "strip", z.ZodTypeAny, {
19
19
  content: string;
20
20
  "deck-id": string;
21
- fields: Record<string, {
21
+ "template-id": string | null;
22
+ "manual-tags"?: string[] | undefined;
23
+ fields?: Record<string, {
22
24
  id: string;
23
25
  value: string;
24
- }>;
25
- "template-id"?: string | undefined;
26
- "manual-tags"?: string[] | undefined;
26
+ }> | undefined;
27
27
  }, {
28
28
  content: string;
29
29
  "deck-id": string;
30
- fields: Record<string, {
30
+ "template-id"?: string | null | undefined;
31
+ "manual-tags"?: string[] | undefined;
32
+ fields?: Record<string, {
31
33
  id: string;
32
34
  value: string;
33
- }>;
34
- "template-id"?: string | undefined;
35
- "manual-tags"?: string[] | undefined;
35
+ }> | undefined;
36
36
  }>;
37
37
  declare const UpdateCardRequestSchema: z.ZodObject<{
38
38
  content: z.ZodOptional<z.ZodString>;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
2
+ import { CallToolRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
3
3
  import axios from "axios";
4
4
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
5
5
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -28,90 +28,143 @@ class MochiError extends Error {
28
28
  }
29
29
  // Zod schemas for request validation
30
30
  const CreateCardFieldSchema = z.object({
31
- id: z.string(),
32
- value: z.string(),
31
+ id: z.string().describe("Unique identifier for the field"),
32
+ value: z.string().describe("Value of the field"),
33
33
  });
34
34
  const CreateCardRequestSchema = z.object({
35
- content: z.string().min(1),
36
- "deck-id": z.string().min(1),
37
- "template-id": z.string().optional(),
38
- "manual-tags": z.array(z.string()).optional(),
39
- fields: z.record(z.string(), CreateCardFieldSchema),
35
+ content: z
36
+ .string()
37
+ .min(1)
38
+ .describe("Markdown content of the card. Separate front and back using a horizontal rule (---)"),
39
+ "deck-id": z.string().min(1).describe("ID of the deck to create the card in"),
40
+ "template-id": z
41
+ .string()
42
+ .optional()
43
+ .nullable()
44
+ .default(null)
45
+ .describe("Optional template ID to use for the card. Defaults to null if not set."),
46
+ "manual-tags": z
47
+ .array(z.string())
48
+ .optional()
49
+ .describe("Optional array of tags to add to the card"),
50
+ fields: z
51
+ .record(z.string(), CreateCardFieldSchema)
52
+ .optional()
53
+ .describe("Map of field IDs to field values. Required only when using a template"),
40
54
  });
41
55
  const UpdateCardRequestSchema = z.object({
42
- content: z.string().optional(),
43
- "deck-id": z.string().optional(),
44
- "template-id": z.string().optional(),
45
- "archived?": z.boolean().optional(),
46
- "trashed?": z.string().optional(),
47
- fields: z.record(z.string(), CreateCardFieldSchema).optional(),
56
+ content: z
57
+ .string()
58
+ .optional()
59
+ .describe("Updated markdown content of the card"),
60
+ "deck-id": z
61
+ .string()
62
+ .optional()
63
+ .describe("ID of the deck to move the card to"),
64
+ "template-id": z
65
+ .string()
66
+ .optional()
67
+ .describe("Template ID to use for the card"),
68
+ "archived?": z.boolean().optional().describe("Whether the card is archived"),
69
+ "trashed?": z.string().optional().describe("Whether the card is trashed"),
70
+ fields: z
71
+ .record(z.string(), CreateCardFieldSchema)
72
+ .optional()
73
+ .describe("Updated map of field IDs to field values"),
48
74
  });
49
75
  const ListDecksParamsSchema = z.object({
50
- bookmark: z.string().optional(),
76
+ bookmark: z
77
+ .string()
78
+ .optional()
79
+ .describe("Pagination bookmark for fetching next page of results"),
51
80
  });
52
81
  const ListCardsParamsSchema = z.object({
53
- "deck-id": z.string().optional(),
54
- limit: z.number().min(1).max(100).optional(),
55
- bookmark: z.string().optional(),
82
+ "deck-id": z.string().optional().describe("Get cards from deck ID"),
83
+ limit: z
84
+ .number()
85
+ .min(1)
86
+ .max(100)
87
+ .optional()
88
+ .describe("Number of cards to return per page (1-100)"),
89
+ bookmark: z
90
+ .string()
91
+ .optional()
92
+ .describe("Pagination bookmark for fetching next page of results"),
56
93
  });
57
94
  const ListTemplatesParamsSchema = z.object({
58
- bookmark: z.string().optional(),
95
+ bookmark: z
96
+ .string()
97
+ .optional()
98
+ .describe("Pagination bookmark for fetching next page of results"),
59
99
  });
60
100
  const TemplateFieldSchema = z.object({
61
- id: z.string(),
62
- name: z.string(),
63
- pos: z.string(),
101
+ id: z.string().describe("Unique identifier for the template field"),
102
+ name: z.string().describe("Display name of the field"),
103
+ pos: z.string().describe("Position of the field in the template"),
64
104
  options: z
65
105
  .object({
66
- "multi-line?": z.boolean().optional(),
106
+ "multi-line?": z
107
+ .boolean()
108
+ .optional()
109
+ .describe("Whether the field supports multiple lines of text"),
67
110
  })
68
- .optional(),
111
+ .optional()
112
+ .describe("Additional options for the field"),
69
113
  });
70
114
  const TemplateSchema = z
71
115
  .object({
72
- id: z.string(),
73
- name: z.string(),
74
- content: z.string(),
75
- pos: z.string(),
76
- fields: z.record(z.string(), TemplateFieldSchema),
116
+ id: z.string().describe("Unique identifier for the template"),
117
+ name: z.string().describe("Display name of the template"),
118
+ content: z.string().describe("Template content in markdown format"),
119
+ pos: z.string().describe("Position of the template in the list"),
120
+ fields: z
121
+ .record(z.string(), TemplateFieldSchema)
122
+ .describe("Map of field IDs to field definitions"),
77
123
  })
78
124
  .strip();
79
125
  const ListTemplatesResponseSchema = z
80
126
  .object({
81
- bookmark: z.string(),
82
- docs: z.array(TemplateSchema),
127
+ bookmark: z.string().describe("Pagination bookmark for fetching next page"),
128
+ docs: z.array(TemplateSchema).describe("Array of templates"),
83
129
  })
84
130
  .strip();
85
131
  // Response Zod schemas
86
132
  const CardSchema = z
87
133
  .object({
88
- id: z.string(),
89
- tags: z.array(z.string()),
90
- content: z.string(),
91
- name: z.string(),
92
- "deck-id": z.string(),
93
- fields: z.record(z.unknown()).optional(),
134
+ id: z.string().describe("Unique identifier for the card"),
135
+ tags: z
136
+ .array(z.string())
137
+ .describe("Array of tags associated with the card"),
138
+ content: z
139
+ .string()
140
+ .describe('Markdown content of the card. Separate front and back of card with "---"'),
141
+ name: z.string().describe("Display name of the card"),
142
+ "deck-id": z.string().describe("ID of the deck containing the card"),
143
+ fields: z
144
+ .record(z.unknown())
145
+ .optional()
146
+ .describe("Map of field IDs to field values. Need to match the field IDs in the template"),
94
147
  })
95
148
  .strip();
96
149
  const CreateCardResponseSchema = CardSchema.strip();
97
150
  const ListCardsResponseSchema = z
98
151
  .object({
99
- bookmark: z.string(),
100
- docs: z.array(CardSchema),
152
+ bookmark: z.string().describe("Pagination bookmark for fetching next page"),
153
+ docs: z.array(CardSchema).describe("Array of cards"),
101
154
  })
102
155
  .strip();
103
156
  const DeckSchema = z
104
157
  .object({
105
- id: z.string(),
106
- sort: z.number(),
107
- name: z.string(),
108
- archived: z.boolean().optional(),
158
+ id: z.string().describe("Unique identifier for the deck"),
159
+ sort: z.number().describe("Sort order of the deck"),
160
+ name: z.string().describe("Display name of the deck"),
161
+ archived: z.boolean().optional().describe("Whether the deck is archived"),
109
162
  })
110
163
  .strip();
111
164
  const ListDecksResponseSchema = z
112
165
  .object({
113
- bookmark: z.string(),
114
- docs: z.array(DeckSchema),
166
+ bookmark: z.string().describe("Pagination bookmark for fetching next page"),
167
+ docs: z.array(DeckSchema).describe("Array of decks"),
115
168
  })
116
169
  .strip();
117
170
  function getApiKey() {
@@ -171,11 +224,12 @@ export class MochiClient {
171
224
  // Server setup
172
225
  const server = new Server({
173
226
  name: "mcp-server/mochi",
174
- version: "1.0.2",
227
+ version: "1.0.3",
175
228
  }, {
176
229
  capabilities: {
177
230
  tools: {},
178
231
  resources: {},
232
+ prompts: {},
179
233
  },
180
234
  });
181
235
  // Set up request handlers
@@ -193,10 +247,19 @@ ALWAYS look up deck-id with the mochi_list_decks tool.
193
247
  ### content (required)
194
248
  The markdown content of the card. Separate front and back using a horizontal rule (---).
195
249
 
250
+ ### template-id (optional)
251
+ When using a template, the field ids MUST match the template ones. If not using a template, omit this field.
252
+
196
253
  ### fields (optional)
197
- A map of field IDs (keyword) to field values. The field IDs should correspond to the fields defined on the template used by the card.
254
+ A map of field IDs (keyword) to field values. Only required when using a template. The field IDs must correspond to the fields defined on the template.
198
255
 
199
- ## Example
256
+ ## Example without template
257
+ {
258
+ "content": "What is the capital of France?\n---\nParis",
259
+ "deck-id": "btmZUXWM"
260
+ }
261
+
262
+ ## Example with template
200
263
  {
201
264
  "content": "New card from API. ![](@media/foobar03.png)",
202
265
  "deck-id": "btmZUXWM",
@@ -209,12 +272,11 @@ A map of field IDs (keyword) to field values. The field IDs should correspond to
209
272
  "JNEnw1e7": {
210
273
  "id": "JNEnw1e7",
211
274
  "value": "World!"
212
- },
213
- },
275
+ }
276
+ }
214
277
  }
215
278
 
216
- ## Good cards:
217
- - **concise**: as short question and answer as possible.
279
+ ## Properties of good flashcards:
218
280
  - **focused:** A question or answer involving too much detail will dull your concentration and stimulate incomplete retrievals, leaving some bulbs unlit.
219
281
  - **precise** about what they're asking for. Vague questions will elicit vague answers, which won't reliably light the bulbs you're targeting.
220
282
  - **consistent** answers, lighting the same bulbs each time you perform the task.
@@ -232,7 +294,7 @@ A map of field IDs (keyword) to field values. The field IDs should correspond to
232
294
  },
233
295
  {
234
296
  name: "mochi_update_card",
235
- description: `Update an existing flashcard in Mochi.`,
297
+ description: `Update or delete an existing flashcard in Mochi. To delete set trashed to true.`,
236
298
  inputSchema: zodToJsonSchema(z.object({
237
299
  "card-id": z.string(),
238
300
  ...UpdateCardRequestSchema.shape,
@@ -369,6 +431,49 @@ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
369
431
  }
370
432
  }
371
433
  });
434
+ const CreateFlashcardPromptSchema = z.object({
435
+ input: z
436
+ .string()
437
+ .describe("The information to base the flashcard on.")
438
+ .optional(),
439
+ });
440
+ server.setRequestHandler(ListPromptsRequestSchema, async () => {
441
+ return {
442
+ prompts: [
443
+ {
444
+ name: "write-flashcard",
445
+ description: "Write a flashcard based on user-provided information.",
446
+ arguments: [
447
+ {
448
+ name: "input",
449
+ description: "The information to base the flashcard on.",
450
+ },
451
+ ],
452
+ },
453
+ ],
454
+ };
455
+ });
456
+ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
457
+ const params = CreateFlashcardPromptSchema.parse(request.params.arguments);
458
+ const { input } = params;
459
+ return {
460
+ messages: [
461
+ {
462
+ role: "user",
463
+ content: {
464
+ type: "text",
465
+ text: `Create a flashcard using the info below while adhering to these principles:
466
+ - Keep questions and answers atomic.
467
+ - Utilize cloze prompts when applicable, like "This is a text with {{hidden}} part. Then don't use '---' separator.".
468
+ - Focus on effective retrieval practice by being concise and clear.
469
+ - Make it just challenging enough to reinforce specific facts.
470
+ Input: ${input}
471
+ `,
472
+ },
473
+ },
474
+ ],
475
+ };
476
+ });
372
477
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
373
478
  try {
374
479
  switch (request.params.name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fredrika/mcp-mochi",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "MCP server for Mochi flashcard integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",