diff --git a/CHANGELOG.md b/CHANGELOG.md index 7252192..a0156c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ All notable changes to this project will be documented in this file. -## [Unreleased] +## [0.4.0] - 2026-11-12 + +This is the last release. The LPM CLI serves MCP itself from version 0.86.0, as `lpm mcp serve`; run `lpm mcp setup` to move your editors to it. + +### Changed + +- **Hands off to `lpm mcp serve`.** When the server finds LPM CLI 0.86.0 or later, at `LPM_CLI_PATH` or as `lpm` on `PATH` outside the project, it starts `lpm mcp serve` on its stdio and passes stop signals on, so editors that start this package get the LPM CLI's server. With an earlier CLI, or none, it serves its own tools as before. An earlier CLI's `lpm mcp serve` runs this package, and a server started that way never hands off again. +- **Says it is retired.** The server's instructions to agents and its log line say how to move to `lpm mcp serve`. ### Fixed diff --git a/README.md b/README.md index a82155f..64d4db2 100644 --- a/README.md +++ b/README.md @@ -1,147 +1,47 @@ # @lpm-registry/mcp-server -MCP (Model Context Protocol) server for the [LPM](https://lpm.dev) package registry. Gives AI tools like Claude Code, Cursor, and other MCP-compatible agents access to search, browse source code, install packages, check quality, and more. +**This package is retired and gets no more updates.** +The LPM CLI serves MCP itself from version 0.86.0, as `lpm mcp serve`. +It has the current LPM.dev Registry tools and tools that install, add, and audit packages in your projects. -## Quick Setup +## Move to `lpm mcp serve` -If you have the [LPM CLI](https://lpm.dev/docs/cli) installed, one command configures all your editors: +Upgrade the LPM CLI to 0.86.0 or later, for example with `lpm self-update`. Then point your editors at its server: ```bash lpm mcp setup ``` -This auto-detects Claude Code, Cursor, VS Code, Claude Desktop, and Windsurf, then writes the correct config to each. Authentication is handled via `lpm login` (stored in your OS keychain) — no tokens in config files. +Restart your editors. +`lpm mcp setup` writes the server entry named `lpm-registry`, the name earlier setups and this README used, so it replaces that entry. +Remove an entry you named differently with `lpm mcp remove `, and edit project files such as `.vscode/mcp.json` by hand. +See [MCP servers](https://cli.lpm.dev/docs/reference/mcp-servers) in the LPM CLI documentation. -The generated command is `npx -y @lpm-registry/mcp-server@latest`. The `latest` dist-tag is resolved when the editor starts, so editor restarts pick up the current published MCP server release. +To use the registry tools without the LPM CLI, connect your MCP client to `https://lpm.dev/mcp`. +It signs you in through LPM.dev in your browser. See [the LPM.dev MCP server](https://lpm.dev/docs/ai/mcp). -For a custom registry, set `LPM_REGISTRY_URL` in the environment inherited by your editor or add it to the editor's MCP server environment configuration. +## What this last version does -## Manual Setup +Editors may still start this package, for example through `npx -y @lpm-registry/mcp-server@latest`. -If you prefer manual configuration, add to your editor's MCP config: +- If it finds LPM CLI 0.86.0 or later, it starts `lpm mcp serve` in its place, and the editor gets the LPM CLI's server. + It looks for the CLI at `LPM_CLI_PATH`, or as `lpm` on `PATH` outside the current project. +- Otherwise it serves the tools of earlier versions, and tells the editor's agent that it is retired. + `lpm mcp serve` in LPM CLI releases before 0.86.0 runs this package, so those releases keep working until you upgrade. -### Claude Code +## Renamed tools -```json -{ - "mcpServers": { - "lpm-registry": { - "command": "npx", - "args": ["-y", "@lpm-registry/mcp-server@latest"] - } - } -} -``` - -### Cursor (`.cursor/mcp.json`) - -```json -{ - "mcpServers": { - "lpm-registry": { - "command": "npx", - "args": ["-y", "@lpm-registry/mcp-server@latest"] - } - } -} -``` - -### VS Code (`.vscode/mcp.json`) - -```json -{ - "servers": { - "lpm-registry": { - "command": "npx", - "args": ["-y", "@lpm-registry/mcp-server@latest"] - } - } -} -``` - -### Claude Desktop (`claude_desktop_config.json`) - -```json -{ - "mcpServers": { - "lpm-registry": { - "command": "npx", - "args": ["-y", "@lpm-registry/mcp-server@latest"] - } - } -} -``` - -## Authentication - -`LPM_TOKEN` has highest priority. When it is unset, the server reads the OS keychain entry created by `lpm login` for the effective registry URL. Credentials are registry-scoped, so hosted, local, and custom registries do not reuse one another's tokens. - -Set `LPM_TOKEN` explicitly for environments without keychain access: - -```bash -export LPM_TOKEN=lpm_your_token_here -``` - -### Registry URL - -Defaults to `https://lpm.dev`. Override with: - -```bash -export LPM_REGISTRY_URL=https://your-registry.dev -``` - -For local development, copy `.env.example` to `.env.local` and set your local registry URL. These files are gitignored. - -## Available Tools - -| Tool | Description | Auth | Cache | -| ----------------------- | ----------------------------------------------------------------------- | -------- | ----- | -| `lpm_search` | Search packages with natural language or structured filters | Optional | 5m | -| `lpm_package_info` | Get package metadata, install method, access model, and readme | Optional | 5m | -| `lpm_api_docs` | Get structured API docs — functions, classes, types, signatures | Optional | 5m | -| `lpm_llm_context` | Get LLM-optimized usage guide — quickStart, patterns, gotchas | Optional | 5m | -| `lpm_package_context` | Get complete package context in one call (pre-install evaluation) | Optional | 5m | -| `lpm_package_skills` | Get Agent Skills for building with an installed package | Optional | 5m | -| `lpm_docs` | Search or read LPM documentation (setup, CLI, publishing, etc.) | No | 30m | -| `lpm_browse_source` | Browse package source code remotely (last resort) | Yes | 5m | -| `lpm_add` | Add a package by extracting source files into the project | Yes | — | -| `lpm_install` | Install a managed dependency (JS → node_modules, Swift → Package.swift) | Yes | — | -| `lpm_audit` | Security audit — behavioral tags, AI findings, quality scores | Yes | — | -| `lpm_marketplace_info` | Marketplace pricing, licensing, and seat management | Optional | 5m | -| `lpm_quality_report` | Get quality score and 28-check breakdown | Optional | 5m | -| `lpm_search_owners` | Search for users or organizations by name | No | 5m | -| `lpm_packages_by_owner` | List packages published by a specific user or org | No | 5m | -| `lpm_pool_stats` | Get your Pool revenue earnings for the current month | Yes | 1h | -| `lpm_user_info` | Get authenticated user info, orgs, and usage | Yes | 5m | - -### Access Control - -- **Pool packages** require a Pool subscription ($12/mo). Without one, `lpm_browse_source`, `lpm_add`, and `lpm_install` return an error with subscription info. -- **Marketplace packages** require a license purchase. Errors include a link to the package page. -- **Public metadata** (`lpm_package_info`, `lpm_search`, `lpm_quality_report`) works without auth for public packages. - -## Troubleshooting - -**"No LPM token found"** -Set the `LPM_TOKEN` environment variable in your MCP client configuration, or run `lpm login` first. - -**"Authentication required"** -Some tools (`lpm_browse_source`, `lpm_add`, `lpm_install`) require authentication. Run `lpm login` or set `LPM_TOKEN`. - -**"Authentication failed"** -Your token may be expired or revoked. Generate a new token at https://lpm.dev/dashboard/tokens or run `lpm login`. - -**"Cannot reach lpm.dev"** -Check your internet connection. If you're behind a proxy, ensure it allows HTTPS connections to lpm.dev. +The LPM CLI's server combines some tools: -**"Package not found"** -Verify the package name format: `owner.package-name` (e.g., `alice.ui-kit`). +| Earlier tools | Now | +| --- | --- | +| `lpm_package_info`, `lpm_quality_report`, `lpm_marketplace_info`, `lpm_api_docs`, `lpm_llm_context`, `lpm_package_context` | `lpm_package` | +| `lpm_search_owners`, `lpm_packages_by_owner` | `lpm_owner` | +| `lpm_user_info`, `lpm_pool_stats` | `lpm_account` | -**"Rate limit exceeded"** -Source browsing is rate limited to 30 requests per minute. Wait and retry. +`lpm_search`, `lpm_package_skills`, `lpm_browse_source`, `lpm_docs`, `lpm_install`, `lpm_add`, and `lpm_audit` keep their names. +`lpm_install`, `lpm_add`, and `lpm_audit` now take `projectPath`, the absolute path of the project's directory. -**"Source browsing is currently disabled"** -The registry has temporarily disabled source browsing. Try again later. +## License -**"Response was truncated"** -Use the `path` parameter with `lpm_browse_source` to request specific files or directories instead of the entire package. +ISC diff --git a/bin/mcp-server.js b/bin/mcp-server.js index 081edaa..b977e44 100755 --- a/bin/mcp-server.js +++ b/bin/mcp-server.js @@ -1,11 +1,28 @@ #!/usr/bin/env node // CRITICAL: Never use console.log() — stdout is the MCP JSON-RPC transport -import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" -import { createServer } from "../lib/server.js" +import { RETIREMENT_NOTICE } from "../lib/constants.js" +import { exitLike, findNativeServer, runNativeServer } from "../lib/handoff.js" + +// Nothing here may touch process.stdin before the hand-off: the CLI's server +// reads the client's first requests from the same stream. +const cli = await findNativeServer() +if (cli) { + console.error( + `@lpm-registry/mcp-server is retired. Starting ${cli} mcp serve instead; run \`lpm mcp setup\` so your editors start it directly.`, + ) + const result = await runNativeServer(cli) + if (result.started) exitLike(result) + console.error(`Could not start ${cli}: ${result.error.message}`) +} + +const { StdioServerTransport } = await import( + "@modelcontextprotocol/sdk/server/stdio.js" +) +const { createServer } = await import("../lib/server.js") const server = createServer() const transport = new StdioServerTransport() await server.connect(transport) -console.error("LPM MCP server started") +console.error(`LPM MCP server started. ${RETIREMENT_NOTICE}`) diff --git a/lib/__tests__/handoff.test.js b/lib/__tests__/handoff.test.js new file mode 100644 index 0000000..58f3860 --- /dev/null +++ b/lib/__tests__/handoff.test.js @@ -0,0 +1,306 @@ +import { spawn } from "node:child_process" +import { + existsSync, + mkdtempSync, + readFileSync, + realpathSync, + rmSync, + writeFileSync, +} from "node:fs" +import { tmpdir } from "node:os" +import path from "node:path" +import { fileURLToPath } from "node:url" +import { Client } from "@modelcontextprotocol/sdk/client/index.js" +import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js" +import { afterEach, beforeEach, describe, expect, it } from "vitest" +import { + findNativeServer, + HANDOFF_ENV, + parseCliVersion, + runNativeServer, + servesMcpNatively, +} from "../handoff.js" + +const BIN = fileURLToPath(new URL("../../bin/mcp-server.js", import.meta.url)) +const posix = process.platform !== "win32" + +describe("parseCliVersion", () => { + it("reads a release", () => { + expect(parseCliVersion("lpm 0.86.0\n")).toEqual({ + major: 0, + minor: 86, + patch: 0, + prerelease: null, + }) + }) + + it("reads a nightly", () => { + expect( + parseCliVersion("lpm 0.87.0-nightly.20261111.264.1d26c11\r\n"), + ).toEqual({ + major: 0, + minor: 87, + patch: 0, + prerelease: "nightly.20261111.264.1d26c11", + }) + }) + + it("reads the version line above an update notice", () => { + expect( + parseCliVersion( + "lpm 0.85.0\n\n \u2b06 Update available: 0.85.0 \u2192 0.86.0 \u2014 run lpm self-update\n", + ), + ).toMatchObject({ major: 0, minor: 85, patch: 0, prerelease: null }) + }) + + it("refuses output that is not an LPM CLI version", () => { + for (const output of [ + null, + "", + "0.86.0", + "npm 10.9.0", + "lpm version 0.86.0", + "lpm 0.86", + "warning\nlpm 0.86.0", + ]) { + expect(parseCliVersion(output)).toBeNull() + } + }) +}) + +describe("servesMcpNatively", () => { + const version = text => parseCliVersion(`lpm ${text}`) + + it("starts at LPM CLI 0.86.0", () => { + expect(servesMcpNatively(version("0.85.9"))).toBe(false) + expect(servesMcpNatively(version("0.86.0"))).toBe(true) + expect(servesMcpNatively(version("0.86.1"))).toBe(true) + expect(servesMcpNatively(version("0.100.0"))).toBe(true) + expect(servesMcpNatively(version("1.0.0"))).toBe(true) + }) + + it("leaves out 0.86.0 nightlies, which were built before the native server", () => { + expect( + servesMcpNatively(version("0.86.0-nightly.20261109.260.daa536a")), + ).toBe(false) + expect( + servesMcpNatively(version("0.87.0-nightly.20261111.264.1d26c11")), + ).toBe(true) + }) +}) + +describe("findNativeServer", () => { + const probeOf = output => async () => output + + it("returns a CLI that serves MCP itself", async () => { + await expect( + findNativeServer({ + env: {}, + resolve: () => "/opt/lpm", + probe: probeOf("lpm 0.86.0\n"), + }), + ).resolves.toBe("/opt/lpm") + }) + + it("keeps the bundled server for an older CLI", async () => { + await expect( + findNativeServer({ + env: {}, + resolve: () => "/opt/lpm", + probe: probeOf("lpm 0.85.0\n"), + }), + ).resolves.toBeNull() + }) + + it("keeps the bundled server when the version cannot be read", async () => { + await expect( + findNativeServer({ + env: {}, + resolve: () => "/opt/lpm", + probe: probeOf(null), + }), + ).resolves.toBeNull() + }) + + it("keeps the bundled server without a CLI", async () => { + let probed = false + await expect( + findNativeServer({ + env: {}, + resolve: () => null, + probe: async () => { + probed = true + return "lpm 0.86.0" + }, + }), + ).resolves.toBeNull() + expect(probed).toBe(false) + }) + + it("never hands off twice", async () => { + let resolved = false + await expect( + findNativeServer({ + env: { [HANDOFF_ENV]: "1" }, + resolve: () => { + resolved = true + return "/opt/lpm" + }, + probe: probeOf("lpm 0.86.0"), + }), + ).resolves.toBeNull() + expect(resolved).toBe(false) + }) +}) + +it("reports a CLI that cannot start without reading stdin", async () => { + const missing = path.join(tmpdir(), "lpm-mcp-missing", "lpm") + const result = await runNativeServer(missing, { stdio: "ignore" }) + expect(result.started).toBe(false) + expect(result.error.code).toBe("ENOENT") +}) + +describe.skipIf(!posix)("the published executable", () => { + let root + beforeEach(() => { + root = realpathSync(mkdtempSync(path.join(tmpdir(), "lpm-mcp-handoff-"))) + }) + afterEach(() => rmSync(root, { recursive: true, force: true })) + + function fakeCli(version, serve) { + const executable = path.join(root, "lpm") + writeFileSync( + executable, + [ + "#!/bin/sh", + `if [ "$1" = "--version" ]; then echo "lpm ${version}"; exit 0; fi`, + 'if [ "$1" = "mcp" ] && [ "$2" = "serve" ]; then', + `echo "$${HANDOFF_ENV}" > "${root}/handoff"`, + serve, + "fi", + "exit 64", + "", + ].join("\n"), + { mode: 0o755 }, + ) + return executable + } + + function environment(cli) { + const env = { ...process.env, LPM_CLI_PATH: cli } + delete env[HANDOFF_ENV] + return env + } + + function start(cli) { + const child = spawn(process.execPath, [BIN], { + cwd: root, + env: environment(cli), + stdio: ["pipe", "pipe", "pipe"], + }) + const exited = new Promise(resolve => + child.once("exit", (code, signal) => resolve({ code, signal })), + ) + let stdout = "" + child.stdout.setEncoding("utf8") + const line = new Promise(resolve => + child.stdout.on("data", chunk => { + stdout += chunk + if (stdout.includes("\n")) resolve(stdout.split("\n", 1)[0]) + }), + ) + return { child, exited, line } + } + + async function connect(cli) { + const client = new Client({ name: "test", version: "1.0.0" }) + await client.connect( + new StdioClientTransport({ + command: process.execPath, + args: [BIN], + cwd: root, + env: environment(cli), + stderr: "ignore", + }), + ) + return client + } + + it("hands its stdio to a CLI that serves MCP itself, requests sent at once included", async () => { + const cli = fakeCli( + "0.86.0", + [ + `read request; printf '%s\\n' "$request" > "${root}/request"`, + `printf '{"jsonrpc":"2.0","id":1,"result":{"handedOff":true}}\\n'`, + "exit 3", + ].join("\n"), + ) + const server = start(cli) + const request = JSON.stringify({ + jsonrpc: "2.0", + id: 1, + method: "initialize", + params: {}, + }) + server.child.stdin.write(`${request}\n`) + + expect(JSON.parse(await server.line).result.handedOff).toBe(true) + expect(await server.exited).toEqual({ code: 3, signal: null }) + expect(readFileSync(path.join(root, "request"), "utf8").trim()).toBe( + request, + ) + expect(readFileSync(path.join(root, "handoff"), "utf8").trim()).toBe("1") + }) + + it("passes a stop signal on to the CLI's server", async () => { + const cli = fakeCli( + "0.86.0", + [ + `trap 'echo stopped > "${root}/signal"; exit 0' TERM`, + "echo ready", + "while :; do sleep 0.05; done", + ].join("\n"), + ) + const server = start(cli) + expect(await server.line).toBe("ready") + server.child.kill("SIGTERM") + + expect(await server.exited).toEqual({ code: 0, signal: null }) + expect(readFileSync(path.join(root, "signal"), "utf8").trim()).toBe( + "stopped", + ) + }) + + it("runs its own tools for an older CLI, and says it is retired", async () => { + const cli = fakeCli("0.85.0", "exit 70") + const client = await connect(cli) + try { + expect(client.getInstructions()).toContain("lpm mcp setup") + const { tools } = await client.listTools() + expect(tools.map(tool => tool.name)).toContain("lpm_package_info") + } finally { + await client.close() + } + expect(existsSync(path.join(root, "handoff"))).toBe(false) + }) + + it("runs its own tools when a CLI that serves MCP starts it again", async () => { + const cli = fakeCli( + "0.86.0", + [ + `echo started >> "${root}/starts"`, + `exec "${process.execPath}" "${BIN}"`, + ].join("\n"), + ) + const client = await connect(cli) + try { + const { tools } = await client.listTools() + expect(tools.map(tool => tool.name)).toContain("lpm_package_info") + } finally { + await client.close() + } + expect( + readFileSync(path.join(root, "starts"), "utf8").trim().split("\n"), + ).toEqual(["started"]) + }) +}) diff --git a/lib/__tests__/server-contract.test.js b/lib/__tests__/server-contract.test.js index 92acbf1..1e2e67c 100644 --- a/lib/__tests__/server-contract.test.js +++ b/lib/__tests__/server-contract.test.js @@ -13,6 +13,7 @@ import { searchGet } from "../api.js" afterEach(() => vi.unstubAllEnvs()) +import { RETIREMENT_NOTICE } from "../constants.js" import { createServer } from "../server.js" it("tells clients the version it was published as", async () => { @@ -36,6 +37,22 @@ it("tells clients the version it was published as", async () => { } }) +it("tells agents the server is retired and what replaces it", async () => { + const server = createServer() + const client = new Client({ name: "test", version: "1.0.0" }) + const [clientTransport, serverTransport] = + InMemoryTransport.createLinkedPair() + try { + await server.connect(serverTransport) + await client.connect(clientTransport) + expect(client.getInstructions()).toBe(RETIREMENT_NOTICE) + expect(RETIREMENT_NOTICE).toContain("lpm mcp setup") + } finally { + await client.close() + await server.close() + } +}) + it("offers Free as a registry distribution filter", async () => { const server = createServer() const client = new Client({ name: "test", version: "1.0.0" }) diff --git a/lib/constants.js b/lib/constants.js index 91e3400..288fa1c 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -2,6 +2,9 @@ export const DEFAULT_REGISTRY_URL = "https://lpm.dev" +export const RETIREMENT_NOTICE = + "@lpm-registry/mcp-server is retired and gets no more updates. LPM CLI 0.86.0 and later serve MCP themselves: upgrade the LPM CLI, then run `lpm mcp setup` so your editors start `lpm mcp serve`. See https://cli.lpm.dev/docs/reference/mcp-servers#upgrading-from-the-npm-server" + export const KEYTAR_SERVICE_NAME = "lpm-cli" export const KEYTAR_ACCOUNT_PREFIX = "auth-token" diff --git a/lib/handoff.js b/lib/handoff.js new file mode 100644 index 0000000..2a755cd --- /dev/null +++ b/lib/handoff.js @@ -0,0 +1,115 @@ +import { execFile, spawn } from "node:child_process" +import { constants } from "node:os" +import { resolveCli } from "./cli.js" + +/** + * Set for the LPM CLI's server. An older CLI ignores it and starts this + * package again, which then serves its own tools instead of handing off. + */ +export const HANDOFF_ENV = "LPM_MCP_NPM_HANDOFF" + +const NATIVE_SERVER_RELEASE = { major: 0, minor: 86, patch: 0 } +const PROBE_TIMEOUT_MS = 10_000 +const PROBE_MAX_BYTES = 4096 +const VERSION_LINE = + /^lpm (0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/ + +/** Parse the first line of `lpm --version`. */ +export function parseCliVersion(output) { + if (typeof output !== "string") return null + const match = VERSION_LINE.exec(output.split(/\r?\n/, 1)[0].trim()) + if (!match) return null + return { + major: Number(match[1]), + minor: Number(match[2]), + patch: Number(match[3]), + prerelease: match[4] ?? null, + } +} + +/** Whether an LPM CLI version has `lpm mcp serve` as its own server. */ +export function servesMcpNatively(version) { + for (const part of ["major", "minor", "patch"]) { + if (version[part] !== NATIVE_SERVER_RELEASE[part]) { + return version[part] > NATIVE_SERVER_RELEASE[part] + } + } + // A prerelease sorts before its release, and 0.86.0's nightlies predate the + // native server. Earlier CLIs' `lpm mcp serve` runs this package. + return version.prerelease === null +} + +/** Run `lpm --version`, resolving its output, or null when it fails. */ +export function probeCliVersion(cli) { + return new Promise(resolve => { + execFile( + cli, + ["--version"], + { + timeout: PROBE_TIMEOUT_MS, + maxBuffer: PROBE_MAX_BYTES, + windowsHide: true, + }, + (error, stdout) => resolve(error ? null : stdout), + ) + }) +} + +/** Find an LPM CLI whose `lpm mcp serve` is its own server. */ +export async function findNativeServer({ + env = process.env, + resolve = resolveCli, + probe = probeCliVersion, +} = {}) { + if (env[HANDOFF_ENV]) return null + const cli = resolve() + if (!cli) return null + const version = parseCliVersion(await probe(cli)) + return version && servesMcpNatively(version) ? cli : null +} + +/** + * Run ` mcp serve` on this process's stdio, passing stop signals on. + * + * Resolves `{ started: false, error }` when the CLI could not start, before + * anything read stdin, and `{ started: true, code, signal }` when it exits. + */ +export function runNativeServer( + cli, + { env = process.env, stdio = "inherit" } = {}, +) { + return new Promise(resolve => { + const signals = + process.platform === "win32" + ? ["SIGINT", "SIGTERM", "SIGBREAK"] + : ["SIGINT", "SIGTERM", "SIGHUP"] + const forward = signal => child.kill(signal) + let started = false + const child = spawn(cli, ["mcp", "serve"], { + stdio, + env: { ...env, [HANDOFF_ENV]: "1" }, + windowsHide: true, + }) + child.once("spawn", () => { + started = true + for (const signal of signals) process.on(signal, forward) + }) + child.once("error", error => { + if (!started) resolve({ started: false, error }) + }) + child.once("exit", (code, signal) => { + for (const name of signals) process.off(name, forward) + resolve({ started: true, code, signal }) + }) + }) +} + +/** End this process the way the CLI's server ended. */ +export function exitLike({ code, signal }) { + if (signal) { + process.kill(process.pid, signal) + // Node ignores some signals, such as SIGPIPE, so raising one may return. + process.exit(128 + (constants.signals[signal] ?? 0)) + } + process.exit(code ?? 1) +} diff --git a/lib/server.js b/lib/server.js index 56c7dbb..e4cf241 100644 --- a/lib/server.js +++ b/lib/server.js @@ -3,6 +3,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" import { z } from "zod" import { getBaseUrl, getToken } from "./auth.js" import { MemoryCache } from "./cache.js" +import { RETIREMENT_NOTICE } from "./constants.js" import { add } from "./tools/add.js" import { apiDocs } from "./tools/api-docs.js" import { audit } from "./tools/audit.js" @@ -28,10 +29,13 @@ const { version } = createRequire(import.meta.url)("../package.json") * @returns {import('@modelcontextprotocol/sdk/server/mcp.js').McpServer} */ export function createServer() { - const server = new McpServer({ - name: "lpm-registry", - version, - }) + const server = new McpServer( + { + name: "lpm-registry", + version, + }, + { instructions: RETIREMENT_NOTICE }, + ) const cache = new MemoryCache() const context = { cache, getToken, getBaseUrl } diff --git a/package-lock.json b/package-lock.json index 16a27af..70616d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lpm-registry/mcp-server", - "version": "0.3.0", + "version": "0.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@lpm-registry/mcp-server", - "version": "0.3.0", + "version": "0.4.0", "license": "ISC", "dependencies": { "@modelcontextprotocol/sdk": "^1.12.0", diff --git a/package.json b/package.json index eeb678f..4f83c4a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@lpm-registry/mcp-server", - "version": "0.3.0", - "description": "MCP server for the LPM package registry — exposes package info, quality reports, name checks, pool stats, and marketplace search as AI tools", + "version": "0.4.0", + "description": "Retired: the LPM CLI serves MCP itself from 0.86.0 as `lpm mcp serve`. This last release hands off to it when installed.", "author": "LPM (https://lpm.dev)", "repository": { "type": "git",