npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

contract-template-mcp-server

v1.1.0

Published

MCP Server - CRM合同模版库管理,支持合同模版分类管理、合同模版管理、合同模版版本管理

Downloads

476

Readme

Contract Template MCP Server

CRM 合同模版库管理 MCP Server,为智能体(如 CodeBuddy/WorkBuddy)提供合同模板分类管理、合同模板管理和模板文件获取能力。

功能概览

| 工具名称 | 功能说明 | 对应后端API | |---------|---------|-----------| | list_contract_categories | 查询合同模板分类列表(支持关键词搜索) | GET /mcp/contract/category/list | | create_contract_category | 创建新的合同模板分类 | POST /mcp/contract/category/create | | list_contract_templates | 查询合同模板列表(支持分类/关键词筛选) | GET /mcp/contract/template/list | | get_contract_template | 获取模板详情及文件下载URL | GET /mcp/contract/template/detail | | create_contract_template | 在分类下创建新模板(含 v1.0 初版) | POST /mcp/contract/template/create | | upload_file_to_template_category | 上传文件并一步创建模板(推荐) | POST /mcp/contract/template/upload-and-create |

安装与配置

1. 安装依赖

cd contract-template-mcp-server
npm install

2. 配置 MCP Client

在 CodeBuddy/WorkBuddy 的 MCP 配置中添加:

{
  "mcpServers": {
    "contract-template": {
      "command": "contract-template-mcp-server",
      "env": {
        "CONTRACT_TEMPLATE_API_BASE_URL": "http://your-crm-backend:port",
        "CRM_MCP_ACCESS_KEY": "从管理系统获取的access-key"
      }
    }
  }
}

3. 环境变量

| 变量名 | 必填 | 说明 | |--------|------|------| | CONTRACT_TEMPLATE_API_BASE_URL | 否 | 后端CRM服务地址,默认 http://localhost:3000 | | CRM_MCP_ACCESS_KEY | 是 | MCP 访问密钥,从管理系统 agent/access-key 获取 |

使用示例

查询分类

用户: 目前有哪些合同模板分类?
AI: 调用 list_contract_categories → 返回分类列表

创建分类

用户: 在"销售合同"下帮我创建一个"2025版"子分类
AI: 调用 list_contract_categories(获取"销售合同"的ID)
    → 调用 create_contract_category(parentId=销售合同ID, categoryName="2025版")

查询模板

用户: 销售合同分类下有哪些模板?
AI: 调用 list_contract_templates(categoryId=销售合同分类ID)

获取模板文件

用户: 我需要"2025年版销售合同模板",发给我一下
AI: 调用 list_contract_templates(keyword="2025年销售合同")找到目标模板
    → 调用 get_contract_template(templateId=模板ID)
    → 返回模板详情 + currentFileUrl 文件下载地址

创建模板(含文件上传)

用户: 在"2025版"分类下创建"新版销售合同模板",文件是xxx.docx
AI: ① 先调用文件上传接口 /resource/nas-center/upload 上传文件,获取 fileId
    → ② 调用 create_contract_template(categoryId, templateName, fileId, fileName, fileSize)
    → 模板创建成功(v1.0 草稿状态)

上传文件一步创建模板(推荐)

用户: 帮我把这个文件上传到销售合同分类下
AI: 调用 upload_file_to_template_category(filePath="/path/to/file.docx", categoryId=销售合同分类ID)
    → 内部自动完成:文件读取 + 上传 NAS/OSS + 模板创建 + 版本初始化
    → 模板创建成功(v1.0 草稿状态)

性能说明:MCP Server 与 WorkBuddy 同机运行,upload_file_to_template_category 直接通过 filePath 读取本地文件,无需客户端做 base64 编码,大文件上传速度大幅提升。

数据来源标记

所有通过 MCP Server 创建的分类和模板,数据库 data_source 字段会自动标记为 MCP_SERVER, 可通过 model_name 字段追溯由哪个 AI 模型创建。

文件上传说明

方式一:upload_file_to_template_category(推荐)

直接传文件本地路径,MCP Server 自动完成文件读取、上传和模板创建:

  • 参数 filePath:本地文件的绝对路径
  • 参数 fileName:可选,不传则从路径自动提取

方式二:手动分步上传

  1. 先上传文件获取 fileId
    • NAS 上传POST /resource/nas-center/upload(multipart/form-data)
    • OSS 上传POST /resource/oss/upload(multipart/form-data)
  2. 使用 create_contract_template 传入 fileId 创建模板

技术架构

┌─────────────────────┐     stdio(MCP协议)     ┌─────────────────────┐
│  CodeBuddy/智能体    │ ◄──────────────────► │  MCP Server (Node)  │
└─────────────────────┘                        └──────────┬──────────┘
                                                          │ HTTP + CrmMcpAccessKey
                                                          ▼
┌─────────────────────────────────────────────────────────────────────┐
│  CRM Backend (Spring Boot)                                          │
│  ├── McpContractTemplateCategoryController  /mcp/contract/category  │
│  └── McpContractTemplateController          /mcp/contract/template  │
└─────────────────────────────────────────────────────────────────────┘

License

MIT