memos-mcp 1.0.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.
@@ -0,0 +1,19 @@
1
+ {
2
+ "[typescript]": {
3
+ "editor.formatOnSave": true,
4
+ "editor.formatOnSaveMode": "file"
5
+ },
6
+ "editor.formatOnSave": true,
7
+ "editor.formatOnSaveMode": "file",
8
+ "editor.codeActionsOnSave": {
9
+ "source.fixAll.biome": "explicit",
10
+ "source.organizeImports.biome": "explicit"
11
+ },
12
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
13
+ "nodejs-testing.extensions": [
14
+ {
15
+ "extensions": ["mjs", "cjs", "js", "ts"],
16
+ "parameters": []
17
+ }
18
+ ]
19
+ }
package/AGENTS.md ADDED
@@ -0,0 +1,96 @@
1
+ # Agent Guidelines for memos-mcp
2
+
3
+ ## Overview
4
+
5
+ This is an MCP (Model Context Protocol) server for Memos - a lightweight, self-hosted memo hub. The server provides tools to create and search memos via the Memos API.
6
+
7
+ ## Required Checks Before Committing
8
+
9
+ **IMPORTANT:** Always run these commands before committing changes:
10
+
11
+ ```bash
12
+ # 1. Type checking - REQUIRED
13
+ npm run typecheck
14
+
15
+ # 2. Linting - REQUIRED
16
+ npm run lint
17
+
18
+ # 3. Format check - REQUIRED
19
+ npm run format:check
20
+
21
+ # 4. Tests - REQUIRED
22
+ npm run test
23
+ ```
24
+
25
+ All checks must pass before committing. You can auto-fix lint and format issues:
26
+
27
+ ```bash
28
+ npm run lint:fix # Auto-fix lint issues
29
+ npm run format # Auto-format code
30
+ ```
31
+
32
+ ## Project Structure
33
+
34
+ ```
35
+ src/
36
+ ├── index.ts # MCP server entry point
37
+ ├── memos-client.ts # Memos API client
38
+ ├── memos-client.test.ts # Client tests
39
+ ├── cert-manager.ts # SSL certificate auto-fetch & cache
40
+ └── cert-manager.test.ts # Cert manager tests
41
+ ```
42
+
43
+ ## Key Technical Details
44
+
45
+ ### SSL Certificate Handling
46
+
47
+ The project includes automatic SSL certificate management for servers with incomplete certificate chains (missing intermediates). See `cert-manager.ts`:
48
+
49
+ - Auto-fetches Let's Encrypt intermediate certificates via HTTPS
50
+ - Caches certificates in `~/.cache/memos-mcp/certs/`
51
+ - Auto-refreshes when cache > 30 days or cert expires within 30 days
52
+
53
+ ### Dependencies
54
+
55
+ - `@modelcontextprotocol/sdk` - MCP SDK for server implementation
56
+ - `undici` - HTTP client with custom TLS agent support
57
+
58
+ ### Node.js Version
59
+
60
+ Requires Node.js >= 22.0.0
61
+
62
+ ## Code Style
63
+
64
+ - Uses Prettier for formatting (config in package.json)
65
+ - Uses ESLint with TypeScript plugin
66
+ - Double quotes for strings
67
+ - Semicolons required
68
+ - 120 character line width
69
+
70
+ ## Testing
71
+
72
+ Tests use Node.js built-in test runner (`node:test`):
73
+
74
+ ```bash
75
+ npm run test
76
+ ```
77
+
78
+ Integration tests in `cert-manager.test.ts` make real network requests to Let's Encrypt servers.
79
+
80
+ ## Common Tasks
81
+
82
+ ### Adding a new MCP tool
83
+
84
+ 1. Add tool definition in `src/index.ts` under `server.setRequestHandler(ListToolsRequestSchema, ...)`
85
+ 2. Add tool handler in `server.setRequestHandler(CallToolRequestSchema, ...)`
86
+ 3. Implement the method in `src/memos-client.ts`
87
+ 4. Add tests in `src/memos-client.test.ts`
88
+
89
+ ### Updating certificates
90
+
91
+ Certificates are auto-fetched, but you can force refresh:
92
+
93
+ ```typescript
94
+ import { refreshAllCerts } from "./cert-manager.ts";
95
+ await refreshAllCerts();
96
+ ```
package/Jenkinsfile ADDED
@@ -0,0 +1,80 @@
1
+ pipeline {
2
+ agent any
3
+ tools {
4
+ nodejs 'NodeJS 24.x'
5
+ }
6
+ stages {
7
+ stage('Checkout') {
8
+ steps {
9
+ checkout scm
10
+ }
11
+ }
12
+
13
+ stage('Install') {
14
+ steps {
15
+ script {
16
+ sh 'npm i'
17
+ }
18
+ }
19
+ }
20
+
21
+ stage('Lint') {
22
+ steps {
23
+ script {
24
+ sh 'npm run lint --if-present'
25
+ sh 'npm run format:check --if-present'
26
+ }
27
+ }
28
+ }
29
+
30
+ stage('Test') {
31
+ steps {
32
+ script {
33
+ sh 'npm test --if-present'
34
+ }
35
+ }
36
+ }
37
+
38
+ stage('Build') {
39
+ steps {
40
+ script {
41
+ sh 'npm run build --if-present'
42
+ }
43
+ }
44
+ }
45
+
46
+ stage('Publish Official Release') {
47
+ when {
48
+ expression { env.TAG_NAME != null } // Only run for tag builds
49
+ }
50
+ environment {
51
+ NPM_TOKEN = credentials('npm-verdaccio-publish-token')
52
+ }
53
+ steps {
54
+ sh 'npm config set //verdaccio-verdaccio-68mj54-e6081a-192-168-111-123.traefik.me/:_authToken=${NPM_TOKEN} --location project'
55
+ sh 'npm publish --tag latest'
56
+ }
57
+ }
58
+
59
+ // stage('Publish Snapshot Build') {
60
+ // when {
61
+ // expression { env.TAG_NAME == null } // Only run for non-tag builds
62
+ // }
63
+ // environment {
64
+ // NPM_TOKEN = credentials('npm-verdaccio-publish-token')
65
+ // }
66
+ // steps {
67
+ // sh 'npm config set //verdaccio-verdaccio-68mj54-e6081a-192-168-111-123.traefik.me/:_authToken=${NPM_TOKEN} --location project'
68
+ // sh 'npm version 0.0.0-BUILD-${BUILD_NUMBER} --no-git-tag-version' // Apply snapshot version
69
+ // sh 'npm publish --tag snapshot' // Publish with snapshot tag
70
+ // }
71
+ // }
72
+
73
+ }
74
+
75
+ post {
76
+ always {
77
+ cleanWs()
78
+ }
79
+ }
80
+ }
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # Memos MCP Server
2
+
3
+ A Model Context Protocol (MCP) server for [Memos](https://usememos.com/) - a self-hosted memo hub. This server enables AI assistants to create and search memos through the Memos API.
4
+
5
+ ## Features
6
+
7
+ - **Create memos** with content, visibility settings, and location data
8
+ - **Search memos** by text query, tag, visibility, or state
9
+ - **Get individual memos** by ID
10
+
11
+ ## Requirements
12
+
13
+ - Node.js 22+ (uses native TypeScript type stripping)
14
+ - A running Memos instance
15
+ - Personal Access Token from your Memos account
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install
21
+ ```
22
+
23
+ ## Configuration
24
+
25
+ The server requires two environment variables:
26
+
27
+ | Variable | Description | Example |
28
+ | -------------------- | -------------------------------- | --------------------------- |
29
+ | `MEMOS_URL` | Your Memos instance URL | `https://memos.example.com` |
30
+ | `MEMOS_ACCESS_TOKEN` | Personal Access Token from Memos | `eyJhbGciOiJIUzI1...` |
31
+
32
+ ### Getting an Access Token
33
+
34
+ 1. Log into your Memos instance
35
+ 2. Go to Settings → My Account
36
+ 3. Create a new Personal Access Token
37
+ 4. Copy the token (it's only shown once)
38
+
39
+ ## Usage
40
+
41
+ ### Running the Server
42
+
43
+ ```bash
44
+ MEMOS_URL=https://memos.example.com MEMOS_ACCESS_TOKEN=your-token npm start
45
+ ```
46
+
47
+ ### OpenCode Configuration
48
+
49
+ Add to your `opencode.json` (or `opencode.jsonc`):
50
+
51
+ ```json
52
+ {
53
+ "$schema": "https://opencode.ai/config.json",
54
+ "mcp": {
55
+ "memos": {
56
+ "type": "local",
57
+ "command": ["node", "/path/to/memos-map/src/index.ts"],
58
+ "enabled": true,
59
+ "environment": {
60
+ "MEMOS_URL": "https://your-memos-instance.com",
61
+ "MEMOS_ACCESS_TOKEN": "{env:MEMOS_ACCESS_TOKEN}"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ You can also use environment variables directly:
69
+
70
+ ```json
71
+ {
72
+ "$schema": "https://opencode.ai/config.json",
73
+ "mcp": {
74
+ "memos": {
75
+ "type": "local",
76
+ "command": ["node", "/path/to/memos-map/src/index.ts"],
77
+ "enabled": true,
78
+ "environment": {
79
+ "MEMOS_URL": "{env:MEMOS_URL}",
80
+ "MEMOS_ACCESS_TOKEN": "{env:MEMOS_ACCESS_TOKEN}"
81
+ }
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
87
+ Then use `memos` tools in your prompts:
88
+
89
+ ```
90
+ Create a memo with today's meeting notes. use memos
91
+ ```
92
+
93
+ ### Claude Desktop Configuration
94
+
95
+ Add to your Claude Desktop MCP configuration:
96
+
97
+ ```json
98
+ {
99
+ "mcpServers": {
100
+ "memos": {
101
+ "command": "node",
102
+ "args": ["/path/to/memos-map/src/index.ts"],
103
+ "env": {
104
+ "MEMOS_URL": "https://your-memos-instance.com",
105
+ "MEMOS_ACCESS_TOKEN": "your-access-token-here"
106
+ }
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ ## Available Tools
113
+
114
+ ### `create_memo`
115
+
116
+ Create a new memo.
117
+
118
+ | Parameter | Type | Required | Description |
119
+ | ------------ | ------ | -------- | -------------------------------------------------------- |
120
+ | `content` | string | Yes | Memo content (supports Markdown) |
121
+ | `visibility` | string | No | `PRIVATE`, `PROTECTED`, or `PUBLIC` (default: `PRIVATE`) |
122
+ | `location` | object | No | Location with `placeholder`, `latitude`, `longitude` |
123
+
124
+ ### `search_memos`
125
+
126
+ Search and list memos.
127
+
128
+ | Parameter | Type | Required | Description |
129
+ | ------------ | ------ | -------- | ------------------------------------------ |
130
+ | `query` | string | No | Text to search in memo content |
131
+ | `tag` | string | No | Filter by tag (without #) |
132
+ | `visibility` | string | No | Filter by visibility |
133
+ | `state` | string | No | `NORMAL` or `ARCHIVED` (default: `NORMAL`) |
134
+ | `pageSize` | number | No | Results per page (default: 20) |
135
+ | `orderBy` | string | No | Sort order (default: `display_time desc`) |
136
+
137
+ ### `get_memo`
138
+
139
+ Get a single memo by ID.
140
+
141
+ | Parameter | Type | Required | Description |
142
+ | --------- | ------ | -------- | ----------- |
143
+ | `memoId` | string | Yes | The memo ID |
144
+
145
+ ## Development
146
+
147
+ ### Running Tests
148
+
149
+ ```bash
150
+ npm test
151
+ ```
152
+
153
+ ### Project Structure
154
+
155
+ ```
156
+ src/
157
+ ├── index.ts # MCP server entry point
158
+ ├── memos-client.ts # Memos API client
159
+ └── memos-client.test.ts # Tests
160
+ ```
161
+
162
+ ## License
163
+
164
+ MIT
package/RELEASE.md ADDED
@@ -0,0 +1,25 @@
1
+ ## Release Process
2
+
3
+ This project uses a two-pronged release approach:
4
+
5
+ ### Official Releases (Versioned)
6
+
7
+ Official releases follow Semantic Versioning (MAJOR.MINOR.PATCH) and are published to npm with the `latest` tag.
8
+
9
+ **Steps for a Developer to Create an Official Release:**
10
+
11
+ 1. **Ensure your local `main` branch is up-to-date** and all changes intended for the release are merged.
12
+ 2. **Run `npm version <patch|minor|major>` locally.** This command will:
13
+ - Increment the version in `package.json`.
14
+ - Create a git commit for the version change.
15
+ - Create a corresponding local git tag (e.g., `v1.0.0`).
16
+ - Example: `npm version patch`
17
+ 3. **Push the commit and the new tag to the remote repository:**
18
+ ```bash
19
+ git push && git push --tags
20
+ ```
21
+ 4. **Jenkins will automatically detect the new tag** and trigger a pipeline build. The `Publish Official Release` stage in the `Jenkinsfile` will then publish the package to npm with the `latest` tag.
22
+
23
+ ### Snapshot Builds
24
+
25
+ For builds on branches that are not triggered by a git tag (e.g., `main` branch builds from regular commits), a snapshot version is automatically applied and published to npm with a `snapshot` tag. These builds are primarily for continuous integration and testing purposes and do not represent official releases.
@@ -0,0 +1,34 @@
1
+ // eslint.config.js
2
+ import js from "@eslint/js";
3
+ import typescript from "@typescript-eslint/eslint-plugin";
4
+ import typescriptParser from "@typescript-eslint/parser";
5
+ import prettier from "eslint-plugin-prettier";
6
+ import prettierConfig from "eslint-config-prettier";
7
+ import globals from "globals";
8
+
9
+ export default [
10
+ js.configs.recommended,
11
+ {
12
+ files: ["**/*.{js,mjs,cjs,ts,tsx}"],
13
+ languageOptions: {
14
+ ecmaVersion: "latest",
15
+ sourceType: "module",
16
+ parser: typescriptParser,
17
+ globals: {
18
+ ...globals.node,
19
+ RequestInit: "readonly",
20
+ },
21
+ },
22
+ plugins: {
23
+ "@typescript-eslint": typescript,
24
+ prettier: prettier,
25
+ },
26
+ rules: {
27
+ ...typescript.configs.recommended.rules,
28
+ ...prettierConfig.rules,
29
+ "prettier/prettier": "error",
30
+ "no-unused-vars": "off",
31
+ "@typescript-eslint/no-unused-vars": "error",
32
+ },
33
+ },
34
+ ];
package/memory.md ADDED
@@ -0,0 +1,51 @@
1
+ # Memory
2
+
3
+ ## Project Purpose
4
+
5
+ This project appears to be a TypeScript project template, providing a basic setup for developing and testing TypeScript code. It includes a simple `add` function and a corresponding unit test.
6
+
7
+ ## Project Structure
8
+
9
+ - `.gitignore`: Specifies intentionally untracked files to ignore.
10
+ - `eslint.config.js`: ESLint configuration for linting TypeScript files.
11
+ - `Jenkinsfile`: Likely a Jenkins pipeline definition for CI/CD.
12
+ - `package-lock.json`: Records the exact dependency tree.
13
+ - `package.json`: Project metadata, scripts, and dependencies.
14
+ - `README.md`: Project README file.
15
+ - `RELEASE.md`: Release notes or guidelines.
16
+ - `src/`: Source code directory.
17
+ - `src/index.ts`: Contains the main application logic (currently a simple `add` function).
18
+ - `test/`: Test code directory.
19
+ - `test/index.test.ts`: Contains unit tests for `src/index.ts`.
20
+
21
+ ## Project Technical Details
22
+
23
+ ### Technical Stack
24
+
25
+ - **Language**: Node.js Native TypeScript (means not compiler required and must import module with `.ts`/`.js` suffix)
26
+ - **Runtime**: Node.js
27
+ - **Linting**: ESLint with `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser`
28
+ - **Formatting**: Prettier with `eslint-config-prettier` and `eslint-plugin-prettier`
29
+ - **Testing**: Node.js built-in test runner (`node --test`)
30
+
31
+ ### Important Dependent Libraries
32
+
33
+ - `@types/node`: Type definitions for Node.js.
34
+ - `@typescript-eslint/eslint-plugin`: ESLint plugin for TypeScript.
35
+ - `@typescript-eslint/parser`: Parser for ESLint to understand TypeScript.
36
+ - `eslint`: Linter.
37
+ - `eslint-config-prettier`: Disables ESLint rules that conflict with Prettier.
38
+ - `eslint-plugin-prettier`: Runs Prettier as an ESLint rule.
39
+ - `prettier`: Code formatter.
40
+
41
+ ## Features Implemented
42
+
43
+ - A basic `add` function in `src/index.ts`.
44
+ - A unit test for the `add` function in `test/index.test.ts`.
45
+ - Linting and formatting configurations.
46
+ - A test script using Node.js's built-in test runner.
47
+
48
+ ## Design Patterns
49
+
50
+ - **Modular Design**: The `add` function is exported from `index.ts` and imported into `index.test.ts`, demonstrating modularity.
51
+ - **Unit Testing**: The project includes a dedicated test file and uses a unit testing framework to verify the correctness of the `add` function.
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "memos-mcp",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "description": "MCP server for Memos - create and search memos",
6
+ "main": "src/index.ts",
7
+ "bin": {
8
+ "memos-mcp": "./src/index.ts"
9
+ },
10
+ "scripts": {
11
+ "start": "node src/index.ts",
12
+ "test": "node --test",
13
+ "typecheck": "tsc --noEmit",
14
+ "lint": "eslint .",
15
+ "lint:fix": "eslint . --fix",
16
+ "format": "prettier --write .",
17
+ "format:check": "prettier --check ."
18
+ },
19
+ "dependencies": {
20
+ "@modelcontextprotocol/sdk": "^1.0.0",
21
+ "undici": "^7.21.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^24.10.1",
25
+ "@typescript-eslint/eslint-plugin": "^8.48.1",
26
+ "@typescript-eslint/parser": "^8.48.1",
27
+ "eslint": "^9.39.1",
28
+ "eslint-config-prettier": "^10.1.8",
29
+ "eslint-plugin-prettier": "^5.5.4",
30
+ "prettier": "^3.7.4"
31
+ },
32
+ "prettier": {
33
+ "semi": true,
34
+ "singleQuote": false,
35
+ "printWidth": 120,
36
+ "tabWidth": 2,
37
+ "trailingComma": "all",
38
+ "endOfLine": "lf"
39
+ },
40
+ "engines": {
41
+ "node": ">=22.0.0"
42
+ }
43
+ }