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

campus-security-mcp

v1.1.3

Published

校园安防助手 MCP 服务器

Downloads

91

Readme

校园安防助手 MCP 服务器

这是一个基于 Node.js 的 MCP (Model Context Protocol) 服务器,提供校园区域查询、街道查询和警告数量查询功能。

本项目使用官方 @modelcontextprotocol/sdk 构建,符合标准 MCP 协议规范。

目录

功能特性

  • 区域查询: 返回所有学校区域名称(东、西、南、北)
  • 街道查询: 返回所有学校街道名称(共 9 条街道)
  • 警告数量查询: 根据时间、区域和街道参数查询警告数量
  • Mock 数据: 使用模拟数据进行测试,预留真实 API 接口

安装使用

全局安装

npm install -g campus-security-mcp

直接使用 npx 运行

npx campus-security-mcp

启动服务器

# 全局安装后
campus-security-mcp

Trae 配置

Trae 中添加 MCP 服务器,按以下步骤操作:

  1. 打开 Trae → 点击右侧 AI 侧栏(或快捷键 Cmd/Ctrl + L
  2. 点击右上角 齿轮设置图标 → 选择 MCP
  3. 点击 手动配置添加更多工具
  4. 粘贴以下配置:
{
  "mcpServers": {
    "campus-security-mcp": {
      "command": "npx",
      "args": ["-y", "campus-security-mcp"]
    }
  }
}

配置成功后,即可在 Trae 的智能体中使用校园安防助手工具。

Trae中使用mcp

在 Trae 的智能体中,您可以通过以下自然语言提问来使用校园安防助手工具:

1. 区域查询

提问:查询学校有哪些区域

2. 街道查询

提问:学校有哪些街道?春晖路在哪个区域?

3. 警告数量查询

提问:查询东区春晖路在最近7天之间有多少警告?按日期和街道统计一下

Trae 会自动识别这些问题并调用相应的 MCP 工具,返回查询结果。

调用工具

服务器启动后,会监听标准输入,处理 JSON 格式的请求,并返回响应。

示例请求与响应

  1. 区域查询

自然语言提问:查询学校有哪些区域

请求:

{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "tools/call",
  "params": {
    "name": "campus_security_get_areas",
    "arguments": {}
  }
}

响应:

{
  "result": {
    "content": [
      {
        "type": "text",
        "text": "学校区域列表:东、西、南、北"
      }
    ]
  },
  "jsonrpc": "2.0",
  "id": "1"
}
  1. 街道查询

自然语言提问:学校有哪些街道?春晖路在哪个区域?

请求:

{
  "jsonrpc": "2.0",
  "id": "2",
  "method": "tools/call",
  "params": {
    "name": "campus_security_get_streets",
    "arguments": {}
  }
}

响应:

{
  "result": {
    "content": [
      {
        "type": "text",
        "text": "学校街道列表:春晖路、洋房路、经一路、经二路、经三路、经四路、八里庄街道、紫竹院街道、北新桥街道"
      }
    ]
  },
  "jsonrpc": "2.0",
  "id": "2"
}
  1. 警告数量查询

自然语言提问:查询东区春晖路在2026年4月6日到4月12日之间有多少警告?按日期和街道统计一下。

请求:

{
  "jsonrpc": "2.0",
  "id": "3",
  "method": "tools/call",
  "params": {
    "name": "campus_security_get_warnings",
    "arguments": {
      "startDate": "2026-04-06",
      "endDate": "2026-04-12",
      "area": "东",
      "street": "春晖路"
    }
  }
}

响应:

{
  "result": {
    "content": [
      {
        "type": "text",
        "text": "警告查询结果:\n总警告数:14\n\n按日期统计:\n2026-04-07: 3个\n2026-04-08: 1个\n2026-04-09: 5个\n2026-04-10: 1个\n2026-04-11: 1个\n2026-04-12: 3个\n\n按区域统计:\n东区: 14个\n\n按街道统计:\n春晖路: 14个\n"
      }
    ],
    "structuredContent": {
      "totalCount": 14,
      "dailyData": [
        {"date": "2026-04-07", "count": 3},
        {"date": "2026-04-08", "count": 1},
        {"date": "2026-04-09", "count": 5},
        {"date": "2026-04-10", "count": 1},
        {"date": "2026-04-11", "count": 1},
        {"date": "2026-04-12", "count": 3}
      ],
      "areaBreakdown": [{"area": "东", "count": 14}],
      "streetBreakdown": [{"street": "春晖路", "count": 14}]
    }
  },
  "jsonrpc": "2.0",
  "id": "3"
}

测试

前置条件

运行测试前需要先安装项目依赖:

npm install

运行测试

npm test

开发指南

安装依赖

npm install

编译项目

npm run build

开发模式启动

npm run dev

生产模式启动

npm start

代码检查

npm run lint

发布包

npm run publish

项目结构

campus-security-mcp/
├── dist/              # 构建输出目录(包含可执行文件)
├── src/
│   ├── data/          # 数据相关文件
│   │   ├── mockData.ts    # 模拟数据
│   │   └── types.ts       # 类型定义
│   ├── utils/         # 工具函数
│   │   └── dateUtils.ts   # 日期工具函数
│   └── index.ts       # 服务器入口(主程序)
├── package.json       # 包配置信息
├── README.md          # 使用说明
├── test.js            # 测试脚本
└── tsconfig.json      # TypeScript 配置

技术栈

  • TypeScript 5.5.4
  • Node.js 18+
  • @modelcontextprotocol/sdk 1.29.0
  • Zod 3.25.76
  • tsx 4.16.5

未来规划

  • 接入真实 API 接口
  • 添加更多校园安防相关工具
  • 优化数据生成策略
  • 提高服务性能和可靠性

许可证

MIT 许可证