server-instructions.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day 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
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
1 day ago