MCP Server

MCP Server

A modular server based on Model Context Protocol (MCP) that provides weather queries, mathematical calculations, and search functionalities.

Category
Visit Server

README

MCP Server - 模块化多工具服务

English below 中文介绍


📝 项目简介

MCP Server 是基于 Model Context Protocol (MCP) 的模块化服务端,支持天气、定位、数学计算、IoT 设备控制、GitHub 搜索等多种工具,适合智能体/AI 助手等场景。

📁 目录结构

├── src/
│   ├── app.ts              # 应用主类
│   ├── index.ts            # 启动入口
│   ├── config/             # 配置
│   ├── types/              # 类型定义
│   ├── middleware/         # 中间件
│   ├── routes/             # 路由
│   ├── services/           # 业务服务
│   ├── tools/              # 工具函数(天气、定位、计算、IoT、搜索等)
│   └── utils/              # 通用工具
├── test/                   # 测试脚本
├── package.json            # 依赖与脚本
├── tsconfig.json           # TypeScript 配置
└── ...

🚀 快速开始

安装依赖

npm install

启动开发环境

npm run dev

生产环境

npm run build
npm run start:prod

其他命令

npm run dev:watch   # nodemon 热重载
npm run dev:debug   # 调试模式
npm start           # 直接运行(ts-node)

⚙️ 配置

  • 端口、名称、版本、日志、会话等均可通过环境变量配置,详见 src/config/index.ts
  • 常用环境变量:
    • PORTSERVER_NAMESERVER_VERSIONNODE_ENVLOG_LEVELMAX_SESSIONSSESSION_TIMEOUT

🔧 可用工具(API)

1. 天气查询 getWeather

  • 参数:city(可选,城市名,缺省自动定位),unit(可选,celsius/fahrenheit)
  • 示例:
    { "city": "北京", "unit": "celsius" }
    

2. 定位 getLocation

  • 参数:无
  • 返回:当前定位的城市名(模拟/可扩展)

3. 数学计算 calculate

  • 参数:operation(add/subtract/multiply/divide),ab
  • 示例:
    { "operation": "add", "a": 1, "b": 2 }
    

4. IoT 设备控制 iotControl

  • 参数:deviceIdaction(lock/unlock/open/close/getStatus),value(可选)
  • 示例:
    { "deviceId": "lock001", "action": "lock" }
    

5. GitHub 搜索 search

  • 参数:query(关键词),可选:languagestarsforksusertopiccreatedsortorderlimit
  • 示例:
    { "query": "nodejs", "language": "TypeScript", "limit": 3 }
    

📊 健康检查

  • GET /health 返回服务器状态

🧪 测试

所有测试脚本位于 test/ 目录:

  • test/test-mcp.jstest/test-modular.jstest/test-tools-rename.js
  • 运行示例:
    node test/test-mcp.js
    node test/test-modular.js
    node test/test-tools-rename.js
    

🔄 扩展指引

  • 新增工具:在 src/tools/ 新建文件并注册
  • 新增服务/中间件/类型:参考现有目录结构

📝 许可证

ISC


MCP Server - Modular Multi-Tool Service (English)

📝 Introduction

MCP Server is a modular backend based on Model Context Protocol (MCP), supporting weather, location, calculator, IoT device control, GitHub search and more. Ideal for AI agents and assistant scenarios.

📁 Structure

See above for directory tree. Main code in src/, tests in test/.

🚀 Quick Start

Install dependencies

npm install

Start development server

npm run dev

Production

npm run build
npm run start:prod

Other scripts

npm run dev:watch   # nodemon hot reload
npm run dev:debug   # debug mode
npm start           # direct run (ts-node)

⚙️ Configuration

  • All configs (port, name, version, log, session, etc.) via env vars, see src/config/index.ts
  • Common env vars: PORT, SERVER_NAME, SERVER_VERSION, NODE_ENV, LOG_LEVEL, MAX_SESSIONS, SESSION_TIMEOUT

🔧 Tools (APIs)

1. Weather getWeather

  • Params: city (optional, auto-location if omitted), unit (optional, celsius/fahrenheit)
  • Example:
    { "city": "Beijing", "unit": "celsius" }
    

2. Location getLocation

  • Params: none
  • Returns: current city (mocked/extendable)

3. Calculator calculate

  • Params: operation (add/subtract/multiply/divide), a, b
  • Example:
    { "operation": "add", "a": 1, "b": 2 }
    

4. IoT Device Control iotControl

  • Params: deviceId, action (lock/unlock/open/close/getStatus), value (optional)
  • Example:
    { "deviceId": "lock001", "action": "lock" }
    

5. GitHub Search search

  • Params: query (keyword), optional: language, stars, forks, user, topic, created, sort, order, limit
  • Example:
    { "query": "nodejs", "language": "TypeScript", "limit": 3 }
    

📊 Health Check

  • GET /health returns server status

🧪 Testing

All test scripts in test/:

  • test/test-mcp.js, test/test-modular.js, test/test-tools-rename.js
  • Run example:
    node test/test-mcp.js
    node test/test-modular.js
    node test/test-tools-rename.js
    

🔄 Extension

  • Add tool: create file in src/tools/ and register
  • Add service/middleware/type: follow existing structure

📝 License

ISC

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured