-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathserver.ts
More file actions
executable file
·60 lines (48 loc) · 1.75 KB
/
Copy pathserver.ts
File metadata and controls
executable file
·60 lines (48 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env node
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { createServer } from "./src/createServer.js";
import { readFileSync } from "fs";
import { fileURLToPath } from "url";
import { dirname, join, resolve } from "path";
// Get package.json version
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const packageJson = JSON.parse(
readFileSync(join(__dirname, "../package.json"), "utf-8")
);
const VERSION = packageJson.version;
// Handle --version and --help flags
const cliArgs = process.argv.slice(2);
const firstArg = cliArgs[0];
if (firstArg === "--version" || firstArg === "-v") {
console.log(VERSION);
process.exit(0);
}
if (firstArg === "--help" || firstArg === "-h") {
console.log(`
mcpvault v${VERSION}
Universal AI bridge for Obsidian vaults - connect any MCP-compatible assistant
Usage:
npx @bitbonsai/mcpvault [vault-path]
Arguments:
[vault-path] Optional path to your Obsidian vault directory
Defaults to current working directory when omitted
Options:
--version, -v Show version number
--help, -h Show this help message
Examples:
npx @bitbonsai/mcpvault
npx @bitbonsai/mcpvault ~/Documents/MyVault
npx @bitbonsai/mcpvault ./Vault
npx @bitbonsai/mcpvault /path/to/obsidian/vault
npx @bitbonsai/mcpvault "/path/with spaces/Obsidian Vault"
`);
process.exit(0);
}
// Join trailing args to support vault paths with spaces.
// When omitted, default to current working directory.
const vaultPathArg = cliArgs.join(' ').trim();
const vaultPath = resolve(vaultPathArg || process.cwd());
const server = createServer(vaultPath, { version: VERSION });
const transport = new StdioServerTransport();
await server.connect(transport);