obsidian-mcp-server 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +35 -0
- package/README.md +171 -0
- package/build/index.js +11 -0
- package/build/obsidian.js +197 -0
- package/build/server.js +211 -0
- package/build/tools.js +381 -0
- package/build/types.js +20 -0
- package/package.json +55 -0
- package/src/index.ts +12 -0
- package/src/obsidian.ts +235 -0
- package/src/server.ts +277 -0
- package/src/tools.ts +429 -0
- package/src/types.ts +99 -0
- package/tsconfig.json +17 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Tool, TextContent, ImageContent, EmbeddedResource } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
|
|
3
|
+
export interface ObsidianConfig {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
verifySSL?: boolean;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
maxContentLength?: number;
|
|
8
|
+
maxBodyLength?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ObsidianServerConfig {
|
|
12
|
+
protocol: "http" | "https";
|
|
13
|
+
host: string;
|
|
14
|
+
port: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const DEFAULT_OBSIDIAN_CONFIG: ObsidianServerConfig = {
|
|
18
|
+
protocol: "https",
|
|
19
|
+
host: "127.0.0.1",
|
|
20
|
+
port: 27124
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
export interface ObsidianFile {
|
|
24
|
+
path: string;
|
|
25
|
+
type: "file" | "folder";
|
|
26
|
+
children?: ObsidianFile[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface SearchMatch {
|
|
30
|
+
context: string;
|
|
31
|
+
match: {
|
|
32
|
+
start: number;
|
|
33
|
+
end: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface SearchResult {
|
|
38
|
+
filename: string;
|
|
39
|
+
score: number;
|
|
40
|
+
matches: SearchMatch[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ToolHandler<T = Record<string, unknown>> {
|
|
44
|
+
name: string;
|
|
45
|
+
getToolDescription(): Tool;
|
|
46
|
+
runTool(args: T): Promise<Array<TextContent | ImageContent | EmbeddedResource>>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface PatchContentArgs {
|
|
50
|
+
filepath: string;
|
|
51
|
+
content: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface AppendContentArgs {
|
|
55
|
+
filepath: string;
|
|
56
|
+
content: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SearchArgs {
|
|
60
|
+
query: string;
|
|
61
|
+
contextLength?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface JsonLogicQuery {
|
|
65
|
+
[operator: string]: unknown[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ComplexSearchArgs {
|
|
69
|
+
query: JsonLogicQuery;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface FileContentsArgs {
|
|
73
|
+
filepath: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ListFilesArgs {
|
|
77
|
+
dirpath: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface RateLimitConfig {
|
|
81
|
+
windowMs: number;
|
|
82
|
+
maxRequests: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const DEFAULT_RATE_LIMIT_CONFIG: RateLimitConfig = {
|
|
86
|
+
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
87
|
+
maxRequests: 200
|
|
88
|
+
} as const;
|
|
89
|
+
|
|
90
|
+
export class ObsidianError extends Error {
|
|
91
|
+
constructor(
|
|
92
|
+
message: string,
|
|
93
|
+
public readonly code?: number,
|
|
94
|
+
public readonly details?: unknown
|
|
95
|
+
) {
|
|
96
|
+
super(message);
|
|
97
|
+
this.name = "ObsidianError";
|
|
98
|
+
}
|
|
99
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"outDir": "./build",
|
|
11
|
+
"rootDir": "./src",
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"sourceMap": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"],
|
|
16
|
+
"exclude": ["node_modules", "build"]
|
|
17
|
+
}
|