@fredrika/mcp-mochi 1.0.0 → 1.0.1
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 +3 -3
- package/dist/index.js +48 -57
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ To use this with Claude Desktop, add the following to your `claude_desktop_confi
|
|
|
114
114
|
```json
|
|
115
115
|
{
|
|
116
116
|
"mcpServers": {
|
|
117
|
-
"
|
|
117
|
+
"mochi": {
|
|
118
118
|
"command": "docker",
|
|
119
119
|
"args": [
|
|
120
120
|
"run",
|
|
@@ -137,11 +137,11 @@ To use this with Claude Desktop, add the following to your `claude_desktop_confi
|
|
|
137
137
|
```json
|
|
138
138
|
{
|
|
139
139
|
"mcpServers": {
|
|
140
|
-
"
|
|
140
|
+
"mochi": {
|
|
141
141
|
"command": "npx",
|
|
142
142
|
"args": [
|
|
143
143
|
"-y",
|
|
144
|
-
"@
|
|
144
|
+
"@fredrika/mcp-mochi"
|
|
145
145
|
],
|
|
146
146
|
"env": {
|
|
147
147
|
"MOCHI_API_KEY": "<YOUR_TOKEN>"
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
6
|
import dotenv from "dotenv";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
8
9
|
dotenv.config();
|
|
9
10
|
/**
|
|
10
11
|
* Custom error class for Mochi API errors
|
|
@@ -100,59 +101,6 @@ function getApiKey() {
|
|
|
100
101
|
return apiKey;
|
|
101
102
|
}
|
|
102
103
|
const MOCHI_API_KEY = getApiKey();
|
|
103
|
-
// Tool definitions
|
|
104
|
-
const CREATE_CARD_TOOL = {
|
|
105
|
-
name: "mochi_create_card",
|
|
106
|
-
description: "Create a new flashcard",
|
|
107
|
-
inputSchema: {
|
|
108
|
-
type: "object",
|
|
109
|
-
properties: {
|
|
110
|
-
content: {
|
|
111
|
-
type: "string",
|
|
112
|
-
description: "The markdown content of the card. Separate front from back with `\n---\n`",
|
|
113
|
-
},
|
|
114
|
-
"deck-id": {
|
|
115
|
-
type: "string",
|
|
116
|
-
description: "The deck ID that the card belongs too.",
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
required: ["content", "deck-id"],
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
const LIST_CARDS_TOOL = {
|
|
123
|
-
name: "mochi_list_cards",
|
|
124
|
-
description: "List cards in pages of 10 cards per page",
|
|
125
|
-
inputSchema: {
|
|
126
|
-
type: "object",
|
|
127
|
-
properties: {
|
|
128
|
-
"deck-id": {
|
|
129
|
-
type: "string",
|
|
130
|
-
description: "Only return cards for the specified deck ID",
|
|
131
|
-
},
|
|
132
|
-
limit: {
|
|
133
|
-
type: "number",
|
|
134
|
-
description: "Number of cards to return per page (1-100, default 10)",
|
|
135
|
-
},
|
|
136
|
-
bookmark: {
|
|
137
|
-
type: "string",
|
|
138
|
-
description: "Cursor for pagination from a previous list request",
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
const LIST_DECKS_TOOL = {
|
|
144
|
-
name: "mochi_list_decks",
|
|
145
|
-
description: "List all decks",
|
|
146
|
-
inputSchema: {
|
|
147
|
-
type: "object",
|
|
148
|
-
properties: {},
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
const MOCHI_TOOLS = [
|
|
152
|
-
CREATE_CARD_TOOL,
|
|
153
|
-
LIST_CARDS_TOOL,
|
|
154
|
-
LIST_DECKS_TOOL,
|
|
155
|
-
];
|
|
156
104
|
export class MochiClient {
|
|
157
105
|
api;
|
|
158
106
|
token;
|
|
@@ -197,7 +145,23 @@ const server = new Server({
|
|
|
197
145
|
});
|
|
198
146
|
// Set up request handlers
|
|
199
147
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
200
|
-
tools:
|
|
148
|
+
tools: [
|
|
149
|
+
{
|
|
150
|
+
name: "mochi_create_card",
|
|
151
|
+
description: "Create a new flashcard",
|
|
152
|
+
inputSchema: zodToJsonSchema(CreateCardRequestSchema),
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "mochi_list_cards",
|
|
156
|
+
description: "List cards in pages of 10 cards per page",
|
|
157
|
+
inputSchema: zodToJsonSchema(ListCardsParamsSchema),
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "mochi_list_decks",
|
|
161
|
+
description: "List all decks",
|
|
162
|
+
inputSchema: zodToJsonSchema(ListDecksParamsSchema),
|
|
163
|
+
},
|
|
164
|
+
],
|
|
201
165
|
}));
|
|
202
166
|
// Add resource handlers
|
|
203
167
|
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
@@ -241,15 +205,42 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
241
205
|
switch (request.params.name) {
|
|
242
206
|
case "mochi_create_card": {
|
|
243
207
|
const validatedArgs = CreateCardRequestSchema.parse(request.params.arguments);
|
|
244
|
-
|
|
208
|
+
const response = await mochiClient.createCard(validatedArgs);
|
|
209
|
+
return {
|
|
210
|
+
content: [
|
|
211
|
+
{
|
|
212
|
+
type: "text",
|
|
213
|
+
text: JSON.stringify(response, null, 2),
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
isError: false,
|
|
217
|
+
};
|
|
245
218
|
}
|
|
246
219
|
case "mochi_list_decks": {
|
|
247
220
|
const validatedArgs = ListDecksParamsSchema.parse(request.params.arguments);
|
|
248
|
-
|
|
221
|
+
const response = await mochiClient.listDecks(validatedArgs);
|
|
222
|
+
return {
|
|
223
|
+
content: [
|
|
224
|
+
{
|
|
225
|
+
type: "text",
|
|
226
|
+
text: JSON.stringify(response, null, 2),
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
isError: false,
|
|
230
|
+
};
|
|
249
231
|
}
|
|
250
232
|
case "mochi_list_cards": {
|
|
251
233
|
const validatedArgs = ListCardsParamsSchema.parse(request.params.arguments);
|
|
252
|
-
|
|
234
|
+
const response = await mochiClient.listCards(validatedArgs);
|
|
235
|
+
return {
|
|
236
|
+
content: [
|
|
237
|
+
{
|
|
238
|
+
type: "text",
|
|
239
|
+
text: JSON.stringify(response, null, 2),
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
isError: false,
|
|
243
|
+
};
|
|
253
244
|
}
|
|
254
245
|
default:
|
|
255
246
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fredrika/mcp-mochi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "MCP server for Mochi flashcard integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"start": "node dist/index.js",
|
|
17
17
|
"dev": "ts-node-esm src/index.ts",
|
|
18
|
-
"dev:inspect": "npx @modelcontextprotocol/inspector ts-node-esm src/
|
|
18
|
+
"dev:inspect": "npx @modelcontextprotocol/inspector ts-node-esm src/index.ts",
|
|
19
19
|
"test": "jest",
|
|
20
20
|
"prepublishOnly": "npm run build"
|
|
21
21
|
},
|