@mentagen/mcp 0.1.0

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.
Files changed (39) hide show
  1. package/README.md +100 -0
  2. package/dist/client/helene.js +178 -0
  3. package/dist/client/types.js +27 -0
  4. package/dist/index.js +26 -0
  5. package/dist/tools/batch-update.js +118 -0
  6. package/dist/tools/boards.js +50 -0
  7. package/dist/tools/check-collision.js +55 -0
  8. package/dist/tools/colors.js +35 -0
  9. package/dist/tools/create-board.js +50 -0
  10. package/dist/tools/create-edge.js +61 -0
  11. package/dist/tools/create-graph.js +174 -0
  12. package/dist/tools/create.js +152 -0
  13. package/dist/tools/delete-edge.js +36 -0
  14. package/dist/tools/delete.js +36 -0
  15. package/dist/tools/extract-board-content.js +207 -0
  16. package/dist/tools/find-position.js +117 -0
  17. package/dist/tools/grid-calc.js +205 -0
  18. package/dist/tools/index.js +940 -0
  19. package/dist/tools/link.js +22 -0
  20. package/dist/tools/list-edges.js +58 -0
  21. package/dist/tools/list-nodes.js +96 -0
  22. package/dist/tools/list-positions.js +64 -0
  23. package/dist/tools/node-types.js +65 -0
  24. package/dist/tools/patch-content.js +143 -0
  25. package/dist/tools/read.js +41 -0
  26. package/dist/tools/search-board.js +99 -0
  27. package/dist/tools/search-boards.js +50 -0
  28. package/dist/tools/search.js +89 -0
  29. package/dist/tools/size-calc.js +108 -0
  30. package/dist/tools/update-board.js +64 -0
  31. package/dist/tools/update-edge.js +63 -0
  32. package/dist/tools/update.js +157 -0
  33. package/dist/utils/collision.js +177 -0
  34. package/dist/utils/config.js +16 -0
  35. package/dist/utils/ejson.js +30 -0
  36. package/dist/utils/errors.js +16 -0
  37. package/dist/utils/formatting.js +15 -0
  38. package/dist/utils/urls.js +18 -0
  39. package/package.json +49 -0
@@ -0,0 +1,30 @@
1
+ import { EJSON } from 'ejson2';
2
+ /**
3
+ * Parse an EJSON value and convert EJSON types (like $date) to native JS types.
4
+ * Use this when receiving data from the Mentagen API.
5
+ */
6
+ export function parseEJSON(value) {
7
+ return EJSON.fromJSONValue(value);
8
+ }
9
+ /**
10
+ * Format a date value (which may be an EJSON $date object) to ISO string.
11
+ */
12
+ export function formatDate(value) {
13
+ if (!value)
14
+ return '';
15
+ const parsed = parseEJSON(value);
16
+ if (parsed instanceof Date) {
17
+ return parsed.toISOString();
18
+ }
19
+ if (typeof parsed === 'string') {
20
+ return new Date(parsed).toISOString();
21
+ }
22
+ return '';
23
+ }
24
+ /**
25
+ * Format a date value to short date string (YYYY-MM-DD).
26
+ */
27
+ export function formatShortDate(value) {
28
+ const iso = formatDate(value);
29
+ return iso ? iso.split('T')[0] : '';
30
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Format error messages for AI consumption.
3
+ * Errors should be clear and actionable.
4
+ */
5
+ export function formatError(error) {
6
+ if (error instanceof Error) {
7
+ if (error.message.includes('Not Authorized')) {
8
+ return 'Permission denied. Your token may not have access to this resource.';
9
+ }
10
+ if (error.message.includes('not found')) {
11
+ return `Resource not found. ${error.message}`;
12
+ }
13
+ return error.message;
14
+ }
15
+ return String(error);
16
+ }
@@ -0,0 +1,15 @@
1
+ export function formatSearchResults(hits) {
2
+ const results = hits.map(hit => ({
3
+ id: hit._id,
4
+ name: hit.name,
5
+ content: hit.content || null,
6
+ type: hit.type || 'text',
7
+ board: hit.board || null,
8
+ score: hit._rankingScore || 0,
9
+ updatedAt: hit.updatedAt ? new Date(hit.updatedAt).toISOString() : null,
10
+ }));
11
+ return {
12
+ results,
13
+ total: results.length,
14
+ };
15
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Get the app URL from the API URL.
3
+ * Locally, the API runs on port 8002 but the app runs on port 8000.
4
+ */
5
+ export function getAppUrl(apiUrl) {
6
+ const url = apiUrl.replace(/\/$/, '');
7
+ // Local dev: API is on 8002, app is on 8000
8
+ if (url.includes('localhost:8002')) {
9
+ return url.replace(':8002', ':8000');
10
+ }
11
+ return url;
12
+ }
13
+ export function getBoardUrl(baseUrl, boardId) {
14
+ return `${getAppUrl(baseUrl)}/b/${boardId}`;
15
+ }
16
+ export function getNodeUrl(baseUrl, boardId, nodeId) {
17
+ return `${getAppUrl(baseUrl)}/b/${boardId}/n/${nodeId}`;
18
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@mentagen/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for Mentagen knowledge base integration with Cursor",
5
+ "type": "module",
6
+ "bin": "dist/index.js",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "sideEffects": false,
11
+ "scripts": {
12
+ "clean": "rm -rf dist",
13
+ "prebuild": "yarn clean",
14
+ "build": "tsc --project tsconfig.build.json",
15
+ "verify": "node scripts/verify-build.js",
16
+ "dev": "tsx watch src/index.ts",
17
+ "start": "node dist/index.js",
18
+ "prepublishOnly": "yarn test && yarn build && yarn verify",
19
+ "test": "vitest run",
20
+ "test:watch": "vitest"
21
+ },
22
+ "keywords": [
23
+ "mcp",
24
+ "mentagen",
25
+ "cursor",
26
+ "knowledge-base",
27
+ "ai"
28
+ ],
29
+ "license": "UNLICENSED",
30
+ "dependencies": {
31
+ "@modelcontextprotocol/sdk": "^1.0.0",
32
+ "ejson2": "^1.1.0",
33
+ "papaparse": "^5.5.3",
34
+ "zod": "^3.24.1"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^22.10.5",
38
+ "@types/papaparse": "^5.5.2",
39
+ "tsx": "^4.19.2",
40
+ "typescript": "^5.7.3",
41
+ "vitest": "^3.0.0"
42
+ },
43
+ "engines": {
44
+ "node": ">=18"
45
+ },
46
+ "resolutions": {
47
+ "tar": "7.5.3"
48
+ }
49
+ }