obsidian-mcp-server 2.0.4 → 2.0.6
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 +17 -0
- package/README.md +80 -88
- package/dist/mcp-server/server.js +8 -8
- package/dist/mcp-server/tools/{obsidianDeleteFileTool → obsidianDeleteNoteTool}/index.d.ts +4 -4
- package/dist/mcp-server/tools/{obsidianDeleteFileTool → obsidianDeleteNoteTool}/index.js +4 -4
- package/dist/mcp-server/tools/{obsidianDeleteFileTool → obsidianDeleteNoteTool}/logic.d.ts +9 -9
- package/dist/mcp-server/tools/{obsidianDeleteFileTool → obsidianDeleteNoteTool}/logic.js +6 -6
- package/dist/mcp-server/tools/{obsidianDeleteFileTool → obsidianDeleteNoteTool}/registration.d.ts +2 -2
- package/dist/mcp-server/tools/{obsidianDeleteFileTool → obsidianDeleteNoteTool}/registration.js +12 -12
- package/dist/mcp-server/tools/{obsidianListFilesTool → obsidianListNotesTool}/index.d.ts +4 -4
- package/dist/mcp-server/tools/{obsidianListFilesTool → obsidianListNotesTool}/index.js +4 -4
- package/dist/mcp-server/tools/{obsidianListFilesTool → obsidianListNotesTool}/logic.d.ts +10 -10
- package/dist/mcp-server/tools/{obsidianListFilesTool → obsidianListNotesTool}/logic.js +14 -13
- package/dist/mcp-server/tools/{obsidianListFilesTool → obsidianListNotesTool}/registration.d.ts +4 -4
- package/dist/mcp-server/tools/{obsidianListFilesTool → obsidianListNotesTool}/registration.js +14 -14
- package/dist/mcp-server/tools/{obsidianReadFileTool → obsidianReadNoteTool}/index.d.ts +4 -4
- package/dist/mcp-server/tools/{obsidianReadFileTool → obsidianReadNoteTool}/index.js +4 -4
- package/dist/mcp-server/tools/{obsidianReadFileTool → obsidianReadNoteTool}/logic.d.ts +9 -9
- package/dist/mcp-server/tools/{obsidianReadFileTool → obsidianReadNoteTool}/logic.js +8 -8
- package/dist/mcp-server/tools/{obsidianReadFileTool → obsidianReadNoteTool}/registration.d.ts +2 -2
- package/dist/mcp-server/tools/{obsidianReadFileTool → obsidianReadNoteTool}/registration.js +12 -12
- package/dist/mcp-server/tools/{obsidianUpdateFileTool → obsidianUpdateNoteTool}/index.d.ts +4 -4
- package/dist/mcp-server/tools/{obsidianUpdateFileTool → obsidianUpdateNoteTool}/index.js +4 -4
- package/dist/mcp-server/tools/{obsidianUpdateFileTool → obsidianUpdateNoteTool}/logic.d.ts +8 -8
- package/dist/mcp-server/tools/{obsidianUpdateFileTool → obsidianUpdateNoteTool}/logic.js +7 -7
- package/dist/mcp-server/tools/{obsidianUpdateFileTool → obsidianUpdateNoteTool}/registration.d.ts +2 -2
- package/dist/mcp-server/tools/{obsidianUpdateFileTool → obsidianUpdateNoteTool}/registration.js +13 -13
- package/dist/mcp-server/transports/{authentication → auth/core}/authContext.d.ts +2 -2
- package/dist/mcp-server/transports/{authentication → auth/core}/authContext.js +1 -1
- package/dist/mcp-server/transports/{authentication/types.d.ts → auth/core/authTypes.d.ts} +1 -1
- package/dist/mcp-server/transports/{authentication/types.js → auth/core/authTypes.js} +1 -1
- package/dist/mcp-server/transports/{authentication → auth/core}/authUtils.d.ts +1 -1
- package/dist/mcp-server/transports/{authentication → auth/core}/authUtils.js +3 -3
- package/dist/mcp-server/transports/auth/index.d.ts +10 -0
- package/dist/mcp-server/transports/auth/index.js +9 -0
- package/dist/mcp-server/transports/{authentication/authMiddleware.d.ts → auth/strategies/jwt/jwtMiddleware.d.ts} +4 -7
- package/dist/mcp-server/transports/{authentication/authMiddleware.js → auth/strategies/jwt/jwtMiddleware.js} +40 -36
- package/dist/mcp-server/transports/{authentication → auth/strategies/oauth}/oauthMiddleware.d.ts +2 -6
- package/dist/mcp-server/transports/{authentication → auth/strategies/oauth}/oauthMiddleware.js +33 -18
- package/dist/mcp-server/transports/httpErrorHandler.d.ts +26 -0
- package/dist/mcp-server/transports/httpErrorHandler.js +73 -0
- package/dist/mcp-server/transports/httpTransport.d.ts +11 -14
- package/dist/mcp-server/transports/httpTransport.js +91 -379
- package/package.json +14 -19
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.0.6] - 2025-06-20
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Tool Renaming**: Renamed `obsidian_read_file`, `obsidian_delete_file`, and `obsidian_list_files` to `obsidian_read_note`, `obsidian_delete_note`, and `obsidian_list_notes` respectively. This change improves semantic clarity and aligns the tool names more closely with Obsidian's terminology, reducing ambiguity for AI agents.
|
|
13
|
+
- **Dependency Updates**: Updated all dependencies to their latest versions.
|
|
14
|
+
- **Documentation Improvements**: Updated `.clinerules` to reflect the new tool names and ensure all documentation is current.
|
|
15
|
+
|
|
16
|
+
## [2.0.5] - 2025-06-20
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **Tool Renaming**: Renamed the `obsidian_update_file` tool to `obsidian_update_note` to avoid conflicts and better reflect its function. During agentic use, LLMs confused this tool with filesystem operations, leading to errors. The new name clarifies that it operates on Obsidian notes specifically.
|
|
21
|
+
- **HTTP Transport Refactor**: Restructured the HTTP transport layer for improved clarity and robustness. Authentication logic is now more modular, and a centralized error handler has been implemented.
|
|
22
|
+
- **Dependency Updates**: Updated all dependencies to their latest versions.
|
|
23
|
+
- **Documentation Improvements**: Enhanced the documentation around installation & MCP Client configuration. Suggested by [@bgheneti](https://github.com/bgheneti) in [PR #14](https://github.com/cyanheads/obsidian-mcp-server/pull/14). Thanks!
|
|
24
|
+
|
|
8
25
|
## [2.0.4] - 2025-06-13
|
|
9
26
|
|
|
10
27
|
### Added
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Obsidian MCP Server
|
|
2
2
|
|
|
3
3
|
[](https://www.typescriptlang.org/)
|
|
4
|
-
[](https://modelcontextprotocol.io/)
|
|
5
|
+
[](./CHANGELOG.md)
|
|
6
6
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
7
|
[](https://github.com/cyanheads/obsidian-mcp-server/issues)
|
|
8
8
|
[](https://github.com/cyanheads/obsidian-mcp-server)
|
|
@@ -20,7 +20,7 @@ This server equips your AI with specialized tools to interact with your Obsidian
|
|
|
20
20
|
| Tool Name | Description | Key Features |
|
|
21
21
|
| :------------------------------------------------------------------------------------- | :-------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
22
|
| [`obsidian_read_file`](./src/mcp-server/tools/obsidianReadFileTool/) | Retrieves the content and metadata of a specified file. | - Read in `markdown` or `json` format.<br/>- Case-insensitive path fallback.<br/>- Includes file stats (creation/modification time). |
|
|
23
|
-
| [`
|
|
23
|
+
| [`obsidian_update_note`](./src/mcp-server/tools/obsidianUpdateNoteTool/) | Modifies notes using whole-file operations. | - `append`, `prepend`, or `overwrite` content.<br/>- Can create files if they don't exist.<br/>- Targets files by path, active note, or periodic note. |
|
|
24
24
|
| [`obsidian_search_replace`](./src/mcp-server/tools/obsidianSearchReplaceTool/) | Performs search-and-replace operations within a target note. | - Supports string or regex search.<br/>- Options for case sensitivity, whole word, and replacing all occurrences. |
|
|
25
25
|
| [`obsidian_global_search`](./src/mcp-server/tools/obsidianGlobalSearchTool/) | Performs a search across the entire vault. | - Text or regex search.<br/>- Filter by path and modification date.<br/>- Paginated results. |
|
|
26
26
|
| [`obsidian_list_files`](./src/mcp-server/tools/obsidianListFilesTool/) | Lists files and subdirectories within a specified vault folder. | - Filter by file extension or name regex.<br/>- Provides a formatted tree view of the directory. |
|
|
@@ -32,8 +32,8 @@ This server equips your AI with specialized tools to interact with your Obsidian
|
|
|
32
32
|
|
|
33
33
|
## Table of Contents
|
|
34
34
|
|
|
35
|
-
| [Overview](#overview) | [Features](#features) | [
|
|
36
|
-
| [
|
|
35
|
+
| [Overview](#overview) | [Features](#features) | [Configuration](#configuration) |
|
|
36
|
+
| [Project Structure](#project-structure) | [Vault Cache Service](#vault-cache-service) |
|
|
37
37
|
| [Tools](#tools) | [Resources](#resources) | [Development](#development) | [License](#license) |
|
|
38
38
|
|
|
39
39
|
## Overview
|
|
@@ -54,7 +54,7 @@ Built on the robust `mcp-ts-template`, this server provides a standardized, secu
|
|
|
54
54
|
|
|
55
55
|
### Core Utilities
|
|
56
56
|
|
|
57
|
-
Leverages the robust utilities provided by
|
|
57
|
+
Leverages the robust utilities provided by `cyanheads/mcp-ts-template`:
|
|
58
58
|
|
|
59
59
|
- **Logging**: Structured, configurable logging (file rotation, console, MCP notifications) with sensitive data redaction.
|
|
60
60
|
- **Error Handling**: Centralized error processing, standardized error types (`McpError`), and automatic logging.
|
|
@@ -62,7 +62,7 @@ Leverages the robust utilities provided by the `mcp-ts-template`:
|
|
|
62
62
|
- **Input Validation/Sanitization**: Uses `zod` for schema validation and custom sanitization logic.
|
|
63
63
|
- **Request Context**: Tracking and correlation of operations via unique request IDs.
|
|
64
64
|
- **Type Safety**: Strong typing enforced by TypeScript and Zod schemas.
|
|
65
|
-
- **HTTP Transport Option**: Built-in Hono server with SSE, session management, CORS support, and JWT
|
|
65
|
+
- **HTTP Transport Option**: Built-in Hono server with SSE, session management, CORS support, and pluggable authentication strategies (JWT and OAuth 2.1).
|
|
66
66
|
|
|
67
67
|
### Obsidian Integration
|
|
68
68
|
|
|
@@ -82,52 +82,73 @@ Leverages the robust utilities provided by the `mcp-ts-template`:
|
|
|
82
82
|
3. **API Key**: Configure an API key within the Local REST API plugin settings in Obsidian. You will need this key to configure the server.
|
|
83
83
|
4. **Node.js & npm**: Ensure you have Node.js (v18 or later recommended) and npm installed.
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
## Configuration
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
npm install obsidian-mcp-server
|
|
89
|
-
```
|
|
87
|
+
### MCP Client Settings
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
1. Clone the repository:
|
|
94
|
-
```bash
|
|
95
|
-
git clone https://github.com/cyanheads/obsidian-mcp-server.git
|
|
96
|
-
cd obsidian-mcp-server
|
|
97
|
-
```
|
|
98
|
-
2. Install dependencies:
|
|
99
|
-
```bash
|
|
100
|
-
npm install
|
|
101
|
-
```
|
|
102
|
-
3. Build the project:
|
|
103
|
-
```bash
|
|
104
|
-
npm run build
|
|
105
|
-
```
|
|
106
|
-
This compiles the TypeScript code to JavaScript in the `dist/` directory and makes the entry point executable.
|
|
89
|
+
Add the following to your MCP client's configuration file (e.g., `cline_mcp_settings.json`). This configuration uses `npx` to run the server, which will automatically download & install the package if not already present:
|
|
107
90
|
|
|
108
|
-
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"mcpServers": {
|
|
94
|
+
"obsidian-mcp-server": {
|
|
95
|
+
"command": "npx",
|
|
96
|
+
"args": ["obsidian-mcp-server"],
|
|
97
|
+
"env": {
|
|
98
|
+
"OBSIDIAN_API_KEY": "YOUR_API_KEY_FROM_OBSIDIAN_PLUGIN",
|
|
99
|
+
"OBSIDIAN_BASE_URL": "http://127.0.0.1:27123",
|
|
100
|
+
"OBSIDIAN_VERIFY_SSL": "false",
|
|
101
|
+
"OBSIDIAN_ENABLE_CACHE": "true"
|
|
102
|
+
},
|
|
103
|
+
"disabled": false,
|
|
104
|
+
"autoApprove": []
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
**Note**: Verify SSL is set to false here because the Obsidian Local REST API plugin uses a self-signed certificate by default. If you are deploying this in a production environment, consider using the encrypted HTTPS endpoint and set `OBSIDIAN_VERIFY_SSL` to `true` after configuring your server to trust the self-signed certificate.
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
If you installed from source, change `command` and `args` to point to your local build:
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"mcpServers": {
|
|
117
|
+
"obsidian-mcp-server": {
|
|
118
|
+
"command": "node",
|
|
119
|
+
"args": ["/path/to/your/obsidian-mcp-server/dist/index.js"],
|
|
120
|
+
"env": {
|
|
121
|
+
"OBSIDIAN_API_KEY": "YOUR_OBSIDIAN_API_KEY",
|
|
122
|
+
"OBSIDIAN_BASE_URL": "http://127.0.0.1:27123",
|
|
123
|
+
"OBSIDIAN_VERIFY_SSL": "false",
|
|
124
|
+
"OBSIDIAN_ENABLE_CACHE": "true"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
115
130
|
|
|
116
|
-
|
|
131
|
+
### Environment Variables
|
|
117
132
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
|
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
|
|
|
127
|
-
| `
|
|
128
|
-
| `
|
|
129
|
-
|
|
|
130
|
-
| `
|
|
133
|
+
Configure the server using environment variables. These environmental variables are set within your MCP client config/settings (e.g. `cline_mcp_settings.json` for Cline, `claude_desktop_config.json` for Claude Desktop).
|
|
134
|
+
|
|
135
|
+
| Variable | Description | Required | Default |
|
|
136
|
+
| :------------------------------------ | :----------------------------------------------------------------------- | :------------------- | :----------------------- |
|
|
137
|
+
| **`OBSIDIAN_API_KEY`** | API Key from the Obsidian Local REST API plugin. | **Yes** | `undefined` |
|
|
138
|
+
| **`OBSIDIAN_BASE_URL`** | Base URL of your Obsidian Local REST API. | **Yes** | `http://127.0.0.1:27123` |
|
|
139
|
+
| `MCP_TRANSPORT_TYPE` | Server transport: `stdio` or `http`. | No | `stdio` |
|
|
140
|
+
| `MCP_HTTP_PORT` | Port for the HTTP server. | No | `3010` |
|
|
141
|
+
| `MCP_HTTP_HOST` | Host for the HTTP server. | No | `127.0.0.1` |
|
|
142
|
+
| `MCP_ALLOWED_ORIGINS` | Comma-separated origins for CORS. **Set for production.** | No | (none) |
|
|
143
|
+
| `MCP_AUTH_MODE` | Authentication strategy: `jwt` or `oauth`. | No | (none) |
|
|
144
|
+
| **`MCP_AUTH_SECRET_KEY`** | 32+ char secret for JWT. **Required for `jwt` mode.** | **Yes (if `jwt`)** | `undefined` |
|
|
145
|
+
| `OAUTH_ISSUER_URL` | URL of the OAuth 2.1 issuer. | **Yes (if `oauth`)** | `undefined` |
|
|
146
|
+
| `OAUTH_AUDIENCE` | Audience claim for OAuth tokens. | **Yes (if `oauth`)** | `undefined` |
|
|
147
|
+
| `OAUTH_JWKS_URI` | URI for the JSON Web Key Set (optional, derived from issuer if omitted). | No | (derived) |
|
|
148
|
+
| `MCP_LOG_LEVEL` | Logging level (`debug`, `info`, `error`, etc.). | No | `info` |
|
|
149
|
+
| `OBSIDIAN_VERIFY_SSL` | Set to `false` to disable SSL verification. | No | `true` |
|
|
150
|
+
| `OBSIDIAN_ENABLE_CACHE` | Set to `true` to enable the in-memory vault cache. | No | `true` |
|
|
151
|
+
| `OBSIDIAN_CACHE_REFRESH_INTERVAL_MIN` | Refresh interval for the vault cache in minutes. | No | `10` |
|
|
131
152
|
|
|
132
153
|
### Connecting to the Obsidian API
|
|
133
154
|
|
|
@@ -165,27 +186,6 @@ _Using the encrypted HTTPS URL:_
|
|
|
165
186
|
}
|
|
166
187
|
```
|
|
167
188
|
|
|
168
|
-
### MCP Client Settings
|
|
169
|
-
|
|
170
|
-
Add to your MCP client settings (e.g., `cline_mcp_settings.json`):
|
|
171
|
-
|
|
172
|
-
```json
|
|
173
|
-
{
|
|
174
|
-
"mcpServers": {
|
|
175
|
-
"obsidian-mcp-server": {
|
|
176
|
-
"command": "node",
|
|
177
|
-
"args": ["/path/to/your/obsidian-mcp-server/dist/index.js"],
|
|
178
|
-
"env": {
|
|
179
|
-
"OBSIDIAN_API_KEY": "YOUR_OBSIDIAN_API_KEY",
|
|
180
|
-
"OBSIDIAN_BASE_URL": "http://127.0.0.1:27123",
|
|
181
|
-
"OBSIDIAN_VERIFY_SSL": "false",
|
|
182
|
-
"OBSIDIAN_ENABLE_CACHE": "true"
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
```
|
|
188
|
-
|
|
189
189
|
## Project Structure
|
|
190
190
|
|
|
191
191
|
The codebase follows a modular structure within the `src/` directory:
|
|
@@ -199,7 +199,8 @@ src/
|
|
|
199
199
|
│ ├── server.ts # Server setup, transport handling, tool/resource registration
|
|
200
200
|
│ ├── resources/ # MCP Resource implementations (currently none)
|
|
201
201
|
│ ├── tools/ # MCP Tool implementations (subdirs per tool)
|
|
202
|
-
│ └── transports/ # Stdio and HTTP transport logic
|
|
202
|
+
│ └── transports/ # Stdio and HTTP transport logic
|
|
203
|
+
│ └── auth/ # Authentication strategies (JWT, OAuth)
|
|
203
204
|
├── services/ # Abstractions for external APIs or internal caching
|
|
204
205
|
│ └── obsidianRestAPI/ # Typed client for Obsidian Local REST API
|
|
205
206
|
├── types-global/ # Shared TypeScript type definitions (errors, etc.)
|
|
@@ -239,7 +240,7 @@ The Obsidian MCP Server provides a suite of tools for interacting with your vaul
|
|
|
239
240
|
| Tool Name | Description | Key Arguments |
|
|
240
241
|
| :---------------------------- | :-------------------------------------------------------- | :------------------------------------------------------------ |
|
|
241
242
|
| `obsidian_read_file` | Retrieves the content and metadata of a file. | `filePath`, `format?`, `includeStat?` |
|
|
242
|
-
| `
|
|
243
|
+
| `obsidian_update_note` | Modifies a file by appending, prepending, or overwriting. | `targetType`, `content`, `targetIdentifier?`, `wholeFileMode` |
|
|
243
244
|
| `obsidian_search_replace` | Performs search-and-replace operations in a note. | `targetType`, `replacements`, `useRegex?`, `replaceAll?` |
|
|
244
245
|
| `obsidian_global_search` | Searches the entire vault for content. | `query`, `searchInPath?`, `useRegex?`, `page?`, `pageSize?` |
|
|
245
246
|
| `obsidian_list_files` | Lists files and subdirectories in a folder. | `dirPath`, `fileExtensionFilter?`, `nameRegexFilter?` |
|
|
@@ -259,32 +260,23 @@ This server currently focuses on providing interactive tools for vault manipulat
|
|
|
259
260
|
|
|
260
261
|
### Build and Test
|
|
261
262
|
|
|
263
|
+
To get started with development, clone the repository, install dependencies, and use the following scripts:
|
|
264
|
+
|
|
262
265
|
```bash
|
|
263
|
-
#
|
|
264
|
-
npm
|
|
266
|
+
# Install dependencies
|
|
267
|
+
npm install
|
|
265
268
|
|
|
266
|
-
#
|
|
267
|
-
npm run
|
|
269
|
+
# Build the project (compile TS to JS in dist/ and make executable)
|
|
270
|
+
npm run rebuild
|
|
268
271
|
|
|
269
|
-
#
|
|
270
|
-
npm start
|
|
271
|
-
# or specifically:
|
|
272
|
-
npm run start:stdio
|
|
272
|
+
# Start the server locally using stdio transport
|
|
273
|
+
npm start:stdio
|
|
273
274
|
|
|
274
|
-
#
|
|
275
|
+
# Start the server using http transport
|
|
275
276
|
npm run start:http
|
|
276
277
|
|
|
277
|
-
#
|
|
278
|
-
npm run
|
|
279
|
-
|
|
280
|
-
# Clean build artifacts and then rebuild the project
|
|
281
|
-
npm run rebuild
|
|
282
|
-
|
|
283
|
-
# Fetch the Obsidian API spec (requires Obsidian running with Local REST API)
|
|
284
|
-
npm run fetch:spec http://127.0.0.1:27123/ docs/obsidian-api/obsidian_rest_api_spec
|
|
285
|
-
|
|
286
|
-
# Generate API documentation using TypeDoc
|
|
287
|
-
npm run docs:generate
|
|
278
|
+
# Format code using Prettier
|
|
279
|
+
npm run format
|
|
288
280
|
|
|
289
281
|
# Inspect the server's capabilities using the MCP Inspector tool
|
|
290
282
|
npm run inspect:stdio
|
|
@@ -19,12 +19,12 @@ import { config, environment } from "../config/index.js";
|
|
|
19
19
|
// Import core utilities: ErrorHandler, logger, requestContextService.
|
|
20
20
|
import { ErrorHandler, logger, requestContextService } from "../utils/index.js";
|
|
21
21
|
// Import registration functions for specific resources and tools.
|
|
22
|
-
import {
|
|
22
|
+
import { registerObsidianDeleteNoteTool } from "./tools/obsidianDeleteNoteTool/index.js";
|
|
23
23
|
import { registerObsidianGlobalSearchTool } from "./tools/obsidianGlobalSearchTool/index.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
24
|
+
import { registerObsidianListNotesTool } from "./tools/obsidianListNotesTool/index.js";
|
|
25
|
+
import { registerObsidianReadNoteTool } from "./tools/obsidianReadNoteTool/index.js";
|
|
26
26
|
import { registerObsidianSearchReplaceTool } from "./tools/obsidianSearchReplaceTool/index.js";
|
|
27
|
-
import {
|
|
27
|
+
import { registerObsidianUpdateNoteTool } from "./tools/obsidianUpdateNoteTool/index.js";
|
|
28
28
|
import { registerObsidianManageFrontmatterTool } from "./tools/obsidianManageFrontmatterTool/index.js";
|
|
29
29
|
import { registerObsidianManageTagsTool } from "./tools/obsidianManageTagsTool/index.js";
|
|
30
30
|
// Import transport setup functions.
|
|
@@ -83,9 +83,9 @@ async function createMcpServerInstance(obsidianService, vaultCacheService) {
|
|
|
83
83
|
try {
|
|
84
84
|
logger.debug("Registering resources and tools using shared services...", context);
|
|
85
85
|
// Register all tools, passing the vaultCacheService which may be undefined
|
|
86
|
-
await
|
|
87
|
-
await
|
|
88
|
-
await
|
|
86
|
+
await registerObsidianListNotesTool(server, obsidianService);
|
|
87
|
+
await registerObsidianReadNoteTool(server, obsidianService);
|
|
88
|
+
await registerObsidianDeleteNoteTool(server, obsidianService, vaultCacheService);
|
|
89
89
|
if (vaultCacheService) {
|
|
90
90
|
await registerObsidianGlobalSearchTool(server, obsidianService, vaultCacheService);
|
|
91
91
|
}
|
|
@@ -93,7 +93,7 @@ async function createMcpServerInstance(obsidianService, vaultCacheService) {
|
|
|
93
93
|
logger.warning("Skipping registration of 'obsidian_global_search' because the Vault Cache Service is disabled.", context);
|
|
94
94
|
}
|
|
95
95
|
await registerObsidianSearchReplaceTool(server, obsidianService, vaultCacheService);
|
|
96
|
-
await
|
|
96
|
+
await registerObsidianUpdateNoteTool(server, obsidianService, vaultCacheService);
|
|
97
97
|
await registerObsidianManageFrontmatterTool(server, obsidianService, vaultCacheService);
|
|
98
98
|
await registerObsidianManageTagsTool(server, obsidianService, vaultCacheService);
|
|
99
99
|
logger.info("Resources and tools registered successfully", context);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Barrel file for the '
|
|
2
|
+
* @fileoverview Barrel file for the 'obsidian_delete_note' MCP tool.
|
|
3
3
|
*
|
|
4
|
-
* This file serves as the public entry point for the
|
|
5
|
-
* It re-exports the primary registration function (`
|
|
4
|
+
* This file serves as the public entry point for the obsidian_delete_note tool module.
|
|
5
|
+
* It re-exports the primary registration function (`registerObsidianDeleteNoteTool`)
|
|
6
6
|
* from the './registration.js' module. This pattern simplifies imports for consumers
|
|
7
7
|
* of the tool, allowing them to import necessary components from a single location.
|
|
8
8
|
*
|
|
9
9
|
* Consumers (like the main server setup) should import the registration function
|
|
10
10
|
* from this file to integrate the tool into the MCP server instance.
|
|
11
11
|
*/
|
|
12
|
-
export {
|
|
12
|
+
export { registerObsidianDeleteNoteTool } from "./registration.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Barrel file for the '
|
|
2
|
+
* @fileoverview Barrel file for the 'obsidian_delete_note' MCP tool.
|
|
3
3
|
*
|
|
4
|
-
* This file serves as the public entry point for the
|
|
5
|
-
* It re-exports the primary registration function (`
|
|
4
|
+
* This file serves as the public entry point for the obsidian_delete_note tool module.
|
|
5
|
+
* It re-exports the primary registration function (`registerObsidianDeleteNoteTool`)
|
|
6
6
|
* from the './registration.js' module. This pattern simplifies imports for consumers
|
|
7
7
|
* of the tool, allowing them to import necessary components from a single location.
|
|
8
8
|
*
|
|
9
9
|
* Consumers (like the main server setup) should import the registration function
|
|
10
10
|
* from this file to integrate the tool into the MCP server instance.
|
|
11
11
|
*/
|
|
12
|
-
export {
|
|
12
|
+
export { registerObsidianDeleteNoteTool } from "./registration.js";
|
|
@@ -2,9 +2,9 @@ import { z } from "zod";
|
|
|
2
2
|
import { ObsidianRestApiService, VaultCacheService } from "../../../services/obsidianRestAPI/index.js";
|
|
3
3
|
import { RequestContext } from "../../../utils/index.js";
|
|
4
4
|
/**
|
|
5
|
-
* Zod schema for validating the input parameters of the '
|
|
5
|
+
* Zod schema for validating the input parameters of the 'obsidian_delete_note' tool.
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const ObsidianDeleteNoteInputSchema: z.ZodObject<{
|
|
8
8
|
/**
|
|
9
9
|
* The vault-relative path to the file to be permanently deleted.
|
|
10
10
|
* Must include the file extension (e.g., "Old Notes/Obsolete File.md").
|
|
@@ -18,15 +18,15 @@ export declare const ObsidianDeleteFileInputSchema: z.ZodObject<{
|
|
|
18
18
|
filePath: string;
|
|
19
19
|
}>;
|
|
20
20
|
/**
|
|
21
|
-
* TypeScript type inferred from the input schema (`
|
|
21
|
+
* TypeScript type inferred from the input schema (`ObsidianDeleteNoteInputSchema`).
|
|
22
22
|
* Represents the validated input parameters used within the core processing logic.
|
|
23
23
|
*/
|
|
24
|
-
export type
|
|
24
|
+
export type ObsidianDeleteNoteInput = z.infer<typeof ObsidianDeleteNoteInputSchema>;
|
|
25
25
|
/**
|
|
26
|
-
* Defines the structure of the successful response returned by the `
|
|
26
|
+
* Defines the structure of the successful response returned by the `processObsidianDeleteNote` function.
|
|
27
27
|
* This object is typically serialized to JSON and sent back to the client.
|
|
28
28
|
*/
|
|
29
|
-
export interface
|
|
29
|
+
export interface ObsidianDeleteNoteResponse {
|
|
30
30
|
/** Indicates whether the deletion operation was successful. */
|
|
31
31
|
success: boolean;
|
|
32
32
|
/** A human-readable message confirming the deletion and specifying the path used. */
|
|
@@ -40,12 +40,12 @@ export interface ObsidianDeleteFileResponse {
|
|
|
40
40
|
* it lists the directory, finds a unique case-insensitive match for the filename,
|
|
41
41
|
* and retries the deletion with the corrected path.
|
|
42
42
|
*
|
|
43
|
-
* @param {
|
|
43
|
+
* @param {ObsidianDeleteNoteInput} params - The validated input parameters.
|
|
44
44
|
* @param {RequestContext} context - The request context for logging and correlation.
|
|
45
45
|
* @param {ObsidianRestApiService} obsidianService - An instance of the Obsidian REST API service.
|
|
46
|
-
* @returns {Promise<
|
|
46
|
+
* @returns {Promise<ObsidianDeleteNoteResponse>} A promise resolving to the structured success response
|
|
47
47
|
* containing a confirmation message.
|
|
48
48
|
* @throws {McpError} Throws an McpError if the file cannot be found (even with fallback),
|
|
49
49
|
* if there's an ambiguous fallback match, or if any other API interaction fails.
|
|
50
50
|
*/
|
|
51
|
-
export declare const
|
|
51
|
+
export declare const processObsidianDeleteNote: (params: ObsidianDeleteNoteInput, context: RequestContext, obsidianService: ObsidianRestApiService, vaultCacheService: VaultCacheService | undefined) => Promise<ObsidianDeleteNoteResponse>;
|
|
@@ -6,9 +6,9 @@ import { logger, retryWithDelay, } from "../../../utils/index.js";
|
|
|
6
6
|
// Schema Definitions for Input Validation
|
|
7
7
|
// ====================================================================================
|
|
8
8
|
/**
|
|
9
|
-
* Zod schema for validating the input parameters of the '
|
|
9
|
+
* Zod schema for validating the input parameters of the 'obsidian_delete_note' tool.
|
|
10
10
|
*/
|
|
11
|
-
export const
|
|
11
|
+
export const ObsidianDeleteNoteInputSchema = z
|
|
12
12
|
.object({
|
|
13
13
|
/**
|
|
14
14
|
* The vault-relative path to the file to be permanently deleted.
|
|
@@ -33,18 +33,18 @@ export const ObsidianDeleteFileInputSchema = z
|
|
|
33
33
|
* it lists the directory, finds a unique case-insensitive match for the filename,
|
|
34
34
|
* and retries the deletion with the corrected path.
|
|
35
35
|
*
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {ObsidianDeleteNoteInput} params - The validated input parameters.
|
|
37
37
|
* @param {RequestContext} context - The request context for logging and correlation.
|
|
38
38
|
* @param {ObsidianRestApiService} obsidianService - An instance of the Obsidian REST API service.
|
|
39
|
-
* @returns {Promise<
|
|
39
|
+
* @returns {Promise<ObsidianDeleteNoteResponse>} A promise resolving to the structured success response
|
|
40
40
|
* containing a confirmation message.
|
|
41
41
|
* @throws {McpError} Throws an McpError if the file cannot be found (even with fallback),
|
|
42
42
|
* if there's an ambiguous fallback match, or if any other API interaction fails.
|
|
43
43
|
*/
|
|
44
|
-
export const
|
|
44
|
+
export const processObsidianDeleteNote = async (params, context, obsidianService, vaultCacheService) => {
|
|
45
45
|
const { filePath: originalFilePath } = params;
|
|
46
46
|
let effectiveFilePath = originalFilePath; // Track the path actually used for deletion
|
|
47
|
-
logger.debug(`Processing
|
|
47
|
+
logger.debug(`Processing obsidian_delete_note request for path: ${originalFilePath}`, context);
|
|
48
48
|
const shouldRetryNotFound = (err) => err instanceof McpError && err.code === BaseErrorCode.NOT_FOUND;
|
|
49
49
|
try {
|
|
50
50
|
// --- Attempt 1: Delete using the provided path (case-sensitive) ---
|
package/dist/mcp-server/tools/{obsidianDeleteFileTool → obsidianDeleteNoteTool}/registration.d.ts
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { ObsidianRestApiService, VaultCacheService } from "../../../services/obsidianRestAPI/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* Registers the '
|
|
4
|
+
* Registers the 'obsidian_delete_note' tool with the MCP server.
|
|
5
5
|
*
|
|
6
6
|
* This tool permanently deletes a specified file from the user's Obsidian vault.
|
|
7
7
|
* It requires the vault-relative path, including the file extension. The tool
|
|
@@ -16,4 +16,4 @@ import { ObsidianRestApiService, VaultCacheService } from "../../../services/obs
|
|
|
16
16
|
* @returns {Promise<void>} A promise that resolves when the tool registration is complete or rejects on error.
|
|
17
17
|
* @throws {McpError} Throws an McpError if registration fails critically.
|
|
18
18
|
*/
|
|
19
|
-
export declare const
|
|
19
|
+
export declare const registerObsidianDeleteNoteTool: (server: McpServer, obsidianService: ObsidianRestApiService, vaultCacheService: VaultCacheService | undefined) => Promise<void>;
|
package/dist/mcp-server/tools/{obsidianDeleteFileTool → obsidianDeleteNoteTool}/registration.js
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BaseErrorCode, McpError } from "../../../types-global/errors.js";
|
|
2
2
|
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ObsidianDeleteNoteInputSchema, processObsidianDeleteNote, } from "./logic.js";
|
|
4
4
|
/**
|
|
5
|
-
* Registers the '
|
|
5
|
+
* Registers the 'obsidian_delete_note' tool with the MCP server.
|
|
6
6
|
*
|
|
7
7
|
* This tool permanently deletes a specified file from the user's Obsidian vault.
|
|
8
8
|
* It requires the vault-relative path, including the file extension. The tool
|
|
@@ -17,26 +17,26 @@ import { ObsidianDeleteFileInputSchema, processObsidianDeleteFile, } from "./log
|
|
|
17
17
|
* @returns {Promise<void>} A promise that resolves when the tool registration is complete or rejects on error.
|
|
18
18
|
* @throws {McpError} Throws an McpError if registration fails critically.
|
|
19
19
|
*/
|
|
20
|
-
export const
|
|
21
|
-
const toolName = "
|
|
20
|
+
export const registerObsidianDeleteNoteTool = async (server, obsidianService, vaultCacheService) => {
|
|
21
|
+
const toolName = "obsidian_delete_note";
|
|
22
22
|
// Updated description to accurately reflect the response (no timestamp)
|
|
23
23
|
const toolDescription = "Permanently deletes a specified file from the Obsidian vault. Tries the exact path first, then attempts a case-insensitive fallback if the file is not found. Requires the vault-relative path including the file extension. Returns a success message.";
|
|
24
24
|
// Create a context specifically for the registration process.
|
|
25
25
|
const registrationContext = requestContextService.createRequestContext({
|
|
26
|
-
operation: "
|
|
26
|
+
operation: "RegisterObsidianDeleteNoteTool",
|
|
27
27
|
toolName: toolName,
|
|
28
|
-
module: "
|
|
28
|
+
module: "ObsidianDeleteNoteRegistration", // Identify the module
|
|
29
29
|
});
|
|
30
30
|
logger.info(`Attempting to register tool: ${toolName}`, registrationContext);
|
|
31
31
|
// Wrap the registration logic in a tryCatch block for robust error handling during server setup.
|
|
32
32
|
await ErrorHandler.tryCatch(async () => {
|
|
33
33
|
// Use the high-level SDK method `server.tool` for registration.
|
|
34
|
-
server.tool(toolName, toolDescription,
|
|
34
|
+
server.tool(toolName, toolDescription, ObsidianDeleteNoteInputSchema.shape, // Provide the Zod schema shape for input definition.
|
|
35
35
|
/**
|
|
36
|
-
* The handler function executed when the '
|
|
36
|
+
* The handler function executed when the 'obsidian_delete_note' tool is called by the client.
|
|
37
37
|
*
|
|
38
|
-
* @param {
|
|
39
|
-
* validated against the
|
|
38
|
+
* @param {ObsidianDeleteNoteInput} params - The input parameters received from the client,
|
|
39
|
+
* validated against the ObsidianDeleteNoteInputSchema shape.
|
|
40
40
|
* @returns {Promise<CallToolResult>} A promise resolving to the structured result for the MCP client,
|
|
41
41
|
* containing either the successful response data (serialized JSON) or an error indication.
|
|
42
42
|
*/
|
|
@@ -45,7 +45,7 @@ export const registerObsidianDeleteFileTool = async (server, obsidianService, va
|
|
|
45
45
|
// Create a specific context for this handler invocation.
|
|
46
46
|
const handlerContext = requestContextService.createRequestContext({
|
|
47
47
|
parentContext: registrationContext, // Link to registration context
|
|
48
|
-
operation: "
|
|
48
|
+
operation: "HandleObsidianDeleteNoteRequest",
|
|
49
49
|
toolName: toolName,
|
|
50
50
|
params: { filePath: params.filePath }, // Log the file path being targeted
|
|
51
51
|
});
|
|
@@ -54,7 +54,7 @@ export const registerObsidianDeleteFileTool = async (server, obsidianService, va
|
|
|
54
54
|
return await ErrorHandler.tryCatch(async () => {
|
|
55
55
|
// Delegate the actual file deletion logic to the processing function.
|
|
56
56
|
// Note: Input schema and shape are identical, no separate refinement parse needed here.
|
|
57
|
-
const response = await
|
|
57
|
+
const response = await processObsidianDeleteNote(params, handlerContext, obsidianService, vaultCacheService);
|
|
58
58
|
logger.debug(`'${toolName}' processed successfully`, handlerContext);
|
|
59
59
|
// Format the successful response object from the logic function into the required MCP CallToolResult structure.
|
|
60
60
|
// The response object (success, message) is serialized to JSON.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Barrel file for the '
|
|
2
|
+
* @fileoverview Barrel file for the 'obsidian_list_notes' MCP tool.
|
|
3
3
|
*
|
|
4
|
-
* This file serves as the public entry point for the
|
|
5
|
-
* It re-exports the primary registration function (`
|
|
4
|
+
* This file serves as the public entry point for the obsidian_list_notes tool module.
|
|
5
|
+
* It re-exports the primary registration function (`registerObsidianListNotesTool`)
|
|
6
6
|
* from the './registration.js' module. This pattern simplifies imports for consumers
|
|
7
7
|
* of the tool, allowing them to import necessary components from a single location.
|
|
8
8
|
*
|
|
9
9
|
* Consumers (like the main server setup) should import the registration function
|
|
10
10
|
* from this file to integrate the tool into the MCP server instance.
|
|
11
11
|
*/
|
|
12
|
-
export {
|
|
12
|
+
export { registerObsidianListNotesTool } from "./registration.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Barrel file for the '
|
|
2
|
+
* @fileoverview Barrel file for the 'obsidian_list_notes' MCP tool.
|
|
3
3
|
*
|
|
4
|
-
* This file serves as the public entry point for the
|
|
5
|
-
* It re-exports the primary registration function (`
|
|
4
|
+
* This file serves as the public entry point for the obsidian_list_notes tool module.
|
|
5
|
+
* It re-exports the primary registration function (`registerObsidianListNotesTool`)
|
|
6
6
|
* from the './registration.js' module. This pattern simplifies imports for consumers
|
|
7
7
|
* of the tool, allowing them to import necessary components from a single location.
|
|
8
8
|
*
|
|
9
9
|
* Consumers (like the main server setup) should import the registration function
|
|
10
10
|
* from this file to integrate the tool into the MCP server instance.
|
|
11
11
|
*/
|
|
12
|
-
export {
|
|
12
|
+
export { registerObsidianListNotesTool } from "./registration.js";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Core logic for the '
|
|
2
|
+
* @fileoverview Core logic for the 'obsidian_list_notes' tool.
|
|
3
3
|
* This module defines the input schema, response types, and processing logic for
|
|
4
4
|
* recursively listing files and directories in an Obsidian vault with filtering.
|
|
5
|
-
* @module src/mcp-server/tools/
|
|
5
|
+
* @module src/mcp-server/tools/obsidianListNotesTool/logic
|
|
6
6
|
*/
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { ObsidianRestApiService } from "../../../services/obsidianRestAPI/index.js";
|
|
9
9
|
import { RequestContext } from "../../../utils/index.js";
|
|
10
10
|
/**
|
|
11
|
-
* Zod schema for validating the input parameters of the '
|
|
11
|
+
* Zod schema for validating the input parameters of the 'obsidian_list_notes' tool.
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const ObsidianListNotesInputSchema: z.ZodObject<{
|
|
14
14
|
/**
|
|
15
15
|
* The vault-relative path to the directory whose contents should be listed.
|
|
16
16
|
* The path is treated as case-sensitive by the underlying Obsidian API.
|
|
@@ -45,13 +45,13 @@ export declare const ObsidianListFilesInputSchema: z.ZodObject<{
|
|
|
45
45
|
recursionDepth?: number | undefined;
|
|
46
46
|
}>;
|
|
47
47
|
/**
|
|
48
|
-
* TypeScript type inferred from the input schema (`
|
|
48
|
+
* TypeScript type inferred from the input schema (`ObsidianListNotesInputSchema`).
|
|
49
49
|
*/
|
|
50
|
-
export type
|
|
50
|
+
export type ObsidianListNotesInput = z.infer<typeof ObsidianListNotesInputSchema>;
|
|
51
51
|
/**
|
|
52
52
|
* Defines the structure of the successful response returned by the core logic function.
|
|
53
53
|
*/
|
|
54
|
-
export interface
|
|
54
|
+
export interface ObsidianListNotesResponse {
|
|
55
55
|
directoryPath: string;
|
|
56
56
|
tree: string;
|
|
57
57
|
totalEntries: number;
|
|
@@ -59,10 +59,10 @@ export interface ObsidianListFilesResponse {
|
|
|
59
59
|
/**
|
|
60
60
|
* Processes the core logic for listing files and directories recursively within the Obsidian vault.
|
|
61
61
|
*
|
|
62
|
-
* @param {
|
|
62
|
+
* @param {ObsidianListNotesInput} params - The validated input parameters.
|
|
63
63
|
* @param {RequestContext} context - The request context for logging and correlation.
|
|
64
64
|
* @param {ObsidianRestApiService} obsidianService - An instance of the Obsidian REST API service.
|
|
65
|
-
* @returns {Promise<
|
|
65
|
+
* @returns {Promise<ObsidianListNotesResponse>} A promise resolving to the structured success response.
|
|
66
66
|
* @throws {McpError} Throws an McpError if the initial directory is not found or another error occurs.
|
|
67
67
|
*/
|
|
68
|
-
export declare const
|
|
68
|
+
export declare const processObsidianListNotes: (params: ObsidianListNotesInput, context: RequestContext, obsidianService: ObsidianRestApiService) => Promise<ObsidianListNotesResponse>;
|