@aniketbiswas/obsidian-mcp-server 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.
- package/LICENSE +21 -0
- package/README.md +232 -0
- package/build/index.d.ts +26 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +148 -0
- package/build/index.js.map +1 -0
- package/build/prompts/index.d.ts +33 -0
- package/build/prompts/index.d.ts.map +1 -0
- package/build/prompts/index.js +152 -0
- package/build/prompts/index.js.map +1 -0
- package/build/prompts/obsidian.d.ts +17 -0
- package/build/prompts/obsidian.d.ts.map +1 -0
- package/build/prompts/obsidian.js +305 -0
- package/build/prompts/obsidian.js.map +1 -0
- package/build/resources/index.d.ts +31 -0
- package/build/resources/index.d.ts.map +1 -0
- package/build/resources/index.js +111 -0
- package/build/resources/index.js.map +1 -0
- package/build/resources/obsidian.d.ts +19 -0
- package/build/resources/obsidian.d.ts.map +1 -0
- package/build/resources/obsidian.js +246 -0
- package/build/resources/obsidian.js.map +1 -0
- package/build/tools/_template.d.ts +23 -0
- package/build/tools/_template.d.ts.map +1 -0
- package/build/tools/_template.js +124 -0
- package/build/tools/_template.js.map +1 -0
- package/build/tools/calculator.d.ts +32 -0
- package/build/tools/calculator.d.ts.map +1 -0
- package/build/tools/calculator.js +130 -0
- package/build/tools/calculator.js.map +1 -0
- package/build/tools/daily-notes.d.ts +19 -0
- package/build/tools/daily-notes.d.ts.map +1 -0
- package/build/tools/daily-notes.js +469 -0
- package/build/tools/daily-notes.js.map +1 -0
- package/build/tools/greeting.d.ts +23 -0
- package/build/tools/greeting.d.ts.map +1 -0
- package/build/tools/greeting.js +111 -0
- package/build/tools/greeting.js.map +1 -0
- package/build/tools/index.d.ts +28 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +46 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/links.d.ts +19 -0
- package/build/tools/links.d.ts.map +1 -0
- package/build/tools/links.js +467 -0
- package/build/tools/links.js.map +1 -0
- package/build/tools/metadata.d.ts +18 -0
- package/build/tools/metadata.d.ts.map +1 -0
- package/build/tools/metadata.js +447 -0
- package/build/tools/metadata.js.map +1 -0
- package/build/tools/navigation.d.ts +19 -0
- package/build/tools/navigation.d.ts.map +1 -0
- package/build/tools/navigation.js +378 -0
- package/build/tools/navigation.js.map +1 -0
- package/build/tools/notes.d.ts +19 -0
- package/build/tools/notes.d.ts.map +1 -0
- package/build/tools/notes.js +622 -0
- package/build/tools/notes.js.map +1 -0
- package/build/tools/search.d.ts +19 -0
- package/build/tools/search.d.ts.map +1 -0
- package/build/tools/search.js +418 -0
- package/build/tools/search.js.map +1 -0
- package/build/tools/templates.d.ts +18 -0
- package/build/tools/templates.d.ts.map +1 -0
- package/build/tools/templates.js +581 -0
- package/build/tools/templates.js.map +1 -0
- package/build/tools/vault.d.ts +19 -0
- package/build/tools/vault.d.ts.map +1 -0
- package/build/tools/vault.js +403 -0
- package/build/tools/vault.js.map +1 -0
- package/build/types/index.d.ts +11 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +11 -0
- package/build/types/index.js.map +1 -0
- package/build/types/obsidian.d.ts +329 -0
- package/build/types/obsidian.d.ts.map +1 -0
- package/build/types/obsidian.js +38 -0
- package/build/types/obsidian.js.map +1 -0
- package/build/utils/client.d.ts +201 -0
- package/build/utils/client.d.ts.map +1 -0
- package/build/utils/client.js +656 -0
- package/build/utils/client.js.map +1 -0
- package/build/utils/config.d.ts +43 -0
- package/build/utils/config.d.ts.map +1 -0
- package/build/utils/config.js +117 -0
- package/build/utils/config.js.map +1 -0
- package/build/utils/frontmatter.d.ts +90 -0
- package/build/utils/frontmatter.d.ts.map +1 -0
- package/build/utils/frontmatter.js +306 -0
- package/build/utils/frontmatter.js.map +1 -0
- package/build/utils/index.d.ts +13 -0
- package/build/utils/index.d.ts.map +1 -0
- package/build/utils/index.js +13 -0
- package/build/utils/index.js.map +1 -0
- package/build/utils/markdown.d.ts +134 -0
- package/build/utils/markdown.d.ts.map +1 -0
- package/build/utils/markdown.js +330 -0
- package/build/utils/markdown.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* OBSIDIAN MCP - Markdown Utilities
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* Utilities for parsing and manipulating markdown content,
|
|
7
|
+
* extracting links, headings, and other structural elements.
|
|
8
|
+
* ============================================================================
|
|
9
|
+
*/
|
|
10
|
+
import { NoteLink } from "../types/obsidian.js";
|
|
11
|
+
/**
|
|
12
|
+
* Represents a heading in markdown content.
|
|
13
|
+
*/
|
|
14
|
+
export interface MarkdownHeading {
|
|
15
|
+
/** Heading level (1-6) */
|
|
16
|
+
level: number;
|
|
17
|
+
/** Heading text */
|
|
18
|
+
text: string;
|
|
19
|
+
/** Line number (1-indexed) */
|
|
20
|
+
lineNumber: number;
|
|
21
|
+
/** Full line including # symbols */
|
|
22
|
+
raw: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Extract all headings from markdown content.
|
|
26
|
+
*
|
|
27
|
+
* @param content - Markdown content
|
|
28
|
+
* @returns Array of headings with their levels and positions
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractHeadings(content: string): MarkdownHeading[];
|
|
31
|
+
/**
|
|
32
|
+
* Extract the content under a specific heading.
|
|
33
|
+
*
|
|
34
|
+
* @param content - Markdown content
|
|
35
|
+
* @param headingText - The heading text to find
|
|
36
|
+
* @returns Content under the heading (until next same-level or higher heading)
|
|
37
|
+
*/
|
|
38
|
+
export declare function getContentUnderHeading(content: string, headingText: string): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Extract all internal links ([[link]]) from markdown content.
|
|
41
|
+
*
|
|
42
|
+
* @param content - Markdown content
|
|
43
|
+
* @returns Array of internal links
|
|
44
|
+
*/
|
|
45
|
+
export declare function extractInternalLinks(content: string): NoteLink[];
|
|
46
|
+
/**
|
|
47
|
+
* Extract all external links from markdown content.
|
|
48
|
+
*
|
|
49
|
+
* @param content - Markdown content
|
|
50
|
+
* @returns Array of external links
|
|
51
|
+
*/
|
|
52
|
+
export declare function extractExternalLinks(content: string): NoteLink[];
|
|
53
|
+
/**
|
|
54
|
+
* Extract all tag references from markdown content.
|
|
55
|
+
*
|
|
56
|
+
* @param content - Markdown content
|
|
57
|
+
* @returns Array of tag links
|
|
58
|
+
*/
|
|
59
|
+
export declare function extractTagLinks(content: string): NoteLink[];
|
|
60
|
+
/**
|
|
61
|
+
* Extract all links (internal, external, tags) from markdown content.
|
|
62
|
+
*
|
|
63
|
+
* @param content - Markdown content
|
|
64
|
+
* @param sourcePath - Path of the source file
|
|
65
|
+
* @returns Array of all links
|
|
66
|
+
*/
|
|
67
|
+
export declare function extractAllLinks(content: string, sourcePath: string): NoteLink[];
|
|
68
|
+
/**
|
|
69
|
+
* Insert content under a specific heading.
|
|
70
|
+
*
|
|
71
|
+
* @param content - Original markdown content
|
|
72
|
+
* @param headingText - Heading to insert under
|
|
73
|
+
* @param newContent - Content to insert
|
|
74
|
+
* @param position - 'start' or 'end' of the section
|
|
75
|
+
* @returns Updated content
|
|
76
|
+
*/
|
|
77
|
+
export declare function insertUnderHeading(content: string, headingText: string, newContent: string, position?: "start" | "end"): string;
|
|
78
|
+
/**
|
|
79
|
+
* Insert content after a specific line containing text.
|
|
80
|
+
*
|
|
81
|
+
* @param content - Original markdown content
|
|
82
|
+
* @param targetText - Text to search for
|
|
83
|
+
* @param newContent - Content to insert
|
|
84
|
+
* @returns Updated content
|
|
85
|
+
*/
|
|
86
|
+
export declare function insertAfterText(content: string, targetText: string, newContent: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* Insert content before a specific line containing text.
|
|
89
|
+
*
|
|
90
|
+
* @param content - Original markdown content
|
|
91
|
+
* @param targetText - Text to search for
|
|
92
|
+
* @param newContent - Content to insert
|
|
93
|
+
* @returns Updated content
|
|
94
|
+
*/
|
|
95
|
+
export declare function insertBeforeText(content: string, targetText: string, newContent: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Get a summary/excerpt from markdown content.
|
|
98
|
+
*
|
|
99
|
+
* @param content - Markdown content
|
|
100
|
+
* @param maxLength - Maximum length of the summary
|
|
101
|
+
* @returns Summary text
|
|
102
|
+
*/
|
|
103
|
+
export declare function getSummary(content: string, maxLength?: number): string;
|
|
104
|
+
/**
|
|
105
|
+
* Count words in markdown content (excluding frontmatter and code).
|
|
106
|
+
*
|
|
107
|
+
* @param content - Markdown content
|
|
108
|
+
* @returns Word count
|
|
109
|
+
*/
|
|
110
|
+
export declare function countWords(content: string): number;
|
|
111
|
+
/**
|
|
112
|
+
* Create a wikilink from a path.
|
|
113
|
+
*
|
|
114
|
+
* @param path - File path
|
|
115
|
+
* @param displayText - Optional display text
|
|
116
|
+
* @returns Wikilink string
|
|
117
|
+
*/
|
|
118
|
+
export declare function createWikilink(path: string, displayText?: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Create an embed link from a path.
|
|
121
|
+
*
|
|
122
|
+
* @param path - File path
|
|
123
|
+
* @returns Embed string
|
|
124
|
+
*/
|
|
125
|
+
export declare function createEmbed(path: string): string;
|
|
126
|
+
/**
|
|
127
|
+
* Format a date for use in notes.
|
|
128
|
+
*
|
|
129
|
+
* @param date - Date object
|
|
130
|
+
* @param format - Format string (simple tokens: YYYY, MM, DD, HH, mm, ss)
|
|
131
|
+
* @returns Formatted date string
|
|
132
|
+
*/
|
|
133
|
+
export declare function formatDate(date: Date, format?: string): string;
|
|
134
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/utils/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,0BAA0B;IAC1B,KAA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S,GAAE,MAAY,GAAG,MAAM,CAsC3E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAoBlD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CASzE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,MAAqB,GAAG,MAAM,CAe5E"}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* OBSIDIAN MCP - Markdown Utilities
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* Utilities for parsing and manipulating markdown content,
|
|
7
|
+
* extracting links, headings, and other structural elements.
|
|
8
|
+
* ============================================================================
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Extract all headings from markdown content.
|
|
12
|
+
*
|
|
13
|
+
* @param content - Markdown content
|
|
14
|
+
* @returns Array of headings with their levels and positions
|
|
15
|
+
*/
|
|
16
|
+
export function extractHeadings(content) {
|
|
17
|
+
const headings = [];
|
|
18
|
+
const lines = content.split(/\r?\n/);
|
|
19
|
+
for (let i = 0; i < lines.length; i++) {
|
|
20
|
+
const line = lines[i];
|
|
21
|
+
const match = line.match(/^(#{1,6})\s+(.+)$/);
|
|
22
|
+
if (match) {
|
|
23
|
+
headings.push({
|
|
24
|
+
level: match[1].length,
|
|
25
|
+
text: match[2].trim(),
|
|
26
|
+
lineNumber: i + 1,
|
|
27
|
+
raw: line,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return headings;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Extract the content under a specific heading.
|
|
35
|
+
*
|
|
36
|
+
* @param content - Markdown content
|
|
37
|
+
* @param headingText - The heading text to find
|
|
38
|
+
* @returns Content under the heading (until next same-level or higher heading)
|
|
39
|
+
*/
|
|
40
|
+
export function getContentUnderHeading(content, headingText) {
|
|
41
|
+
const headings = extractHeadings(content);
|
|
42
|
+
const lines = content.split(/\r?\n/);
|
|
43
|
+
// Find the target heading
|
|
44
|
+
const targetHeading = headings.find((h) => h.text.toLowerCase() === headingText.toLowerCase());
|
|
45
|
+
if (!targetHeading) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
// Find the end of this section (next heading of same or higher level)
|
|
49
|
+
const startLine = targetHeading.lineNumber;
|
|
50
|
+
const nextHeading = headings.find((h) => h.lineNumber > startLine && h.level <= targetHeading.level);
|
|
51
|
+
const endLine = nextHeading ? nextHeading.lineNumber - 1 : lines.length;
|
|
52
|
+
// Extract content (skip the heading line itself)
|
|
53
|
+
const sectionLines = lines.slice(startLine, endLine);
|
|
54
|
+
return sectionLines.join("\n").trim();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Extract all internal links ([[link]]) from markdown content.
|
|
58
|
+
*
|
|
59
|
+
* @param content - Markdown content
|
|
60
|
+
* @returns Array of internal links
|
|
61
|
+
*/
|
|
62
|
+
export function extractInternalLinks(content) {
|
|
63
|
+
const links = [];
|
|
64
|
+
// Match [[link]] and ![[embed]] patterns
|
|
65
|
+
// Handles: [[note]], [[note|display]], [[note#heading]], [[note#heading|display]]
|
|
66
|
+
const linkRegex = /(!?)\[\[([^\]|#]+)(?:#([^\]|]+))?(?:\|([^\]]+))?\]\]/g;
|
|
67
|
+
let match;
|
|
68
|
+
while ((match = linkRegex.exec(content)) !== null) {
|
|
69
|
+
const isEmbed = match[1] === "!";
|
|
70
|
+
const target = match[2].trim();
|
|
71
|
+
const heading = match[3]?.trim();
|
|
72
|
+
const displayText = match[4]?.trim();
|
|
73
|
+
links.push({
|
|
74
|
+
source: "", // Will be filled by caller
|
|
75
|
+
target: heading ? `${target}#${heading}` : target,
|
|
76
|
+
displayText: displayText || target,
|
|
77
|
+
isEmbed,
|
|
78
|
+
type: "internal",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return links;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Extract all external links from markdown content.
|
|
85
|
+
*
|
|
86
|
+
* @param content - Markdown content
|
|
87
|
+
* @returns Array of external links
|
|
88
|
+
*/
|
|
89
|
+
export function extractExternalLinks(content) {
|
|
90
|
+
const links = [];
|
|
91
|
+
// Match [text](url) pattern
|
|
92
|
+
const linkRegex = /\[([^\]]+)\]\(([^)]+)\)/g;
|
|
93
|
+
let match;
|
|
94
|
+
while ((match = linkRegex.exec(content)) !== null) {
|
|
95
|
+
const displayText = match[1];
|
|
96
|
+
const url = match[2];
|
|
97
|
+
// Skip internal links that might use this format
|
|
98
|
+
if (!url.startsWith("http://") && !url.startsWith("https://")) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
links.push({
|
|
102
|
+
source: "",
|
|
103
|
+
target: url,
|
|
104
|
+
displayText,
|
|
105
|
+
isEmbed: false,
|
|
106
|
+
type: "external",
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return links;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Extract all tag references from markdown content.
|
|
113
|
+
*
|
|
114
|
+
* @param content - Markdown content
|
|
115
|
+
* @returns Array of tag links
|
|
116
|
+
*/
|
|
117
|
+
export function extractTagLinks(content) {
|
|
118
|
+
const tags = [];
|
|
119
|
+
// Match #tag pattern (not inside code blocks or links)
|
|
120
|
+
// Tags can contain letters, numbers, underscores, hyphens, and forward slashes
|
|
121
|
+
const tagRegex = /(?:^|[^\w])#([a-zA-Z][a-zA-Z0-9_/-]*)/g;
|
|
122
|
+
let match;
|
|
123
|
+
while ((match = tagRegex.exec(content)) !== null) {
|
|
124
|
+
tags.push({
|
|
125
|
+
source: "",
|
|
126
|
+
target: match[1],
|
|
127
|
+
displayText: `#${match[1]}`,
|
|
128
|
+
isEmbed: false,
|
|
129
|
+
type: "tag",
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return tags;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Extract all links (internal, external, tags) from markdown content.
|
|
136
|
+
*
|
|
137
|
+
* @param content - Markdown content
|
|
138
|
+
* @param sourcePath - Path of the source file
|
|
139
|
+
* @returns Array of all links
|
|
140
|
+
*/
|
|
141
|
+
export function extractAllLinks(content, sourcePath) {
|
|
142
|
+
const internal = extractInternalLinks(content).map((l) => ({
|
|
143
|
+
...l,
|
|
144
|
+
source: sourcePath,
|
|
145
|
+
}));
|
|
146
|
+
const external = extractExternalLinks(content).map((l) => ({
|
|
147
|
+
...l,
|
|
148
|
+
source: sourcePath,
|
|
149
|
+
}));
|
|
150
|
+
const tags = extractTagLinks(content).map((l) => ({
|
|
151
|
+
...l,
|
|
152
|
+
source: sourcePath,
|
|
153
|
+
}));
|
|
154
|
+
return [...internal, ...external, ...tags];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Insert content under a specific heading.
|
|
158
|
+
*
|
|
159
|
+
* @param content - Original markdown content
|
|
160
|
+
* @param headingText - Heading to insert under
|
|
161
|
+
* @param newContent - Content to insert
|
|
162
|
+
* @param position - 'start' or 'end' of the section
|
|
163
|
+
* @returns Updated content
|
|
164
|
+
*/
|
|
165
|
+
export function insertUnderHeading(content, headingText, newContent, position = "end") {
|
|
166
|
+
const headings = extractHeadings(content);
|
|
167
|
+
const lines = content.split(/\r?\n/);
|
|
168
|
+
// Find the target heading
|
|
169
|
+
const targetHeading = headings.find((h) => h.text.toLowerCase() === headingText.toLowerCase());
|
|
170
|
+
if (!targetHeading) {
|
|
171
|
+
// Heading not found, append at end
|
|
172
|
+
return content + "\n\n" + newContent;
|
|
173
|
+
}
|
|
174
|
+
const startLine = targetHeading.lineNumber;
|
|
175
|
+
// Find the end of this section
|
|
176
|
+
const nextHeading = headings.find((h) => h.lineNumber > startLine && h.level <= targetHeading.level);
|
|
177
|
+
const endLine = nextHeading ? nextHeading.lineNumber - 1 : lines.length;
|
|
178
|
+
if (position === "start") {
|
|
179
|
+
// Insert right after the heading
|
|
180
|
+
lines.splice(startLine, 0, "", newContent);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
// Insert before the next section
|
|
184
|
+
lines.splice(endLine, 0, newContent, "");
|
|
185
|
+
}
|
|
186
|
+
return lines.join("\n");
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Insert content after a specific line containing text.
|
|
190
|
+
*
|
|
191
|
+
* @param content - Original markdown content
|
|
192
|
+
* @param targetText - Text to search for
|
|
193
|
+
* @param newContent - Content to insert
|
|
194
|
+
* @returns Updated content
|
|
195
|
+
*/
|
|
196
|
+
export function insertAfterText(content, targetText, newContent) {
|
|
197
|
+
const lines = content.split(/\r?\n/);
|
|
198
|
+
for (let i = 0; i < lines.length; i++) {
|
|
199
|
+
if (lines[i].includes(targetText)) {
|
|
200
|
+
lines.splice(i + 1, 0, newContent);
|
|
201
|
+
return lines.join("\n");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// Target not found, append at end
|
|
205
|
+
return content + "\n\n" + newContent;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Insert content before a specific line containing text.
|
|
209
|
+
*
|
|
210
|
+
* @param content - Original markdown content
|
|
211
|
+
* @param targetText - Text to search for
|
|
212
|
+
* @param newContent - Content to insert
|
|
213
|
+
* @returns Updated content
|
|
214
|
+
*/
|
|
215
|
+
export function insertBeforeText(content, targetText, newContent) {
|
|
216
|
+
const lines = content.split(/\r?\n/);
|
|
217
|
+
for (let i = 0; i < lines.length; i++) {
|
|
218
|
+
if (lines[i].includes(targetText)) {
|
|
219
|
+
lines.splice(i, 0, newContent);
|
|
220
|
+
return lines.join("\n");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// Target not found, prepend at start
|
|
224
|
+
return newContent + "\n\n" + content;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get a summary/excerpt from markdown content.
|
|
228
|
+
*
|
|
229
|
+
* @param content - Markdown content
|
|
230
|
+
* @param maxLength - Maximum length of the summary
|
|
231
|
+
* @returns Summary text
|
|
232
|
+
*/
|
|
233
|
+
export function getSummary(content, maxLength = 200) {
|
|
234
|
+
// Remove frontmatter
|
|
235
|
+
const withoutFrontmatter = content.replace(/^---[\s\S]*?---\n?/, "");
|
|
236
|
+
// Remove headings
|
|
237
|
+
const withoutHeadings = withoutFrontmatter.replace(/^#+\s+.+$/gm, "");
|
|
238
|
+
// Remove links but keep text
|
|
239
|
+
const withoutLinks = withoutHeadings
|
|
240
|
+
.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g, "$2$1")
|
|
241
|
+
.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1");
|
|
242
|
+
// Remove images
|
|
243
|
+
const withoutImages = withoutLinks.replace(/!\[[^\]]*\]\([^)]+\)/g, "");
|
|
244
|
+
// Remove code blocks
|
|
245
|
+
const withoutCodeBlocks = withoutImages.replace(/```[\s\S]*?```/g, "");
|
|
246
|
+
// Remove inline code
|
|
247
|
+
const withoutInlineCode = withoutCodeBlocks.replace(/`[^`]+`/g, "");
|
|
248
|
+
// Collapse whitespace and trim
|
|
249
|
+
const cleaned = withoutInlineCode.replace(/\s+/g, " ").trim();
|
|
250
|
+
// Truncate if needed
|
|
251
|
+
if (cleaned.length <= maxLength) {
|
|
252
|
+
return cleaned;
|
|
253
|
+
}
|
|
254
|
+
// Try to break at a word boundary
|
|
255
|
+
const truncated = cleaned.slice(0, maxLength);
|
|
256
|
+
const lastSpace = truncated.lastIndexOf(" ");
|
|
257
|
+
if (lastSpace > maxLength * 0.7) {
|
|
258
|
+
return truncated.slice(0, lastSpace) + "...";
|
|
259
|
+
}
|
|
260
|
+
return truncated + "...";
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Count words in markdown content (excluding frontmatter and code).
|
|
264
|
+
*
|
|
265
|
+
* @param content - Markdown content
|
|
266
|
+
* @returns Word count
|
|
267
|
+
*/
|
|
268
|
+
export function countWords(content) {
|
|
269
|
+
// Remove frontmatter
|
|
270
|
+
const withoutFrontmatter = content.replace(/^---[\s\S]*?---\n?/, "");
|
|
271
|
+
// Remove code blocks
|
|
272
|
+
const withoutCodeBlocks = withoutFrontmatter.replace(/```[\s\S]*?```/g, "");
|
|
273
|
+
// Remove inline code
|
|
274
|
+
const withoutInlineCode = withoutCodeBlocks.replace(/`[^`]+`/g, "");
|
|
275
|
+
// Remove markdown syntax
|
|
276
|
+
const plainText = withoutInlineCode
|
|
277
|
+
.replace(/\[\[([^\]|]+)(?:\|([^\]]+))?\]\]/g, "$2$1")
|
|
278
|
+
.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1")
|
|
279
|
+
.replace(/[#*_~`]/g, "");
|
|
280
|
+
// Count words
|
|
281
|
+
const words = plainText.split(/\s+/).filter((word) => word.length > 0);
|
|
282
|
+
return words.length;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Create a wikilink from a path.
|
|
286
|
+
*
|
|
287
|
+
* @param path - File path
|
|
288
|
+
* @param displayText - Optional display text
|
|
289
|
+
* @returns Wikilink string
|
|
290
|
+
*/
|
|
291
|
+
export function createWikilink(path, displayText) {
|
|
292
|
+
// Remove .md extension if present
|
|
293
|
+
const linkPath = path.replace(/\.md$/, "");
|
|
294
|
+
if (displayText && displayText !== linkPath) {
|
|
295
|
+
return `[[${linkPath}|${displayText}]]`;
|
|
296
|
+
}
|
|
297
|
+
return `[[${linkPath}]]`;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Create an embed link from a path.
|
|
301
|
+
*
|
|
302
|
+
* @param path - File path
|
|
303
|
+
* @returns Embed string
|
|
304
|
+
*/
|
|
305
|
+
export function createEmbed(path) {
|
|
306
|
+
return `![[${path}]]`;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Format a date for use in notes.
|
|
310
|
+
*
|
|
311
|
+
* @param date - Date object
|
|
312
|
+
* @param format - Format string (simple tokens: YYYY, MM, DD, HH, mm, ss)
|
|
313
|
+
* @returns Formatted date string
|
|
314
|
+
*/
|
|
315
|
+
export function formatDate(date, format = "YYYY-MM-DD") {
|
|
316
|
+
const year = date.getFullYear().toString();
|
|
317
|
+
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
318
|
+
const day = date.getDate().toString().padStart(2, "0");
|
|
319
|
+
const hours = date.getHours().toString().padStart(2, "0");
|
|
320
|
+
const minutes = date.getMinutes().toString().padStart(2, "0");
|
|
321
|
+
const seconds = date.getSeconds().toString().padStart(2, "0");
|
|
322
|
+
return format
|
|
323
|
+
.replace("YYYY", year)
|
|
324
|
+
.replace("MM", month)
|
|
325
|
+
.replace("DD", day)
|
|
326
|
+
.replace("HH", hours)
|
|
327
|
+
.replace("mm", minutes)
|
|
328
|
+
.replace("ss", seconds);
|
|
329
|
+
}
|
|
330
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/utils/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkBH;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAErC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAE9C,IAAI,KAAK,EAAE,CAAC;YACV,QAAQ,CA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package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aniketbiswas/obsidian-mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for integrating AI assistants with Obsidian via the Local REST API plugin. 40+ tools for vault management, notes, search, and more.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"obsidian-mcp-server": "./build/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./build/index.js",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc && chmod 755 build/index.js",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"start": "node build/index.js",
|
|
14
|
+
"inspector": "npx @modelcontextprotocol/inspector node build/index.js",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"build",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"mcp",
|
|
24
|
+
"model-context-protocol",
|
|
25
|
+
"obsidian",
|
|
26
|
+
"ai",
|
|
27
|
+
"llm",
|
|
28
|
+
"claude",
|
|
29
|
+
"tools",
|
|
30
|
+
"typescript",
|
|
31
|
+
"notes",
|
|
32
|
+
"knowledge-base",
|
|
33
|
+
"pkm",
|
|
34
|
+
"cli"
|
|
35
|
+
],
|
|
36
|
+
"author": "Aniket Biswas",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/aniketbiswas/obsidian-mcp-server.git"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/aniketbiswas/obsidian-mcp-server#readme",
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/aniketbiswas/obsidian-mcp-server/issues"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
51
|
+
"zod": "^3.23.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^20.0.0",
|
|
55
|
+
"typescript": "^5.0.0"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=18.0.0"
|
|
59
|
+
}
|
|
60
|
+
}
|