remnote-mcp-server 0.13.1 → 0.14.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/CHANGELOG.md +40 -0
- package/README.md +44 -23
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/remnote-cli/cli.d.ts +3 -0
- package/dist/remnote-cli/cli.js +37 -0
- package/dist/remnote-cli/cli.js.map +1 -0
- package/dist/remnote-cli/client/command-client.d.ts +3 -0
- package/dist/remnote-cli/client/command-client.js +9 -0
- package/dist/remnote-cli/client/command-client.js.map +1 -0
- package/dist/remnote-cli/client/mcp-server-client.d.ts +18 -0
- package/dist/remnote-cli/client/mcp-server-client.js +116 -0
- package/dist/remnote-cli/client/mcp-server-client.js.map +1 -0
- package/dist/remnote-cli/commands/arg-utils.d.ts +33 -0
- package/dist/remnote-cli/commands/arg-utils.js +89 -0
- package/dist/remnote-cli/commands/arg-utils.js.map +1 -0
- package/dist/remnote-cli/commands/content-input.d.ts +31 -0
- package/dist/remnote-cli/commands/content-input.js +81 -0
- package/dist/remnote-cli/commands/content-input.js.map +1 -0
- package/dist/remnote-cli/commands/create.d.ts +2 -0
- package/dist/remnote-cli/commands/create.js +61 -0
- package/dist/remnote-cli/commands/create.js.map +1 -0
- package/dist/remnote-cli/commands/journal.d.ts +2 -0
- package/dist/remnote-cli/commands/journal.js +52 -0
- package/dist/remnote-cli/commands/journal.js.map +1 -0
- package/dist/remnote-cli/commands/read.d.ts +2 -0
- package/dist/remnote-cli/commands/read.js +74 -0
- package/dist/remnote-cli/commands/read.js.map +1 -0
- package/dist/remnote-cli/commands/search.d.ts +3 -0
- package/dist/remnote-cli/commands/search.js +107 -0
- package/dist/remnote-cli/commands/search.js.map +1 -0
- package/dist/remnote-cli/commands/status.d.ts +2 -0
- package/dist/remnote-cli/commands/status.js +41 -0
- package/dist/remnote-cli/commands/status.js.map +1 -0
- package/dist/remnote-cli/commands/table.d.ts +2 -0
- package/dist/remnote-cli/commands/table.js +79 -0
- package/dist/remnote-cli/commands/table.js.map +1 -0
- package/dist/remnote-cli/commands/update.d.ts +2 -0
- package/dist/remnote-cli/commands/update.js +62 -0
- package/dist/remnote-cli/commands/update.js.map +1 -0
- package/dist/remnote-cli/config.d.ts +9 -0
- package/dist/remnote-cli/config.js +10 -0
- package/dist/remnote-cli/config.js.map +1 -0
- package/dist/remnote-cli/index.d.ts +2 -0
- package/dist/remnote-cli/index.js +4 -0
- package/dist/remnote-cli/index.js.map +1 -0
- package/dist/remnote-cli/output/formatter.d.ts +9 -0
- package/dist/remnote-cli/output/formatter.js +28 -0
- package/dist/remnote-cli/output/formatter.js.map +1 -0
- package/dist/remnote-cli/version-compat.d.ts +7 -0
- package/dist/remnote-cli/version-compat.js +28 -0
- package/dist/remnote-cli/version-compat.js.map +1 -0
- package/mcpb/remnote-local/.mcpbignore +5 -0
- package/mcpb/remnote-local/README.md +25 -0
- package/mcpb/remnote-local/manifest.json +87 -0
- package/mcpb/remnote-local/package.json +11 -0
- package/mcpb/remnote-local/remnote-local.mcpb +0 -0
- package/mcpb/remnote-local/server/index.js +300 -0
- package/package.json +16 -9
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,46 @@ Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.14.1] - 2026-05-08
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Added a `remnote-local` MCPB package for Claude Desktop that proxies stdio MCP calls to a locally running
|
|
15
|
+
`remnote-mcp-server` Streamable HTTP endpoint without public HTTPS, including setup docs, screenshots, and official
|
|
16
|
+
MCPB references.
|
|
17
|
+
- Added `remnote-mcp-server mcpb-path` to print the bundled Claude Desktop extension path after npm installation.
|
|
18
|
+
- Added the `remnote-mcp-stdio` executable for local MCP clients that consume stdio servers, including help/version
|
|
19
|
+
output and smoke-test commands in the configuration guide.
|
|
20
|
+
- Added Codex TUI and Codex.app configuration documentation covering Streamable HTTP MCP, `remnote-mcp-stdio`, and
|
|
21
|
+
`remnote-cli` skill setup.
|
|
22
|
+
- Added MCP protocol compatibility guidance clarifying that `2025-11-25` initialize requests are supported and separate
|
|
23
|
+
from bridge/server package versions.
|
|
24
|
+
- Added clearer stdio proxy prerequisites and cross-links between the generic stdio MCP client section and the Codex
|
|
25
|
+
stdio setup example.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Reordered the README AI client setup list to include Codex and prioritize the local Claude Desktop MCPB path before
|
|
30
|
+
remote connector setup.
|
|
31
|
+
- Updated documentation and agent repo maps to reflect that the old standalone `remnote-cli` repository is
|
|
32
|
+
discontinued and the maintained CLI lives in this package.
|
|
33
|
+
|
|
34
|
+
## [0.14.0] - 2026-05-07
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- Bundled the `remnote-cli` executable into the `remnote-mcp-server` package. The package now provides both
|
|
39
|
+
`remnote-mcp-server` and `remnote-cli`.
|
|
40
|
+
- Added local `link-cli.sh` and `unlink-cli.sh` helpers for linking both executables during development.
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- Consolidated CLI installation guidance around `npm install -g remnote-mcp-server`; the old standalone
|
|
45
|
+
`remnote-cli` package is now treated as a legacy migration path.
|
|
46
|
+
- Updated agent-assisted and manual integration workflows so the direct MCP and bundled CLI paths run through the
|
|
47
|
+
unified MCP server, with `--suite mcp|cli|all` for targeted reruns.
|
|
48
|
+
- Added server-owned CLI command, troubleshooting, demo, and skill documentation.
|
|
49
|
+
|
|
10
50
|
## [0.13.1] - 2026-05-06
|
|
11
51
|
|
|
12
52
|
### Changed
|
package/README.md
CHANGED
|
@@ -5,23 +5,19 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/remnote-mcp-server)
|
|
6
6
|
[](https://codecov.io/gh/robert7/remnote-mcp-server)
|
|
7
7
|
|
|
8
|
-
MCP server that bridges AI agents
|
|
9
|
-
|
|
8
|
+
MCP server and CLI package that bridges AI agents, local scripts, and coding harnesses to
|
|
9
|
+
[RemNote](https://remnote.com/) via the [RemNote Automation Bridge
|
|
10
|
+
plugin](https://github.com/robert7/remnote-mcp-bridge).
|
|
10
11
|
|
|
11
12
|
> If you run into any issues, please [report them here](https://github.com/robert7/remnote-mcp-server/issues).
|
|
12
13
|
|
|
13
14
|
## What is This?
|
|
14
15
|
|
|
15
16
|
The RemNote MCP Server enables AI assistants like Claude Code to interact directly with your RemNote knowledge base
|
|
16
|
-
through the Model Context Protocol (MCP).
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
For some agentic workflows or CLI-first automation, the companion app
|
|
21
|
-
**[remnote-cli](https://github.com/robert7/remnote-cli)** may be a better fit than running a full MCP server.
|
|
22
|
-
In particular, **coding harnesses** (Claude Code, GitHub Copilot CLI, Codex CLI, etc.) can use `remnote-cli` with
|
|
23
|
-
**zero config** — paste one prompt that loads the skill file and the agent handles the rest. See
|
|
24
|
-
[Use RemNote from Any Coding Harness](https://github.com/robert7/remnote-cli/blob/main/docs/demo.md#use-remnote-from-any-coding-harness).
|
|
17
|
+
through the Model Context Protocol (MCP). The same npm package also provides `remnote-cli`, a command-line MCP client
|
|
18
|
+
for local scripts and coding harnesses, and `remnote-mcp-stdio`, a stdio MCP proxy for clients that cannot consume
|
|
19
|
+
Streamable HTTP directly. Create notes, hierarchical markdown trees, and RemNote-native flashcards; search and read
|
|
20
|
+
your knowledge base; update existing notes; and maintain your daily journal through MCP tools or shell commands.
|
|
25
21
|
|
|
26
22
|
## Demo
|
|
27
23
|
|
|
@@ -29,14 +25,15 @@ See AI agent examples in action with RemNote: **[View Demo →](docs/demo.md)**
|
|
|
29
25
|
|
|
30
26
|
### Two-Component Architecture
|
|
31
27
|
|
|
32
|
-
This system consists of **two separate components** that work together:
|
|
28
|
+
This system consists of **two separate runtime components** that work together:
|
|
33
29
|
|
|
34
30
|
1. **[RemNote Automation Bridge](https://github.com/robert7/remnote-mcp-bridge)** - A RemNote plugin that runs in your
|
|
35
31
|
browser or RemNote desktop app and exposes RemNote API functionality via WebSocket
|
|
36
|
-
2. **RemNote MCP Server** (this project) - A standalone server that
|
|
37
|
-
|
|
32
|
+
2. **RemNote MCP Server** (this project) - A standalone server package that provides `remnote-mcp-server` for MCP
|
|
33
|
+
HTTP clients, `remnote-mcp-stdio` for stdio MCP clients, and `remnote-cli` for command-line workflows
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
The `remnote-cli` and `remnote-mcp-stdio` commands are not second RemNote-facing servers. They call the MCP endpoint
|
|
36
|
+
exposed by `remnote-mcp-server`.
|
|
40
37
|
|
|
41
38
|
For the detailed bridge connection lifecycle, retry phases, and wake-up triggers, use the bridge repo as the source of
|
|
42
39
|
truth: [Connection Lifecycle Guide](https://github.com/robert7/remnote-mcp-bridge/blob/main/docs/guides/connection-lifecycle.md).
|
|
@@ -44,12 +41,16 @@ truth: [Connection Lifecycle Guide](https://github.com/robert7/remnote-mcp-bridg
|
|
|
44
41
|
### How It Works
|
|
45
42
|
|
|
46
43
|
```text
|
|
47
|
-
AI agents (HTTP)
|
|
44
|
+
AI agents (HTTP) -> MCP HTTP Server :3001 -> WebSocket Server :3002 -> RemNote Plugin -> RemNote
|
|
45
|
+
AI agents (stdio) -> remnote-mcp-stdio -> MCP HTTP Server :3001 -> WebSocket Server :3002 -> RemNote Plugin -> RemNote
|
|
46
|
+
CLI commands -> remnote-cli -> MCP HTTP Server :3001 -> WebSocket Server :3002 -> RemNote Plugin -> RemNote
|
|
48
47
|
```
|
|
49
48
|
|
|
50
49
|
The server acts as a bridge:
|
|
51
50
|
|
|
52
51
|
- Communicates with AI agents via Streamable HTTP transport (MCP protocol) - supports both local and remote access
|
|
52
|
+
- Provides `remnote-mcp-stdio` as a local stdio MCP proxy for clients that need stdio transport
|
|
53
|
+
- Provides `remnote-cli` as a bundled command-line MCP client for local automation
|
|
53
54
|
- HTTP server (port 3001) manages MCP sessions for multiple concurrent agents
|
|
54
55
|
- WebSocket server (port 3002) connects to the RemNote browser plugin
|
|
55
56
|
- Translates MCP tool calls into RemNote API actions
|
|
@@ -81,6 +82,14 @@ connection always stays local for security. See [Remote Access Guide](docs/guide
|
|
|
81
82
|
npm install -g remnote-mcp-server
|
|
82
83
|
```
|
|
83
84
|
|
|
85
|
+
The package installs these commands:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
remnote-mcp-server --version
|
|
89
|
+
remnote-cli --version
|
|
90
|
+
remnote-mcp-stdio --version
|
|
91
|
+
```
|
|
92
|
+
|
|
84
93
|
### 2. Install the RemNote Plugin
|
|
85
94
|
|
|
86
95
|
Install the [RemNote Automation Bridge plugin](https://github.com/robert7/remnote-mcp-bridge) in your RemNote app.
|
|
@@ -96,7 +105,7 @@ remnote-mcp-server
|
|
|
96
105
|
Expected output:
|
|
97
106
|
|
|
98
107
|
```text
|
|
99
|
-
RemNote MCP Server v0.
|
|
108
|
+
RemNote MCP Server v0.14.1 listening { wsPort: 3002, httpPort: 3001 }
|
|
100
109
|
```
|
|
101
110
|
|
|
102
111
|
Keep this terminal running.
|
|
@@ -104,10 +113,13 @@ Keep this terminal running.
|
|
|
104
113
|
### 4. Configure Your AI Client
|
|
105
114
|
|
|
106
115
|
- [Configuration Guide](docs/guides/configuration.md) - Overview and generic setup
|
|
116
|
+
- [Codex TUI / Codex.app](docs/guides/configuration-codex.md) - HTTP MCP, stdio proxy, and `remnote-cli` skill setup
|
|
117
|
+
- [Claude Desktop Local MCPB](docs/guides/configuration-claude-desktop-local-mcpb.md) - Preferred local Claude Desktop setup, no public HTTPS required
|
|
118
|
+
- [Claude Desktop / Cowork](docs/guides/configuration-claude-desktop-cowork.md) - Remote connector setup when local MCPB is not applicable
|
|
119
|
+
- [Claude Code CLI](docs/guides/configuration-claude-code-CLI.md) - Claude Code local MCP setup
|
|
107
120
|
- [ChatGPT](docs/guides/configuration-chatgpt.md) - ChatGPT Apps configuration
|
|
108
|
-
- [Claude Desktop / Cowork](docs/guides/configuration-claude-desktop-cowork.md) - Remote connector setup (requires remote access setup)
|
|
109
|
-
- [Claude Code CLI](docs/guides/configuration-claude-code-CLI.md) - Detailed Claude Code CLI configuration
|
|
110
121
|
- [Accomplish](docs/guides/configuration-accomplish.md) - Accomplish (Openwork) configuration
|
|
122
|
+
- [Generic stdio MCP clients](docs/guides/configuration.md#stdio-mcp-clients) - Use `remnote-mcp-stdio`
|
|
111
123
|
|
|
112
124
|
## Documentation
|
|
113
125
|
|
|
@@ -119,12 +131,14 @@ Keep this terminal running.
|
|
|
119
131
|
\- Match server version to installed bridge plugin version (`0.x` semver)
|
|
120
132
|
- **[Bridge Connection Lifecycle](https://github.com/robert7/remnote-mcp-bridge/blob/main/docs/guides/connection-lifecycle.md)** - Canonical bridge connect/retry behavior
|
|
121
133
|
- **[Configuration Guide](docs/guides/configuration.md)** - Configure Claude Code CLI, Accomplish, and other clients
|
|
134
|
+
- **[Codex Configuration Guide](docs/guides/configuration-codex.md)** - Set up Codex TUI and Codex.app with RemNote
|
|
122
135
|
- **[ChatGPT Configuration Guide](docs/guides/configuration-chatgpt.md)** - Set up ChatGPT Apps with your MCP server
|
|
123
136
|
- **[Demo & Screenshots](docs/demo.md)** - See the server in action with different AI clients
|
|
124
137
|
|
|
125
138
|
### Usage
|
|
126
139
|
|
|
127
140
|
- **[CLI Options Reference](docs/guides/cli-options.md)** - Command-line options and environment variables
|
|
141
|
+
- **[remnote-cli Command Reference](docs/guides/cli-command-reference.md)** - Shell command reference for the bundled CLI
|
|
128
142
|
- **[MCP Tools Reference](docs/guides/tools-reference.md)** - Detailed reference for all 9 RemNote tools
|
|
129
143
|
- **[Remote Access Setup](docs/guides/remote-access.md)** - Expose server for Claude Desktop / Cowork (ngrok, etc.)
|
|
130
144
|
|
|
@@ -157,14 +171,21 @@ Tools that declare an `outputSchema` return MCP `structuredContent` plus a JSON
|
|
|
157
171
|
See the [MCP tools specification](https://modelcontextprotocol.io/specification/2025-11-25/server/tools) for the
|
|
158
172
|
protocol contract.
|
|
159
173
|
|
|
174
|
+
The server uses `@modelcontextprotocol/sdk` and supports current MCP protocol negotiation, including `2025-11-25`.
|
|
175
|
+
Do not confuse MCP protocol versions with `remnote-mcp-server` or bridge plugin package versions; package versions use
|
|
176
|
+
`0.x` semver and should usually match by minor line.
|
|
177
|
+
|
|
160
178
|
See the [Tools Reference](docs/guides/tools-reference.md) for detailed usage and examples.
|
|
161
179
|
|
|
162
180
|
## Supported AI Clients
|
|
163
181
|
|
|
164
182
|
- **[Claude Code CLI](https://claude.com/claude-code)** - Local terminal-based agent
|
|
183
|
+
- **Codex TUI / Codex.app** - Local OpenAI coding agent clients
|
|
165
184
|
- **Claude Desktop / Cowork** - Remote connector clients (require [remote access](docs/guides/remote-access.md))
|
|
166
185
|
- **[Accomplish](https://github.com/accomplish-ai/accomplish)** - Task-based MCP client (formerly Openwork)
|
|
167
186
|
- **Any MCP client** supporting Streamable HTTP transport
|
|
187
|
+
- **Any local MCP client** supporting stdio transport through `remnote-mcp-stdio`
|
|
188
|
+
- **Any local command runner** that can call `remnote-cli`
|
|
168
189
|
|
|
169
190
|
## Example Usage
|
|
170
191
|
|
|
@@ -245,9 +266,9 @@ See the [Troubleshooting Guide](docs/guides/troubleshooting.md) for detailed sol
|
|
|
245
266
|
```bash
|
|
246
267
|
git clone https://github.com/robert7/remnote-mcp-server.git
|
|
247
268
|
cd remnote-mcp-server
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
269
|
+
./link-cli.sh
|
|
270
|
+
# Later, remove the local links for package executables:
|
|
271
|
+
./unlink-cli.sh
|
|
251
272
|
```
|
|
252
273
|
|
|
253
274
|
**Development workflow:**
|
|
@@ -260,7 +281,7 @@ npm test # Run test suite
|
|
|
260
281
|
|
|
261
282
|
See the [Development Setup Guide](docs/guides/development-setup.md) for complete instructions.
|
|
262
283
|
|
|
263
|
-
Pull requests that affect bridge-consumer behavior should follow the shared PR rules in the bridge repo: [Pull Request Guide](https://github.com/robert7/remnote-mcp-bridge/blob/main/docs/guides/pull-request-guide.md). In particular, keep bridge
|
|
284
|
+
Pull requests that affect bridge-consumer behavior should follow the shared PR rules in the bridge repo: [Pull Request Guide](https://github.com/robert7/remnote-mcp-bridge/blob/main/docs/guides/pull-request-guide.md). In particular, keep bridge and server-package behavior aligned for shared functionality changes.
|
|
264
285
|
|
|
265
286
|
For the canonical workflow for updating and running shared live integration coverage, see the [Integration Testing Guide](docs/guides/integration-testing.md).
|
|
266
287
|
|
package/dist/cli.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export interface CliOptions {
|
|
|
9
9
|
requestLog?: string;
|
|
10
10
|
responseLog?: string;
|
|
11
11
|
}
|
|
12
|
+
export declare function getBundledMcpbPath(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Handle utility commands that do not start the MCP server.
|
|
15
|
+
*/
|
|
16
|
+
export declare function handleUtilityCommand(argv?: string[]): boolean;
|
|
12
17
|
/**
|
|
13
18
|
* Parse CLI arguments and return typed options
|
|
14
19
|
*/
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
3
4
|
const require = createRequire(import.meta.url);
|
|
4
5
|
const packageJson = require('../package.json');
|
|
5
6
|
const validLogLevels = ['debug', 'info', 'warn', 'error'];
|
|
7
|
+
const MCPB_PATH_COMMAND = 'mcpb-path';
|
|
8
|
+
export function getBundledMcpbPath() {
|
|
9
|
+
return fileURLToPath(new URL('../mcpb/remnote-local/remnote-local.mcpb', import.meta.url));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Handle utility commands that do not start the MCP server.
|
|
13
|
+
*/
|
|
14
|
+
export function handleUtilityCommand(argv = process.argv) {
|
|
15
|
+
if (argv[2] !== MCPB_PATH_COMMAND) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
console.log(getBundledMcpbPath());
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
6
21
|
/**
|
|
7
22
|
* Parse CLI arguments and return typed options
|
|
8
23
|
*/
|
|
@@ -12,6 +27,7 @@ export function parseCliArgs() {
|
|
|
12
27
|
.name('remnote-mcp-server')
|
|
13
28
|
.description('MCP server bridge for RemNote knowledge base')
|
|
14
29
|
.version(packageJson.version)
|
|
30
|
+
.addHelpText('after', '\nCommands:\n mcpb-path Print the bundled Claude Desktop MCPB extension path')
|
|
15
31
|
.option('--ws-port <number>', 'WebSocket port (default: 3002, env: REMNOTE_WS_PORT)', parsePort)
|
|
16
32
|
.option('--http-port <number>', 'HTTP MCP port (default: 3001, env: REMNOTE_HTTP_PORT)', parsePort)
|
|
17
33
|
.option('--http-host <host>', 'HTTP server bind address (default: 127.0.0.1, env: REMNOTE_HTTP_HOST). Use 0.0.0.0 for Docker/VPS deployments', validateHost)
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAc/C,MAAM,cAAc,GAA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ED,uBAAuB;IACvB,MAAM,WAAW,GAAG,yBAAyB,CAAC;IAC9C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,iBAAiB,KAAK,kEAAkE,CACzF,CAAC;IACJ,CAAC;IAED,+BAA+B;IAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,iBAAiB,KAAK,yCAAyC,CAAC,CAAC;IACnF,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import { WebSocketServer } from './websocket-server.js';
|
|
4
4
|
import { HttpMcpServer } from './http-server.js';
|
|
5
|
-
import { parseCliArgs } from './cli.js';
|
|
5
|
+
import { handleUtilityCommand, parseCliArgs } from './cli.js';
|
|
6
6
|
import { getConfig } from './config.js';
|
|
7
7
|
import { createLogger, ensureLogDirectory, createRequestResponseLogger } from './logger.js';
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
@@ -69,6 +69,9 @@ async function main() {
|
|
|
69
69
|
process.on('SIGINT', shutdown);
|
|
70
70
|
process.on('SIGTERM', shutdown);
|
|
71
71
|
}
|
|
72
|
+
if (handleUtilityCommand()) {
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
72
75
|
main().catch((error) => {
|
|
73
76
|
// Pre-logger error handling
|
|
74
77
|
console.error('[MCP Server] Fatal error:', error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","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AAK,EAAE,CAAC;IAEzB,sBAAsB;IACtB,MAAM,CAAC,IAAI,CACT;QACE,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;KAC1B,EACD,uBAAuB,WAAW,CAAC,OAAO,YAAY,CACvD,CAAC;IAEF,oBAAoB;IACpB,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;QAC1B,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC7B,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,oBAAoB,EAAE,EAAE,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,4BAA4B;IAC5B,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { DEFAULT_MCP_URL } from './config.js';
|
|
4
|
+
import { registerCreateCommand } from './commands/create.js';
|
|
5
|
+
import { registerSearchByTagCommand, registerSearchCommand } from './commands/search.js';
|
|
6
|
+
import { registerReadCommand } from './commands/read.js';
|
|
7
|
+
import { registerUpdateCommand } from './commands/update.js';
|
|
8
|
+
import { registerJournalCommand } from './commands/journal.js';
|
|
9
|
+
import { registerStatusCommand } from './commands/status.js';
|
|
10
|
+
import { registerReadTableCommand } from './commands/table.js';
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const packageJson = require('../../package.json');
|
|
13
|
+
export function createProgram(version) {
|
|
14
|
+
const program = new Command();
|
|
15
|
+
program
|
|
16
|
+
.name('remnote-cli')
|
|
17
|
+
.description('CLI client for RemNote MCP Server')
|
|
18
|
+
.version(version)
|
|
19
|
+
.option('--json', 'JSON output (default)')
|
|
20
|
+
.option('--text', 'Human-readable output')
|
|
21
|
+
.option('--mcp-url <url>', 'RemNote MCP server URL', process.env.REMNOTE_MCP_URL || DEFAULT_MCP_URL)
|
|
22
|
+
.option('--verbose', 'Enable verbose stderr logging');
|
|
23
|
+
registerCreateCommand(program);
|
|
24
|
+
registerSearchCommand(program);
|
|
25
|
+
registerSearchByTagCommand(program);
|
|
26
|
+
registerReadCommand(program);
|
|
27
|
+
registerUpdateCommand(program);
|
|
28
|
+
registerJournalCommand(program);
|
|
29
|
+
registerStatusCommand(program);
|
|
30
|
+
registerReadTableCommand(program);
|
|
31
|
+
return program;
|
|
32
|
+
}
|
|
33
|
+
export function runCli(argv = process.argv) {
|
|
34
|
+
const program = createProgram(packageJson.version);
|
|
35
|
+
program.parse(argv);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/remnote-cli/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EA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CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;IACxC,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { McpServerClient } from './mcp-server-client.js';
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
const packageJson = require('../../../package.json');
|
|
5
|
+
export function createCommandClient(program) {
|
|
6
|
+
const opts = program.opts();
|
|
7
|
+
return new McpServerClient(opts.mcpUrl, { name: 'remnote-cli', version: packageJson.version });
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=command-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-client.js","sourceRoot":"","sources":["../../../src/remnote-cli/client/command-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAwB,CAAC;AAE5E,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAsB,CAAC;IAChD,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Short-lived MCP client used by CLI commands to call remnote-mcp-server.
|
|
3
|
+
*/
|
|
4
|
+
export declare class McpServerClient {
|
|
5
|
+
private readonly mcpUrl;
|
|
6
|
+
private readonly clientInfo;
|
|
7
|
+
private client;
|
|
8
|
+
private transport;
|
|
9
|
+
constructor(mcpUrl: string, clientInfo?: {
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
});
|
|
13
|
+
execute(action: string, payload: Record<string, unknown>): Promise<unknown>;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
private connect;
|
|
16
|
+
private extractText;
|
|
17
|
+
private parseResult;
|
|
18
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
3
|
+
import { checkVersionCompatibility } from '../version-compat.js';
|
|
4
|
+
const ACTION_TO_TOOL = {
|
|
5
|
+
create_note: 'remnote_create_note',
|
|
6
|
+
search: 'remnote_search',
|
|
7
|
+
search_by_tag: 'remnote_search_by_tag',
|
|
8
|
+
read_note: 'remnote_read_note',
|
|
9
|
+
update_note: 'remnote_update_note',
|
|
10
|
+
append_journal: 'remnote_append_journal',
|
|
11
|
+
get_status: 'remnote_status',
|
|
12
|
+
read_table: 'remnote_read_table',
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Short-lived MCP client used by CLI commands to call remnote-mcp-server.
|
|
16
|
+
*/
|
|
17
|
+
export class McpServerClient {
|
|
18
|
+
mcpUrl;
|
|
19
|
+
clientInfo;
|
|
20
|
+
client = null;
|
|
21
|
+
transport = null;
|
|
22
|
+
constructor(mcpUrl, clientInfo = { name: 'remnote-cli', version: '0.14.1' }) {
|
|
23
|
+
this.mcpUrl = normalizeMcpUrl(mcpUrl);
|
|
24
|
+
this.clientInfo = clientInfo;
|
|
25
|
+
}
|
|
26
|
+
async execute(action, payload) {
|
|
27
|
+
const toolName = ACTION_TO_TOOL[action];
|
|
28
|
+
if (!toolName) {
|
|
29
|
+
throw new Error(`Unknown bridge action: ${action}`);
|
|
30
|
+
}
|
|
31
|
+
await this.connect();
|
|
32
|
+
const result = await this.client.callTool({ name: toolName, arguments: payload });
|
|
33
|
+
if (result.isError) {
|
|
34
|
+
throw new Error(this.extractText(result));
|
|
35
|
+
}
|
|
36
|
+
const parsed = this.parseResult(result);
|
|
37
|
+
if (action === 'get_status' && parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
38
|
+
const status = { ...parsed, cliVersion: this.clientInfo.version };
|
|
39
|
+
const serverVersion = status.serverVersion;
|
|
40
|
+
if (typeof serverVersion === 'string') {
|
|
41
|
+
const warning = checkVersionCompatibility(this.clientInfo.version, serverVersion, 'CLI', 'MCP server');
|
|
42
|
+
if (warning) {
|
|
43
|
+
status.version_warning =
|
|
44
|
+
typeof status.version_warning === 'string'
|
|
45
|
+
? `${status.version_warning}\n${warning}`
|
|
46
|
+
: warning;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return status;
|
|
50
|
+
}
|
|
51
|
+
return parsed;
|
|
52
|
+
}
|
|
53
|
+
async close() {
|
|
54
|
+
try {
|
|
55
|
+
if (this.transport) {
|
|
56
|
+
await this.transport.terminateSession();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Ignore shutdown errors; CLI commands are already done at this point.
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
if (this.client) {
|
|
64
|
+
await this.client.close();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Ignore shutdown errors; connection cleanup is best-effort.
|
|
69
|
+
}
|
|
70
|
+
this.client = null;
|
|
71
|
+
this.transport = null;
|
|
72
|
+
}
|
|
73
|
+
async connect() {
|
|
74
|
+
if (this.client) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.transport = new StreamableHTTPClientTransport(new URL(this.mcpUrl));
|
|
78
|
+
this.client = new Client(this.clientInfo);
|
|
79
|
+
try {
|
|
80
|
+
await this.client.connect(this.transport);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
this.client = null;
|
|
84
|
+
this.transport = null;
|
|
85
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
86
|
+
throw new Error(`Cannot connect to MCP server at ${this.mcpUrl}. Is remnote-mcp-server running? ${message}`, { cause: error });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
extractText(result) {
|
|
90
|
+
const content = result.content;
|
|
91
|
+
const text = content?.find((item) => item.type === 'text' && item.text)?.text;
|
|
92
|
+
return text ?? JSON.stringify(result);
|
|
93
|
+
}
|
|
94
|
+
parseResult(result) {
|
|
95
|
+
if (result.structuredContent &&
|
|
96
|
+
typeof result.structuredContent === 'object' &&
|
|
97
|
+
!Array.isArray(result.structuredContent)) {
|
|
98
|
+
return result.structuredContent;
|
|
99
|
+
}
|
|
100
|
+
const text = this.extractText(result);
|
|
101
|
+
try {
|
|
102
|
+
return JSON.parse(text);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return { _raw: text };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function normalizeMcpUrl(value) {
|
|
110
|
+
const trimmed = value.trim();
|
|
111
|
+
if (trimmed.endsWith('/mcp')) {
|
|
112
|
+
return trimmed;
|
|
113
|
+
}
|
|
114
|
+
return `${trimmed.replace(/\/+$/, '')}/mcp`;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=mcp-server-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server-client.js","sourceRoot":"","sources":["../../../src/remnote-cli/client/mcp-server-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,cAA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AC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Determines if a given string value looks like a CLI flag instead of a standard argument.
|
|
4
|
+
* This is used to detect "argument shifting" (e.g., when an empty string "" is swallowed by the shell,
|
|
5
|
+
* causing the next flag to be incorrectly parsed as the value for the current option).
|
|
6
|
+
*
|
|
7
|
+
* @param value - The string argument to evaluate.
|
|
8
|
+
* @param cmd - (Optional) The Command instance. If provided, enables strict matching against registered flags.
|
|
9
|
+
* @returns True if the value is likely a shifted flag; otherwise, false.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isFlag(value: string | undefined, cmd?: Command): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Validates an entire record of parsed arguments to ensure none of them are shifted flags.
|
|
14
|
+
* Useful for running a bulk check after Commander has finished parsing,
|
|
15
|
+
* especially when using dynamic commands or positional arguments.
|
|
16
|
+
*
|
|
17
|
+
* @param fields - A key-value record of parsed arguments (e.g., { title: '--content', parentId: '123' }).
|
|
18
|
+
* @param cmd - (Optional) The Command instance for strict flag matching.
|
|
19
|
+
* @throws {Error} If any value is identified as a shifted flag.
|
|
20
|
+
*/
|
|
21
|
+
export declare function checkPayloadForFlags(fields: Record<string, string | undefined>, cmd?: Command): void;
|
|
22
|
+
/**
|
|
23
|
+
* A higher-order function designed to be used as a custom processing function in Commander's `.option()`.
|
|
24
|
+
* It binds the Command context to the validation logic.
|
|
25
|
+
*
|
|
26
|
+
* @param cmd - The current Commander instance.
|
|
27
|
+
* @returns A validation function that throws an InvalidArgumentError if the value is a shifted flag.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const check = validateNotFlag(program);
|
|
31
|
+
* program.option('--title <text>', 'Note title', check);
|
|
32
|
+
*/
|
|
33
|
+
export declare function validateNotFlag(value: string, cmd?: Command): string;
|