Cover image
简单的MCP服务器
Public

简单的MCP服务器

Try Now
2025-04-03

示例,用极简代码,演示如何构建MCP服务器。

3 years

Works with Finder

1

Github Watches

0

Github Forks

3

Github Stars

Simple MCP Server

这是一个示例项目,用极简方式演示如何构建MCP Server。

  • 天气查询:使用高德开放平台提供的天气查询API实现MCP Server,可获取实况和未来天气.
  • 钉钉群消息:使用钉钉群机器人,发送消息到钉钉群。

效果演示

Cherry Studio使用

如上图:

  • 用户问"西安今天用穿棉袄吗"
  • AI自动判断是否要调用天气MCP Server
  • AI按照MCP Server的参数要求,将西安的经纬度信息提供给MCP Server
  • MCP Server内部调用了高德提供的天气查询API,并将结果返回给AI
  • AI将天气结果进行汇总整理,输出给用户

与钉钉群消息结合效果如下图:

问天气,发送到钉钉

钉钉群消息

环境准备

MCP Server 构建和执行

MCP Client和大模型

支持MCP协议的任何AI对话客户端程序都可以,如:Cline、Continue、Claude Desktop等, 本例使用Cherry Studio。

Cherry Studio

Cherry Studio是一个AI对话客户端,其支持很多个大模型提供商,如:硅基流动、阿里云百炼、OpenAI等几十个国内外提供商,各提供商分别提供很多大模型服务,各个大模型的能力也有差异,有免费和收费的,也有不同作用和能力的。 当然,Cherry Studio也支持本地运行的大模型,如:Ollama、LLM Studio等。

本文使用硅基流动提供的Qwen2.5-7B-Instruct模型,请先注册硅基流动账户,申请API密钥,并在Cherry Studio中配置API密钥。

注意:请选择带有Function Call功能的大模型(Cherry Studio中带🔧符合的大模型),如:Qwen2.5-7B-Instruct

配置大模型和密钥

高德开放平台API密钥

从高德开放平台申请Web API密钥(key)

钉钉群API密钥

参见钉钉开放平台——自定义机器人接入

注意: 钉钉的本例中采用安全设置/自定义关键字方式,关键字为天气,如下图所示:

添加钉钉群机器人

构建

  • Clone本项目代码到本地,如/Users/yourname/simple-mcp-server/目录;
  • 打开命令行工具;
  • 跳转到此路径 cd /Users/yourname/simple-mcp-server/;
  • 安装依赖 pnpm i;
  • 构建 pnpm build.

构建完成后,在项目路径下会产生build/index.js文件。

构建的执行文件完整路径为:/Users/yourname/simple-mcp-server/build/index.js.

安装使用

在 Cherry Studio中打开设置/MCP服务器,添加MCP服务器,如下图:

添加MCP服务器

  • 名称: 随意写
  • 类型:STDIO
  • 命令:node
  • 参数:刚才构建的执行文件路径,即/Users/yourname/simple-mcp-server/build/index.js
  • 环境变量:
    • GAODE_API_KEY :高德开放平台申请的Web API 32位密钥 GAODE_API_KEY=your_api_key
    • DINGTALK_ACCESS_TOKEN: 创建钉钉群机器人的Webhook 地址后面的64位密钥 DINGTALK_ACCESS_TOKEN=your_access_token

使用

在Cherry Studio中新建对话,对话框下方开启MCP服务器和刚才安装的MCP Server。

注意:当选择了带有Function Call功能的大模型时,下方才有MCP相关选项。

使用MCP对话

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • rahulc0dy
  • 测试您的MCP服务器。

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • GeyserMC
  • 与Minecraft客户端/服务器通信的库。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • awslabs
  • AWS MCP服务器 - 将AWS最佳实践直接带入您的开发工作流程的专门MCP服务器

    Reviews

    1 (1)
    Avatar
    user_suUUimEr
    2025-04-18

    I've been using simple-mcp-server for a while now, and it has exceeded my expectations in every way. Developed by guog, this server is incredibly straightforward to set up and use. The documentation on the GitHub page is clear and concise, making the whole process smooth even for beginners. Highly recommend it!