server-instructions.mjs
56 lines 2.2 KB
Raw
sha256:87f84653ce4706be8c65b0c4494ed6fb891213cca82db2b1824772cddc41a752 feat(auth): durable MCP OAuth refresh via shared strong sto… Agent minor 59 days ago
1 /**
2 * MCP Phase G — scope hints for clients: initialize `instructions` + optional client roots logging.
3 * MCP "roots" are normally declared by the client; we document server filesystem scope in `instructions`.
4 */
5
6 import { pathToFileURL } from 'node:url';
7 import { loadConfig } from '../lib/config.mjs';
8
9 /**
10 * @param {string} absPath
11 * @returns {string}
12 */
13 export function fileUriForPath(absPath) {
14 return pathToFileURL(absPath).href;
15 }
16
17 /**
18 * @param {{ vault_path: string, data_dir: string, vaultList?: Array<{ id: string, path: string, label?: string }> }} config
19 * @returns {string}
20 */
21 export function buildKnowtationMcpInstructions(config) {
22 const vaultUri = fileUriForPath(config.vault_path);
23 const dataUri = fileUriForPath(config.data_dir);
24 const lines = [
25 'Knowtation is a personal knowledge assistant: it searches, reads, and writes Markdown notes in your vault, keeps a search index under your data directory, and exposes the same operations through MCP tools and resources as the CLI.',
26 'The server reads and writes only the configured vault paths and index data below—not arbitrary paths on your machine unless a tool is given an explicit vault-relative path inside that vault.',
27 '',
28 'Authoritative filesystem scope (add these as MCP client workspace roots when your client supports roots, so the model knows what this server is tied to):',
29 `- Vault (notes, media): ${vaultUri}`,
30 `- Data directory (index, sidecars): ${dataUri}`,
31 ];
32 if (config.vaultList && config.vaultList.length > 1) {
33 lines.push('', 'Configured vaults (multi-vault):');
34 for (const v of config.vaultList) {
35 const label = v.label || v.id;
36 lines.push(`- ${label} (${v.id}): ${fileUriForPath(v.path)}`);
37 }
38 }
39 return lines.join('\n');
40 }
41
42 /**
43 * @returns {string}
44 */
45 export function tryBuildKnowtationMcpInstructions() {
46 try {
47 return buildKnowtationMcpInstructions(loadConfig());
48 } catch (e) {
49 const msg = e instanceof Error ? e.message : String(e);
50 return [
51 'Knowtation MCP needs a valid vault before it can describe scope.',
52 'Set vault_path in config/local.yaml or KNOWTATION_VAULT_PATH, then restart the server.',
53 `Current error: ${msg}`,
54 ].join('\n');
55 }
56 }
File History 5 commits
sha256:87f84653ce4706be8c65b0c4494ed6fb891213cca82db2b1824772cddc41a752 feat(auth): durable MCP OAuth refresh via shared strong sto… Agent minor 59 days ago
sha256:873e30b7fafe601346295f8f4289f388f21d8f715f28584d5481899ba2b714fc Merge pull request #249 from aaronrene/muse-mirror Agent 76 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b fix(7C-L1b): route hosted delegation proposals through cani… Human minor 78 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 98 days ago