模型上下文协议服务器

一个基于TypeScript实现的模型上下文协议(MCP)服务器,支持提示、资源和工具管理。

  • by nand1234
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 nand1234/mcp-server-typescript

使用说明

MCP服务器

一个支持提示、资源和工具的模型上下文协议(MCP)服务器的TypeScript实现。

项目结构

mcp/
├── package.json          # Project dependencies and scripts
├── tsconfig.json         # TypeScript configuration
└── src/
    ├── server.ts         # Main server implementation
    ├── prompts/          # Prompt definitions and handlers
    │   ├── prompt_definition.ts
    │   └── prompt.ts
    ├── resources/        # Resource definitions and handlers
    │   ├── resource_definition.ts
    │   └── resource.ts
    └── tools/            # Tool definitions and handlers
        ├── tool_definition.ts
        └── tool.ts

特点/功能

  • 提示预定义的提示模板和处理程序
  • 资源资源管理与定义
  • 工具MCP服务器的自定义工具实现

先决条件

  • Node.js(建议使用v14或更高版本)
  • npm 或 yarn 包管理器

安装

# Clone the repository
git clone https://github.com/nand1234/mcp-server-typescript.git
cd mcp-server-typescript

# Install dependencies
npm install

发展

# Build the project
npm run build

# Run in debugger mode
npm inspect

配置

配置详情可查阅 package.json 和 tsconfig.json。

使用方法

这个MCP服务器提供了三个主要组件:

提示

提示(Prompts)在(某处)被定义 src/prompts/ 目录并提供可重用的提示模板。

资源

资源在……中定义 src/resources/ 目录并管理各种数据源。

工具

工具在(某处/某文件中)有定义 src/tools/ 目录并实现可通过MCP协议访问的自定义功能。

建筑

该项目使用TypeScript编写,并可通过以下方式编译:

npm run build

项目类型

  • 语言TypeScript
  • 运行时Node.js
  • 协议模型上下文协议(MCP)

做出贡献

欢迎贡献!请随时提交拉取请求。

作者

南德库马尔·加塔格

支持

对于问题和疑问,请在仓库中提交一个议题。

在VS Code中,mcp.json文件中的服务器设置

{ "servers": { "nand-mcp": { "类型": "stdio"(标准输入输出), "命令": "node", "args": ["./dist/server.js"],, "cwd": "/home/nandkumarg/projects/learning/mcp" 翻译成中文是:“当前工作目录(cwd)”:“/home/nandkumarg/projects/learning/mcp” } }, "inputs": [] 翻译成中文是:“输入”:[] }