obsidian-mcp-server 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -5
- package/build/obsidian.js +181 -32
- package/build/properties.js +7 -7
- package/build/propertyTools.js +11 -21
- package/build/propertyTypes.js +4 -13
- package/build/resources.js +111 -0
- package/build/server.js +36 -12
- package/build/tools.js +425 -48
- package/build/types.js +21 -4
- package/package.json +3 -3
- package/src/obsidian.ts +260 -38
- package/src/properties.ts +9 -7
- package/src/propertyTools.ts +13 -21
- package/src/propertyTypes.ts +5 -13
- package/src/resources.ts +123 -0
- package/src/server.ts +39 -14
- package/src/tools.ts +461 -49
- package/src/types.ts +89 -4
package/src/types.ts
CHANGED
|
@@ -15,17 +15,48 @@ export interface ObsidianServerConfig {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const DEFAULT_OBSIDIAN_CONFIG: ObsidianServerConfig = {
|
|
18
|
-
protocol: "https",
|
|
18
|
+
protocol: "https", // HTTPS required by default in Obsidian REST API plugin
|
|
19
19
|
host: "127.0.0.1",
|
|
20
20
|
port: 27124
|
|
21
21
|
} as const;
|
|
22
22
|
|
|
23
|
+
export interface NoteJson {
|
|
24
|
+
content: string;
|
|
25
|
+
frontmatter: Record<string, unknown>;
|
|
26
|
+
path: string;
|
|
27
|
+
stat: {
|
|
28
|
+
ctime: number;
|
|
29
|
+
mtime: number;
|
|
30
|
+
size: number;
|
|
31
|
+
};
|
|
32
|
+
tags: string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
23
35
|
export interface ObsidianFile {
|
|
24
36
|
path: string;
|
|
25
37
|
type: "file" | "folder";
|
|
26
38
|
children?: ObsidianFile[];
|
|
27
39
|
}
|
|
28
40
|
|
|
41
|
+
export interface ObsidianCommand {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ObsidianStatus {
|
|
47
|
+
authenticated: boolean;
|
|
48
|
+
ok: string;
|
|
49
|
+
service: string;
|
|
50
|
+
versions: {
|
|
51
|
+
obsidian: string;
|
|
52
|
+
self: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface PeriodType {
|
|
57
|
+
type: "daily" | "weekly" | "monthly" | "quarterly" | "yearly";
|
|
58
|
+
}
|
|
59
|
+
|
|
29
60
|
export interface SearchMatch {
|
|
30
61
|
context: string;
|
|
31
62
|
match: {
|
|
@@ -35,11 +66,18 @@ export interface SearchMatch {
|
|
|
35
66
|
}
|
|
36
67
|
|
|
37
68
|
export interface SearchResult {
|
|
69
|
+
filename: string;
|
|
70
|
+
result: unknown;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SimpleSearchResult {
|
|
38
74
|
filename: string;
|
|
39
75
|
score: number;
|
|
40
76
|
matches: SearchMatch[];
|
|
41
77
|
}
|
|
42
78
|
|
|
79
|
+
export type SearchResponse = SearchResult | SimpleSearchResult;
|
|
80
|
+
|
|
43
81
|
export interface ToolHandler<T = Record<string, unknown>> {
|
|
44
82
|
name: string;
|
|
45
83
|
getToolDescription(): Tool;
|
|
@@ -62,7 +100,7 @@ export interface SearchArgs {
|
|
|
62
100
|
}
|
|
63
101
|
|
|
64
102
|
export interface JsonLogicQuery {
|
|
65
|
-
[operator: string]: unknown
|
|
103
|
+
[operator: string]: unknown;
|
|
66
104
|
}
|
|
67
105
|
|
|
68
106
|
export interface ComplexSearchArgs {
|
|
@@ -77,6 +115,28 @@ export interface ListFilesArgs {
|
|
|
77
115
|
dirpath: string;
|
|
78
116
|
}
|
|
79
117
|
|
|
118
|
+
export interface GetTagsArgs {
|
|
119
|
+
path?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface TagInfo {
|
|
123
|
+
name: string;
|
|
124
|
+
count: number;
|
|
125
|
+
files: string[];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface TagMetadata {
|
|
129
|
+
totalOccurrences: number;
|
|
130
|
+
uniqueTags: number;
|
|
131
|
+
scannedFiles: number;
|
|
132
|
+
lastUpdate: number; // Timestamp of last cache update
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface TagResponse {
|
|
136
|
+
tags: TagInfo[];
|
|
137
|
+
metadata: TagMetadata;
|
|
138
|
+
}
|
|
139
|
+
|
|
80
140
|
export interface RateLimitConfig {
|
|
81
141
|
windowMs: number;
|
|
82
142
|
maxRequests: number;
|
|
@@ -87,13 +147,38 @@ export const DEFAULT_RATE_LIMIT_CONFIG: RateLimitConfig = {
|
|
|
87
147
|
maxRequests: 200
|
|
88
148
|
} as const;
|
|
89
149
|
|
|
90
|
-
export
|
|
150
|
+
export interface ApiError {
|
|
151
|
+
errorCode: number; // 5-digit error code
|
|
152
|
+
message: string; // Message describing the error
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export class ObsidianError extends Error implements ApiError {
|
|
156
|
+
public readonly errorCode: number;
|
|
157
|
+
|
|
91
158
|
constructor(
|
|
92
159
|
message: string,
|
|
93
|
-
|
|
160
|
+
errorCode: number = 50000, // Default server error code
|
|
94
161
|
public readonly details?: unknown
|
|
95
162
|
) {
|
|
96
163
|
super(message);
|
|
97
164
|
this.name = "ObsidianError";
|
|
165
|
+
|
|
166
|
+
// Ensure 5-digit error code
|
|
167
|
+
if (errorCode < 10000 || errorCode > 99999) {
|
|
168
|
+
// Convert HTTP status codes to 5-digit codes
|
|
169
|
+
// 4xx -> 4xxxx
|
|
170
|
+
// 5xx -> 5xxxx
|
|
171
|
+
this.errorCode = errorCode < 1000 ? errorCode * 100 : 50000;
|
|
172
|
+
} else {
|
|
173
|
+
this.errorCode = errorCode;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Convert to API error format
|
|
178
|
+
toApiError(): ApiError {
|
|
179
|
+
return {
|
|
180
|
+
errorCode: this.errorCode,
|
|
181
|
+
message: this.message
|
|
182
|
+
};
|
|
98
183
|
}
|
|
99
184
|
}
|