@bitbonsai/mcpvault 0.8.2
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 +994 -0
- package/dist/server.js +690 -0
- package/dist/src/filesystem.js +763 -0
- package/dist/src/filesystem.test.js +946 -0
- package/dist/src/frontmatter.js +129 -0
- package/dist/src/frontmatter.test.js +118 -0
- package/dist/src/integration.test.js +168 -0
- package/dist/src/pathfilter.js +94 -0
- package/dist/src/pathfilter.test.js +264 -0
- package/dist/src/search.js +182 -0
- package/dist/src/search.test.js +212 -0
- package/dist/src/types.js +1 -0
- package/dist/src/uri.js +22 -0
- package/dist/src/uri.test.js +46 -0
- package/package.json +69 -0
package/dist/src/uri.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an Obsidian URI for a given note path.
|
|
3
|
+
* Uses the absolute path format: obsidian:///absolute/path/to/note
|
|
4
|
+
*
|
|
5
|
+
* @param vaultPath - The absolute path to the vault root
|
|
6
|
+
* @param notePath - The relative path to the note within the vault
|
|
7
|
+
* @returns A properly encoded Obsidian URI
|
|
8
|
+
*/
|
|
9
|
+
export function generateObsidianUri(vaultPath, notePath) {
|
|
10
|
+
// Remove leading slash from notePath if present
|
|
11
|
+
const cleanPath = notePath.startsWith('/') ? notePath.slice(1) : notePath;
|
|
12
|
+
// Construct absolute path
|
|
13
|
+
const absolutePath = `${vaultPath}/${cleanPath}`;
|
|
14
|
+
// Remove .md extension if present (Obsidian handles this automatically)
|
|
15
|
+
const pathWithoutExtension = absolutePath.replace(/\.md$/, '');
|
|
16
|
+
// URI encode the path, but keep slashes as slashes
|
|
17
|
+
const encodedPath = pathWithoutExtension
|
|
18
|
+
.split('/')
|
|
19
|
+
.map(segment => encodeURIComponent(segment))
|
|
20
|
+
.join('/');
|
|
21
|
+
return `obsidian:///${encodedPath}`;
|
|
22
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { generateObsidianUri } from './uri.js';
|
|
3
|
+
describe('generateObsidianUri', () => {
|
|
4
|
+
it('generates URI with absolute path', () => {
|
|
5
|
+
const vaultPath = '/Users/test/vault';
|
|
6
|
+
const notePath = 'folder/note.md';
|
|
7
|
+
const uri = generateObsidianUri(vaultPath, notePath);
|
|
8
|
+
expect(uri).toBe('obsidian:////Users/test/vault/folder/note');
|
|
9
|
+
});
|
|
10
|
+
it('handles paths with leading slash', () => {
|
|
11
|
+
const vaultPath = '/Users/test/vault';
|
|
12
|
+
const notePath = '/folder/note.md';
|
|
13
|
+
const uri = generateObsidianUri(vaultPath, notePath);
|
|
14
|
+
expect(uri).toBe('obsidian:////Users/test/vault/folder/note');
|
|
15
|
+
});
|
|
16
|
+
it('removes .md extension', () => {
|
|
17
|
+
const vaultPath = '/Users/test/vault';
|
|
18
|
+
const notePath = 'note.md';
|
|
19
|
+
const uri = generateObsidianUri(vaultPath, notePath);
|
|
20
|
+
expect(uri).toBe('obsidian:////Users/test/vault/note');
|
|
21
|
+
});
|
|
22
|
+
it('encodes special characters', () => {
|
|
23
|
+
const vaultPath = '/Users/test/vault';
|
|
24
|
+
const notePath = 'folder/my note with spaces.md';
|
|
25
|
+
const uri = generateObsidianUri(vaultPath, notePath);
|
|
26
|
+
expect(uri).toBe('obsidian:////Users/test/vault/folder/my%20note%20with%20spaces');
|
|
27
|
+
});
|
|
28
|
+
it('handles notes in root directory', () => {
|
|
29
|
+
const vaultPath = '/Users/test/vault';
|
|
30
|
+
const notePath = 'note.md';
|
|
31
|
+
const uri = generateObsidianUri(vaultPath, notePath);
|
|
32
|
+
expect(uri).toBe('obsidian:////Users/test/vault/note');
|
|
33
|
+
});
|
|
34
|
+
it('handles nested directories', () => {
|
|
35
|
+
const vaultPath = '/Users/test/vault';
|
|
36
|
+
const notePath = 'folder1/folder2/folder3/note.md';
|
|
37
|
+
const uri = generateObsidianUri(vaultPath, notePath);
|
|
38
|
+
expect(uri).toBe('obsidian:////Users/test/vault/folder1/folder2/folder3/note');
|
|
39
|
+
});
|
|
40
|
+
it('encodes special characters in directory names', () => {
|
|
41
|
+
const vaultPath = '/Users/test/vault';
|
|
42
|
+
const notePath = 'my folder/sub folder/note.md';
|
|
43
|
+
const uri = generateObsidianUri(vaultPath, notePath);
|
|
44
|
+
expect(uri).toBe('obsidian:////Users/test/vault/my%20folder/sub%20folder/note');
|
|
45
|
+
});
|
|
46
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bitbonsai/mcpvault",
|
|
3
|
+
"version": "0.8.2",
|
|
4
|
+
"description": "Universal AI bridge for Obsidian vaults - connect any MCP-compatible assistant",
|
|
5
|
+
"homepage": "https://mcpvault.org",
|
|
6
|
+
"author": "bitbonsai",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"packageManager": "npm@10.9.0+sha512.65a9c38a8172948f617a53619762cd77e12b9950fe1f9239debcb8d62c652f2081824b986fee7c0af6c0a7df615becebe4bf56e17ec27214a87aa29d9e038b4b",
|
|
10
|
+
"main": "dist/server.js",
|
|
11
|
+
"bin": {
|
|
12
|
+
"mcpvault": "dist/server.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/**/*",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"start": "tsx server.ts",
|
|
21
|
+
"website": "cd website && bun dev",
|
|
22
|
+
"build": "tsc --project tsconfig.build.json",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest",
|
|
25
|
+
"prepublishOnly": "npm run build && npm test",
|
|
26
|
+
"prepack": "npm install",
|
|
27
|
+
"publish:dry": "npm publish --dry-run",
|
|
28
|
+
"publish:beta": "npm publish --tag beta",
|
|
29
|
+
"publish:latest": "npm publish"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@modelcontextprotocol/sdk": "^1.20.0",
|
|
33
|
+
"gray-matter": "^4.0.3"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^25.3.3",
|
|
37
|
+
"tsx": "^4.20.6",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"vitest": "^4.0.15"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.0.0"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/bitbonsai/mcpvault.git"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"mcp",
|
|
50
|
+
"obsidian",
|
|
51
|
+
"model-context-protocol",
|
|
52
|
+
"universal",
|
|
53
|
+
"ai-bridge",
|
|
54
|
+
"mcp-server",
|
|
55
|
+
"claude",
|
|
56
|
+
"chatgpt",
|
|
57
|
+
"ai",
|
|
58
|
+
"knowledge-management",
|
|
59
|
+
"pkm",
|
|
60
|
+
"vault",
|
|
61
|
+
"notes",
|
|
62
|
+
"markdown",
|
|
63
|
+
"future-proof",
|
|
64
|
+
"open-standard"
|
|
65
|
+
],
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
}
|
|
69
|
+
}
|