mcp-server

iqszlong/mcp-server

3.1

If you are the rightful owner of mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This is an MCP server example demonstrating how to use the MCP protocol to call a server in AI. The service relies on Node.js, so please ensure the runtime environment has Node.js installed.

Tools
2
Resources
0
Prompts
0

介绍

这是一个mcp服务端示例,用于演示如何使用mcp协议在AI中调用服务端。服务依赖nodejs,请先确保运行环境已安装nodejs。

该服务有2个工具:

  1. add 2个数字相加返回结果
  2. fetch-data 从API获取PageSize条数据,可以从lazy测试服务器上获取文章列表数据

注意

  • AI模型需要能够使用MCP的能力,也就是functioncall,否则会报错无法调用MCP服务
    • deepseek是可以使用MCP工具的,在模型列表中有标注工具的一般都支持MCP调用
  • fetch-data工具的使用,要确保AI模型能够访问网络,否则会报错无法请求。
  • 在配置好MCP服务后,对话时需先开启mcp服务,让AI能识别工具。不同的工具有不同的开启方式,Cherry Studio是在对话框中多了一个命令行似的工具按钮,点击后开启工具即可。

获取依赖后启动服务

npm install
npm start

在AI中如何使用

在mcpServers中添加服务端配置,server.js的路径需要使用绝对路径,例如:

MAC

{
  "mcpServers": {
    "demo-server": {
      "isActive": true,
      "name": "MCP",
      "key": "demo-server",
      "type": "stdio",
      "description": "",
      "command": "node",
      "args": [
        "path/to/root/mcp-server/server.js"
      ]
    }
  }
}

Windows

这里是node的,所以不需要修改(跳过)

如果使用Windows,其他命令需要改成cmd,例如:

{
  "mcpServers": {
    "demo-server": {
      "isActive": true,
      "name": "MCP",
      "key": "demo-server",
      "type": "stdio",
      "description": "",
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "D:\\path\\to\\root\\mcp-server\\server.js"
      ]
    }
  }
}

使用效果参考