模型上下文协议服务器

MCP服务器是一个提供从不同仓库源访问资源和提示的工具,支持团队共享编码标准、文档和可重用提示。

  • by cressie176
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 cressie176/mcp-server

使用说明

MCP服务器

一种模型上下文协议(MCP)服务器,提供对来自不同存储库源的资源和提示的访问。这允许您通过将编码标准、文档和可重用提示存储在GitHub存储库中,使Claude和其他兼容MCP的AI工具可以访问它们,从而在整个团队中共享这些标准、文档以及可重用提示。

快速开始

最快的入门方法是使用GitHub存储库。首先,创建一个具有以下结构的存储库:

your-repo/
├── index.json
├── resources/
│   └── your-resource.md
└── prompts/
    └── your-prompt.md

创建 index.json 声明可用资源和提示的文件:

{
  "resources": [
    {
      "name": "your-resource",
      "description": "Description of your resource"
    }
  ],
  "prompts": [
    {
      "name": "your-prompt",
      "description": "Description of your prompt"
    }
  ]
}

将此添加到您的Claude配置中:

{
  "mcpServers": {
    "mcp-server": {
      "command": "npx",
      "args": [
        "--yes",
        "github:cressie176/mcp-server",
        "--repository-type", "github",
        "--user", "your-username",
        "--repository", "your-repo"
      ]
    }
  }
}

重新启动Claude,您的资源和提示将可用。您可以使用确认 /mcp 命令。

看我的 提示 例如,存储库。

用法

GitHub存储库

从GitHub存储库访问资源和提示:

npx --yes github:cressie176/mcp-server --repository-type github --user your-user --repository your-repo

GitHub选项:

  • --user:GitHub用户名
  • --organisation:GitHub组织名称
  • --repository:存储库名称
  • --ref:Git引用(默认值: heads/main)
  • --path:存储库中的路径(可选)
  • --log-level:日志记录级别(调试、信息、警告、错误、关闭)
  • --log-file:日志文件路径(默认:debug.Log)

本地文件系统

从本地目录访问资源和提示(对测试有用):

npx --yes github:cressie176/mcp-server --repository-type filesystem --path ./path/to/folder

文件系统选项:

  • --path:包含资源和提示的目录的路径
  • --log-level:日志记录级别(调试、信息、警告、错误、关闭)
  • --log-file:日志文件路径(默认:debug.Log)

存储库结构

您的存储库(无论是GitHub还是本地文件系统)应遵循以下结构:

├── index.json          # Defines available resources and prompts
├── resources/          # Directory containing resource files
│   └── *.md           # Markdown resource files
└── prompts/           # Directory containing prompt files
    └── *.md           # Markdown prompt files

index.json格式

{
  "resources": [
    {
      "name": "code-standards",
      "description": "Coding standards and guidelines"
    }
  ],
  "prompts": [
    {
      "name": "code-review",
      "description": "Perform a comprehensive code review"
    }
  ]
}

克劳德配置

GitHub存储库:

{
  "mcpServers": {
    "your-server-name": {
      "command": "npx",
      "args": [
        "--yes",
        "github:cressie176/mcp-server"
        "--repository-type", "github",
        "--user", "your-username",
        "--repository", "your-repo"
      ]
    }
  }
}

文件系统存储库

将以下内容添加到您的claude配置文件中:

{
  "mcpServers": {
    "your-server-name": {
      "command": "npx",
      "args": [
        "--yes",
        "github:cressie176/mcp-server",
        "--repository-type",
        "filesystem",
        "--path",
        "/path/to/your/data"
      ]
    }
  }
}

发展

使用MCP检查器进行调试

使用MCP检查器调试和测试您的服务器:

npx @modelcontextprotocol/inspector node index.js --repository-type filesystem --path ./test/data

这将打开一个web界面,您可以在其中:

  • 测试资源和提示列表
  • 检查服务器响应
  • 调试客户端和服务器之间的通信

运行测试

npm test

代码的风格

npm run lint
npm run format

许可证

国际学生委员会