diff --git a/CHANGELOG.md b/CHANGELOG.md index 27616a7..7636a72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 4.0.0 - 2026-07-29 + +### Changed + +- Migrated to the stable MCP TypeScript SDK v2 package family. +- Added stdio negotiation for MCP 2026-07-28 while retaining legacy client compatibility. +- Raised the minimum supported Node.js version from 18 to 20. +- Migrated tools, prompts, and resources to the v2 registration APIs and Zod 4 schemas. ## [3.0.0] - 2026-07-29 ### Added diff --git a/package-lock.json b/package-lock.json index 4331ea0..65abe5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "@takescake/1password-mcp", - "version": "2.4.0", + "version": "4.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@takescake/1password-mcp", - "version": "2.4.0", + "version": "4.0.0", "license": "Apache-2.0", "dependencies": { "@1password/sdk": "^0.3.1", - "@modelcontextprotocol/sdk": "^1.26.0", - "zod": "^3.23.8" + "@modelcontextprotocol/server": "^2.0.0-beta.5", + "zod": "^4.0.0" }, "bin": { "1password-mcp": "bin/1password-mcp.js" @@ -22,7 +22,7 @@ "vitest": "^3.0.0" }, "engines": { - "node": ">=18" + "node": ">=20" } }, "node_modules/@1password/sdk": { @@ -482,18 +482,6 @@ "node": ">=18" } }, - "node_modules/@hono/node-server": { - "version": "1.19.9", - "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.19.9.tgz", - "integrity": "sha512-vHL6w3ecZsky+8P5MD+eFfaGTyCeOHUIFYMGpQGbrBTSmNNoxv0if69rEZ5giu36weC5saFuznL411gRX7bJDw==", - "license": "MIT", - "engines": { - "node": ">=18.14.1" - }, - "peerDependencies": { - "hono": "^4" - } - }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", @@ -501,44 +489,29 @@ "dev": true, "license": "MIT" }, - "node_modules/@modelcontextprotocol/sdk": { - "version": "1.27.1", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.27.1.tgz", - "integrity": "sha512-sr6GbP+4edBwFndLbM60gf07z0FQ79gaExpnsjMGePXqFcSSb7t6iscpjk9DhFhwd+mTEQrzNafGP8/iGGFYaA==", + "node_modules/@modelcontextprotocol/core": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.0.0.tgz", + "integrity": "sha512-pJCEwGG7Lfr/+PQp9ZTwKXNeO5wzbfKL7H3MYpCorM4oFBoQrdjnBgEoqG+RjhsvS1FKrDbKux+M1HhlnGWqcA==", "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" + "zod": "^4.2.0" }, "engines": { - "node": ">=18" - }, - "peerDependencies": { - "@cfworker/json-schema": "^4.1.1", - "zod": "^3.25 || ^4.0" + "node": ">=20" + } + }, + "node_modules/@modelcontextprotocol/server": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/server/-/server-2.0.0.tgz", + "integrity": "sha512-YhHWdHfpFMQfd0prsEnxKeS3Qz3ytIGmsS0sth4KDjnacIT7hxk6hXHkJ9KysxlkvTM+WZAtQbbcUhdoP4Hvtw==", + "license": "MIT", + "dependencies": { + "@modelcontextprotocol/core": "2.0.0", + "zod": "^4.2.0" }, - "peerDependenciesMeta": { - "@cfworker/json-schema": { - "optional": true - }, - "zod": { - "optional": false - } + "engines": { + "node": ">=20" } }, "node_modules/@rollup/rollup-android-arm-eabi": { @@ -1041,52 +1014,6 @@ "url": "https://opencollective.com/vitest" } }, - "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.17.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", - "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", - "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/assertion-error": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", @@ -1097,39 +1024,6 @@ "node": ">=12" } }, - "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/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -1140,35 +1034,6 @@ "node": ">=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/chai": { "version": "5.3.3", "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", @@ -1196,81 +1061,11 @@ "node": ">= 16" } }, - "node_modules/content-disposition": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", - "integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==", - "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==", + "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -1294,62 +1089,6 @@ "node": ">=6" } }, - "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-module-lexer": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", @@ -1357,18 +1096,6 @@ "dev": true, "license": "MIT" }, - "node_modules/es-object-atoms": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", - "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/esbuild": { "version": "0.25.12", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", @@ -1411,12 +1138,6 @@ "@esbuild/win32-x64": "0.25.12" } }, - "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/estree-walker": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", @@ -1427,36 +1148,6 @@ "@types/estree": "^1.0.0" } }, - "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.0.6", - "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.6.tgz", - "integrity": "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg==", - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/expect-type": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", @@ -1467,89 +1158,6 @@ "node": ">=12.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.3.1", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.3.1.tgz", - "integrity": "sha512-D1dKN+cmyPWuvB+G2SREQDzPY1agpBIcTa9sJxOPMCNeH3gwzhqJRDWCXW3gg0y//+LQ/8j52JbMROWyrKdMdw==", - "license": "MIT", - "dependencies": { - "ip-address": "10.1.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.0", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz", - "integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fastify" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fastify" - } - ], - "license": "BSD-3-Clause" - }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -1568,45 +1176,6 @@ } } }, - "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/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -1622,178 +1191,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "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.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/hono": { - "version": "4.11.7", - "resolved": "https://registry.npmjs.org/hono/-/hono-4.11.7.tgz", - "integrity": "sha512-l7qMiNee7t82bH3SeyUCt9UF15EVmaBvsppY2zQtrbIhl/yzBTny+YUxsVjSjQ6gaqaeVtZmGocom8TzBlA4Yw==", - "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.1.0", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz", - "integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==", - "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.1.3", - "resolved": "https://registry.npmjs.org/jose/-/jose-6.1.3.tgz", - "integrity": "sha512-0TpaTfihd4QMNwrz/ob2Bp7X04yuxJkjRGi4aKmOqwhov54i6u79oCv7T+C7lo70MKH6BesI3vscD1yb/yzKXQ==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/panva" - } - }, "node_modules/js-tokens": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", @@ -1801,18 +1198,6 @@ "dev": true, "license": "MIT" }, - "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/loupe": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", @@ -1830,65 +1215,11 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, - "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==", + "dev": true, "license": "MIT" }, "node_modules/nanoid": { @@ -1910,85 +1241,6 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, - "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.3.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", - "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/pathe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", @@ -2026,15 +1278,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "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/postcss": { "version": "8.5.6", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", @@ -2064,67 +1307,6 @@ "node": "^10 || ^12 || >=14" } }, - "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.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.0.tgz", - "integrity": "sha512-mAZTtNCeetKMH+pSjrb76NAM8V9a05I9aBZOHztWy/UqcJdQYNsf59vrRKWnojAT9Y+GbIvoTBC++CPHqpDBhQ==", - "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/rollup": { "version": "4.57.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.57.1.tgz", @@ -2170,172 +1352,6 @@ "fsevents": "~2.3.2" } }, - "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.0", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", - "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.3" - }, - "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/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -2360,15 +1376,6 @@ "dev": true, "license": "MIT" }, - "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/std-env": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", @@ -2450,29 +1457,6 @@ "node": ">=14.0.0" } }, - "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.0.1", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", - "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", - "license": "MIT", - "dependencies": { - "content-type": "^1.0.5", - "media-typer": "^1.1.0", - "mime-types": "^3.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", @@ -2494,24 +1478,6 @@ "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/vite": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.1.tgz", @@ -2683,21 +1649,6 @@ } } }, - "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/why-is-node-running": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", @@ -2715,29 +1666,14 @@ "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": "3.25.76", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", - "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "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.1", - "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.1.tgz", - "integrity": "sha512-pM/SU9d3YAggzi6MtR4h7ruuQlqKtad8e9S0fmxcMi+ueAK5Korys/aWcV9LIIHTVbj01NdzxcnXSN+O74ZIVA==", - "license": "ISC", - "peerDependencies": { - "zod": "^3.25 || ^4" - } } } } diff --git a/package.json b/package.json index 6e0cf38..0d5d508 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@takescake/1password-mcp", - "version": "3.0.0", + "version": "4.0.0", "private": false, "type": "module", "description": "MCP server for 1Password service accounts — tools, prompts, and resources for vault and credential management", @@ -24,7 +24,7 @@ "service-account" ], "engines": { - "node": ">=18" + "node": ">=20" }, "main": "dist/index.js", "types": "dist/index.d.ts", @@ -51,12 +51,12 @@ ], "dependencies": { "@1password/sdk": "^0.3.1", - "@modelcontextprotocol/sdk": "^1.26.0", - "zod": "^3.23.8" + "zod": "^4.0.0", + "@modelcontextprotocol/server": "^2.0.0-beta.5" }, "devDependencies": { "@types/node": "^22.0.0", "typescript": "^5.7.0", "vitest": "^3.0.0" } -} \ No newline at end of file +} diff --git a/server.json b/server.json index 327c6e6..260be4c 100644 --- a/server.json +++ b/server.json @@ -6,12 +6,12 @@ "url": "https://github.com/CakeRepository/1Password-MCP.git", "source": "github" }, - "version": "3.0.0", + "version": "4.0.0", "packages": [ { "registryType": "npm", "identifier": "@takescake/1password-mcp", - "version": "3.0.0", + "version": "4.0.0", "transport": { "type": "stdio" }, @@ -40,4 +40,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/config.ts b/src/config.ts index 428db67..728986c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,7 +6,7 @@ import { execFileSync } from "node:child_process"; import { LOG_LEVEL_VALUES, type LogLevel } from "./types.js"; export const SERVER_NAME = "1password-mcp"; -export const SERVER_VERSION = "3.0.0"; +export const SERVER_VERSION = "4.0.0"; /** Parse a `--flag value` or `--flag=value` argument from process.argv. */ function getArgValue(name: string): string | undefined { diff --git a/src/index.ts b/src/index.ts index aeef1af..b7f86aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,32 +1,31 @@ /** * 1Password MCP Server — main entrypoint. * - * Wires together the MCP server with tools, prompts, resources, - * and the stdio transport. + * Builds one server instance per stdio connection and lets the MCP v2 + * transport negotiate either protocol revision 2026-07-28 or a legacy + * 2025-era connection. */ -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; -import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; +import { McpServer } from "@modelcontextprotocol/server"; +import { serveStdio } from "@modelcontextprotocol/server/stdio"; import { SERVER_NAME, SERVER_VERSION, getConfig } from "./config.js"; import { log, logError } from "./logger.js"; import { registerAllTools } from "./tools/index.js"; import { registerAllPrompts } from "./prompts/index.js"; import { registerAllResources } from "./resources/index.js"; -// ─── Create the MCP server ────────────────────────────────────────── - -const server = new McpServer({ - name: SERVER_NAME, - version: SERVER_VERSION, -}); - -// ─── Register capabilities ────────────────────────────────────────── +export function buildServer(): McpServer { + const server = new McpServer({ + name: SERVER_NAME, + version: SERVER_VERSION, + }); -registerAllTools(server); -registerAllPrompts(server); -registerAllResources(server); + registerAllTools(server); + registerAllPrompts(server); + registerAllResources(server); -// ─── Global error handlers ────────────────────────────────────────── + return server; +} process.on("uncaughtException", (error) => { logError("Uncaught exception.", error); @@ -36,8 +35,6 @@ process.on("unhandledRejection", (reason) => { logError("Unhandled rejection.", reason); }); -// ─── Start ────────────────────────────────────────────────────────── - async function main(): Promise { const config = getConfig(); @@ -50,10 +47,8 @@ async function main(): Promise { tokenSource: config.tokenSource, }); - const transport = new StdioServerTransport(); - log("info", "Connecting MCP server transport."); - await server.connect(transport); - log("info", "MCP server connected. Awaiting requests."); + log("info", "Starting MCP stdio protocol negotiation."); + await serveStdio(() => buildServer()); } main().catch((error) => { diff --git a/src/prompts/index.ts b/src/prompts/index.ts index ab5f929..213491b 100644 --- a/src/prompts/index.ts +++ b/src/prompts/index.ts @@ -1,193 +1,172 @@ /** * MCP Prompts — interactive prompt templates for 1Password workflows. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; /** Register all MCP prompts on the server. */ export function registerAllPrompts(server: McpServer): void { // ─── generate-secure-password ───────────────────────────────────── - server.prompt( - "generate-secure-password", - "Guide through generating a secure password with specific requirements", - { - purpose: z - .string() - .optional() - .describe("What the password is for (e.g., 'database', 'API key', 'user account')."), - style: z - .enum(["random", "memorable"]) - .optional() - .describe("Password style: 'random' for maximum entropy or 'memorable' for a passphrase. Defaults to 'random'."), - }, - async ({ purpose, style }) => { - const passwordStyle = style ?? "random"; - const purposeText = purpose ? ` for "${purpose}"` : ""; + server.registerPrompt("generate-secure-password", { description: "Guide through generating a secure password with specific requirements", argsSchema: z.object({ + purpose: z + .string() + .optional() + .describe("What the password is for (e.g., 'database', 'API key', 'user account')."), + style: z + .enum(["random", "memorable"]) + .optional() + .describe("Password style: 'random' for maximum entropy or 'memorable' for a passphrase. Defaults to 'random'."), + }) }, async ({ purpose, style }) => { + const passwordStyle = style ?? "random"; + const purposeText = purpose ? ` for "${purpose}"` : ""; - return { - messages: [ - { - role: "user" as const, - content: { - type: "text" as const, - text: [ - `I need to generate a secure password${purposeText}.`, - ``, - `Please help me create a ${passwordStyle === "memorable" ? "memorable passphrase" : "strong random password"} with these steps:`, - ``, - `1. Use the \`password_generate${passwordStyle === "memorable" ? "_memorable" : ""}\` tool to create the password.`, - passwordStyle === "random" - ? ` - Use at least 20 characters with uppercase, numbers, and symbols.` - : ` - Use at least 4 words for good entropy.`, - `2. If I want to store it, use \`vault_list\` to show available vaults.`, - `3. Then use \`password_create\` to save it securely in 1Password.`, - `4. Provide the \`op://\` secret reference so I can use it in my configuration.`, - ``, - `Important: Do NOT display the raw password in your response unless I explicitly ask. Instead, confirm it was generated and stored, and provide the secret reference.`, - ].join("\n"), - }, - }, - ], - }; - }, - ); + return { + messages: [ + { + role: "user" as const, + content: { + type: "text" as const, + text: [ + `I need to generate a secure password${purposeText}.`, + ``, + `Please help me create a ${passwordStyle === "memorable" ? "memorable passphrase" : "strong random password"} with these steps:`, + ``, + `1. Use the \`password_generate${passwordStyle === "memorable" ? "_memorable" : ""}\` tool to create the password.`, + passwordStyle === "random" + ? ` - Use at least 20 characters with uppercase, numbers, and symbols.` + : ` - Use at least 4 words for good entropy.`, + `2. If I want to store it, use \`vault_list\` to show available vaults.`, + `3. Then use \`password_create\` to save it securely in 1Password.`, + `4. Provide the \`op://\` secret reference so I can use it in my configuration.`, + ``, + `Important: Do NOT display the raw password in your response unless I explicitly ask. Instead, confirm it was generated and stored, and provide the secret reference.`, + ].join("\n"), + }, + }, + ], + }; + }); // ─── credential-rotation ────────────────────────────────────────── - server.prompt( - "credential-rotation", - "Step-by-step workflow for rotating a credential stored in 1Password", - { - vaultId: z.string().optional().describe("Vault ID containing the credential to rotate."), - itemId: z.string().optional().describe("Item ID of the credential to rotate."), - }, - async ({ vaultId, itemId }) => { - const hasTarget = vaultId && itemId; + server.registerPrompt("credential-rotation", { description: "Step-by-step workflow for rotating a credential stored in 1Password", argsSchema: z.object({ + vaultId: z.string().optional().describe("Vault ID containing the credential to rotate."), + itemId: z.string().optional().describe("Item ID of the credential to rotate."), + }) }, async ({ vaultId, itemId }) => { + const hasTarget = vaultId && itemId; - return { - messages: [ - { - role: "user" as const, - content: { - type: "text" as const, - text: [ - `I need to rotate a credential in 1Password.`, - ``, - hasTarget - ? `Target: vault \`${vaultId}\`, item \`${itemId}\`.` - : `I haven't specified which credential yet. Please help me find it.`, - ``, - `Follow this rotation workflow:`, - ``, - !hasTarget - ? `1. Use \`vault_list\` to show my vaults, then \`item_lookup\` to find the item.\n` - : "", - `${hasTarget ? "1" : "2"}. Use \`password_read\` to verify access to the current credential (with \`reveal: false\` for safety).`, - `${hasTarget ? "2" : "3"}. Use \`password_generate\` to create a new strong password.`, - `${hasTarget ? "3" : "4"}. Use \`password_update\` to save the new password to 1Password.`, - `${hasTarget ? "4" : "5"}. Confirm the rotation was successful and provide the updated \`op://\` reference.`, - ``, - `Important: After rotation, remind me to update the password wherever it's used (services, configs, etc.).`, - ] - .filter(Boolean) - .join("\n"), - }, - }, - ], - }; - }, - ); + return { + messages: [ + { + role: "user" as const, + content: { + type: "text" as const, + text: [ + `I need to rotate a credential in 1Password.`, + ``, + hasTarget + ? `Target: vault \`${vaultId}\`, item \`${itemId}\`.` + : `I haven't specified which credential yet. Please help me find it.`, + ``, + `Follow this rotation workflow:`, + ``, + !hasTarget + ? `1. Use \`vault_list\` to show my vaults, then \`item_lookup\` to find the item.\n` + : "", + `${hasTarget ? "1" : "2"}. Use \`password_read\` to verify access to the current credential (with \`reveal: false\` for safety).`, + `${hasTarget ? "2" : "3"}. Use \`password_generate\` to create a new strong password.`, + `${hasTarget ? "3" : "4"}. Use \`password_update\` to save the new password to 1Password.`, + `${hasTarget ? "4" : "5"}. Confirm the rotation was successful and provide the updated \`op://\` reference.`, + ``, + `Important: After rotation, remind me to update the password wherever it's used (services, configs, etc.).`, + ] + .filter(Boolean) + .join("\n"), + }, + }, + ], + }; + }); // ─── vault-audit ────────────────────────────────────────────────── - server.prompt( - "vault-audit", - "Audit the contents of a 1Password vault — list all items with categories and metadata", - { - vaultId: z.string().optional().describe("Vault ID to audit. If omitted, all vaults will be listed first."), - }, - async ({ vaultId }) => { - return { - messages: [ - { - role: "user" as const, - content: { - type: "text" as const, - text: [ - `I want to audit my 1Password vault${vaultId ? ` (vault ID: \`${vaultId}\`)` : ""}.`, - ``, - `Please perform the following:`, - ``, - !vaultId - ? `1. Use \`vault_list\` to show all accessible vaults and ask which one to audit.\n` - : "", - `${!vaultId ? "2" : "1"}. Use \`item_lookup\` to list all items in the vault (no query filter, high limit).`, - `${!vaultId ? "3" : "2"}. Summarize the findings:`, - ` - Total number of items`, - ` - Breakdown by category (Login, Password, etc.)`, - ` - List of all item titles (but NOT passwords)`, - `${!vaultId ? "4" : "3"}. Flag any concerns:`, - ` - Items without a category`, - ` - Duplicate-looking titles`, - ` - Any items that look like they could be consolidated`, - ``, - `Do NOT reveal any secret values during the audit.`, - ] - .filter(Boolean) - .join("\n"), - }, - }, - ], - }; - }, - ); + server.registerPrompt("vault-audit", { description: "Audit the contents of a 1Password vault — list all items with categories and metadata", argsSchema: z.object({ + vaultId: z.string().optional().describe("Vault ID to audit. If omitted, all vaults will be listed first."), + }) }, async ({ vaultId }) => { + return { + messages: [ + { + role: "user" as const, + content: { + type: "text" as const, + text: [ + `I want to audit my 1Password vault${vaultId ? ` (vault ID: \`${vaultId}\`)` : ""}.`, + ``, + `Please perform the following:`, + ``, + !vaultId + ? `1. Use \`vault_list\` to show all accessible vaults and ask which one to audit.\n` + : "", + `${!vaultId ? "2" : "1"}. Use \`item_lookup\` to list all items in the vault (no query filter, high limit).`, + `${!vaultId ? "3" : "2"}. Summarize the findings:`, + ` - Total number of items`, + ` - Breakdown by category (Login, Password, etc.)`, + ` - List of all item titles (but NOT passwords)`, + `${!vaultId ? "4" : "3"}. Flag any concerns:`, + ` - Items without a category`, + ` - Duplicate-looking titles`, + ` - Any items that look like they could be consolidated`, + ``, + `Do NOT reveal any secret values during the audit.`, + ] + .filter(Boolean) + .join("\n"), + }, + }, + ], + }; + }); // ─── secret-reference-helper ────────────────────────────────────── - server.prompt( - "secret-reference-helper", - "Help construct an op://vault/item/field secret reference from vault and item names", - { - vaultName: z - .string() - .optional() - .describe("Name of the vault (partial match is OK)."), - itemName: z - .string() - .optional() - .describe("Name of the item to reference (partial match is OK)."), - }, - async ({ vaultName, itemName }) => { - return { - messages: [ - { - role: "user" as const, - content: { - type: "text" as const, - text: [ - `I need to construct a 1Password secret reference (\`op://vault/item/field\`).`, - ``, - vaultName - ? `Vault name: "${vaultName}"` - : `I'm not sure which vault to use.`, - itemName - ? `Item name: "${itemName}"` - : `I'm not sure which item to reference.`, - ``, - `Steps:`, - `1. Use \`vault_list\` to find the vault${vaultName ? ` matching "${vaultName}"` : ""}.`, - `2. Use \`item_lookup\` with the vault ID${itemName ? ` and query "${itemName}"` : ""} to find the item.`, - `3. Use \`password_read\` with \`reveal: false\` to inspect available fields.`, - `4. Construct the \`op://vault-name/item-name/field\` reference and present it.`, - ``, - `The final reference should be ready to paste into my configuration files.`, - ].join("\n"), - }, - }, - ], - }; - }, - ); + server.registerPrompt("secret-reference-helper", { description: "Help construct an op://vault/item/field secret reference from vault and item names", argsSchema: z.object({ + vaultName: z + .string() + .optional() + .describe("Name of the vault (partial match is OK)."), + itemName: z + .string() + .optional() + .describe("Name of the item to reference (partial match is OK)."), + }) }, async ({ vaultName, itemName }) => { + return { + messages: [ + { + role: "user" as const, + content: { + type: "text" as const, + text: [ + `I need to construct a 1Password secret reference (\`op://vault/item/field\`).`, + ``, + vaultName + ? `Vault name: "${vaultName}"` + : `I'm not sure which vault to use.`, + itemName + ? `Item name: "${itemName}"` + : `I'm not sure which item to reference.`, + ``, + `Steps:`, + `1. Use \`vault_list\` to find the vault${vaultName ? ` matching "${vaultName}"` : ""}.`, + `2. Use \`item_lookup\` with the vault ID${itemName ? ` and query "${itemName}"` : ""} to find the item.`, + `3. Use \`password_read\` with \`reveal: false\` to inspect available fields.`, + `4. Construct the \`op://vault-name/item-name/field\` reference and present it.`, + ``, + `The final reference should be ready to paste into my configuration files.`, + ].join("\n"), + }, + }, + ], + }; + }); } diff --git a/src/resources/index.ts b/src/resources/index.ts index c3b311d..2d6e98d 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,8 +1,7 @@ /** * MCP Resources — browsable data exposed by the 1Password MCP server. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { getClient } from "../client.js"; import { getConfig, SERVER_NAME, SERVER_VERSION } from "../config.js"; import { log, logError } from "../logger.js"; @@ -11,7 +10,7 @@ import { log, logError } from "../logger.js"; export function registerAllResources(server: McpServer): void { // ─── 1password://config ─────────────────────────────────────────── - server.resource( + server.registerResource( "server-config", "1password://config", { @@ -47,7 +46,7 @@ export function registerAllResources(server: McpServer): void { // ─── 1password://vaults ─────────────────────────────────────────── - server.resource( + server.registerResource( "vault-list", "1password://vaults", { @@ -98,7 +97,7 @@ export function registerAllResources(server: McpServer): void { // ─── 1password://vaults/{vaultId}/items ─────────────────────────── - server.resource( + server.registerResource( "vault-items", "1password://vaults/{vaultId}/items", { diff --git a/src/tools/index.ts b/src/tools/index.ts index 1fdc1ae..8feecc7 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -1,8 +1,7 @@ /** * Barrel module — registers all MCP tools on the server. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { registerVaultList } from "./vault-list.js"; import { registerItemLookup } from "./item-lookup.js"; import { registerItemDelete } from "./item-delete.js"; diff --git a/src/tools/item-archive.ts b/src/tools/item-archive.ts index 269927e..b9f18a8 100644 --- a/src/tools/item-archive.ts +++ b/src/tools/item-archive.ts @@ -1,36 +1,30 @@ /** * item_archive — Archive an item in a 1Password vault (instead of hard-deleting). */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { getClient } from "../client.js"; import { log, logError } from "../logger.js"; import { jsonResult, errorResult } from "../utils.js"; export function registerItemArchive(server: McpServer): void { - server.tool( - "item_archive", - "Archive an item in a 1Password vault. The item is moved to the archive and hidden from regular views, rather than being permanently deleted.", - { - vaultId: z.string().min(1).describe("Vault ID containing the item."), - itemId: z.string().min(1).describe("Item ID to archive."), - }, - async ({ vaultId, itemId }) => { - try { - log("debug", "Tool call: item_archive.", { vaultId, itemId }); - const client = await getClient(); - if (!client?.items?.archive) { - throw new Error( - "Your @1password/sdk version does not support archiving items.", - ); - } - await client.items.archive(vaultId, itemId); - return jsonResult({ archived: true, vaultId, itemId }); - } catch (error) { - logError("item_archive failed.", error); - return errorResult(error); - } - }, - ); + server.registerTool("item_archive", { description: "Archive an item in a 1Password vault. The item is moved to the archive and hidden from regular views, rather than being permanently deleted.", inputSchema: z.object({ + vaultId: z.string().min(1).describe("Vault ID containing the item."), + itemId: z.string().min(1).describe("Item ID to archive."), + }) }, async ({ vaultId, itemId }) => { + try { + log("debug", "Tool call: item_archive.", { vaultId, itemId }); + const client = await getClient(); + if (!client?.items?.archive) { + throw new Error( + "Your @1password/sdk version does not support archiving items.", + ); + } + await client.items.archive(vaultId, itemId); + return jsonResult({ archived: true, vaultId, itemId }); + } catch (error) { + logError("item_archive failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/item-delete.ts b/src/tools/item-delete.ts index 0204adb..5f26a46 100644 --- a/src/tools/item-delete.ts +++ b/src/tools/item-delete.ts @@ -1,40 +1,34 @@ /** * item_delete — Delete an item from a 1Password vault. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { getClient } from "../client.js"; import { log, logError } from "../logger.js"; import { jsonResult, errorResult } from "../utils.js"; export function registerItemDelete(server: McpServer): void { - server.tool( - "item_delete", - "Permanently delete an item from a 1Password vault. This action cannot be undone.", - { - vaultId: z.string().min(1).describe("Vault ID containing the item."), - itemId: z.string().min(1).describe("Item ID to delete."), - }, - async ({ vaultId, itemId }) => { - try { - log("debug", "Tool call: item_delete.", { vaultId, itemId }); - const client = await getClient(); - if (!(client?.items as any)?.delete) { - throw new Error( - "Your @1password/sdk version does not support deleting items.", - ); - } - await (client.items as any).delete(vaultId, itemId); - return jsonResult({ - deleted: true, - vaultId, - itemId, - }); - } catch (error) { - logError("item_delete failed.", error); - return errorResult(error); - } - }, - ); + server.registerTool("item_delete", { description: "Permanently delete an item from a 1Password vault. This action cannot be undone.", inputSchema: z.object({ + vaultId: z.string().min(1).describe("Vault ID containing the item."), + itemId: z.string().min(1).describe("Item ID to delete."), + }) }, async ({ vaultId, itemId }) => { + try { + log("debug", "Tool call: item_delete.", { vaultId, itemId }); + const client = await getClient(); + if (!(client?.items as any)?.delete) { + throw new Error( + "Your @1password/sdk version does not support deleting items.", + ); + } + await (client.items as any).delete(vaultId, itemId); + return jsonResult({ + deleted: true, + vaultId, + itemId, + }); + } catch (error) { + logError("item_delete failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/item-edit.ts b/src/tools/item-edit.ts index 81d381c..d404103 100644 --- a/src/tools/item-edit.ts +++ b/src/tools/item-edit.ts @@ -5,8 +5,7 @@ * back via items.put. Unreferenced fields are preserved untouched. Field values * are never logged. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { ItemFieldType, @@ -45,145 +44,140 @@ function fieldMatches(field: ItemField, idOrTitle: string): boolean { } export function registerItemEdit(server: McpServer): void { - server.tool( - "item_edit", - "Edit an existing 1Password item. Update the title, notes (pass an empty string to clear notes), tags, website URL, upsert fields, or remove fields. Only referenced fields are changed; all others are preserved.", - { - vaultId: z.string().min(1).describe("Vault ID containing the item."), - itemId: z.string().min(1).describe("Item ID to edit."), - title: z.string().min(1).optional().describe("New item title."), - notes: z - .string() - .optional() - .describe( - "Full replacement of the item's notes. Pass an empty string to clear notes.", - ), - tags: z - .array(z.string().min(1)) - .optional() - .describe("Replacement set of tags (replaces all existing tags)."), - url: z - .string() - .url() - .optional() - .describe("Replacement primary website URL for the item."), - fields: z - .array(fieldInput) - .optional() - .describe("Fields to upsert (create or update) by id or title."), - removeFields: z - .array(z.string().min(1)) - .optional() - .describe("Field ids or titles to remove from the item."), - }, - async ({ vaultId, itemId, title, notes, tags, url, fields, removeFields }) => { - try { - // NOTE: field values are intentionally excluded from logs. - log("debug", "Tool call: item_edit.", { - vaultId, - itemId, - changeTitle: title !== undefined, - changeNotes: notes !== undefined, - changeTags: tags !== undefined, - changeUrl: url !== undefined, - upsertCount: fields?.length ?? 0, - removeCount: removeFields?.length ?? 0, - }); + server.registerTool("item_edit", { description: "Edit an existing 1Password item. Update the title, notes (pass an empty string to clear notes), tags, website URL, upsert fields, or remove fields. Only referenced fields are changed; all others are preserved.", inputSchema: z.object({ + vaultId: z.string().min(1).describe("Vault ID containing the item."), + itemId: z.string().min(1).describe("Item ID to edit."), + title: z.string().min(1).optional().describe("New item title."), + notes: z + .string() + .optional() + .describe( + "Full replacement of the item's notes. Pass an empty string to clear notes.", + ), + tags: z + .array(z.string().min(1)) + .optional() + .describe("Replacement set of tags (replaces all existing tags)."), + url: z + .string() + .url() + .optional() + .describe("Replacement primary website URL for the item."), + fields: z + .array(fieldInput) + .optional() + .describe("Fields to upsert (create or update) by id or title."), + removeFields: z + .array(z.string().min(1)) + .optional() + .describe("Field ids or titles to remove from the item."), + }) }, async ({ vaultId, itemId, title, notes, tags, url, fields, removeFields }) => { + try { + // NOTE: field values are intentionally excluded from logs. + log("debug", "Tool call: item_edit.", { + vaultId, + itemId, + changeTitle: title !== undefined, + changeNotes: notes !== undefined, + changeTags: tags !== undefined, + changeUrl: url !== undefined, + upsertCount: fields?.length ?? 0, + removeCount: removeFields?.length ?? 0, + }); - const client = await getClient(); - if (!client?.items?.get) { - throw new Error( - "Your @1password/sdk version does not support getting items.", - ); - } - if (!client?.items?.put) { - throw new Error( - "Your @1password/sdk version does not support updating items.", - ); - } + const client = await getClient(); + if (!client?.items?.get) { + throw new Error( + "Your @1password/sdk version does not support getting items.", + ); + } + if (!client?.items?.put) { + throw new Error( + "Your @1password/sdk version does not support updating items.", + ); + } - const existing: Item = await client.items.get(vaultId, itemId); + const existing: Item = await client.items.get(vaultId, itemId); - // Build the next field list immutably, preserving unreferenced fields. - const removeSet = new Set( - (removeFields ?? []).map((value) => value.toLowerCase()), - ); + // Build the next field list immutably, preserving unreferenced fields. + const removeSet = new Set( + (removeFields ?? []).map((value) => value.toLowerCase()), + ); - let nextFields: ItemField[] = (existing.fields ?? []).filter( - (field) => - !removeSet.has(field.id?.toLowerCase()) && - !removeSet.has(field.title?.toLowerCase()), - ); + let nextFields: ItemField[] = (existing.fields ?? []).filter( + (field) => + !removeSet.has(field.id?.toLowerCase()) && + !removeSet.has(field.title?.toLowerCase()), + ); - for (const upsert of fields ?? []) { - const fieldType = - upsert.type === "concealed" - ? ItemFieldType.Concealed - : ItemFieldType.Text; - const index = nextFields.findIndex((field) => - fieldMatches(field, upsert.idOrTitle), - ); + for (const upsert of fields ?? []) { + const fieldType = + upsert.type === "concealed" + ? ItemFieldType.Concealed + : ItemFieldType.Text; + const index = nextFields.findIndex((field) => + fieldMatches(field, upsert.idOrTitle), + ); - if (index >= 0) { - const current = nextFields[index]; - const replacement: ItemField = { - ...current, - fieldType, - value: upsert.value, - sectionId: upsert.section ?? current.sectionId, - }; - nextFields = nextFields.map((field, i) => - i === index ? replacement : field, - ); - } else { - nextFields = [ - ...nextFields, - { - id: upsert.idOrTitle, - title: upsert.idOrTitle, - fieldType, - value: upsert.value, - sectionId: upsert.section, - }, - ]; - } - } + if (index >= 0) { + const current = nextFields[index]; + const replacement: ItemField = { + ...current, + fieldType, + value: upsert.value, + sectionId: upsert.section ?? current.sectionId, + }; + nextFields = nextFields.map((field, i) => + i === index ? replacement : field, + ); + } else { + nextFields = [ + ...nextFields, + { + id: upsert.idOrTitle, + title: upsert.idOrTitle, + fieldType, + value: upsert.value, + sectionId: upsert.section, + }, + ]; + } + } - let nextWebsites: Website[] | undefined = existing.websites; - if (url !== undefined) { - nextWebsites = [ - { - url, - label: "website", - autofillBehavior: AutofillBehavior.AnywhereOnWebsite, - }, - ]; - } + let nextWebsites: Website[] | undefined = existing.websites; + if (url !== undefined) { + nextWebsites = [ + { + url, + label: "website", + autofillBehavior: AutofillBehavior.AnywhereOnWebsite, + }, + ]; + } - const updated: Item = { - ...existing, - title: title ?? existing.title, - notes: notes ?? existing.notes, - tags: tags ?? existing.tags, - websites: nextWebsites, - fields: nextFields, - }; + const updated: Item = { + ...existing, + title: title ?? existing.title, + notes: notes ?? existing.notes, + tags: tags ?? existing.tags, + websites: nextWebsites, + fields: nextFields, + }; - const result: Item = await client.items.put(updated); + const result: Item = await client.items.put(updated); - return jsonResult({ - id: result.id, - title: result.title, - vaultId: result.vaultId, - category: result.category, - tags: result.tags ?? [], - fieldCount: result.fields?.length ?? 0, - updatedAt: result.updatedAt, - }); - } catch (error) { - logError("item_edit failed.", error); - return errorResult(error); - } - }, - ); + return jsonResult({ + id: result.id, + title: result.title, + vaultId: result.vaultId, + category: result.category, + tags: result.tags ?? [], + fieldCount: result.fields?.length ?? 0, + updatedAt: result.updatedAt, + }); + } catch (error) { + logError("item_edit failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/item-get.ts b/src/tools/item-get.ts index 6c4e7fc..8165c2f 100644 --- a/src/tools/item-get.ts +++ b/src/tools/item-get.ts @@ -1,8 +1,7 @@ /** * item_get — Retrieve a full 1Password item, with concealed values hidden by default. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { ItemFieldType, type Item, type ItemField } from "@1password/sdk"; import { getClient } from "../client.js"; @@ -38,97 +37,92 @@ function summarizeField( } export function registerItemGet(server: McpServer): void { - server.tool( - "item_get", - "Retrieve a full 1Password item — title, category, tags, notes, and all fields (id, title, type, section). Concealed field values are hidden unless reveal is true. Accepts a secret reference (op://vault/item/field) or vault ID + item ID. Revealing a secret puts it in the model context/transcript — to USE a secret in a command or API call, prefer op_run with op:// references instead.", - { - secretReference: z - .string() - .optional() - .describe( - "Secret reference in op://vault/item/field format. If provided, vaultId and itemId are ignored.", - ), - vaultId: z - .string() - .optional() - .describe("Vault ID containing the item (required if secretReference is not provided)."), - itemId: z - .string() - .optional() - .describe("Item ID to retrieve (required if secretReference is not provided)."), - reveal: z - .boolean() - .optional() - .describe( - "If true, include concealed field values in plaintext — this puts the secret in the model context/transcript. Defaults to false; prefer op_run to use a secret without revealing it.", - ), - }, - async ({ secretReference, vaultId, itemId, reveal }) => { - try { - log("debug", "Tool call: item_get.", { - secretReference: Boolean(secretReference), - vaultId, - itemId, - reveal, - }); - const client = await getClient(); - if (!client?.items?.get) { - throw new Error( - "Your @1password/sdk version does not support getting items.", - ); - } + server.registerTool("item_get", { description: "Retrieve a full 1Password item — title, category, tags, notes, and all fields (id, title, type, section). Concealed field values are hidden unless reveal is true. Accepts a secret reference (op://vault/item/field) or vault ID + item ID. Revealing a secret puts it in the model context/transcript — to USE a secret in a command or API call, prefer op_run with op:// references instead.", inputSchema: z.object({ + secretReference: z + .string() + .optional() + .describe( + "Secret reference in op://vault/item/field format. If provided, vaultId and itemId are ignored.", + ), + vaultId: z + .string() + .optional() + .describe("Vault ID containing the item (required if secretReference is not provided)."), + itemId: z + .string() + .optional() + .describe("Item ID to retrieve (required if secretReference is not provided)."), + reveal: z + .boolean() + .optional() + .describe( + "If true, include concealed field values in plaintext — this puts the secret in the model context/transcript. Defaults to false; prefer op_run to use a secret without revealing it.", + ), + }) }, async ({ secretReference, vaultId, itemId, reveal }) => { + try { + log("debug", "Tool call: item_get.", { + secretReference: Boolean(secretReference), + vaultId, + itemId, + reveal, + }); + const client = await getClient(); + if (!client?.items?.get) { + throw new Error( + "Your @1password/sdk version does not support getting items.", + ); + } - let resolvedVaultId = vaultId; - let resolvedItemId = itemId; + let resolvedVaultId = vaultId; + let resolvedItemId = itemId; - if (secretReference) { - if (!client?.secrets?.resolveAll) { - throw new Error( - "Your @1password/sdk version does not support resolving secret references.", - ); - } - const resolved = await client.secrets.resolveAll([secretReference]); - const response = resolved.individualResponses[secretReference]; - if (!response?.content) { - const reason = response?.error?.type ?? "unknown"; - throw new Error( - `Could not resolve secret reference '${secretReference}' (${reason}).`, - ); - } - resolvedVaultId = response.content.vaultId; - resolvedItemId = response.content.itemId; - } + if (secretReference) { + if (!client?.secrets?.resolveAll) { + throw new Error( + "Your @1password/sdk version does not support resolving secret references.", + ); + } + const resolved = await client.secrets.resolveAll([secretReference]); + const response = resolved.individualResponses[secretReference]; + if (!response?.content) { + const reason = response?.error?.type ?? "unknown"; + throw new Error( + `Could not resolve secret reference '${secretReference}' (${reason}).`, + ); + } + resolvedVaultId = response.content.vaultId; + resolvedItemId = response.content.itemId; + } - if (!resolvedVaultId || !resolvedItemId) { - throw new Error( - "Provide secretReference or both vaultId and itemId.", - ); - } + if (!resolvedVaultId || !resolvedItemId) { + throw new Error( + "Provide secretReference or both vaultId and itemId.", + ); + } - const item: Item = await client.items.get(resolvedVaultId, resolvedItemId); - const shouldReveal = reveal === true; + const item: Item = await client.items.get(resolvedVaultId, resolvedItemId); + const shouldReveal = reveal === true; - return jsonResult({ - id: item.id, - title: item.title, - category: item.category, - vaultId: item.vaultId, - tags: item.tags ?? [], - notes: item.notes ?? "", - sections: (item.sections ?? []).map((section) => ({ - id: section.id, - title: section.title, - })), - fields: (item.fields ?? []).map((field) => - summarizeField(field, shouldReveal), - ), - websites: (item.websites ?? []).map((site) => site.url), - updatedAt: item.updatedAt, - }); - } catch (error) { - logError("item_get failed.", error); - return errorResult(error); - } - }, - ); + return jsonResult({ + id: item.id, + title: item.title, + category: item.category, + vaultId: item.vaultId, + tags: item.tags ?? [], + notes: item.notes ?? "", + sections: (item.sections ?? []).map((section) => ({ + id: section.id, + title: section.title, + })), + fields: (item.fields ?? []).map((field) => + summarizeField(field, shouldReveal), + ), + websites: (item.websites ?? []).map((site) => site.url), + updatedAt: item.updatedAt, + }); + } catch (error) { + logError("item_get failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/item-list.ts b/src/tools/item-list.ts index 6f200a0..9e05219 100644 --- a/src/tools/item-list.ts +++ b/src/tools/item-list.ts @@ -1,8 +1,7 @@ /** * item_list — List all items in a 1Password vault (metadata only, no secrets). */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import type { ItemOverview } from "@1password/sdk"; import { getClient } from "../client.js"; @@ -10,36 +9,31 @@ import { log, logError } from "../logger.js"; import { jsonResult, errorResult } from "../utils.js"; export function registerItemList(server: McpServer): void { - server.tool( - "item_list", - "List all items in a 1Password vault, returning id, title, category, tags, and updatedAt for each. Never returns secret values.", - { - vaultId: z.string().min(1).describe("Vault ID to list items from."), - }, - async ({ vaultId }) => { - try { - log("debug", "Tool call: item_list.", { vaultId }); - const client = await getClient(); - if (!client?.items?.list) { - throw new Error( - "Your @1password/sdk version does not support listing items.", - ); - } + server.registerTool("item_list", { description: "List all items in a 1Password vault, returning id, title, category, tags, and updatedAt for each. Never returns secret values.", inputSchema: z.object({ + vaultId: z.string().min(1).describe("Vault ID to list items from."), + }) }, async ({ vaultId }) => { + try { + log("debug", "Tool call: item_list.", { vaultId }); + const client = await getClient(); + if (!client?.items?.list) { + throw new Error( + "Your @1password/sdk version does not support listing items.", + ); + } - const items: ItemOverview[] = await client.items.list(vaultId); - const summary = (items ?? []).map((item) => ({ - id: item.id, - title: item.title, - category: item.category, - tags: item.tags ?? [], - updatedAt: item.updatedAt, - })); + const items: ItemOverview[] = await client.items.list(vaultId); + const summary = (items ?? []).map((item) => ({ + id: item.id, + title: item.title, + category: item.category, + tags: item.tags ?? [], + updatedAt: item.updatedAt, + })); - return jsonResult({ items: summary, count: summary.length }); - } catch (error) { - logError("item_list failed.", error); - return errorResult(error); - } - }, - ); + return jsonResult({ items: summary, count: summary.length }); + } catch (error) { + logError("item_list failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/item-lookup.ts b/src/tools/item-lookup.ts index 2751133..4bf4091 100644 --- a/src/tools/item-lookup.ts +++ b/src/tools/item-lookup.ts @@ -1,8 +1,7 @@ /** * item_lookup — Search for items in a 1Password vault. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { getClient } from "../client.js"; import { log, logError } from "../logger.js"; @@ -10,58 +9,53 @@ import { jsonResult, errorResult } from "../utils.js"; import type { ItemSummary } from "../types.js"; export function registerItemLookup(server: McpServer): void { - server.tool( - "item_lookup", - "Search for items within a 1Password vault by title substring. Returns item IDs, titles, categories, and vault IDs.", - { - vaultId: z.string().min(1).describe("Vault ID to search within."), - query: z - .string() - .optional() - .describe("Optional substring to filter item titles (case-insensitive)."), - limit: z - .number() - .int() - .positive() - .max(200) - .optional() - .describe("Maximum number of items to return (default: all)."), - }, - async ({ vaultId, query, limit }) => { - try { - log("debug", "Tool call: item_lookup.", { - vaultId, - hasQuery: Boolean(query), - limit, - }); - const client = await getClient(); - const listFn = - client?.items?.list ?? (client?.items as any)?.listAll; - if (!listFn) { - throw new Error( - "Your @1password/sdk version does not support listing items.", - ); - } - const items: any[] = await listFn.call(client.items, vaultId); - const normalizedQuery = query?.toLowerCase(); - const filtered = normalizedQuery - ? (items ?? []).filter((item: any) => - item.title?.toLowerCase().includes(normalizedQuery), - ) - : items ?? []; - const sliced = - typeof limit === "number" ? filtered.slice(0, limit) : filtered; - const summary: ItemSummary[] = sliced.map((item: any) => ({ - id: item.id, - title: item.title, - category: item.category, - vaultId: item.vaultId ?? vaultId, - })); - return jsonResult({ items: summary, count: summary.length }); - } catch (error) { - logError("item_lookup failed.", error); - return errorResult(error); - } - }, - ); + server.registerTool("item_lookup", { description: "Search for items within a 1Password vault by title substring. Returns item IDs, titles, categories, and vault IDs.", inputSchema: z.object({ + vaultId: z.string().min(1).describe("Vault ID to search within."), + query: z + .string() + .optional() + .describe("Optional substring to filter item titles (case-insensitive)."), + limit: z + .number() + .int() + .positive() + .max(200) + .optional() + .describe("Maximum number of items to return (default: all)."), + }) }, async ({ vaultId, query, limit }) => { + try { + log("debug", "Tool call: item_lookup.", { + vaultId, + hasQuery: Boolean(query), + limit, + }); + const client = await getClient(); + const listFn = + client?.items?.list ?? (client?.items as any)?.listAll; + if (!listFn) { + throw new Error( + "Your @1password/sdk version does not support listing items.", + ); + } + const items: any[] = await listFn.call(client.items, vaultId); + const normalizedQuery = query?.toLowerCase(); + const filtered = normalizedQuery + ? (items ?? []).filter((item: any) => + item.title?.toLowerCase().includes(normalizedQuery), + ) + : items ?? []; + const sliced = + typeof limit === "number" ? filtered.slice(0, limit) : filtered; + const summary: ItemSummary[] = sliced.map((item: any) => ({ + id: item.id, + title: item.title, + category: item.category, + vaultId: item.vaultId ?? vaultId, + })); + return jsonResult({ items: summary, count: summary.length }); + } catch (error) { + logError("item_lookup failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/note-create.ts b/src/tools/note-create.ts index 157a72d..6e05bd1 100644 --- a/src/tools/note-create.ts +++ b/src/tools/note-create.ts @@ -1,8 +1,7 @@ /** * note_create — Create a Secure Note item in a 1Password vault. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { ItemCategory, @@ -31,73 +30,68 @@ const fieldInput = z.object({ }); export function registerNoteCreate(server: McpServer): void { - server.tool( - "note_create", - "Create a Secure Note item in a 1Password vault, with optional tags and custom fields.", - { - vaultId: z.string().min(1).describe("Vault ID to create the note in."), - title: z.string().min(1).describe("Note title."), - notes: z - .string() - .describe("Note body text. Pass an empty string for an empty note."), - tags: z - .array(z.string().min(1)) - .optional() - .describe("Optional tags for organization."), - fields: z - .array(fieldInput) - .optional() - .describe("Optional custom fields to attach to the note."), - }, - async ({ vaultId, title, notes, tags, fields }) => { - try { - // NOTE: field values are intentionally excluded from logs. - log("debug", "Tool call: note_create.", { - vaultId, - title, - fieldCount: fields?.length ?? 0, - }); - const client = await getClient(); - if (!client?.items?.create) { - throw new Error( - "Your @1password/sdk version does not support creating items.", - ); - } + server.registerTool("note_create", { description: "Create a Secure Note item in a 1Password vault, with optional tags and custom fields.", inputSchema: z.object({ + vaultId: z.string().min(1).describe("Vault ID to create the note in."), + title: z.string().min(1).describe("Note title."), + notes: z + .string() + .describe("Note body text. Pass an empty string for an empty note."), + tags: z + .array(z.string().min(1)) + .optional() + .describe("Optional tags for organization."), + fields: z + .array(fieldInput) + .optional() + .describe("Optional custom fields to attach to the note."), + }) }, async ({ vaultId, title, notes, tags, fields }) => { + try { + // NOTE: field values are intentionally excluded from logs. + log("debug", "Tool call: note_create.", { + vaultId, + title, + fieldCount: fields?.length ?? 0, + }); + const client = await getClient(); + if (!client?.items?.create) { + throw new Error( + "Your @1password/sdk version does not support creating items.", + ); + } - const itemFields: ItemField[] = (fields ?? []).map((field) => ({ - id: field.idOrTitle, - title: field.idOrTitle, - fieldType: - field.type === "concealed" - ? ItemFieldType.Concealed - : ItemFieldType.Text, - value: field.value, - sectionId: field.section, - })); + const itemFields: ItemField[] = (fields ?? []).map((field) => ({ + id: field.idOrTitle, + title: field.idOrTitle, + fieldType: + field.type === "concealed" + ? ItemFieldType.Concealed + : ItemFieldType.Text, + value: field.value, + sectionId: field.section, + })); - const params: ItemCreateParams = { - category: ItemCategory.SecureNote, - vaultId, - title, - notes, - tags, - fields: itemFields.length > 0 ? itemFields : undefined, - }; + const params: ItemCreateParams = { + category: ItemCategory.SecureNote, + vaultId, + title, + notes, + tags, + fields: itemFields.length > 0 ? itemFields : undefined, + }; - const item = await client.items.create(params); + const item = await client.items.create(params); - return jsonResult({ - id: item.id, - title: item.title, - vaultId: item.vaultId, - category: item.category, - tags: item.tags ?? [], - fieldCount: item.fields?.length ?? 0, - }); - } catch (error) { - logError("note_create failed.", error); - return errorResult(error); - } - }, - ); + return jsonResult({ + id: item.id, + title: item.title, + vaultId: item.vaultId, + category: item.category, + tags: item.tags ?? [], + fieldCount: item.fields?.length ?? 0, + }); + } catch (error) { + logError("note_create failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/op-check-ref.ts b/src/tools/op-check-ref.ts index 3bf484f..f1c089b 100644 --- a/src/tools/op-check-ref.ts +++ b/src/tools/op-check-ref.ts @@ -4,8 +4,7 @@ * returning the secret value. Use this to sanity-check a reference before * passing it to op_run. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { getClient } from "../client.js"; import { log, logError } from "../logger.js"; @@ -13,72 +12,67 @@ import { jsonResult, errorResult } from "../utils.js"; import { parseSecretRef, assertVaultAllowed } from "../secret-ref.js"; export function registerOpCheckRef(server: McpServer): void { - server.tool( - "op_check_ref", - "Validate an op://vault/item/field secret reference and return only non-secret metadata (vault name, item title, field label, field type) confirming it resolves — the field VALUE is never returned. Use this to check a reference is correct before using it with op_run; do not use password_read/item_get with reveal just to check a reference exists.", - { - secretReference: z - .string() - .min(1) - .describe("Secret reference to validate, in op://vault/item/field format."), - }, - async ({ secretReference }) => { - try { - log("debug", "Tool call: op_check_ref.", { secretReference: true }); + server.registerTool("op_check_ref", { description: "Validate an op://vault/item/field secret reference and return only non-secret metadata (vault name, item title, field label, field type) confirming it resolves — the field VALUE is never returned. Use this to check a reference is correct before using it with op_run; do not use password_read/item_get with reveal just to check a reference exists.", inputSchema: z.object({ + secretReference: z + .string() + .min(1) + .describe("Secret reference to validate, in op://vault/item/field format."), + }) }, async ({ secretReference }) => { + try { + log("debug", "Tool call: op_check_ref.", { secretReference: true }); - const ref = parseSecretRef(secretReference); - assertVaultAllowed(ref.vault); + const ref = parseSecretRef(secretReference); + assertVaultAllowed(ref.vault); - const client = await getClient(); - if (!client?.secrets?.resolveAll || !client?.items?.get) { - throw new Error( - "Your @1password/sdk version does not support resolving secret references.", - ); - } + const client = await getClient(); + if (!client?.secrets?.resolveAll || !client?.items?.get) { + throw new Error( + "Your @1password/sdk version does not support resolving secret references.", + ); + } - const resolved = await client.secrets.resolveAll([secretReference]); - const response = resolved.individualResponses[secretReference]; - if (!response?.content) { - const reason = response?.error?.type ?? "unknown"; - throw new Error( - `Could not resolve secret reference '${secretReference}' (${reason}).`, - ); - } + const resolved = await client.secrets.resolveAll([secretReference]); + const response = resolved.individualResponses[secretReference]; + if (!response?.content) { + const reason = response?.error?.type ?? "unknown"; + throw new Error( + `Could not resolve secret reference '${secretReference}' (${reason}).`, + ); + } - const { vaultId, itemId } = response.content; - const item: any = await client.items.get(vaultId, itemId); + const { vaultId, itemId } = response.content; + const item: any = await client.items.get(vaultId, itemId); - const desiredField = ref.field.toLowerCase(); - const fields: any[] = item.fields ?? []; - const match = fields.find((candidate: any) => { - const idMatch = candidate.id?.toLowerCase() === desiredField; - const titleMatch = candidate.title?.toLowerCase() === desiredField; - const labelMatch = candidate.label?.toLowerCase() === desiredField; - return idMatch || titleMatch || labelMatch; - }); + const desiredField = ref.field.toLowerCase(); + const fields: any[] = item.fields ?? []; + const match = fields.find((candidate: any) => { + const idMatch = candidate.id?.toLowerCase() === desiredField; + const titleMatch = candidate.title?.toLowerCase() === desiredField; + const labelMatch = candidate.label?.toLowerCase() === desiredField; + return idMatch || titleMatch || labelMatch; + }); - if (!match) { - throw new Error( - `Field '${ref.field}' not found on item '${item.title}'.`, - ); - } + if (!match) { + throw new Error( + `Field '${ref.field}' not found on item '${item.title}'.`, + ); + } - // Deliberately omit match.value — this tool never returns secret plaintext. - return jsonResult({ - resolved: true, - vault: { id: vaultId, name: ref.vault }, - item: { id: item.id, title: item.title, category: item.category }, - field: { - id: match.id, - title: match.title, - type: match.fieldType ?? match.type, - section: match.sectionId, - }, - }); - } catch (error) { - logError("op_check_ref failed.", error); - return errorResult(error); - } - }, - ); + // Deliberately omit match.value — this tool never returns secret plaintext. + return jsonResult({ + resolved: true, + vault: { id: vaultId, name: ref.vault }, + item: { id: item.id, title: item.title, category: item.category }, + field: { + id: match.id, + title: match.title, + type: match.fieldType ?? match.type, + section: match.sectionId, + }, + }); + } catch (error) { + logError("op_check_ref failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/op-run.ts b/src/tools/op-run.ts index 15404b9..4b550e0 100644 --- a/src/tools/op-run.ts +++ b/src/tools/op-run.ts @@ -3,8 +3,7 @@ * environment variables, without ever returning secret plaintext to the * caller. This is the MCP equivalent of `op run -- `. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { spawn } from "node:child_process"; import { z } from "zod"; import { getClient } from "../client.js"; @@ -85,182 +84,177 @@ function truncate(buffer: Buffer): { text: string; truncated: boolean } { } export function registerOpRun(server: McpServer): void { - server.tool( - "op_run", - "Run a local shell command with 1Password secrets injected as environment variables — plaintext secret values are NEVER returned to the caller or written to any log; every resolved secret value is redacted from stdout/stderr before the result is returned. This is the safe way to USE a secret in a command, API call, or script: prefer op_run with op://vault/item/field references in `env` over reading a secret with password_read/item_get and pasting it into a command yourself, which would put the plaintext in the model context and transcript.", - { - command: z - .string() - .optional() - .describe( - "Shell command line to execute (run via the platform shell). Provide either `command` or `argv`, not both.", - ), - argv: z - .array(z.string()) - .optional() - .describe( - "Argument vector [executable, ...args] to execute directly without a shell (safer against quoting/injection issues). Provide either `command` or `argv`, not both.", - ), - cwd: z - .string() - .optional() - .describe("Working directory to run the command in, e.g. a repo checkout path."), - env: z - .record(z.string(), z.string()) - .optional() - .describe( - "Map of ENV_VAR_NAME -> value. A value matching op://vault/item/field is resolved via 1Password and injected as plaintext into the child process env only; any other value is passed through unchanged as a literal.", - ), - shell: z - .string() - .optional() - .describe( - "Optional shell executable to use with `command` (e.g. 'powershell.exe', 'C:/Program Files/Git/bin/bash.exe', '/bin/bash'). Defaults to the platform shell (cmd.exe on Windows, /bin/sh elsewhere). Ignored when `argv` is used.", - ), - timeout_ms: z - .number() - .int() - .positive() - .max(600_000) - .optional() - .describe("Kill the process if it runs longer than this many milliseconds. Default 120000 (2 minutes)."), - stdin: z - .string() - .optional() - .describe("Optional text to write to the process's stdin."), - }, - async ({ command, argv, cwd, env, shell, timeout_ms, stdin }) => { - const startedAt = Date.now(); - let resolvedEnv: ResolvedEnvEntry[] = []; - try { - log("debug", "Tool call: op_run.", { - hasCommand: Boolean(command), - hasArgv: Boolean(argv), - cwd, - envKeys: env ? Object.keys(env) : [], - shell, - timeout_ms, - }); + server.registerTool("op_run", { description: "Run a local shell command with 1Password secrets injected as environment variables — plaintext secret values are NEVER returned to the caller or written to any log; every resolved secret value is redacted from stdout/stderr before the result is returned. This is the safe way to USE a secret in a command, API call, or script: prefer op_run with op://vault/item/field references in `env` over reading a secret with password_read/item_get and pasting it into a command yourself, which would put the plaintext in the model context and transcript.", inputSchema: z.object({ + command: z + .string() + .optional() + .describe( + "Shell command line to execute (run via the platform shell). Provide either `command` or `argv`, not both.", + ), + argv: z + .array(z.string()) + .optional() + .describe( + "Argument vector [executable, ...args] to execute directly without a shell (safer against quoting/injection issues). Provide either `command` or `argv`, not both.", + ), + cwd: z + .string() + .optional() + .describe("Working directory to run the command in, e.g. a repo checkout path."), + env: z + .record(z.string(), z.string()) + .optional() + .describe( + "Map of ENV_VAR_NAME -> value. A value matching op://vault/item/field is resolved via 1Password and injected as plaintext into the child process env only; any other value is passed through unchanged as a literal.", + ), + shell: z + .string() + .optional() + .describe( + "Optional shell executable to use with `command` (e.g. 'powershell.exe', 'C:/Program Files/Git/bin/bash.exe', '/bin/bash'). Defaults to the platform shell (cmd.exe on Windows, /bin/sh elsewhere). Ignored when `argv` is used.", + ), + timeout_ms: z + .number() + .int() + .positive() + .max(600_000) + .optional() + .describe("Kill the process if it runs longer than this many milliseconds. Default 120000 (2 minutes)."), + stdin: z + .string() + .optional() + .describe("Optional text to write to the process's stdin."), + }) }, async ({ command, argv, cwd, env, shell, timeout_ms, stdin }) => { + const startedAt = Date.now(); + let resolvedEnv: ResolvedEnvEntry[] = []; + try { + log("debug", "Tool call: op_run.", { + hasCommand: Boolean(command), + hasArgv: Boolean(argv), + cwd, + envKeys: env ? Object.keys(env) : [], + shell, + timeout_ms, + }); - if (!command && !argv) { - throw new Error("Provide either `command` or `argv`."); - } - if (command && argv) { - throw new Error("Provide only one of `command` or `argv`, not both."); - } - if (argv && argv.length === 0) { - throw new Error("`argv` must contain at least the executable name."); - } + if (!command && !argv) { + throw new Error("Provide either `command` or `argv`."); + } + if (command && argv) { + throw new Error("Provide only one of `command` or `argv`, not both."); + } + if (argv && argv.length === 0) { + throw new Error("`argv` must contain at least the executable name."); + } - resolvedEnv = await resolveEnvEntries(env); - const childEnv: NodeJS.ProcessEnv = { ...process.env }; - for (const entry of resolvedEnv) { - childEnv[entry.name] = entry.value; - } + resolvedEnv = await resolveEnvEntries(env); + const childEnv: NodeJS.ProcessEnv = { ...process.env }; + for (const entry of resolvedEnv) { + childEnv[entry.name] = entry.value; + } - const timeout = timeout_ms ?? DEFAULT_TIMEOUT_MS; + const timeout = timeout_ms ?? DEFAULT_TIMEOUT_MS; - const result = await new Promise<{ - exitCode: number | null; - signal: NodeJS.Signals | null; - stdout: Buffer; - stderr: Buffer; - timedOut: boolean; - spawnError?: Error; - }>((resolve) => { - const stdoutChunks: Buffer[] = []; - const stderrChunks: Buffer[] = []; - let timedOut = false; + const result = await new Promise<{ + exitCode: number | null; + signal: NodeJS.Signals | null; + stdout: Buffer; + stderr: Buffer; + timedOut: boolean; + spawnError?: Error; + }>((resolve) => { + const stdoutChunks: Buffer[] = []; + const stderrChunks: Buffer[] = []; + let timedOut = false; - const child = argv - ? spawn(argv[0], argv.slice(1), { - cwd, - env: childEnv, - shell: false, - timeout, - killSignal: "SIGTERM", - }) - : spawn(command as string, { - cwd, - env: childEnv, - shell: shell ?? true, - timeout, - killSignal: "SIGTERM", - }); + const child = argv + ? spawn(argv[0], argv.slice(1), { + cwd, + env: childEnv, + shell: false, + timeout, + killSignal: "SIGTERM", + }) + : spawn(command as string, { + cwd, + env: childEnv, + shell: shell ?? true, + timeout, + killSignal: "SIGTERM", + }); - child.on("error", (spawnError) => { - resolve({ - exitCode: null, - signal: null, - stdout: Buffer.concat(stdoutChunks), - stderr: Buffer.concat(stderrChunks), - timedOut, - spawnError, - }); - }); + child.on("error", (spawnError) => { + resolve({ + exitCode: null, + signal: null, + stdout: Buffer.concat(stdoutChunks), + stderr: Buffer.concat(stderrChunks), + timedOut, + spawnError, + }); + }); - child.stdout?.on("data", (chunk: Buffer) => stdoutChunks.push(chunk)); - child.stderr?.on("data", (chunk: Buffer) => stderrChunks.push(chunk)); + child.stdout?.on("data", (chunk: Buffer) => stdoutChunks.push(chunk)); + child.stderr?.on("data", (chunk: Buffer) => stderrChunks.push(chunk)); - if (stdin !== undefined && child.stdin) { - child.stdin.write(stdin); - } - child.stdin?.end(); + if (stdin !== undefined && child.stdin) { + child.stdin.write(stdin); + } + child.stdin?.end(); - child.on("close", (code, signal) => { - if (signal === "SIGTERM" || signal === "SIGKILL") { - // Node sets a timeout-triggered kill signal; heuristically - // treat it as a timeout when we hit/exceed the deadline. - timedOut = Date.now() - startedAt >= timeout; - } - resolve({ - exitCode: code, - signal, - stdout: Buffer.concat(stdoutChunks), - stderr: Buffer.concat(stderrChunks), - timedOut, - }); - }); - }); + child.on("close", (code, signal) => { + if (signal === "SIGTERM" || signal === "SIGKILL") { + // Node sets a timeout-triggered kill signal; heuristically + // treat it as a timeout when we hit/exceed the deadline. + timedOut = Date.now() - startedAt >= timeout; + } + resolve({ + exitCode: code, + signal, + stdout: Buffer.concat(stdoutChunks), + stderr: Buffer.concat(stderrChunks), + timedOut, + }); + }); + }); - const durationMs = Date.now() - startedAt; - const { text: stdoutRaw, truncated: stdoutTruncated } = truncate(result.stdout); - const { text: stderrRaw, truncated: stderrTruncated } = truncate(result.stderr); + const durationMs = Date.now() - startedAt; + const { text: stdoutRaw, truncated: stdoutTruncated } = truncate(result.stdout); + const { text: stderrRaw, truncated: stderrTruncated } = truncate(result.stderr); - const stdout = redact(stdoutRaw, resolvedEnv); - const stderr = redact(stderrRaw, resolvedEnv); + const stdout = redact(stdoutRaw, resolvedEnv); + const stderr = redact(stderrRaw, resolvedEnv); - if (result.spawnError) { - const message = redact(result.spawnError.message, resolvedEnv); - logError("op_run spawn failed.", new Error(message)); - return errorResult(new Error(message)); - } + if (result.spawnError) { + const message = redact(result.spawnError.message, resolvedEnv); + logError("op_run spawn failed.", new Error(message)); + return errorResult(new Error(message)); + } - log("debug", "op_run completed.", { - exitCode: result.exitCode, - signal: result.signal, - durationMs, - timedOut: result.timedOut, - }); + log("debug", "op_run completed.", { + exitCode: result.exitCode, + signal: result.signal, + durationMs, + timedOut: result.timedOut, + }); - return jsonResult({ - exitCode: result.exitCode, - signal: result.signal, - timedOut: result.timedOut, - stdout, - stderr, - stdoutTruncated, - stderrTruncated, - durationMs, - }); - } catch (error) { - // Redact even on the error path in case a partially-resolved secret - // ended up embedded in the thrown error's message. - const message = error instanceof Error ? redact(error.message, resolvedEnv) : String(error); - const safeError = new Error(message); - logError("op_run failed.", safeError); - return errorResult(safeError); - } - }, - ); + return jsonResult({ + exitCode: result.exitCode, + signal: result.signal, + timedOut: result.timedOut, + stdout, + stderr, + stdoutTruncated, + stderrTruncated, + durationMs, + }); + } catch (error) { + // Redact even on the error path in case a partially-resolved secret + // ended up embedded in the thrown error's message. + const message = error instanceof Error ? redact(error.message, resolvedEnv) : String(error); + const safeError = new Error(message); + logError("op_run failed.", safeError); + return errorResult(safeError); + } + }); } diff --git a/src/tools/password-create.ts b/src/tools/password-create.ts index d373dd1..ff634ba 100644 --- a/src/tools/password-create.ts +++ b/src/tools/password-create.ts @@ -1,8 +1,7 @@ /** * password_create — Create a new password item in a 1Password vault. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import * as sdk from "@1password/sdk"; import { getClient } from "../client.js"; @@ -10,112 +9,107 @@ import { log, logError } from "../logger.js"; import { jsonResult, errorResult } from "../utils.js"; export function registerPasswordCreate(server: McpServer): void { - server.tool( - "password_create", - "Create a new password/login item in a 1Password vault with optional username, URL, tags, and notes.", - { - vaultId: z.string().min(1).describe("Vault ID to create the item in."), - title: z.string().min(1).describe("Item title."), - username: z - .string() - .optional() - .describe("Username to store in the item."), - password: z.string().min(1).describe("Password to store in the item."), - category: z - .enum(["Login", "Password"]) - .optional() - .describe("Item category. Defaults to Login."), - tags: z - .array(z.string().min(1)) - .optional() - .describe("Optional tags for organization."), - notes: z.string().optional().describe("Optional notes."), - url: z - .string() - .url() - .optional() - .describe("Optional website URL to associate."), - returnSecret: z - .boolean() - .optional() - .describe( - "If true, include the created password in the response. Defaults to false for security.", - ), - }, - async ({ - vaultId, - title, - username, - password, - category, - tags, - notes, - url, - returnSecret, - }) => { - try { - log("debug", "Tool call: password_create.", { vaultId, title }); - const client = await getClient(); - if (!client?.items?.create) { - throw new Error( - "Your @1password/sdk version does not support creating items.", - ); - } + server.registerTool("password_create", { description: "Create a new password/login item in a 1Password vault with optional username, URL, tags, and notes.", inputSchema: z.object({ + vaultId: z.string().min(1).describe("Vault ID to create the item in."), + title: z.string().min(1).describe("Item title."), + username: z + .string() + .optional() + .describe("Username to store in the item."), + password: z.string().min(1).describe("Password to store in the item."), + category: z + .enum(["Login", "Password"]) + .optional() + .describe("Item category. Defaults to Login."), + tags: z + .array(z.string().min(1)) + .optional() + .describe("Optional tags for organization."), + notes: z.string().optional().describe("Optional notes."), + url: z + .string() + .url() + .optional() + .describe("Optional website URL to associate."), + returnSecret: z + .boolean() + .optional() + .describe( + "If true, include the created password in the response. Defaults to false for security.", + ), + }) }, async ({ + vaultId, + title, + username, + password, + category, + tags, + notes, + url, + returnSecret, + }) => { + try { + log("debug", "Tool call: password_create.", { vaultId, title }); + const client = await getClient(); + if (!client?.items?.create) { + throw new Error( + "Your @1password/sdk version does not support creating items.", + ); + } - const fields: Array<{ - id: string; - title: string; - fieldType: string; - value: string; - }> = []; + const fields: Array<{ + id: string; + title: string; + fieldType: string; + value: string; + }> = []; - if (username) { - fields.push({ - id: "username", - title: "username", - fieldType: sdk.ItemFieldType.Text, - value: username, - }); - } + if (username) { + fields.push({ + id: "username", + title: "username", + fieldType: sdk.ItemFieldType.Text, + value: username, + }); + } - fields.push({ - id: "password", - title: "password", - fieldType: sdk.ItemFieldType.Concealed, - value: password, - }); + fields.push({ + id: "password", + title: "password", + fieldType: sdk.ItemFieldType.Concealed, + value: password, + }); - const categoryEnum = - (category ?? "Login") === "Password" - ? sdk.ItemCategory.Password - : sdk.ItemCategory.Login; + const categoryEnum = + (category ?? "Login") === "Password" + ? sdk.ItemCategory.Password + : sdk.ItemCategory.Login; - const item = await client.items.create({ - title, - category: categoryEnum, - vaultId, - fields, - tags, - notes, - websites: url ? [{ url }] : undefined, - } as any); + const item = await client.items.create({ + title, + category: categoryEnum, + vaultId, + fields, + tags, + notes, + websites: url ? [{ url }] : undefined, + } as any); - const response: Record = { - id: item.id, - title: item.title, - vaultId: (item as any).vaultId ?? vaultId, - category: item.category, - }; + const response: Record = { + id: item.id, + title: item.title, + vaultId: (item as any).vaultId ?? vaultId, + category: item.category, + }; - if (returnSecret) { - response.password = password; - } + if (returnSecret) { + response.password = password; + } - return jsonResult(response); - } catch (error) { - logError("password_create failed.", error); - return errorResult(error); - } - }, - ); + return jsonResult(response); + } catch (error) { + logError("password_create failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/password-generate-memorable.ts b/src/tools/password-generate-memorable.ts index 194e920..2a20f67 100644 --- a/src/tools/password-generate-memorable.ts +++ b/src/tools/password-generate-memorable.ts @@ -1,8 +1,7 @@ /** * password_generate_memorable — Generate a memorable passphrase from random words. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { log, logError } from "../logger.js"; import { @@ -12,64 +11,59 @@ import { } from "../utils.js"; export function registerPasswordGenerateMemorable(server: McpServer): void { - server.tool( - "password_generate_memorable", - "Generate a memorable passphrase from random dictionary words with optional number and symbol suffixes. Uses a ~500-word curated list for good entropy.", - { - wordCount: z - .number() - .int() - .min(2) - .max(10) - .optional() - .describe("Number of words to include. Defaults to 3."), - separator: z - .string() - .max(5) - .optional() - .describe("Separator between words. Defaults to '-'."), - includeNumber: z - .boolean() - .optional() - .describe("Append a random number (0-99) at the end. Defaults to true."), - includeSymbol: z - .boolean() - .optional() - .describe("Append a random symbol at the end. Defaults to true."), - capitalize: z - .boolean() - .optional() - .describe("Capitalize each word. Defaults to true."), - }, - async ({ - wordCount = 3, - separator = "-", - includeNumber = true, - includeSymbol = true, - capitalize = true, - }) => { - try { - log("debug", "Tool call: password_generate_memorable.", { - wordCount, - separator, - includeNumber, - includeSymbol, - capitalize, - }); + server.registerTool("password_generate_memorable", { description: "Generate a memorable passphrase from random dictionary words with optional number and symbol suffixes. Uses a ~500-word curated list for good entropy.", inputSchema: z.object({ + wordCount: z + .number() + .int() + .min(2) + .max(10) + .optional() + .describe("Number of words to include. Defaults to 3."), + separator: z + .string() + .max(5) + .optional() + .describe("Separator between words. Defaults to '-'."), + includeNumber: z + .boolean() + .optional() + .describe("Append a random number (0-99) at the end. Defaults to true."), + includeSymbol: z + .boolean() + .optional() + .describe("Append a random symbol at the end. Defaults to true."), + capitalize: z + .boolean() + .optional() + .describe("Capitalize each word. Defaults to true."), + }) }, async ({ + wordCount = 3, + separator = "-", + includeNumber = true, + includeSymbol = true, + capitalize = true, + }) => { + try { + log("debug", "Tool call: password_generate_memorable.", { + wordCount, + separator, + includeNumber, + includeSymbol, + capitalize, + }); - const password = generateMemorablePassword({ - wordCount, - separator, - includeNumber, - includeSymbol, - capitalize, - }); + const password = generateMemorablePassword({ + wordCount, + separator, + includeNumber, + includeSymbol, + capitalize, + }); - return jsonResult({ password }); - } catch (error) { - logError("password_generate_memorable failed.", error); - return errorResult(error); - } - }, - ); + return jsonResult({ password }); + } catch (error) { + logError("password_generate_memorable failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/password-generate.ts b/src/tools/password-generate.ts index d8f2d81..ce968eb 100644 --- a/src/tools/password-generate.ts +++ b/src/tools/password-generate.ts @@ -1,8 +1,7 @@ /** * password_generate — Generate a cryptographically secure random password. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { log, logError } from "../logger.js"; import { @@ -13,56 +12,51 @@ import { } from "../utils.js"; export function registerPasswordGenerate(server: McpServer): void { - server.tool( - "password_generate", - "Generate a cryptographically secure random password with configurable length and character types. Uses rejection sampling for unbiased randomness.", - { - length: z - .number() - .int() - .min(8) - .max(128) - .optional() - .describe("Length of the password. Defaults to 20."), - includeSymbols: z - .boolean() - .optional() - .describe("Include symbols (!@#$%^&*…). Defaults to true."), - includeNumbers: z - .boolean() - .optional() - .describe("Include digits (0-9). Defaults to true."), - includeUppercase: z - .boolean() - .optional() - .describe("Include uppercase letters. Defaults to true."), - }, - async ({ - length = 20, - includeSymbols = true, - includeNumbers = true, - includeUppercase = true, - }) => { - try { - log("debug", "Tool call: password_generate.", { - length, - includeSymbols, - includeNumbers, - includeUppercase, - }); + server.registerTool("password_generate", { description: "Generate a cryptographically secure random password with configurable length and character types. Uses rejection sampling for unbiased randomness.", inputSchema: z.object({ + length: z + .number() + .int() + .min(8) + .max(128) + .optional() + .describe("Length of the password. Defaults to 20."), + includeSymbols: z + .boolean() + .optional() + .describe("Include symbols (!@#$%^&*…). Defaults to true."), + includeNumbers: z + .boolean() + .optional() + .describe("Include digits (0-9). Defaults to true."), + includeUppercase: z + .boolean() + .optional() + .describe("Include uppercase letters. Defaults to true."), + }) }, async ({ + length = 20, + includeSymbols = true, + includeNumbers = true, + includeUppercase = true, + }) => { + try { + log("debug", "Tool call: password_generate.", { + length, + includeSymbols, + includeNumbers, + includeUppercase, + }); - const charset = buildCharset({ - includeUppercase, - includeNumbers, - includeSymbols, - }); - const password = generatePassword(length, charset); + const charset = buildCharset({ + includeUppercase, + includeNumbers, + includeSymbols, + }); + const password = generatePassword(length, charset); - return jsonResult({ password }); - } catch (error) { - logError("password_generate failed.", error); - return errorResult(error); - } - }, - ); + return jsonResult({ password }); + } catch (error) { + logError("password_generate failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/password-read.ts b/src/tools/password-read.ts index 718a8bd..a32d778 100644 --- a/src/tools/password-read.ts +++ b/src/tools/password-read.ts @@ -1,114 +1,108 @@ /** * password_read — Retrieve a password or field from a 1Password item. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import { getClient } from "../client.js"; import { log, logError } from "../logger.js"; import { jsonResult, errorResult } from "../utils.js"; export function registerPasswordRead(server: McpServer): void { - server.tool( - "password_read", - "Retrieve a secret from 1Password using either a secret reference (op://vault/item/field) or vault ID + item ID. Supports field selection and optional value reveal (defaults to metadata-only). Revealing a secret puts it in the model context/transcript — to USE a secret in a command or API call, prefer op_run with op:// references instead.", - { - secretReference: z - .string() - .optional() - .describe( - "Secret reference in op://vault/item/field format. If provided, vaultId and itemId are ignored.", - ), - vaultId: z - .string() - .optional() - .describe("Vault ID for item lookup (required if secretReference is not provided)."), - itemId: z - .string() - .optional() - .describe("Item ID for item lookup (required if secretReference is not provided)."), - field: z - .string() - .optional() - .describe("Field id or title to read. Defaults to 'password'."), - reveal: z - .boolean() - .optional() - .describe( - "If true, include the secret value in plaintext in the response — this puts the secret in the model context/transcript. Defaults to false; prefer op_run to use a secret without revealing it.", - ), - }, - async ({ secretReference, vaultId, itemId, field, reveal }) => { - try { - log("debug", "Tool call: password_read.", { - secretReference: Boolean(secretReference), - vaultId, - itemId, - field, - reveal, - }); - const client = await getClient(); - const shouldReveal = reveal === true; + server.registerTool("password_read", { description: "Retrieve a secret from 1Password using either a secret reference (op://vault/item/field) or vault ID + item ID. Supports field selection and optional value reveal (defaults to metadata-only). Revealing a secret puts it in the model context/transcript — to USE a secret in a command or API call, prefer op_run with op:// references instead.", inputSchema: z.object({ + secretReference: z + .string() + .optional() + .describe( + "Secret reference in op://vault/item/field format. If provided, vaultId and itemId are ignored.", + ), + vaultId: z + .string() + .optional() + .describe("Vault ID for item lookup (required if secretReference is not provided)."), + itemId: z + .string() + .optional() + .describe("Item ID for item lookup (required if secretReference is not provided)."), + field: z + .string() + .optional() + .describe("Field id or title to read. Defaults to 'password'."), + reveal: z + .boolean() + .optional() + .describe( + "If true, include the secret value in plaintext in the response — this puts the secret in the model context/transcript. Defaults to false; prefer op_run to use a secret without revealing it.", + ), + }) }, async ({ secretReference, vaultId, itemId, field, reveal }) => { + try { + log("debug", "Tool call: password_read.", { + secretReference: Boolean(secretReference), + vaultId, + itemId, + field, + reveal, + }); + const client = await getClient(); + const shouldReveal = reveal === true; - if (secretReference) { - if (!client?.secrets?.resolve) { - throw new Error( - "Your @1password/sdk version does not support resolving secrets.", - ); - } - const value = await client.secrets.resolve(secretReference); - if (!shouldReveal) { - return jsonResult({ resolved: true }); - } - return jsonResult({ value }); - } + if (secretReference) { + if (!client?.secrets?.resolve) { + throw new Error( + "Your @1password/sdk version does not support resolving secrets.", + ); + } + const value = await client.secrets.resolve(secretReference); + if (!shouldReveal) { + return jsonResult({ resolved: true }); + } + return jsonResult({ value }); + } - if (!vaultId || !itemId) { - throw new Error( - "Provide secretReference or both vaultId and itemId.", - ); - } + if (!vaultId || !itemId) { + throw new Error( + "Provide secretReference or both vaultId and itemId.", + ); + } - if (!client?.items?.get) { - throw new Error( - "Your @1password/sdk version does not support getting items.", - ); - } + if (!client?.items?.get) { + throw new Error( + "Your @1password/sdk version does not support getting items.", + ); + } - const item = await client.items.get(vaultId, itemId); - const desiredField = (field ?? "password").toLowerCase(); - const fields: any[] = (item as any).fields ?? []; - const match = fields.find((candidate: any) => { - const idMatch = candidate.id?.toLowerCase() === desiredField; - const titleMatch = candidate.title?.toLowerCase() === desiredField; - const labelMatch = candidate.label?.toLowerCase() === desiredField; - return idMatch || titleMatch || labelMatch; - }); + const item = await client.items.get(vaultId, itemId); + const desiredField = (field ?? "password").toLowerCase(); + const fields: any[] = (item as any).fields ?? []; + const match = fields.find((candidate: any) => { + const idMatch = candidate.id?.toLowerCase() === desiredField; + const titleMatch = candidate.title?.toLowerCase() === desiredField; + const labelMatch = candidate.label?.toLowerCase() === desiredField; + return idMatch || titleMatch || labelMatch; + }); - if (!match) { - throw new Error(`Field '${desiredField}' not found on item.`); - } + if (!match) { + throw new Error(`Field '${desiredField}' not found on item.`); + } - if (!shouldReveal) { - return jsonResult({ - id: item.id, - title: item.title, - field: match.id ?? match.title, - fieldType: match.fieldType ?? match.type, - }); - } + if (!shouldReveal) { + return jsonResult({ + id: item.id, + title: item.title, + field: match.id ?? match.title, + fieldType: match.fieldType ?? match.type, + }); + } - const value = match.value; - if (typeof value !== "string") { - throw new Error( - "Field value is not a string and cannot be returned.", - ); - } - return jsonResult({ value }); - } catch (error) { - logError("password_read failed.", error); - return errorResult(error); - } - }, - ); + const value = match.value; + if (typeof value !== "string") { + throw new Error( + "Field value is not a string and cannot be returned.", + ); + } + return jsonResult({ value }); + } catch (error) { + logError("password_read failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/password-update.ts b/src/tools/password-update.ts index 217a4b5..8143b38 100644 --- a/src/tools/password-update.ts +++ b/src/tools/password-update.ts @@ -1,8 +1,7 @@ /** * password_update — Update a password field on an existing 1Password item. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { z } from "zod"; import * as sdk from "@1password/sdk"; import { getClient } from "../client.js"; @@ -10,92 +9,87 @@ import { log, logError } from "../logger.js"; import { jsonResult, errorResult } from "../utils.js"; export function registerPasswordUpdate(server: McpServer): void { - server.tool( - "password_update", - "Update (rotate) a password or concealed field on an existing 1Password item. If the target field does not exist, it will be created.", - { - vaultId: z.string().min(1).describe("Vault ID containing the item."), - itemId: z.string().min(1).describe("Item ID to update."), - newPassword: z.string().min(1).describe("New password value."), - field: z - .string() - .optional() - .describe( - "Field id or title to update. Defaults to 'password'.", - ), - returnSecret: z - .boolean() - .optional() - .describe( - "If true, include the updated password in the response. Defaults to false for security.", - ), - }, - async ({ vaultId, itemId, newPassword, field, returnSecret }) => { - try { - log("debug", "Tool call: password_update.", { - vaultId, - itemId, - field, - }); - const client = await getClient(); - if (!client?.items?.get) { - throw new Error( - "Your @1password/sdk version does not support getting items.", - ); - } - if (!client?.items?.put) { - throw new Error( - "Your @1password/sdk version does not support updating items.", - ); - } + server.registerTool("password_update", { description: "Update (rotate) a password or concealed field on an existing 1Password item. If the target field does not exist, it will be created.", inputSchema: z.object({ + vaultId: z.string().min(1).describe("Vault ID containing the item."), + itemId: z.string().min(1).describe("Item ID to update."), + newPassword: z.string().min(1).describe("New password value."), + field: z + .string() + .optional() + .describe( + "Field id or title to update. Defaults to 'password'.", + ), + returnSecret: z + .boolean() + .optional() + .describe( + "If true, include the updated password in the response. Defaults to false for security.", + ), + }) }, async ({ vaultId, itemId, newPassword, field, returnSecret }) => { + try { + log("debug", "Tool call: password_update.", { + vaultId, + itemId, + field, + }); + const client = await getClient(); + if (!client?.items?.get) { + throw new Error( + "Your @1password/sdk version does not support getting items.", + ); + } + if (!client?.items?.put) { + throw new Error( + "Your @1password/sdk version does not support updating items.", + ); + } - const item = await client.items.get(vaultId, itemId); - const desiredField = (field ?? "password").toLowerCase(); - const fields: any[] = Array.isArray((item as any).fields) - ? [...(item as any).fields] - : []; - let updated = false; + const item = await client.items.get(vaultId, itemId); + const desiredField = (field ?? "password").toLowerCase(); + const fields: any[] = Array.isArray((item as any).fields) + ? [...(item as any).fields] + : []; + let updated = false; - for (const candidate of fields) { - const idMatch = candidate.id?.toLowerCase() === desiredField; - const titleMatch = - candidate.title?.toLowerCase() === desiredField; - const labelMatch = - candidate.label?.toLowerCase() === desiredField; - if (idMatch || titleMatch || labelMatch) { - candidate.value = newPassword; - updated = true; - break; - } - } + for (const candidate of fields) { + const idMatch = candidate.id?.toLowerCase() === desiredField; + const titleMatch = + candidate.title?.toLowerCase() === desiredField; + const labelMatch = + candidate.label?.toLowerCase() === desiredField; + if (idMatch || titleMatch || labelMatch) { + candidate.value = newPassword; + updated = true; + break; + } + } - if (!updated) { - fields.push({ - id: desiredField, - title: desiredField, - fieldType: sdk.ItemFieldType.Concealed, - value: newPassword, - }); - } + if (!updated) { + fields.push({ + id: desiredField, + title: desiredField, + fieldType: sdk.ItemFieldType.Concealed, + value: newPassword, + }); + } - (item as any).fields = fields; - const updatedItem = await client.items.put(item); + (item as any).fields = fields; + const updatedItem = await client.items.put(item); - const response: Record = { - id: updatedItem.id, - title: updatedItem.title, - vaultId: (updatedItem as any).vaultId ?? vaultId, - }; + const response: Record = { + id: updatedItem.id, + title: updatedItem.title, + vaultId: (updatedItem as any).vaultId ?? vaultId, + }; - if (returnSecret) { - response.password = newPassword; - } + if (returnSecret) { + response.password = newPassword; + } - return jsonResult(response); - } catch (error) { - logError("password_update failed.", error); - return errorResult(error); - } - }, - ); + return jsonResult(response); + } catch (error) { + logError("password_update failed.", error); + return errorResult(error); + } + }); } diff --git a/src/tools/vault-list.ts b/src/tools/vault-list.ts index 1210e74..fd5f93b 100644 --- a/src/tools/vault-list.ts +++ b/src/tools/vault-list.ts @@ -1,42 +1,37 @@ /** * vault_list — List all accessible 1Password vaults. */ - -import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; +import type { McpServer } from "@modelcontextprotocol/server"; import { getClient } from "../client.js"; import { log, logError } from "../logger.js"; import { jsonResult, errorResult } from "../utils.js"; import type { VaultSummary } from "../types.js"; +import { z } from "zod"; export function registerVaultList(server: McpServer): void { - server.tool( - "vault_list", - "List all 1Password vaults accessible to the service account. Returns vault IDs, names, descriptions, and types.", - {}, - async () => { - try { - log("debug", "Tool call: vault_list."); - const client = await getClient(); - const listFn = client?.vaults?.list ?? (client?.vaults as any)?.listAll; - if (!listFn) { - throw new Error( - "Your @1password/sdk version does not support listing vaults.", - ); - } - const vaults = await listFn.call(client.vaults); - const summary: VaultSummary[] = (vaults ?? []).map( - (vault: any) => ({ - id: vault.id, - name: vault.name ?? vault.title, - description: vault.description, - type: vault.type, - }), - ); - return jsonResult({ vaults: summary }); - } catch (error) { - logError("vault_list failed.", error); - return errorResult(error); - } - }, - ); + server.registerTool("vault_list", { description: "List all 1Password vaults accessible to the service account. Returns vault IDs, names, descriptions, and types.", inputSchema: z.object({}) }, async () => { + try { + log("debug", "Tool call: vault_list."); + const client = await getClient(); + const listFn = client?.vaults?.list ?? (client?.vaults as any)?.listAll; + if (!listFn) { + throw new Error( + "Your @1password/sdk version does not support listing vaults.", + ); + } + const vaults = await listFn.call(client.vaults); + const summary: VaultSummary[] = (vaults ?? []).map( + (vault: any) => ({ + id: vault.id, + name: vault.name ?? vault.title, + description: vault.description, + type: vault.type, + }), + ); + return jsonResult({ vaults: summary }); + } catch (error) { + logError("vault_list failed.", error); + return errorResult(error); + } + }); } diff --git a/tests/op-check-ref.test.ts b/tests/op-check-ref.test.ts index 2ef7af3..c3891ea 100644 --- a/tests/op-check-ref.test.ts +++ b/tests/op-check-ref.test.ts @@ -4,6 +4,7 @@ */ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; +import { McpServer } from "@modelcontextprotocol/server"; vi.mock("../src/client.js", () => ({ getClient: vi.fn(), @@ -15,8 +16,6 @@ vi.mock("../src/logger.js", () => ({ log: vi.fn(), logError: vi.fn(), })); - -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { getClient } from "../src/client.js"; import { resetConfig } from "../src/config.js"; import { registerAllTools } from "../src/tools/index.js"; @@ -35,17 +34,16 @@ describe("op_check_ref", () => { server = new McpServer({ name: "test", version: "0.0.0" }); registeredTools = new Map(); - const originalTool = server.tool.bind(server); - vi.spyOn(server, "tool").mockImplementation((...args: any[]) => { - if (args.length === 4) { - registeredTools.set(args[0], { - description: args[1], - schema: args[2], - handler: args[3], - }); - } - return originalTool(...args); - }); + const originalTool = server.registerTool.bind(server); + vi.spyOn(server, "registerTool").mockImplementation(((...args: any[]) => { + const [name, config, handler] = args; + registeredTools.set(name, { + description: config.description, + schema: config.inputSchema, + handler, + }); + return originalTool(...(args as Parameters)); + }) as any); registerAllTools(server); }); diff --git a/tests/op-run.test.ts b/tests/op-run.test.ts index 1ea172b..9976b10 100644 --- a/tests/op-run.test.ts +++ b/tests/op-run.test.ts @@ -8,6 +8,7 @@ */ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; +import { McpServer } from "@modelcontextprotocol/server"; vi.mock("../src/client.js", () => ({ getClient: vi.fn(), @@ -19,8 +20,6 @@ vi.mock("../src/logger.js", () => ({ log: vi.fn(), logError: vi.fn(), })); - -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { getClient } from "../src/client.js"; import { resetConfig } from "../src/config.js"; import { registerAllTools } from "../src/tools/index.js"; @@ -40,17 +39,16 @@ describe("op_run", () => { server = new McpServer({ name: "test", version: "0.0.0" }); registeredTools = new Map(); - const originalTool = server.tool.bind(server); - vi.spyOn(server, "tool").mockImplementation((...args: any[]) => { - if (args.length === 4) { - registeredTools.set(args[0], { - description: args[1], - schema: args[2], - handler: args[3], - }); - } - return originalTool(...args); - }); + const originalTool = server.registerTool.bind(server); + vi.spyOn(server, "registerTool").mockImplementation(((...args: any[]) => { + const [name, config, handler] = args; + registeredTools.set(name, { + description: config.description, + schema: config.inputSchema, + handler, + }); + return originalTool(...(args as Parameters)); + }) as any); registerAllTools(server); }); diff --git a/tests/prompts.test.ts b/tests/prompts.test.ts index 1c3ef1b..a13464f 100644 --- a/tests/prompts.test.ts +++ b/tests/prompts.test.ts @@ -3,6 +3,7 @@ */ import { describe, it, expect, vi, beforeEach } from "vitest"; +import { McpServer } from "@modelcontextprotocol/server"; // Mock the client and logger vi.mock("../src/client.js", () => ({ @@ -13,8 +14,6 @@ vi.mock("../src/logger.js", () => ({ log: vi.fn(), logError: vi.fn(), })); - -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { registerAllPrompts } from "../src/prompts/index.js"; describe("MCP Prompts", () => { @@ -26,18 +25,16 @@ describe("MCP Prompts", () => { server = new McpServer({ name: "test", version: "0.0.0" }); registeredPrompts = new Map(); - const originalPrompt = server.prompt.bind(server); - vi.spyOn(server, "prompt").mockImplementation((...args: any[]) => { - // (name, description, params, handler) - if (args.length === 4) { - registeredPrompts.set(args[0], { - description: args[1], - params: args[2], - handler: args[3], - }); - } - return originalPrompt(...args); - }); + const originalPrompt = server.registerPrompt.bind(server); + vi.spyOn(server, "registerPrompt").mockImplementation(((...args: any[]) => { + const [name, config, handler] = args; + registeredPrompts.set(name, { + description: config.description, + params: config.argsSchema, + handler, + }); + return originalPrompt(...(args as Parameters)); + }) as any); registerAllPrompts(server); }); diff --git a/tests/tools.test.ts b/tests/tools.test.ts index c9847ab..f92a6d4 100644 --- a/tests/tools.test.ts +++ b/tests/tools.test.ts @@ -3,6 +3,7 @@ */ import { describe, it, expect, vi, beforeEach } from "vitest"; +import { McpServer } from "@modelcontextprotocol/server"; // Mock the client module before importing tools vi.mock("../src/client.js", () => ({ @@ -16,8 +17,6 @@ vi.mock("../src/logger.js", () => ({ log: vi.fn(), logError: vi.fn(), })); - -import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { getClient } from "../src/client.js"; import { registerAllTools } from "../src/tools/index.js"; @@ -33,18 +32,16 @@ describe("MCP Tools", () => { // Spy on server.tool to capture registered handlers registeredTools = new Map(); - const originalTool = server.tool.bind(server); - vi.spyOn(server, "tool").mockImplementation((...args: any[]) => { - // The 4-arg overload: (name, description, schema, handler) - if (args.length === 4) { - registeredTools.set(args[0], { - description: args[1], - schema: args[2], - handler: args[3], - }); - } - return originalTool(...args); - }); + const originalTool = server.registerTool.bind(server); + vi.spyOn(server, "registerTool").mockImplementation(((...args: any[]) => { + const [name, config, handler] = args; + registeredTools.set(name, { + description: config.description, + schema: config.inputSchema, + handler, + }); + return originalTool(...(args as Parameters)); + }) as any); registerAllTools(server); }); @@ -80,14 +77,14 @@ describe("MCP Tools", () => { const itemGet = registeredTools.get("item_get")!; expect(itemGet.description).toContain("op://vault/item/field"); - expect(itemGet.schema.secretReference.description).toContain( + expect(itemGet.schema.shape.secretReference.description).toContain( "op://vault/item/field", ); }); it("documents note_create custom fields as id or title", () => { const noteCreate = registeredTools.get("note_create")!; - const fieldInput = noteCreate.schema.fields.unwrap().element; + const fieldInput = noteCreate.schema.shape.fields.unwrap().element; expect(fieldInput.shape.idOrTitle.description).toBe("Field id or title to create."); });