我学习到的mcp包发布

发布到 npm 后,配置改成用 npx 即可,不再需要绝对路径:

json 复制代码
{
  "mcpServers": {
    "perf-analyzer": {
      "command": "npx",
      "args": ["-y", "mcp-perf-analyzer"]
    }
  }
}

-y 的作用是首次运行时自动确认下载,不需要用户手动交互。

发布前 package.json 需要补充 3 处

1. 加 files 字段(只发布 dist,不带源码)

json 复制代码
"files": ["dist/", "README.md"]

不加的话会把 src/node_modules/ 都传上去,体积很大。

2. 加 prepublishOnly 脚本(发布前自动重新构建)

json 复制代码
"scripts": {
  "build": "tsc",
  "dev": "tsx src/index.ts",
  "start": "node dist/index.js",
  "prepublishOnly": "npm run build"
}

3. 补充元信息(让市场页面好看)

json 复制代码
"keywords": ["mcp", "bundle-analyzer", "performance", "webpack", "vite"],
"author": "你的名字",
"license": "MIT",
"repository": {
  "type": "git",
  "url": "https://github.com/你的用户名/mcp-perf-analyzer"
}

发布流程

csharp 复制代码
# 1. 登录 npm
npm login

# 2. 检查包名是否被占用
npm view mcp-perf-analyzer

# 3. 发布(会自动触发 prepublishOnly 先构建)
npm publish --access public
相关推荐
asaotomo1 小时前
从抓包插件到浏览器安全 Agent:Hx0 鹰眼 v1.0.6,正式接入 MCP
安全·渗透测试·agent·浏览器插件·ai工具·mcp
guwentian8 小时前
手撕 MCP:用 TypeScript 从零写一个能跑的最小客户端(附可运行 demo)
开发语言·nodejs·mcp
deepseek238 小时前
Anthropic开源Commerce Agents:购物与商户智能体如何把审批写进工具链
人工智能·ai agent·mcp
xrlfreedom10 小时前
大厂 MCP 面试实录:基于 Streamable HTTP 的 OAuth 2.1 服务集成测试设计
resources·mcp·oauth 2.1·streamable http 传输
zfelix1 天前
别在 MCP、Skills、Subagent 里挑一个——它们根本不是同一层的东西
mcp
deepseek231 天前
Tenable联合OpenAI做AI Inspector:第三方Agent、Skill与MCP组件如何过供应链验收
人工智能·ai agent·mcp
AIGC大时代1 天前
Claude 科研栈拆解:Connectors 给文献视力,Skills 把 SOP 变成可调用流程
claude·学术写作·mcp·agent skills·科研工作流
xrlfreedom1 天前
大厂 MCP 面试实录:桌面客户端 stdio MCP Server 调试与安全加固方案设计
docker·结构化输出·mcp·提示注入防护
xrlfreedom1 天前
大厂 MCP 面试实录:Tool 调用身份认证与最小权限设计
mcp·rag 知识库·向量检索与重排·typescript mcp sdk
Akiyama_Mio-Kon1 天前
CVE-2026-85654 深度解读:DynamoDB MCP Server 如何把数据模型风险带到 CDK 部署宿主
aws·dynamodb·cdk·mcp·cve-2026-85654·lac·agent 安全