Files
mcp-demo/.github/copilot-instructions.md
CHE LIANG ZHAO 6e8a93c8e9 Initial commit
2026-01-16 18:21:32 +08:00

1.1 KiB

MCP Demo Server - Copilot Instructions

项目概述

这是一个 Model Context Protocol (MCP) 服务器示例项目,使用 TypeScript 编写。

技术栈

  • 语言: TypeScript
  • 运行时: Node.js
  • MCP SDK: @modelcontextprotocol/sdk
  • Schema 验证: Zod

项目结构

  • src/index.ts - MCP 服务器主入口文件
  • build/ - 编译后的 JavaScript 文件
  • .vscode/mcp.json - VS Code MCP 服务器配置

开发指南

添加新工具

使用 server.registerTool() 方法注册新工具:

server.registerTool(
  "tool_name",
  {
    description: "工具描述",
    inputSchema: {
      // 使用 Zod schema 定义参数
    },
  },
  async (params) => {
    // 实现工具逻辑
    return {
      content: [{ type: "text", text: "结果" }],
    };
  }
);

常用命令

  • npm run build - 编译 TypeScript
  • npm start - 运行 MCP 服务器
  • npm run dev - 开发模式(监听文件变化)

MCP 参考文档