@getonlane/mcp-auth

中文文档
1.4.0发布于 2026/10/13MITTypeScriptES Module近 30 天下载 2519

Drop-in OAuth resource-server + connection gate for an MCP server fronted by Lane. Transport-agnostic core; adapters wrap it.

原始使用文档
文档目录3 节
  1. Install and register
  2. Run a server
  3. Add capabilities

@getonlane/mcp-auth

Add Lane sign-in, tool permissions, and user-approved purchases to an MCP server.

Install and register

npm install @getonlane/mcp-auth
npx @getonlane/mcp-auth setup https://acme.com/mcp --name="Acme shop"

Replace the URL with your public MCP endpoint. Setup writes .env with the server credentials. The library also needs LANE_ORG_KEY, even for free tools. Keep that file out of version control.

Use Node.js 22.22.2 or later. The adapters support MCP TypeScript SDK v2 (@modelcontextprotocol/server >=2.1.0 <3), SDK v1 (@modelcontextprotocol/sdk ^1.31.0) and mcp-use ~2.8.0. Each is an optional peer dependency: install the one that your server uses.

Run a server

On MCP TypeScript SDK 2, laneMcpHandler from @getonlane/mcp-auth/mcp-sdk builds the server, gates your tools, serves discovery and verifies the bearer. On mcp-use, oauthLaneProvider and withLaneAuth do the same. On another framework, put laneHttpHandler from @getonlane/mcp-auth/http in front of your MCP transport.

Existing servers has the complete code for each framework: the connection store, test auth, the server and a local test. Follow the MCP SDK or mcp-use guide for the deployed configuration.

Use an in-memory connection store for one process. Use PostgreSQL for multiple processes or registrations that must survive a restart.

Add capabilities

  • Scopes: require permission before a tool runs.
  • Guest access: open selected read tools without sign-in.
  • Claims: read the buyer's shared details.
  • Payments: propose a purchase for the user to approve.
  • Plan events: handle results and release reservations.
  • API reference: options, methods, types, and errors.

版本与发布记录

@getonlane/mcp-auth 共发布 28 个版本,首次发布于 2026/08/21;过去 12 个月发布了 28 个版本。

版本发布日期距今
1.4.0latest2026/10/131 个月前
1.3.12026/10/101 个月前
1.2.12026/10/081 个月前
1.2.02026/10/071 个月前
1.1.02026/10/061 个月前
1.0.02026/10/061 个月前

关于 @getonlane/mcp-auth 的常见问题

@getonlane/mcp-auth 是什么?

Drop-in OAuth resource-server + connection gate for an MCP server fronted by Lane. Transport-agnostic core; adapters wrap it.

如何安装 @getonlane/mcp-auth?

在项目目录运行 npm install @getonlane/mcp-auth,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 lane-mcp-auth,可以用 npx lane-mcp-auth 直接运行。

@getonlane/mcp-auth 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@getonlane/mcp-auth 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@getonlane/mcp-auth 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.22.2。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@getonlane/mcp-auth 可以商用吗?

@getonlane/mcp-auth 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@getonlane/mcp-auth 的下载量有多少?

根据 npm 官方下载统计,@getonlane/mcp-auth 在 2026/10/17 – 2026/11/15 这 30 天内被下载 2,519 次,日均约 84 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@getonlane/mcp-auth 还在维护吗?

最新版本 1.4.0 发布于 2026/10/13(1 个月前);至今共发布 28 个版本,其中过去 12 个月发布了 28 个;首次发布于 2026/08/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。