LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。
TypeScript
release: v0.4.17 add mcp server
nash_su6293765d35fd
diff --git a/mcp-server/README.md b/mcp-server/README.mdnew file mode 100644index 00000000..4e189a91--- /dev/null+++ b/mcp-server/README.md@@ -0,0 +1,72 @@+# LLM Wiki MCP Server++This package exposes the running LLM Wiki desktop app as a Model Context Protocol server.++It does **not** scan project folders directly and does **not** copy the app's search or graph logic. Every tool calls the local desktop API at `http://127.0.0.1:19828/api/v1`, so MCP clients use the same project registry, file permissions, search backend, graph backend, and Source Watch rules as the app.++## Requirements++- Node.js 20++- LLM Wiki desktop app running+- Settings → API + MCP → "Enable local HTTP API"+- Settings → API + MCP → "Enable MCP access"+- Either:+ - Settings → API + MCP → "Allow access without a token", or+ - `LLM_WIKI_API_TOKEN` set to the configured API token++Optional:++- `LLM_WIKI_API_BASE_URL` to override the default API base URL.++## Build++```bash+cd mcp-server+npm install+npm run build+```++## Run++```bash+LLM_WIKI_API_TOKEN=your-token node dist/src/index.js+```++Example MCP client config:++```json+{+ "mcpServers": {+ "llm-wiki": {+ "command": "node",+ "args": ["/absolute/path/to/llm_wiki/mcp-server/dist/src/index.js"],+ "env": {+ "LLM_WIKI_API_TOKEN": "your-token"+ }+ }+ }+}+```++When API unauthenticated mode is enabled, omit `LLM_WIKI_API_TOKEN`. If MCP access is disabled in Settings, `llm_wiki_status` still works for diagnosis but other tools return an explicit disabled error.++## Tools++- `llm_wiki_status`: health and current project summary.+- `llm_wiki_projects`: known projects and active project.+- `llm_wiki_files`: list project files. `project_id` can be a project UUID, a project filesystem path, or `current`.+- `llm_wiki_read_file`: read an allowed text file such as `wiki/index.md`.+- `llm_wiki_search`: search with the app's shared keyword/vector backend.+- `llm_wiki_graph`: query the app's knowledge graph endpoint.+- `llm_wiki_rescan_sources`: trigger a Source Watch rescan using the user's configured rules.++## Security model++The MCP server inherits the desktop API's security model:++- It only talks to `127.0.0.1` by default.+- It uses the same API token or unauthenticated setting as Settings → API + MCP.+- File reads go through the API path allow-list. Internal app state files are not exposed.+- Search and graph tools operate on projects known to the app; use `project_id: "current"` for the active project.++Do not pass API tokens via command-line arguments. Prefer environment variables so they do not appear in shell history.diff --git a/mcp-server/package-lock.json b/mcp-server/package-lock.jsonnew file mode 100644index 00000000..5a539cd1--- /dev/null+++ b/mcp-server/package-lock.json@@ -0,0 +1,1197 @@+{+ "name": "llm-wiki-mcp-server",+ "version": "0.4.17",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "llm-wiki-mcp-server",+ "version": "0.4.17",+ "license": "MIT",+ "dependencies": {+ "@modelcontextprotocol/sdk": "^1.29.0"+ },+ "bin": {+ "llm-wiki-mcp": "dist/index.js"+ },+ "devDependencies": {+ "@types/node": "^20.0.0",+ "typescript": "^5.7.3"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/@hono/node-server": {+ "version": "1.19.14",+ "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.14.tgz",+ "integrity": "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw==",+ "license": "MIT",+ "engines": {+ "node": ">=18.14.1"+ },+ "peerDependencies": {+ "hono": "^4"+ }+ },+ "node_modules/@modelcontextprotocol/sdk": {+ "version": "1.29.0",+ "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.29.0.tgz",+ "integrity": "sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==",+ "license": "MIT",+ "dependencies": {+ "@hono/node-server": "^1.19.9",+ "ajv": "^8.17.1",+ "ajv-formats": "^3.0.1",+ "content-type": "^1.0.5",+ "cors": "^2.8.5",+ "cross-spawn": "^7.0.5",+ "eventsource": "^3.0.2",+ "eventsource-parser": "^3.0.0",+ "express": "^5.2.1",+ "express-rate-limit": "^8.2.1",+ "hono": "^4.11.4",+ "jose": "^6.1.3",+ "json-schema-typed": "^8.0.2",+ "pkce-challenge": "^5.0.0",+ "raw-body": "^3.0.0",+ "zod": "^3.25 || ^4.0",+ "zod-to-json-schema": "^3.25.1"+ },+ "engines": {+ "node": ">=18"+ },+ "peerDependencies": {+ "@cfworker/json-schema": "^4.1.1",+ "zod": "^3.25 || ^4.0"+ },+ "peerDependenciesMeta": {+ "@cfworker/json-schema": {+ "optional": true+ },+ "zod": {+ "optional": false+ }+ }+ },+ "node_modules/@types/node": {+ "version": "20.19.41",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.41.tgz",+ "integrity": "sha512-ECymXOukMnOoVkC2bb1Vc/w/836DXncOg5m8Xj1RH7xSHZJWNYY6Zh7EH477vcnD5egKNNfy2RpNOmuChhFPgQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "undici-types": "~6.21.0"+ }+ },+ "node_modules/accepts": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",+ "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==",+ "license": "MIT",+ "dependencies": {+ "mime-types": "^3.0.0",+ "negotiator": "^1.0.0"+ },+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/ajv": {+ "version": "8.20.0",+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",+ "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",+ "license": "MIT",+ "dependencies": {+ "fast-deep-equal": "^3.1.3",+ "fast-uri": "^3.0.1",+ "json-schema-traverse": "^1.0.0",+ "require-from-string": "^2.0.2"+ },+ "funding": {+ "type": "github",+ "url": "https://github.com/sponsors/epoberezkin"+ }+ },+ "node_modules/ajv-formats": {+ "version": "3.0.1",+ "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz",+ "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==",+ "license": "MIT",+ "dependencies": {+ "ajv": "^8.0.0"+ },+ "peerDependencies": {+ "ajv": "^8.0.0"+ },+ "peerDependenciesMeta": {+ "ajv": {+ "optional": true+ }+ }+ },+ "node_modules/body-parser": {+ "version": "2.2.2",+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz",+ "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==",+ "license": "MIT",+ "dependencies": {+ "bytes": "^3.1.2",+ "content-type": "^1.0.5",+ "debug": "^4.4.3",+ "http-errors": "^2.0.0",+ "iconv-lite": "^0.7.0",+ "on-finished": "^2.4.1",+ "qs": "^6.14.1",+ "raw-body": "^3.0.1",+ "type-is": "^2.0.1"+ },+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/bytes": {+ "version": "3.1.2",+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",+ "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/call-bind-apply-helpers": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",+ "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0",+ "function-bind": "^1.1.2"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/call-bound": {+ "version": "1.0.4",+ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",+ "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",+ "license": "MIT",+ "dependencies": {+ "call-bind-apply-helpers": "^1.0.2",+ "get-intrinsic": "^1.3.0"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/content-disposition": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz",+ "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/content-type": {+ "version": "1.0.5",+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",+ "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/cookie": {+ "version": "0.7.2",+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",+ "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/cookie-signature": {+ "version": "1.2.2",+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",+ "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==",+ "license": "MIT",+ "engines": {+ "node": ">=6.6.0"+ }+ },+ "node_modules/cors": {+ "version": "2.8.6",+ "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz",+ "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==",+ "license": "MIT",+ "dependencies": {+ "object-assign": "^4",+ "vary": "^1"+ },+ "engines": {+ "node": ">= 0.10"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/cross-spawn": {+ "version": "7.0.6",+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",+ "license": "MIT",+ "dependencies": {+ "path-key": "^3.1.0",+ "shebang-command": "^2.0.0",+ "which": "^2.0.1"+ },+ "engines": {+ "node": ">= 8"+ }+ },+ "node_modules/debug": {+ "version": "4.4.3",+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",+ "license": "MIT",+ "dependencies": {+ "ms": "^2.1.3"+ },+ "engines": {+ "node": ">=6.0"+ },+ "peerDependenciesMeta": {+ "supports-color": {+ "optional": true+ }+ }+ },+ "node_modules/depd": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",+ "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/dunder-proto": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",+ "license": "MIT",+ "dependencies": {+ "call-bind-apply-helpers": "^1.0.1",+ "es-errors": "^1.3.0",+ "gopd": "^1.2.0"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/ee-first": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",+ "license": "MIT"+ },+ "node_modules/encodeurl": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",+ "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/es-define-property": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/es-errors": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/es-object-atoms": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",+ "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/escape-html": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",+ "license": "MIT"+ },+ "node_modules/etag": {+ "version": "1.8.1",+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/eventsource": {+ "version": "3.0.7",+ "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz",+ "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==",+ "license": "MIT",+ "dependencies": {+ "eventsource-parser": "^3.0.1"+ },+ "engines": {+ "node": ">=18.0.0"+ }+ },+ "node_modules/eventsource-parser": {+ "version": "3.1.0",+ "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.0.tgz",+ "integrity": "sha512-kJezFj9YFAMLeORyi7aCLxLbD5/qWMQnoMVlVPyHIll7lgRJCc3JVln9Vgl9nwQi0YkMnhdGTMNn7CkRRAptMg==",+ "license": "MIT",+ "engines": {+ "node": ">=18.0.0"+ }+ },+ "node_modules/express": {+ "version": "5.2.1",+ "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",+ "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",+ "license": "MIT",+ "dependencies": {+ "accepts": "^2.0.0",+ "body-parser": "^2.2.1",+ "content-disposition": "^1.0.0",+ "content-type": "^1.0.5",+ "cookie": "^0.7.1",+ "cookie-signature": "^1.2.1",+ "debug": "^4.4.0",+ "depd": "^2.0.0",+ "encodeurl": "^2.0.0",+ "escape-html": "^1.0.3",+ "etag": "^1.8.1",+ "finalhandler": "^2.1.0",+ "fresh": "^2.0.0",+ "http-errors": "^2.0.0",+ "merge-descriptors": "^2.0.0",+ "mime-types": "^3.0.0",+ "on-finished": "^2.4.1",+ "once": "^1.4.0",+ "parseurl": "^1.3.3",+ "proxy-addr": "^2.0.7",+ "qs": "^6.14.0",+ "range-parser": "^1.2.1",+ "router": "^2.2.0",+ "send": "^1.1.0",+ "serve-static": "^2.2.0",+ "statuses": "^2.0.1",+ "type-is": "^2.0.1",+ "vary": "^1.1.2"+ },+ "engines": {+ "node": ">= 18"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/express-rate-limit": {+ "version": "8.5.2",+ "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.5.2.tgz",+ "integrity": "sha512-5Kb34ipNX694DH48vN9irak1Qx30nb0PLYHXfJgw4YEjiC3ZEmZJhwOp+VfiCYwFzvFTdB9QkArYS5kXa2cx2A==",+ "license": "MIT",+ "dependencies": {+ "ip-address": "^10.2.0"+ },+ "engines": {+ "node": ">= 16"+ },+ "funding": {+ "url": "https://github.com/sponsors/express-rate-limit"+ },+ "peerDependencies": {+ "express": ">= 4.11"+ }+ },+ "node_modules/fast-deep-equal": {+ "version": "3.1.3",+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",+ "license": "MIT"+ },+ "node_modules/fast-uri": {+ "version": "3.1.2",+ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz",+ "integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==",+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/fastify"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/fastify"+ }+ ],+ "license": "BSD-3-Clause"+ },+ "node_modules/finalhandler": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz",+ "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==",+ "license": "MIT",+ "dependencies": {+ "debug": "^4.4.0",+ "encodeurl": "^2.0.0",+ "escape-html": "^1.0.3",+ "on-finished": "^2.4.1",+ "parseurl": "^1.3.3",+ "statuses": "^2.0.1"+ },+ "engines": {+ "node": ">= 18.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/forwarded": {+ "version": "0.2.0",+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",+ "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/fresh": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",+ "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/function-bind": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/get-intrinsic": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",+ "license": "MIT",+ "dependencies": {+ "call-bind-apply-helpers": "^1.0.2",+ "es-define-property": "^1.0.1",+ "es-errors": "^1.3.0",+ "es-object-atoms": "^1.1.1",+ "function-bind": "^1.1.2",+ "get-proto": "^1.0.1",+ "gopd": "^1.2.0",+ "has-symbols": "^1.1.0",+ "hasown": "^2.0.2",+ "math-intrinsics": "^1.1.0"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/get-proto": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",+ "license": "MIT",+ "dependencies": {+ "dunder-proto": "^1.0.1",+ "es-object-atoms": "^1.0.0"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/gopd": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/has-symbols": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/hasown": {+ "version": "2.0.4",+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",+ "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",+ "license": "MIT",+ "dependencies": {+ "function-bind": "^1.1.2"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/hono": {+ "version": "4.12.23",+ "resolved": "https://registry.npmjs.org/hono/-/hono-4.12.23.tgz",+ "integrity": "sha512-eIaZ9qDgu7XV0pxOCrg7/WhnQ6Ivm22UcxhXx/A3dcbqbbYgBEkc6e/J/s7j2tS96zoB0S9VBdLwQNCWwUo4LA==",+ "license": "MIT",+ "engines": {+ "node": ">=16.9.0"+ }+ },+ "node_modules/http-errors": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",+ "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",+ "license": "MIT",+ "dependencies": {+ "depd": "~2.0.0",+ "inherits": "~2.0.4",+ "setprototypeof": "~1.2.0",+ "statuses": "~2.0.2",+ "toidentifier": "~1.0.1"+ },+ "engines": {+ "node": ">= 0.8"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/iconv-lite": {+ "version": "0.7.2",+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",+ "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==",+ "license": "MIT",+ "dependencies": {+ "safer-buffer": ">= 2.1.2 < 3.0.0"+ },+ "engines": {+ "node": ">=0.10.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/inherits": {+ "version": "2.0.4",+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",+ "license": "ISC"+ },+ "node_modules/ip-address": {+ "version": "10.2.0",+ "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz",+ "integrity": "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA==",+ "license": "MIT",+ "engines": {+ "node": ">= 12"+ }+ },+ "node_modules/ipaddr.js": {+ "version": "1.9.1",+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",+ "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.10"+ }+ },+ "node_modules/is-promise": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",+ "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",+ "license": "MIT"+ },+ "node_modules/isexe": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",+ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",+ "license": "ISC"+ },+ "node_modules/jose": {+ "version": "6.2.3",+ "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.3.tgz",+ "integrity": "sha512-YYVDInQKFJfR/xa3ojUTl8c2KoTwiL1R5Wg9YCydwH0x0B9grbzlg5HC7mMjCtUJjbQ/YnGEZIhI5tCgfTb4Hw==",+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/panva"+ }+ },+ "node_modules/json-schema-traverse": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",+ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",+ "license": "MIT"+ },+ "node_modules/json-schema-typed": {+ "version": "8.0.2",+ "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz",+ "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==",+ "license": "BSD-2-Clause"+ },+ "node_modules/math-intrinsics": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/media-typer": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz",+ "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/merge-descriptors": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz",+ "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/mime-db": {+ "version": "1.54.0",+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",+ "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/mime-types": {+ "version": "3.0.2",+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz",+ "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==",+ "license": "MIT",+ "dependencies": {+ "mime-db": "^1.54.0"+ },+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/ms": {+ "version": "2.1.3",+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",+ "license": "MIT"+ },+ "node_modules/negotiator": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",+ "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/object-assign": {+ "version": "4.1.1",+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",+ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/object-inspect": {+ "version": "1.13.4",+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",+ "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/on-finished": {+ "version": "2.4.1",+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",+ "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",+ "license": "MIT",+ "dependencies": {+ "ee-first": "1.1.1"+ },+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/once": {+ "version": "1.4.0",+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",+ "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",+ "license": "ISC",+ "dependencies": {+ "wrappy": "1"+ }+ },+ "node_modules/parseurl": {+ "version": "1.3.3",+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",+ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/path-key": {+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/path-to-regexp": {+ "version": "8.4.2",+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz",+ "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==",+ "license": "MIT",+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/pkce-challenge": {+ "version": "5.0.1",+ "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz",+ "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==",+ "license": "MIT",+ "engines": {+ "node": ">=16.20.0"+ }+ },+ "node_modules/proxy-addr": {+ "version": "2.0.7",+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",+ "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",+ "license": "MIT",+ "dependencies": {+ "forwarded": "0.2.0",+ "ipaddr.js": "1.9.1"+ },+ "engines": {+ "node": ">= 0.10"+ }+ },+ "node_modules/qs": {+ "version": "6.15.2",+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",+ "integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "side-channel": "^1.1.0"+ },+ "engines": {+ "node": ">=0.6"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/range-parser": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",+ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/raw-body": {+ "version": "3.0.2",+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz",+ "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==",+ "license": "MIT",+ "dependencies": {+ "bytes": "~3.1.2",+ "http-errors": "~2.0.1",+ "iconv-lite": "~0.7.0",+ "unpipe": "~1.0.0"+ },+ "engines": {+ "node": ">= 0.10"+ }+ },+ "node_modules/require-from-string": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",+ "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/router": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",+ "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==",+ "license": "MIT",+ "dependencies": {+ "debug": "^4.4.0",+ "depd": "^2.0.0",+ "is-promise": "^4.0.0",+ "parseurl": "^1.3.3",+ "path-to-regexp": "^8.0.0"+ },+ "engines": {+ "node": ">= 18"+ }+ },+ "node_modules/safer-buffer": {+ "version": "2.1.2",+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",+ "license": "MIT"+ },+ "node_modules/send": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz",+ "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==",+ "license": "MIT",+ "dependencies": {+ "debug": "^4.4.3",+ "encodeurl": "^2.0.0",+ "escape-html": "^1.0.3",+ "etag": "^1.8.1",+ "fresh": "^2.0.0",+ "http-errors": "^2.0.1",+ "mime-types": "^3.0.2",+ "ms": "^2.1.3",+ "on-finished": "^2.4.1",+ "range-parser": "^1.2.1",+ "statuses": "^2.0.2"+ },+ "engines": {+ "node": ">= 18"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/serve-static": {+ "version": "2.2.1",+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz",+ "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==",+ "license": "MIT",+ "dependencies": {+ "encodeurl": "^2.0.0",+ "escape-html": "^1.0.3",+ "parseurl": "^1.3.3",+ "send": "^1.2.0"+ },+ "engines": {+ "node": ">= 18"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/setprototypeof": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",+ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",+ "license": "ISC"+ },+ "node_modules/shebang-command": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",+ "license": "MIT",+ "dependencies": {+ "shebang-regex": "^3.0.0"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/shebang-regex": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/side-channel": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",+ "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0",+ "object-inspect": "^1.13.3",+ "side-channel-list": "^1.0.0",+ "side-channel-map": "^1.0.1",+ "side-channel-weakmap": "^1.0.2"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/side-channel-list": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",+ "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0",+ "object-inspect": "^1.13.4"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/side-channel-map": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",+ "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",+ "license": "MIT",+ "dependencies": {+ "call-bound": "^1.0.2",+ "es-errors": "^1.3.0",+ "get-intrinsic": "^1.2.5",+ "object-inspect": "^1.13.3"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/side-channel-weakmap": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",+ "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",+ "license": "MIT",+ "dependencies": {+ "call-bound": "^1.0.2",+ "es-errors": "^1.3.0",+ "get-intrinsic": "^1.2.5",+ "object-inspect": "^1.13.3",+ "side-channel-map": "^1.0.1"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/statuses": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",+ "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/toidentifier": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",+ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",+ "license": "MIT",+ "engines": {+ "node": ">=0.6"+ }+ },+ "node_modules/type-is": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz",+ "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==",+ "license": "MIT",+ "dependencies": {+ "content-type": "^2.0.0",+ "media-typer": "^1.1.0",+ "mime-types": "^3.0.0"+ },+ "engines": {+ "node": ">= 18"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/type-is/node_modules/content-type": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",+ "integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/express"+ }+ },+ "node_modules/typescript": {+ "version": "5.9.3",+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",+ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",+ "dev": true,+ "license": "Apache-2.0",+ "bin": {+ "tsc": "bin/tsc",+ "tsserver": "bin/tsserver"+ },+ "engines": {+ "node": ">=14.17"+ }+ },+ "node_modules/undici-types": {+ "version": "6.21.0",+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/unpipe": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/vary": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/which": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",+ "license": "ISC",+ "dependencies": {+ "isexe": "^2.0.0"+ },+ "bin": {+ "node-which": "bin/node-which"+ },+ "engines": {+ "node": ">= 8"+ }+ },+ "node_modules/wrappy": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",+ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",+ "license": "ISC"+ },+ "node_modules/zod": {+ "version": "4.4.3",+ "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",+ "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==",+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/colinhacks"+ }+ },+ "node_modules/zod-to-json-schema": {+ "version": "3.25.2",+ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz",+ "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==",+ "license": "ISC",+ "peerDependencies": {+ "zod": "^3.25.28 || ^4"+ }+ }+ }+}diff --git a/mcp-server/package.json b/mcp-server/package.jsonnew file mode 100644index 00000000..362110f7--- /dev/null+++ b/mcp-server/package.json@@ -0,0 +1,32 @@+{+ "name": "llm-wiki-mcp-server",+ "version": "0.4.17",+ "description": "MCP server for LLM Wiki local API",+ "type": "module",+ "main": "dist/src/index.js",+ "bin": {+ "llm-wiki-mcp": "dist/src/index.js"+ },+ "scripts": {+ "build": "tsc -p tsconfig.json",+ "typecheck": "tsc -p tsconfig.json --noEmit",+ "start": "node dist/src/index.js",+ "test": "npm run build && node --test dist/test/*.test.js"+ },+ "engines": {+ "node": ">=20"+ },+ "keywords": [+ "mcp",+ "llm-wiki",+ "knowledge-base"+ ],+ "license": "MIT",+ "dependencies": {+ "@modelcontextprotocol/sdk": "^1.29.0"+ },+ "devDependencies": {+ "@types/node": "^20.0.0",+ "typescript": "^5.7.3"+ }+}diff --git a/mcp-server/src/api-client.ts b/mcp-server/src/api-client.tsnew file mode 100644index 00000000..6ad99f44--- /dev/null+++ b/mcp-server/src/api-client.ts@@ -0,0 +1,262 @@+export const DEFAULT_API_BASE_URL = "http://127.0.0.1:19828"++export interface LlmWikiApiClientOptions {+ baseUrl?: string+ token?: string+ fetchImpl?: typeof fetch+}++export interface ApiProject {+ id: string+ name: string+ path: string+ current: boolean+}++export interface ApiFileNode {+ name: string+ path: string+ isDir: boolean+ children?: ApiFileNode[]+}++export interface ApiSearchResult {+ path: string+ title: string+ snippet: string+ score: number+ titleMatch?: boolean+ images?: Array<{ url: string; alt: string }>+ vectorScore?: number | null+}++export interface ApiSearchResponse {+ results: ApiSearchResult[]+ mode?: string+ tokenHits?: number+ vectorHits?: number+}++export interface ApiGraphNode {+ id: string+ label: string+ type: string+ path?: string+ linkCount?: number+ weight?: number+}++export interface ApiGraphEdge {+ source: string+ target: string+ weight?: number+}++export interface ApiFilesResponse {+ files: ApiFileNode[]+ truncated?: boolean+}++export interface ApiHealth {+ ok?: boolean+ status?: string+ enabled?: boolean+ mcpEnabled?: boolean+ authRequired?: boolean+ authConfigured?: boolean+ allowUnauthenticated?: boolean+ tokenSource?: string+ [key: string]: unknown+}++export function normalizeBaseUrl(value?: string): string {+ const raw = (value ?? DEFAULT_API_BASE_URL).trim() || DEFAULT_API_BASE_URL+ return raw.replace(/\/+$/, "")+}++function apiPath(path: string): string {+ return path.startsWith("/api/v1") ? path : `/api/v1${path.startsWith("/") ? path : `/${path}`}`+}++function requireObject(value: unknown, context: string): Record<string, unknown> {+ if (!value || typeof value !== "object" || Array.isArray(value)) {+ throw new Error(`${context}: expected JSON object`)+ }+ return value as Record<string, unknown>+}++function numberOrUndefined(value: unknown): number | undefined {+ return typeof value === "number" && Number.isFinite(value) ? value : undefined+}++export class LlmWikiApiClient {+ private readonly baseUrl: string+ private readonly token?: string+ private readonly fetchImpl: typeof fetch++ constructor(options: LlmWikiApiClientOptions = {}) {+ this.baseUrl = normalizeBaseUrl(options.baseUrl ?? process.env.LLM_WIKI_API_BASE_URL)+ this.token = options.token ?? process.env.LLM_WIKI_API_TOKEN+ this.fetchImpl = options.fetchImpl ?? fetch+ }++ async health(): Promise<ApiHealth> {+ return this.request("/health", { auth: false }) as Promise<ApiHealth>+ }++ async projects(): Promise<{ projects: ApiProject[]; currentProject: ApiProject | null }> {+ const json = await this.request("/projects")+ const projects = Array.isArray(json.projects) ? json.projects.map(parseProject) : []+ const currentProject = json.currentProject ? parseProject(json.currentProject) : null+ return { projects, currentProject }+ }++ async files(projectId = "current", options: { root?: "wiki" | "sources" | "all"; recursive?: boolean; maxFiles?: number } = {}): Promise<ApiFilesResponse> {+ const params = new URLSearchParams()+ params.set("root", options.root ?? "wiki")+ if (options.recursive !== undefined) params.set("recursive", String(options.recursive))+ if (options.maxFiles !== undefined) params.set("maxFiles", String(options.maxFiles))+ const json = await this.request(`/projects/${encodeURIComponent(projectId)}/files?${params.toString()}`)+ return {+ files: Array.isArray(json.files) ? json.files.map(parseFileNode) : [],+ truncated: json.truncated === true,+ }+ }++ async fileContent(projectId = "current", path: string): Promise<{ path: string; content: string }> {+ const params = new URLSearchParams({ path })+ const json = await this.request(`/projects/${encodeURIComponent(projectId)}/files/content?${params.toString()}`)+ return {+ path: typeof json.path === "string" ? json.path : path,+ content: typeof json.content === "string" ? json.content : "",+ }+ }++ async search(projectId = "current", query: string, options: { topK?: number; includeContent?: boolean } = {}): Promise<ApiSearchResponse> {+ const json = await this.request(`/projects/${encodeURIComponent(projectId)}/search`, {+ method: "POST",+ body: {+ query,+ topK: options.topK,+ includeContent: options.includeContent,+ },+ })+ return {+ results: Array.isArray(json.results) ? json.results.map(parseSearchResult) : [],+ mode: typeof json.mode === "string" ? json.mode : undefined,+ tokenHits: numberOrUndefined(json.tokenHits),+ vectorHits: numberOrUndefined(json.vectorHits),+ }+ }++ async graph(projectId = "current", options: { q?: string; nodeType?: string; limit?: number } = {}): Promise<{ nodes: ApiGraphNode[]; edges: ApiGraphEdge[] }> {+ const params = new URLSearchParams()+ if (options.q) params.set("q", options.q)+ if (options.nodeType) params.set("nodeType", options.nodeType)+ if (options.limit !== undefined) params.set("limit", String(options.limit))+ const suffix = params.toString() ? `?${params.toString()}` : ""+ const json = await this.request(`/projects/${encodeURIComponent(projectId)}/graph${suffix}`)+ return {+ nodes: Array.isArray(json.nodes) ? json.nodes.map(parseGraphNode) : [],+ edges: Array.isArray(json.edges) ? json.edges.map(parseGraphEdge) : [],+ }+ }++ async rescan(projectId = "current"): Promise<Record<string, unknown>> {+ return this.request(`/projects/${encodeURIComponent(projectId)}/sources/rescan`, {+ method: "POST",+ })+ }++ private async request(path: string, options: { method?: "GET" | "POST"; body?: unknown; auth?: boolean } = {}): Promise<Record<string, unknown>> {+ const url = `${this.baseUrl}${apiPath(path)}`+ const headers: Record<string, string> = { Accept: "application/json" }+ if (options.auth !== false && this.token?.trim()) {+ headers.Authorization = `Bearer ${this.token.trim()}`+ }+ if (options.body !== undefined) headers["Content-Type"] = "application/json"++ let response: Response+ try {+ response = await this.fetchImpl(url, {+ method: options.method ?? (options.body === undefined ? "GET" : "POST"),+ headers,+ body: options.body === undefined ? undefined : JSON.stringify(options.body),+ })+ } catch (err) {+ throw new Error(`LLM Wiki API request failed. Is the desktop app running? ${err instanceof Error ? err.message : String(err)}`)+ }++ const text = await response.text()+ let json: Record<string, unknown>+ try {+ json = text ? requireObject(JSON.parse(text), "LLM Wiki API response") : {}+ } catch (err) {+ throw new Error(`LLM Wiki API returned non-JSON response (${response.status}): ${text.slice(0, 300)}${err instanceof Error ? ` (${err.message})` : ""}`)+ }++ if (!response.ok || json.ok === false) {+ const message = typeof json.error === "string" ? json.error : response.statusText+ throw new Error(`LLM Wiki API ${response.status}: ${message}`)+ }+ return json+ }+}++function parseProject(value: unknown): ApiProject {+ const obj = requireObject(value, "project")+ return {+ id: String(obj.id ?? ""),+ name: String(obj.name ?? ""),+ path: String(obj.path ?? ""),+ current: obj.current === true,+ }+}++function parseFileNode(value: unknown): ApiFileNode {+ const obj = requireObject(value, "file node")+ const children = Array.isArray(obj.children) ? obj.children.map(parseFileNode) : undefined+ return {+ name: String(obj.name ?? ""),+ path: String(obj.path ?? ""),+ isDir: obj.isDir === true || obj.is_dir === true,+ ...(children ? { children } : {}),+ }+}++function parseSearchResult(value: unknown): ApiSearchResult {+ const obj = requireObject(value, "search result")+ return {+ path: String(obj.path ?? ""),+ title: String(obj.title ?? ""),+ snippet: String(obj.snippet ?? ""),+ score: numberOrUndefined(obj.score) ?? 0,+ titleMatch: obj.titleMatch === true,+ images: Array.isArray(obj.images) ? obj.images.map((image) => {+ const item = requireObject(image, "image")+ return { url: String(item.url ?? ""), alt: String(item.alt ?? "") }+ }) : [],+ vectorScore: numberOrUndefined(obj.vectorScore) ?? null,+ }+}++function parseGraphNode(value: unknown): ApiGraphNode {+ const obj = requireObject(value, "graph node")+ return {+ id: String(obj.id ?? ""),+ label: String(obj.label ?? ""),+ type: String(obj.nodeType ?? obj.type ?? "other"),+ path: typeof obj.path === "string" ? obj.path : undefined,+ linkCount: numberOrUndefined(obj.linkCount),+ weight: numberOrUndefined(obj.weight),+ }+}++function parseGraphEdge(value: unknown): ApiGraphEdge {+ const obj = requireObject(value, "graph edge")+ return {+ source: String(obj.source ?? ""),+ target: String(obj.target ?? ""),+ weight: numberOrUndefined(obj.weight),+ }+}diff --git a/mcp-server/src/index.ts b/mcp-server/src/index.tsnew file mode 100644index 00000000..4b636f5d--- /dev/null+++ b/mcp-server/src/index.ts@@ -0,0 +1,310 @@+#!/usr/bin/env node+import { Server } from "@modelcontextprotocol/sdk/server/index.js"+import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"+import {+ CallToolRequestSchema,+ ErrorCode,+ ListToolsRequestSchema,+ McpError,+} from "@modelcontextprotocol/sdk/types.js"+import { LlmWikiApiClient, type ApiFileNode, type ApiGraphNode, type ApiSearchResult } from "./api-client.js"++const VERSION = "0.4.17"+const DEFAULT_PROJECT_ID = "current"+const MAX_TEXT_BYTES = 120_000++const client = new LlmWikiApiClient()++const server = new Server(+ { name: "llm-wiki", version: VERSION },+ { capabilities: { tools: {} } },+)++server.setRequestHandler(ListToolsRequestSchema, async () => ({+ tools: [+ {+ name: "llm_wiki_status",+ description: "Check whether the LLM Wiki desktop local API is reachable and list the current project.",+ inputSchema: {+ type: "object",+ properties: {},+ additionalProperties: false,+ },+ },+ {+ name: "llm_wiki_projects",+ description: "List known LLM Wiki projects. The response includes currentProject when the desktop app has an active project.",+ inputSchema: {+ type: "object",+ properties: {},+ additionalProperties: false,+ },+ },+ {+ name: "llm_wiki_files",+ description: "List files from a project using the desktop app's API permissions. project_id may be a UUID, filesystem path, or 'current'.",+ inputSchema: {+ type: "object",+ properties: {+ project_id: { type: "string", description: "Project UUID, project path, or 'current'. Defaults to current." },+ root: { type: "string", enum: ["wiki", "sources", "all"], description: "Tree root to list. Defaults to wiki." },+ recursive: { type: "boolean", description: "Whether to list recursively. Defaults to true." },+ max_files: { type: "number", description: "Maximum files returned by the local API. Max 10000." },+ },+ additionalProperties: false,+ },+ },+ {+ name: "llm_wiki_read_file",+ description: "Read a text file from a project through the desktop app API. Only public project paths such as wiki/ and raw/sources/ are allowed by the API.",+ inputSchema: {+ type: "object",+ properties: {+ project_id: { type: "string", description: "Project UUID, project path, or 'current'. Defaults to current." },+ path: { type: "string", description: "Project-relative file path, for example wiki/index.md." },+ },+ required: ["path"],+ additionalProperties: false,+ },+ },+ {+ name: "llm_wiki_search",+ description: "Search a project using the same backend keyword/vector retrieval used by the desktop API.",+ inputSchema: {+ type: "object",+ properties: {+ project_id: { type: "string", description: "Project UUID, project path, or 'current'. Defaults to current." },+ query: { type: "string", description: "Search query." },+ top_k: { type: "number", description: "Maximum results. The local API clamps to its configured maximum." },+ include_content: { type: "boolean", description: "Include full page content in results when supported by the API." },+ },+ required: ["query"],+ additionalProperties: false,+ },+ },+ {+ name: "llm_wiki_graph",+ description: "Query the project knowledge graph through the desktop app API.",+ inputSchema: {+ type: "object",+ properties: {+ project_id: { type: "string", description: "Project UUID, project path, or 'current'. Defaults to current." },+ q: { type: "string", description: "Optional text filter." },+ node_type: { type: "string", description: "Optional node type filter." },+ limit: { type: "number", description: "Maximum nodes. The local API clamps to its configured maximum." },+ },+ additionalProperties: false,+ },+ },+ {+ name: "llm_wiki_rescan_sources",+ description: "Trigger the desktop app's source folder rescan for a project, using the user's Source Watch rules.",+ inputSchema: {+ type: "object",+ properties: {+ project_id: { type: "string", description: "Project UUID, project path, or 'current'. Defaults to current." },+ },+ additionalProperties: false,+ },+ },+ ],+}))++server.setRequestHandler(CallToolRequestSchema, async (request) => {+ const args = asObject(request.params.arguments ?? {})+ try {+ switch (request.params.name) {+ case "llm_wiki_status": {+ const [health, projects] = await Promise.all([+ client.health(),+ client.projects().catch(() => ({ projects: [], currentProject: null })),+ ])+ return textResult(JSON.stringify({ ...health, ...projects }, null, 2))+ }+ case "llm_wiki_projects": {+ await assertMcpEnabled()+ return textResult(JSON.stringify(await client.projects(), null, 2))+ }+ case "llm_wiki_files": {+ await assertMcpEnabled()+ const response = await client.files(projectId(args), {+ root: enumArg(args.root, ["wiki", "sources", "all"] as const, "wiki"),+ recursive: boolArg(args.recursive, true),+ maxFiles: numberArg(args.max_files),+ })+ return textResult(formatFileTree(response.files, response.truncated))+ }+ case "llm_wiki_read_file": {+ await assertMcpEnabled()+ const relPath = stringArg(args.path, "path")+ const { path, content } = await client.fileContent(projectId(args), relPath)+ return textResult(`# ${path}\n\n${truncateText(content, MAX_TEXT_BYTES)}`)+ }+ case "llm_wiki_search": {+ await assertMcpEnabled()+ const query = stringArg(args.query, "query")+ const search = await client.search(projectId(args), query, {+ topK: numberArg(args.top_k),+ includeContent: boolArg(args.include_content, false),+ })+ return textResult(formatSearchResults(query, search))+ }+ case "llm_wiki_graph": {+ await assertMcpEnabled()+ const graph = await client.graph(projectId(args), {+ q: optionalStringArg(args.q),+ nodeType: optionalStringArg(args.node_type),+ limit: numberArg(args.limit),+ })+ return textResult(formatGraph(graph.nodes, graph.edges))+ }+ case "llm_wiki_rescan_sources": {+ await assertMcpEnabled()+ return textResult(JSON.stringify(await client.rescan(projectId(args)), null, 2))+ }+ default:+ throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`)+ }+ } catch (err) {+ if (err instanceof McpError) throw err+ throw new McpError(+ ErrorCode.InternalError,+ err instanceof Error ? err.message : String(err),+ )+ }+})++async function assertMcpEnabled(): Promise<void> {+ const health = await client.health()+ if (health.mcpEnabled === false) {+ throw new McpError(+ ErrorCode.InvalidRequest,+ "LLM Wiki MCP access is disabled. Enable Settings -> API + MCP -> Enable MCP access in the desktop app.",+ )+ }+}++function textResult(text: string) {+ return {+ content: [{ type: "text" as const, text }],+ }+}++function asObject(value: unknown): Record<string, unknown> {+ if (!value || typeof value !== "object" || Array.isArray(value)) return {}+ return value as Record<string, unknown>+}++function projectId(args: Record<string, unknown>): string {+ return optionalStringArg(args.project_id) ?? DEFAULT_PROJECT_ID+}++function stringArg(value: unknown, name: string): string {+ if (typeof value !== "string" || value.trim() === "") {+ throw new McpError(ErrorCode.InvalidParams, `${name} is required`)+ }+ return value+}++function optionalStringArg(value: unknown): string | undefined {+ return typeof value === "string" && value.trim() !== "" ? value : undefined+}++function boolArg(value: unknown, fallback: boolean): boolean {+ return typeof value === "boolean" ? value : fallback+}++function numberArg(value: unknown): number | undefined {+ return typeof value === "number" && Number.isFinite(value) ? value : undefined+}++function enumArg<T extends string>(value: unknown, allowed: readonly T[], fallback: T): T {+ return typeof value === "string" && allowed.includes(value as T) ? value as T : fallback+}++function truncateText(value: string, maxBytes: number): string {+ const bytes = Buffer.byteLength(value, "utf8")+ if (bytes <= maxBytes) return value+ let out = ""+ let used = 0+ for (const ch of value) {+ const size = Buffer.byteLength(ch, "utf8")+ if (used + size > maxBytes) break+ out += ch+ used += size+ }+ return `${out}\n\n[truncated: ${bytes - used} bytes omitted]`+}++function formatFileTree(files: ApiFileNode[], truncated = false): string {+ if (files.length === 0) return "No files found."+ const lines: string[] = truncated+ ? ["[warning] File tree was truncated by the LLM Wiki API maxFiles limit.", ""]+ : []+ const walk = (nodes: ApiFileNode[], depth: number) => {+ for (const node of nodes) {+ const prefix = " ".repeat(depth)+ lines.push(`${prefix}${node.isDir ? "📁" : "📄"} ${node.path}`)+ if (node.children) walk(node.children, depth + 1)+ }+ }+ walk(files, 0)+ return lines.join("\n")+}++function formatSearchResults(query: string, search: { results: ApiSearchResult[]; mode?: string; tokenHits?: number; vectorHits?: number }): string {+ const { results } = search+ if (results.length === 0) return `No results for "${query}".`+ const meta = [+ search.mode ? `Mode: ${search.mode}` : null,+ typeof search.tokenHits === "number" ? `Token hits: ${search.tokenHits}` : null,+ typeof search.vectorHits === "number" ? `Vector hits: ${search.vectorHits}` : null,+ ].filter(Boolean)+ const lines = [`# Search results for "${query}"`, ...(meta.length > 0 ? [meta.join(" | ")] : []), ""]+ results.forEach((result, index) => {+ lines.push(`## ${index + 1}. ${result.title}`)+ lines.push(`Path: ${result.path}`)+ lines.push(`Score: ${result.score.toFixed(6)}${typeof result.vectorScore === "number" ? ` | Vector score: ${result.vectorScore.toFixed(6)}` : ""}`)+ if (result.snippet) lines.push(`Snippet: ${result.snippet}`)+ if (result.images && result.images.length > 0) {+ lines.push(`Images: ${result.images.map((image) => image.url).join(", ")}`)+ }+ lines.push("")+ })+ return lines.join("\n")+}++function formatGraph(nodes: ApiGraphNode[], edges: Array<{ source: string; target: string; weight?: number }>): string {+ const typeCounts = new Map<string, number>()+ for (const node of nodes) typeCounts.set(node.type, (typeCounts.get(node.type) ?? 0) + 1)+ const lines = [+ "# Knowledge graph",+ "",+ `Nodes: ${nodes.length}`,+ `Edges: ${edges.length}`,+ "",+ "## Node types",+ ...[...typeCounts.entries()]+ .sort((a, b) => b[1] - a[1])+ .map(([type, count]) => `- ${type}: ${count}`),+ "",+ "## Top nodes",+ ...nodes+ .slice()+ .sort((a, b) => (b.linkCount ?? 0) - (a.linkCount ?? 0))+ .slice(0, 30)+ .map((node) => `- ${node.label} (${node.type}, ${node.linkCount ?? 0} links)${node.path ? ` — ${node.path}` : ""}`),+ ]+ return lines.join("\n")+}++async function main(): Promise<void> {+ const transport = new StdioServerTransport()+ await server.connect(transport)+ console.error(`LLM Wiki MCP server v${VERSION} connected to ${process.env.LLM_WIKI_API_BASE_URL ?? "http://127.0.0.1:19828"}`)+}++main().catch((err) => {+ console.error("Failed to start LLM Wiki MCP server:", err)+ process.exit(1)+})diff --git a/mcp-server/test/api-client.test.ts b/mcp-server/test/api-client.test.tsnew file mode 100644index 00000000..259753ce--- /dev/null+++ b/mcp-server/test/api-client.test.ts@@ -0,0 +1,128 @@+import assert from "node:assert/strict"+import { test } from "node:test"+import { LlmWikiApiClient, normalizeBaseUrl } from "../src/api-client.js"++test("normalizeBaseUrl trims trailing slashes and falls back to localhost", () => {+ assert.equal(normalizeBaseUrl("http://127.0.0.1:19828///"), "http://127.0.0.1:19828")+ assert.equal(normalizeBaseUrl(""), "http://127.0.0.1:19828")+})++test("projects sends bearer token and parses current project", async () => {+ const calls: Array<{ url: string; init?: RequestInit }> = []+ const fetchImpl = async (url: string | URL | Request, init?: RequestInit): Promise<Response> => {+ calls.push({ url: String(url), init })+ return new Response(JSON.stringify({+ ok: true,+ projects: [{ id: "p1", name: "Demo", path: "/tmp/demo", current: true }],+ currentProject: { id: "p1", name: "Demo", path: "/tmp/demo", current: true },+ }), { status: 200 })+ }++ const client = new LlmWikiApiClient({+ baseUrl: "http://localhost:19828/",+ token: "secret",+ fetchImpl,+ })+ const result = await client.projects()++ assert.equal(calls[0]?.url, "http://localhost:19828/api/v1/projects")+ assert.equal((calls[0]?.init?.headers as Record<string, string>).Authorization, "Bearer secret")+ assert.equal(result.currentProject?.id, "p1")+ assert.equal(result.projects[0]?.current, true)+})++test("health does not send authorization", async () => {+ const calls: Array<RequestInit | undefined> = []+ const fetchImpl = async (_url: string | URL | Request, init?: RequestInit): Promise<Response> => {+ calls.push(init)+ return new Response(JSON.stringify({ ok: true, status: "running" }), { status: 200 })+ }++ const client = new LlmWikiApiClient({ token: "secret", fetchImpl })+ await client.health()++ assert.equal((calls[0]?.headers as Record<string, string> | undefined)?.Authorization, undefined)+})++test("search posts JSON body to current project", async () => {+ let body = ""+ const fetchImpl = async (_url: string | URL | Request, init?: RequestInit): Promise<Response> => {+ body = String(init?.body ?? "")+ return new Response(JSON.stringify({+ ok: true,+ mode: "hybrid",+ tokenHits: 2,+ vectorHits: 1,+ results: [{ path: "wiki/a.md", title: "A", snippet: "hit", score: 0.5, vectorScore: 0.9 }],+ }), { status: 200 })+ }++ const client = new LlmWikiApiClient({ fetchImpl })+ const results = await client.search("current", "query", { topK: 3, includeContent: true })++ assert.deepEqual(JSON.parse(body), { query: "query", topK: 3, includeContent: true })+ assert.equal(results.mode, "hybrid")+ assert.equal(results.tokenHits, 2)+ assert.equal(results.vectorHits, 1)+ assert.equal(results.results[0]?.vectorScore, 0.9)+})++test("graph parses nodeType from API graph nodes", async () => {+ const fetchImpl = async (): Promise<Response> => (+ new Response(JSON.stringify({+ ok: true,+ nodes: [{ id: "n1", label: "Node", nodeType: "concept", path: "wiki/concepts/n1.md", linkCount: 4 }],+ edges: [{ source: "n1", target: "n2", weight: 0.75 }],+ }), { status: 200 })+ )++ const client = new LlmWikiApiClient({ fetchImpl })+ const graph = await client.graph("current")++ assert.equal(graph.nodes[0]?.type, "concept")+ assert.equal(graph.nodes[0]?.linkCount, 4)+ assert.equal(graph.edges[0]?.weight, 0.75)+})++test("files exposes truncated flag", async () => {+ const fetchImpl = async (): Promise<Response> => (+ new Response(JSON.stringify({+ ok: true,+ files: [{ name: "index.md", path: "wiki/index.md", isDir: false }],+ truncated: true,+ }), { status: 200 })+ )++ const client = new LlmWikiApiClient({ fetchImpl })+ const files = await client.files("current")++ assert.equal(files.truncated, true)+ assert.equal(files.files[0]?.path, "wiki/index.md")+})++test("network failures include desktop app hint", async () => {+ const fetchImpl = async (): Promise<Response> => {+ throw new Error("ECONNREFUSED")+ }++ const client = new LlmWikiApiClient({ fetchImpl })+ await assert.rejects(() => client.projects(), /Is the desktop app running\? ECONNREFUSED/)+})++test("non-JSON responses include status and body preview", async () => {+ const fetchImpl = async (): Promise<Response> => (+ new Response("not json", { status: 502, statusText: "Bad Gateway" })+ )++ const client = new LlmWikiApiClient({ fetchImpl })+ await assert.rejects(() => client.projects(), /non-JSON response \(502\): not json/)+})++test("API errors include status and server message", async () => {+ const fetchImpl = async (): Promise<Response> => (+ new Response(JSON.stringify({ ok: false, error: "Unauthorized" }), { status: 401 })+ )++ const client = new LlmWikiApiClient({ fetchImpl })+ await assert.rejects(() => client.projects(), /LLM Wiki API 401: Unauthorized/)+})diff --git a/mcp-server/tsconfig.json b/mcp-server/tsconfig.jsonnew file mode 100644index 00000000..dadbbf40--- /dev/null+++ b/mcp-server/tsconfig.json@@ -0,0 +1,18 @@+{+ "compilerOptions": {+ "target": "ES2022",+ "module": "NodeNext",+ "moduleResolution": "NodeNext",+ "lib": ["ES2022"],+ "types": ["node"],+ "strict": true,+ "noUnusedLocals": true,+ "noUnusedParameters": true,+ "esModuleInterop": true,+ "skipLibCheck": true,+ "forceConsistentCasingInFileNames": true,+ "outDir": "dist",+ "rootDir": "."+ },+ "include": ["src/**/*.ts", "test/**/*.ts"]+}diff --git a/package-lock.json b/package-lock.jsonindex 6da1e1bd..96bbe131 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "llm-wiki",- "version": "0.4.16",+ "version": "0.4.17","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "llm-wiki",- "version": "0.4.16",+ "version": "0.4.17","dependencies": {"@base-ui/react": "^1.3.0","@fontsource-variable/geist": "^5.2.8",diff --git a/package.json b/package.jsonindex ff12cc51..b1a0a4f2 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "llm-wiki","private": true,- "version": "0.4.16",+ "version": "0.4.17","type": "module","scripts": {"dev": "vite",@@ -11,6 +11,8 @@"test": "npm run test:mocks && npm run test:llm","test:mocks": "vitest run --exclude='**/*.real-llm.test.ts'","test:llm": "vitest run real-llm --no-file-parallelism --reporter=verbose",+ "mcp:build": "npm --prefix mcp-server run build",+ "mcp:test": "npm --prefix mcp-server test","tauri": "tauri"},"dependencies": {diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex b46964a2..6261edec 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -4461,7 +4461,7 @@ checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"[[package]]name = "llm-wiki"-version = "0.4.16"+version = "0.4.17"dependencies = ["arrow-array","arrow-schema",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex f3f590db..523f9941 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "llm-wiki"-version = "0.4.16"+version = "0.4.17"description = "LLM Wiki - A personal knowledge base for LLM concepts"authors = []edition = "2021"diff --git a/src-tauri/src/api_server.rs b/src-tauri/src/api_server.rsindex cd06302d..8fd4d924 100644--- a/src-tauri/src/api_server.rs+++ b/src-tauri/src/api_server.rs@@ -220,6 +220,7 @@ fn handle_request("authConfigured": api_token(app).is_some(),"tokenSource": api_token_source(app),"enabled": api_enabled(app),+ "mcpEnabled": api_mcp_enabled(app),"allowUnauthenticated": api_allow_unauthenticated(app),}));}@@ -472,6 +473,17 @@ fn api_enabled(app: &AppHandle) -> bool {.unwrap_or(true)}+fn api_mcp_enabled(app: &AppHandle) -> bool {+ let Some(parsed) = load_app_state(app) else {+ return false;+ };+ parsed+ .get("apiConfig")+ .and_then(|v| v.get("mcpEnabled"))+ .and_then(Value::as_bool)+ .unwrap_or(false)+}+fn constant_time_eq(left: &[u8], right: &[u8]) -> bool {let max_len = left.len().max(right.len());let mut diff = left.len() ^ right.len();@@ -1322,6 +1334,7 @@ mod tests {"apiConfig": {"enabled": false,"allowUnauthenticated": true,+ "mcpEnabled": true,"token": "abc"}});@@ -1337,6 +1350,12 @@ mod tests {.and_then(Value::as_bool).unwrap_or(false);assert!(allow_unauthenticated);+ let mcp_enabled = payload+ .get("apiConfig")+ .and_then(|v| v.get("mcpEnabled"))+ .and_then(Value::as_bool)+ .unwrap_or(false);+ assert!(mcp_enabled);let token_source = payload.get("apiConfig").and_then(|v| v.get("token"))@@ -1354,5 +1373,11 @@ mod tests {.unwrap_or(true);// Fail-open by design — see `api_enabled` doc comment.assert!(enabled_missing);+ let mcp_enabled_missing = missing+ .get("apiConfig")+ .and_then(|v| v.get("mcpEnabled"))+ .and_then(Value::as_bool)+ .unwrap_or(false);+ assert!(!mcp_enabled_missing);}}diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex b5edf95e..5a829ce7 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -37,6 +37,49 @@ fn api_server_reload_config() -> String {.unwrap_or_else(|e| format!("error: {e}"))}+#[tauri::command]+fn mcp_server_entry_path(app: tauri::AppHandle) -> Result<String, String> {+ run_guarded("mcp_server_entry_path", || {+ let relative = std::path::Path::new("mcp-server")+ .join("dist")+ .join("src")+ .join("index.js");+ let mut candidates = Vec::new();++ let mut push_repo_candidates = |base: std::path::PathBuf| {+ candidates.push(base.join(&relative));+ candidates.push(base.join("..").join(&relative));+ candidates.push(base.join("..").join("..").join(&relative));+ };++ push_repo_candidates(std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")));+ if let Ok(cwd) = std::env::current_dir() {+ push_repo_candidates(cwd);+ }+ if let Ok(resource_dir) = app.path().resource_dir() {+ candidates.push(resource_dir.join(&relative));+ }+ if let Ok(exe) = std::env::current_exe() {+ if let Some(exe_dir) = exe.parent() {+ candidates.push(exe_dir.join(&relative));+ candidates.push(exe_dir.join("..").join("Resources").join(&relative));+ }+ }++ for candidate in &candidates {+ if candidate.is_file() {+ return Ok(candidate+ .canonicalize()+ .unwrap_or_else(|_| candidate.clone())+ .to_string_lossy()+ .into_owned());+ }+ }++ Err("MCP server entry was not found. Run `npm run mcp:build` from the LLM Wiki repository, then reopen Settings.".to_string())+ })+}+/// Apply a proxy configuration to the process env immediately, so the/// next outbound HTTP request picks it up without needing the user to/// restart the app. tauri-plugin-http builds a fresh@@ -157,6 +200,7 @@ pub fn run() {clip_server_status,api_server_status,api_server_reload_config,+ mcp_server_entry_path,commands::vectorstore::vector_upsert,commands::vectorstore::vector_search,commands::vectorstore::vector_delete,diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex c2d0e942..749efe4f 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -1,7 +1,7 @@{"$schema": "https://schema.tauri.app/config/2","productName": "LLM Wiki",- "version": "0.4.16",+ "version": "0.4.17","identifier": "com.llmwiki.app","build": {"beforeDevCommand": "npm run dev",diff --git a/src/App.tsx b/src/App.tsxindex d4c29daf..911e00d4 100644--- a/src/App.tsx+++ b/src/App.tsx@@ -227,7 +227,7 @@ function App() {}// Local HTTP API server config — global (single token + enable// flag for the whole install, not per-project). The Rust side- // reads `apiConfig.{enabled,token}` from `app-state.json`+ // reads `apiConfig.{enabled,token,mcpEnabled}` from `app-state.json`// directly; this only hydrates the Zustand store so the// Settings UI reflects the persisted values.const savedApi = await loadApiConfig()@@ -238,6 +238,10 @@ function App() {typeof savedApi.allowUnauthenticated === "boolean"? savedApi.allowUnauthenticated: false,+ mcpEnabled:+ typeof savedApi.mcpEnabled === "boolean"+ ? savedApi.mcpEnabled+ : false,token: typeof savedApi.token === "string" ? savedApi.token : "",})}diff --git a/src/commands/fs.ts b/src/commands/fs.tsindex 91170f91..93ca9b47 100644--- a/src/commands/fs.ts+++ b/src/commands/fs.ts@@ -127,3 +127,7 @@ export async function apiServerStatus(): Promise<string> {export async function apiServerReloadConfig(): Promise<string> {return invoke<string>("api_server_reload_config")}++export async function mcpServerEntryPath(): Promise<string> {+ return invoke<string>("mcp_server_entry_path")+}diff --git a/src/components/settings/sections/api-server-section.tsx b/src/components/settings/sections/api-server-section.tsxindex 840928c8..c762fc49 100644--- a/src/components/settings/sections/api-server-section.tsx+++ b/src/components/settings/sections/api-server-section.tsx@@ -10,7 +10,7 @@ import {} from "lucide-react"import { useTranslation } from "react-i18next"import { openUrl } from "@tauri-apps/plugin-opener"-import { apiServerStatus } from "@/commands/fs"+import { apiServerStatus, mcpServerEntryPath } from "@/commands/fs"import { Button } from "@/components/ui/button"import { Input } from "@/components/ui/input"import { Label } from "@/components/ui/label"@@ -28,6 +28,7 @@ interface ApiHealth {ok?: booleanstatus?: stringenabled?: boolean+ mcpEnabled?: booleanauthRequired?: booleanauthConfigured?: booleanallowUnauthenticated?: boolean@@ -54,9 +55,11 @@ const ENDPOINTS: Array<{ method: "GET" | "POST"; path: string; noteKey: string }export function ApiServerSection({ draft, setDraft }: Props) {const { t } = useTranslation()const [showToken, setShowToken] = useState(false)- const [copiedField, setCopiedField] = useState<"token" | "curl" | null>(null)+ const [copiedField, setCopiedField] = useState<"token" | "curl" | "mcp" | null>(null)const [serverStatus, setServerStatus] = useState<string>("...")const [health, setHealth] = useState<ApiHealth | null>(null)+ const [mcpEntryPath, setMcpEntryPath] = useState<string | null>(null)+ const [mcpPathError, setMcpPathError] = useState<string | null>(null)const persistedApiConfig = useWikiStore((s) => s.apiConfig)useEffect(() => {@@ -76,6 +79,17 @@ export function ApiServerSection({ draft, setDraft }: Props) {.catch(() => {if (alive) setHealth(null)})+ mcpServerEntryPath()+ .then((path) => {+ if (!alive) return+ setMcpEntryPath(path)+ setMcpPathError(null)+ })+ .catch((err) => {+ if (!alive) return+ setMcpEntryPath(null)+ setMcpPathError(err instanceof Error ? err.message : String(err))+ })return () => {alive = false}@@ -108,9 +122,30 @@ export function ApiServerSection({ draft, setDraft }: Props) {return `curl -H 'Authorization: Bearer ${tokenForExample}' ${API_SERVER_BASE_URL}/api/v1/projects`}, [draft.apiAllowUnauthenticated, draft.apiToken])+ const sampleMcpConfig = useMemo(() => {+ if (!mcpEntryPath) return ""+ const env = draft.apiAllowUnauthenticated+ ? {}+ : { LLM_WIKI_API_TOKEN: draft.apiToken || "<your-token>" }+ return JSON.stringify(+ {+ mcpServers: {+ "llm-wiki": {+ command: "node",+ args: [mcpEntryPath],+ ...(Object.keys(env).length > 0 ? { env } : {}),+ },+ },+ },+ null,+ 2,+ )+ }, [draft.apiAllowUnauthenticated, draft.apiToken, mcpEntryPath])+const hasUnsavedApiConfig =persistedApiConfig.enabled !== draft.apiEnabled ||persistedApiConfig.allowUnauthenticated !== draft.apiAllowUnauthenticated ||+ persistedApiConfig.mcpEnabled !== draft.apiMcpEnabled ||persistedApiConfig.token !== draft.apiToken.trim()const handleCopyCurl = useCallback(async () => {@@ -123,6 +158,17 @@ export function ApiServerSection({ draft, setDraft }: Props) {}}, [sampleCurl])+ const handleCopyMcpConfig = useCallback(async () => {+ if (!mcpEntryPath) return+ try {+ await navigator.clipboard.writeText(sampleMcpConfig)+ setCopiedField("mcp")+ setTimeout(() => setCopiedField(null), 1500)+ } catch (err) {+ console.error("[api-settings] copy MCP config failed:", err)+ }+ }, [mcpEntryPath, sampleMcpConfig])+const handleOpenHealth = useCallback(() => {void openUrl(API_SERVER_HEALTH_URL).catch((err) => {console.error("[api-settings] open health failed:", err)@@ -182,12 +228,12 @@ export function ApiServerSection({ draft, setDraft }: Props) {<div className="space-y-6"><div><h2 className="text-xl font-semibold">- {t("settings.sections.apiServer.title", { defaultValue: "API Server" })}+ {t("settings.sections.apiServer.title", { defaultValue: "API + MCP" })}</h2><p className="mt-1 text-sm text-muted-foreground">{t("settings.sections.apiServer.description", {defaultValue:- "A local HTTP API at 127.0.0.1:19828 exposes project files, search, graph, and rescan to your own scripts and tools. Bind your favorite editor or shell to read the wiki without going through the UI.",+ "Expose LLM Wiki to your own tools through the local HTTP API, and optionally through the bundled MCP server for agent clients.",})}</p></div>@@ -459,6 +505,75 @@ export function ApiServerSection({ draft, setDraft }: Props) {})}</div></div>++ {/* ── MCP ──────────────────────────────────────────────────── */}+ <div className="space-y-3 rounded-lg border border-border/60 bg-muted/20 p-4">+ <label className="flex items-start gap-3">+ <input+ type="checkbox"+ checked={draft.apiMcpEnabled}+ onChange={(event) => setDraft("apiMcpEnabled", event.target.checked)}+ className="mt-1 h-4 w-4"+ />+ <div className="space-y-1">+ <div className="text-sm font-semibold">+ {t("settings.sections.apiServer.mcpEnable", {+ defaultValue: "Enable MCP access",+ })}+ </div>+ <p className="text-xs leading-relaxed text-muted-foreground">+ {t("settings.sections.apiServer.mcpEnableHint", {+ defaultValue:+ "MCP uses the local API and the same token rules. Keep the HTTP API enabled, then connect an MCP client to the bundled Node server.",+ })}+ </p>+ </div>+ </label>++ <div className="rounded-md border border-border/50 bg-background/50 p-3">+ <div className="flex items-center justify-between gap-2">+ <h3 className="text-sm font-semibold">+ {t("settings.sections.apiServer.mcpUsage", { defaultValue: "MCP usage" })}+ </h3>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={handleCopyMcpConfig}+ disabled={hasUnsavedApiConfig || !draft.apiMcpEnabled || !mcpEntryPath}+ className="gap-1.5"+ >+ <Copy className="h-3.5 w-3.5" />+ {copiedField === "mcp"+ ? t("settings.sections.apiServer.copied", { defaultValue: "Copied" })+ : t("settings.sections.apiServer.copy", { defaultValue: "Copy" })}+ </Button>+ </div>+ <p className="mt-2 text-xs leading-relaxed text-muted-foreground">+ {t("settings.sections.apiServer.mcpUsageHint", {+ defaultValue:+ "Build once with `npm run mcp:build`, then configure your MCP client to run the server below. Use LLM_WIKI_API_TOKEN unless unauthenticated access is enabled.",+ })}+ </p>+ {mcpPathError && (+ <p className="mt-2 text-xs leading-relaxed text-amber-700 dark:text-amber-400">+ {mcpPathError}+ </p>+ )}+ <pre className="mt-3 overflow-x-auto whitespace-pre-wrap break-all rounded-md bg-background/60 px-3 py-2 text-[11px] font-mono leading-relaxed">+ {hasUnsavedApiConfig+ ? t("settings.sections.apiServer.saveFirstExample", {+ defaultValue: "Save settings first, then copy an example request.",+ })+ : !mcpEntryPath+ ? t("settings.sections.apiServer.mcpPathUnavailable", {+ defaultValue:+ "MCP server entry was not found. Run `npm run mcp:build` from the LLM Wiki repository, then reopen Settings.",+ })+ : sampleMcpConfig}+ </pre>+ </div>+ </div></div>)}diff --git a/src/components/settings/settings-types.ts b/src/components/settings/settings-types.tsindex 8fa34d6c..968fba2a 100644--- a/src/components/settings/settings-types.ts+++ b/src/components/settings/settings-types.ts@@ -77,6 +77,7 @@ export interface SettingsDraft {// Local HTTP API serverapiEnabled: booleanapiAllowUnauthenticated: boolean+ apiMcpEnabled: booleanapiToken: string}diff --git a/src/components/settings/settings-view.tsx b/src/components/settings/settings-view.tsxindex c3e63aec..a397f3d8 100644--- a/src/components/settings/settings-view.tsx+++ b/src/components/settings/settings-view.tsx@@ -151,6 +151,7 @@ function initialDraft(sourceWatchConfig: normalizeSourceWatchConfig(sourceWatch),apiEnabled: apiConfig.enabled,apiAllowUnauthenticated: apiConfig.allowUnauthenticated,+ apiMcpEnabled: apiConfig.mcpEnabled,apiToken: apiConfig.token,autostart: generalConfig.autostart,closeBehavior: generalConfig.closeBehavior,@@ -402,12 +403,13 @@ export function SettingsView() {setMaxHistoryMessages(draft.maxHistoryMessages)// ── API server: persist + push to store. The Rust side reads- // `apiConfig.{enabled,token}` from this same `app-state.json` on+ // `apiConfig.{enabled,token,mcpEnabled}` from this same `app-state.json` on// every request via a 5s cache, so saved changes propagate// within that window without any IPC round-trip.const newApiConfig = {enabled: draft.apiEnabled,allowUnauthenticated: draft.apiAllowUnauthenticated,+ mcpEnabled: draft.apiMcpEnabled,token: draft.apiToken.trim(),}setApiConfig(newApiConfig)diff --git a/src/i18n/en.json b/src/i18n/en.jsonindex d60a5fbc..35e0a55e 100644--- a/src/i18n/en.json+++ b/src/i18n/en.json@@ -213,7 +213,7 @@"network": "Network","sourceWatch": "Source Watch","scheduledImport": "Scheduled Import",- "apiServer": "API Server",+ "apiServer": "API + MCP","output": "Output","interface": "Interface","maintenance": "Maintenance",@@ -448,8 +448,8 @@"never": "Never"},"apiServer": {- "title": "API Server",- "description": "A local HTTP API at 127.0.0.1:19828 exposes project files, search, graph, and rescan to your own scripts and tools. Bind your favorite editor or shell to read the wiki without going through the UI.",+ "title": "API + MCP",+ "description": "Expose LLM Wiki to your own tools through the local HTTP API, and optionally through the bundled MCP server for agent clients.","enable": "Enable local HTTP API","enableHint": "Disable to make every non-/health endpoint return 503 even if a token is configured. Useful as a kill-switch without unsetting the token.","status": "Status",@@ -466,6 +466,11 @@"openHealthHint": "Opens in your system browser. /health is the only unauthenticated endpoint.","allowUnauthenticated": "Allow access without a token","allowUnauthenticatedHint": "Use only for trusted local agents. Any process or browser page on this machine can call the API while this is enabled.",+ "mcpEnable": "Enable MCP access",+ "mcpEnableHint": "MCP uses the local API and the same token rules. Keep the HTTP API enabled, then connect an MCP client to the bundled Node server.",+ "mcpUsage": "MCP usage",+ "mcpUsageHint": "Build once with `npm run mcp:build`, then configure your MCP client to run the server below. Use LLM_WIKI_API_TOKEN unless unauthenticated access is enabled.",+ "mcpPathUnavailable": "MCP server entry was not found. Run `npm run mcp:build` from the LLM Wiki repository, then reopen Settings.","token": "Access token","tokenHint": "Required unless unauthenticated access is enabled. Send as `Authorization: Bearer <token>` or `X-LLM-Wiki-Token: <token>`. The environment variable LLM_WIKI_API_TOKEN overrides this field if set.","tokenPlaceholder": "Paste an existing token or click Generate",@@ -478,7 +483,7 @@"tokenUnused": "Token is not used while unauthenticated access is enabled","envTokenActive": "LLM_WIKI_API_TOKEN is active and overrides this field","tokenWeak": "Token is short — consider Generate for 256-bit entropy",- "saveFirst": "Save settings to apply API changes",+ "saveFirst": "Save settings to apply API/MCP changes","saveFirstExample": "Save settings first, then copy an example request.","tokenWarning": "Keep this token secret. Anyone with the token on this machine can read your project files via localhost.","tokenQueryWarning": "Prefer the Authorization header — passing ?token=… via URL leaks the value into shell history, logs, and Referer headers.",diff --git a/src/i18n/zh.json b/src/i18n/zh.jsonindex 2db59037..c07b1d30 100644--- a/src/i18n/zh.json+++ b/src/i18n/zh.json@@ -213,7 +213,7 @@"network": "网络","sourceWatch": "资料文件夹监控","scheduledImport": "定时导入",- "apiServer": "API 服务",+ "apiServer": "API + MCP","output": "输出偏好","interface": "界面","maintenance": "维护",@@ -448,8 +448,8 @@"never": "从未"},"apiServer": {- "title": "API 服务",- "description": "本地在 127.0.0.1:19828 暴露一个 HTTP API,把项目文件、搜索、知识图谱、重新扫描接口开放给你自己的脚本和工具。无需通过 UI 即可读取 wiki。",+ "title": "API + MCP",+ "description": "通过本地 HTTP API 将 LLM Wiki 开放给你的脚本和工具,也可以额外启用内置 MCP 服务供智能体客户端访问。","enable": "启用本地 HTTP API","enableHint": "关闭后,即使已配置 token,除 /health 外的所有接口都会返回 503。可作为不清空 token 的临时关闭开关。","status": "状态",@@ -466,6 +466,11 @@"openHealthHint": "在系统浏览器中打开。/health 是唯一不需要 token 的接口。","allowUnauthenticated": "允许无 token 访问","allowUnauthenticatedHint": "仅用于可信的本地智能体。启用后,这台机器上的任何进程或浏览器页面都可以调用 API。",+ "mcpEnable": "启用 MCP 访问",+ "mcpEnableHint": "MCP 复用本地 API 和同一套 token 规则。保持 HTTP API 启用后,将 MCP 客户端连接到内置 Node 服务即可。",+ "mcpUsage": "MCP 使用说明",+ "mcpUsageHint": "先执行一次 `npm run mcp:build`,然后让 MCP 客户端运行下面的服务配置。除非启用了无认证访问,否则需要设置 LLM_WIKI_API_TOKEN。",+ "mcpPathUnavailable": "没有找到 MCP 服务入口。请在 LLM Wiki 仓库中先执行 `npm run mcp:build`,然后重新打开设置。","token": "访问令牌","tokenHint": "除非启用了无认证访问,否则必须配置。通过 `Authorization: Bearer <token>` 或 `X-LLM-Wiki-Token: <token>` 发送。设置了环境变量 LLM_WIKI_API_TOKEN 时优先生效。","tokenPlaceholder": "粘贴已有 token,或点击生成",@@ -478,7 +483,7 @@"tokenUnused": "启用无认证访问时,token 不会参与鉴权","envTokenActive": "LLM_WIKI_API_TOKEN 正在生效,并会覆盖此处填写的 token","tokenWeak": "token 长度偏短 —— 建议使用「生成新 token」获得 256 位熵",- "saveFirst": "保存设置后 API 改动才会生效",+ "saveFirst": "保存设置后 API/MCP 改动才会生效","saveFirstExample": "请先保存设置,然后再复制示例请求。","tokenWarning": "请妥善保管。任何能访问这台机器 localhost 的进程拿到 token 后,都能通过 API 读取你的项目内容。","tokenQueryWarning": "推荐使用 Authorization header —— 将 token 放在 ?token=… 查询参数里会泄露到 shell 历史、日志和 Referer。",diff --git a/src/lib/api-server.real-llm.test.ts b/src/lib/api-server.real-llm.test.tsindex b4ad2bb4..7759a231 100644--- a/src/lib/api-server.real-llm.test.ts+++ b/src/lib/api-server.real-llm.test.ts@@ -5,7 +5,7 @@* http://127.0.0.1:19828/api/v1 and use a real project id. They are gated* behind RUN_API_TESTS=1 (or RUN_LLM_TESTS=1 for the repo's shared real-test* script) because they require the app to be running and the API server to be- * enabled in Settings -> API Server.+ * enabled in Settings -> API + MCP.** WARNING: the auth/config tests mutate the live app-state.json to verify* enabled=false and unauthenticated mode. They restore the original file in@@ -207,7 +207,7 @@ async function requireUsableApi(): Promise<ApiHealth> {expect(h.enabled).toBe(true)if (h.authRequired && !h.allowUnauthenticated && !API_TOKEN) {throw new Error(- "API requires auth. Re-run with API_TOKEN=<token> or enable Settings -> API Server -> Allow access without a token.",+ "API requires auth. Re-run with API_TOKEN=<token> or enable Settings -> API + MCP -> Allow access without a token.",)}return hdiff --git a/src/lib/changelog.ts b/src/lib/changelog.tsindex dcdfd526..a82eb88f 100644--- a/src/lib/changelog.ts+++ b/src/lib/changelog.ts@@ -25,6 +25,20 @@ export interface ChangelogEntry {}export const CHANGELOG: ChangelogEntry[] = [+ {+ version: "0.4.17",+ date: "2026-06-03",+ highlights: {+ en: [+ "Added a local MCP server for agent clients, using the same project, search, graph, and file APIs as the desktop app.",+ "Updated Settings to manage API + MCP access together, including token guidance and a copyable MCP client configuration.",+ ],+ zh: [+ "新增本地 MCP 服务,方便智能体客户端通过与桌面端一致的项目、搜索、图谱和文件接口访问 LLM Wiki。",+ "设置中新增 API + MCP 管理入口,包含访问开关、token 提示和可复制的 MCP 客户端配置。",+ ],+ },+ },{version: "0.4.16",date: "2026-05-29",diff --git a/src/stores/wiki-store.ts b/src/stores/wiki-store.tsindex dfb537e0..26a97e22 100644--- a/src/stores/wiki-store.ts+++ b/src/stores/wiki-store.ts@@ -176,6 +176,9 @@ interface ScheduledImportConfig {* env-token-only setup keeps working after the toggle is added.* - `allowUnauthenticated` lets local agents call the API without a* token. It is explicit and default-off.+ * - `mcpEnabled` allows the optional MCP stdio server to use this+ * API. It is separate from the HTTP API kill-switch so users can+ * expose scripts while keeping MCP disabled.* - `token` is the bearer secret. Empty + auth required =* every non-/health request returns 401. The env var* `LLM_WIKI_API_TOKEN` overrides this field at the backend.@@ -183,6 +186,7 @@ interface ScheduledImportConfig {interface ApiConfig {enabled: booleanallowUnauthenticated: boolean+ mcpEnabled: booleantoken: string}@@ -437,6 +441,7 @@ export const useWikiStore = create<WikiState>((set) => ({apiConfig: {enabled: true,allowUnauthenticated: false,+ mcpEnabled: false,token: "",},