模型上下文协议服务器

一个生产就绪的模型上下文协议(MCP)服务器,提供文件操作、系统监控、进程管理和AI集成功能,适用于本地系统与AI助手的无缝集成。

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

使用说明

增强MCP服务器

✅ 状态:生产准备就绪

功能齐全且经过优化的MCP服务器 具有组织化的TypeScript架构、全面的功能和企业级安全性。已准备好与Claude Desktop和其他MCP客户端一起用于生产。

🚀 快速开始

# Install dependencies and build
npm install && npm run build

# Run basic tests to verify functionality
npm test

# Start the server
npm start

📖 看 设置.md 有关Claude Desktop集成的详细说明。


🎯 概述

A. 生产就绪模型上下文协议(MCP)服务器 专为与AI助手无缝集成本地系统而设计。该服务器采用TypeScript构建,具有干净、有序的架构,为开发工作流程提供了全面的工具、资源和AI驱动的提示。

🏗️ 建筑亮点

  • 🎨 干净的TypeScript架构:按域组织接口,以实现最大的可维护性
  • 🔒 企业安全:路径遍历保护、输入验证和可配置的访问控制
  • ⚡ 高性能:智能缓存、并发限制和内存管理
  • 🧩 模块化设计:明确分离关注点的特定领域服务
  • 🔧 高度可配置性:功能标志、基于环境的配置和运行时自定义

🌟 特性

🛠️ 综合工具套件

类别 工具 描述
📁 文件操作 read-file, write-file, copy-file, move-file, delete-file, create-directory, list-directory 完整的文件系统管理和安全验证
💻 系统信息 get-system-info, get-process-list, get-network-info, get-disk-usage 实时系统监控和诊断
⚙️ 流程管理 execute-command, kill-process, get-process-info 具有超时保护的安全命令执行
🔍 搜索与分析 search-files, search-content, analyze-code 支持正则表达式和人工智能分析的高级搜索
🤖 人工智能集成 analyze-code, review-code, explain-code 增强人工智能驱动的发展援助

📚 动态资源

资源类型 URI模式 功能
📄 文件内容 file://{path} 具有MIME类型检测的直接文件访问
📂 目录列表 directory://{path} 分层目录浏览
📊 系统度量 system://status, system://processes 实时系统性能数据
🌐 网络信息 network://interfaces, network://connections 网络拓扑和连接状态
⚙️ 服务器配置 config://current, config://capabilities 运行时配置和功能状态

💡 人工智能提示

提示类别 可用提示 用例
🔍 代码审查 code-review 安全性、性能、可维护性分析
📖 文档 generate-docs JSDoc、Markdown、API文档生成
🐛 调试 debug-code, explain-error 问题诊断和解决指南
🧪 测试 generate-tests 为多个框架生成单元测试
📋 分析 analyze-file, project-overview 代码质量和项目结构分析

安装

先决条件

  • Node.js 18.0.0或更高版本
  • npm或yarn包管理器

再进行

npm install

构建项目

npm run build

用法

基本用法

# Start the server
npm start

# Or run directly
node build/server/index.js

发展模式

# Run with hot reload
npm run dev

命令行选项

# Show help
augment-mcp-server --help

# Show version
augment-mcp-server --version

# Show current configuration
augment-mcp-server --config

配置

可以使用环境变量配置服务器:

核心设置

# Logging
LOG_LEVEL=info                    # error, warn, info, debug
LOG_FILE=/path/to/logfile        # Optional log file path

# Security
MAX_FILE_SIZE=104857600          # Maximum file size (100MB)
MAX_BATCH_SIZE=100               # Maximum batch operation size
COMMAND_TIMEOUT=30000            # Command timeout in milliseconds
ALLOWED_DIRECTORIES=.,./src      # Comma-separated allowed directories
BLOCKED_DIRECTORIES=/etc,/usr    # Comma-separated blocked directories

# Performance
CACHE_ENABLED=true               # Enable caching
CACHE_TTL=300000                 # Cache TTL in milliseconds
MAX_CONCURRENT_FILE_OPS=10       # Max concurrent file operations
MAX_CONCURRENT_SEARCHES=5        # Max concurrent searches

增强AI集成

AUGMENT_ENABLED=true                           # Enable Augment AI features
AUGMENT_API_ENDPOINT=http://localhost:8080     # Augment AI API endpoint
AUGMENT_API_KEY=your-api-key                   # API key (if required)
AUGMENT_MODEL=claude-3-sonnet                  # AI model to use
AUGMENT_MAX_TOKENS=4096                        # Maximum tokens per request
AUGMENT_TEMPERATURE=0.7                        # AI temperature setting

功能标志

# Core Features
FEATURE_FILE_OPERATIONS=true        # Enable file operations
FEATURE_SYSTEM_INFO=true            # Enable system information tools
FEATURE_PROCESS_MANAGEMENT=true     # Enable process management
FEATURE_NETWORK_INFO=true           # Enable network information
FEATURE_CODE_ANALYSIS=true          # Enable code analysis tools
FEATURE_SEARCH_OPERATIONS=true      # Enable search operations

# Resources
FEATURE_FILE_RESOURCES=true         # Enable file resources
FEATURE_SYSTEM_RESOURCES=true       # Enable system resources
FEATURE_LOG_RESOURCES=true          # Enable log resources

# Prompts
FEATURE_CODE_REVIEW_PROMPTS=true    # Enable code review prompts
FEATURE_DOCUMENTATION_PROMPTS=true  # Enable documentation prompts
FEATURE_DEBUGGING_PROMPTS=true      # Enable debugging prompts

# Experimental
EXPERIMENTAL_AI_INTEGRATION=false   # Enable experimental AI features
EXPERIMENTAL_ADVANCED_ANALYTICS=false
EXPERIMENTAL_REAL_TIME_MONITORING=false

与Claude Desktop集成

要将此服务器与Claude Desktop一起使用,请将以下内容添加到您的 claude_desktop_config.json:

macOS/Linux

{
  "mcpServers": {
    "augment-mcp-server": {
      "command": "node",
      "args": ["/absolute/path/to/augment-mcp-server/build/server/index.js"],
      "env": {
        "LOG_LEVEL": "info",
        "AUGMENT_ENABLED": "true"
      }
    }
  }
}

视窗

{
  "mcpServers": {
    "augment-mcp-server": {
      "command": "node",
      "args": ["C:\\absolute\\path\\to\\augment-mcp-server\\build\\server\\index.js"],
      "env": {
        "LOG_LEVEL": "info",
        "AUGMENT_ENABLED": "true"
      }
    }
  }
}

发展

🏗️ 项目架构

src/
├── 🖥️  server/                    # Server implementation layer
│   ├── index.ts                  # Main server entry point with graceful shutdown
│   ├── config.ts                 # Environment-based configuration management
│   └── handlers/                 # MCP protocol handlers
│       ├── tools.ts              # Tool implementations with validation
│       ├── resources.ts          # Resource providers with caching
│       └── prompts.ts            # AI-powered prompt templates
├── 🔧 services/                  # Business logic layer
│   ├── fileService.ts            # File system operations with security
│   ├── systemService.ts          # System information and monitoring
│   └── augmentService.ts         # Augment AI integration service
├── 🎯 interfaces/                # Organized TypeScript interfaces
│   ├── server/                   # Server configuration interfaces
│   ├── file/                     # File operation interfaces
│   ├── system/                   # System information interfaces
│   ├── mcp/                      # MCP protocol interfaces
│   ├── analysis/                 # Code analysis interfaces
│   ├── git/                      # Git integration interfaces
│   └── index.ts                  # Central interface export hub
└── 🛠️  utils/                    # Utility functions
    ├── logger.ts                 # Structured logging with Winston
    └── validation.ts             # Zod-based input validation schemas

🎨 接口组织

我们的TypeScript接口按域组织,以实现最大的可维护性:

// Single import point for all interfaces
import type {
  ServerConfig, AugmentConfig,           // Server configuration
  FileInfo, SearchOptions, SearchResult, // File operations
  SystemInfo, ProcessInfo, HealthCheck,  // System information
  ToolResult, ResourceContent,           // MCP protocol
  CodeAnalysisResult                     // Code analysis
} from '../interfaces/index.js';

优点:

  • 🎯 特定领域组织 -相关接口组合在一起
  • 🔄 单一导入点 -所有接口均可在一个中心位置使用
  • 📝 清晰的文件 -每个域都有特定的用途和示例
  • 🔧 易维护 -将新接口添加到适当的域
  • 🚀 更好的IDE支持 -改进了自动补全和导航

🔧 开发脚本

脚本 命令 描述
🏗️ 构建 npm run build 使用类型检查将TypeScript编译为JavaScript
🚀 开始 npm start 启动生产服务器
⚡ 发展 npm run dev 使用热重新加载和调试日志运行
🧪 测试 npm test 运行全面的测试套件
👀 测试手表 npm run test:watch 在监视模式下运行测试以进行开发
🔍 棉绒 npm run lint 使用ESLint检查代码质量
🔧 棉绒修复 npm run lint:fix 自动修复掉毛问题
🧹 清洁 npm run clean 删除构建工件
# Development workflow
npm install              # Install dependencies
npm run build           # Build the project
npm test               # Verify everything works
npm start              # Start the server

测试

# Run all tests
npm test

# Run tests with coverage
npm run test -- --coverage

# Run specific test file
npm test -- fileService.test.ts

# Run tests in watch mode
npm run test:watch

🔒 安全与性能

🛡️ 企业安全功能

安全层 实施 好处
🚫 路径横向保护 全面的路径验证和清理 防止未经授权的文件系统访问
⏱️ 命令执行限制 超时保护和命令过滤 防止系统资源滥用
📏 文件大小限制 可配置的最大文件大小 防止资源耗尽
📁 目录限制 Allowlist/blocklist目录访问 限制文件操作范围
✅ 输入验证 基于Zod模式的验证 确保数据完整性和类型安全
🚦 速率限制 可选请求节流 防止API滥用和DoS攻击

⚡ 性能优化

特性 实施 影响
🗄️ 智能高速缓存 具有可配置大小限制的基于TTL的缓存 减少I/O操作并缩短响应时间
🔄 并发控制 可配置的并行操作限制 防止资源争用和系统过载
🧠 内存管理 自动GC触发器和堆监控 保持稳定的内存使用
📡 流媒体支持 使用流处理大文件 允许处理大于可用RAM的文件
📊 健康监测 实时系统健康检查 主动性能问题检测

故障排除

常见问题

  1. 服务器无法启动

    • 检查Node.js版本(需要18+)
    • 验证是否已安装所有依赖项
    • 检查日志文件以了解错误详细信息
  2. 文件操作失败

    • 验证文件路径是否在允许的目录内
    • 检查文件权限
    • 确保文件大小在限制范围内
  3. 增强AI功能不起作用

    • 验证 AUGMENT_ENABLED=true
    • 检查API端点配置
    • 验证网络连接

调试

启用调试日志记录:

LOG_LEVEL=debug npm start

检查日志文件:

tail -f logs/combined.log
tail -f logs/error.log

贡献

  1. 分叉存储库
  2. 创建要素分支
  3. 进行更改
  4. 添加新功能的测试
  5. 运行测试套件
  6. 提交拉取请求

🎯 为什么选择Augment MCP服务器?

优势 描述 优势
🏗️ 清洁建筑 具有单一导入点的领域组织TypeScript接口 易于维护和开发
🔒 生产安全 具有全面验证的企业级安全 适用于生产环境
⚡ 高性能 智能缓存和资源管理 可根据您的需求进行扩展
🤖 人工智能集成 对开发工作流程的内置增强AI支持 提高了生产力
🔧 高度可配置性 广泛的功能标志和环境配置 适应任何用例
📖 证据充分的 全面的文档和示例 快速入门

📄 许可证

MIT许可证-请参阅 许可证 文件以获取详细信息。

🆘 支持与社区

获取帮助

资源 描述 链接
📚 文档 完整的设置和使用指南 设置.md
🐛 问题 Bug报告和功能请求 GitHub问题
💬 讨论 社区支持和问题 GitHub讨论
📖 故障排除 常见问题和解决方案 请参阅上面的故障排除部分

贡献

我们欢迎捐款!请查看我们的 贡献指南 有关以下内容的详细信息:

  • 🔧 建立开发环境
  • 🧪 运行测试和质量检查
  • 📝 文件标准
  • 🚀 提交拉取请求

📋 更新日志

v1.0.0-生产发布🎉

🏗️ 架构改进

  • ✨ 有组织的TypeScript接口:将单片类型重构为特定于域的接口模块
  • 🎯 中央进口系统:所有接口的单一入口点,通过 src/interfaces/index.ts
  • 🧹 清洁建筑:删除了冗余类型目录,简化了导入结构
  • 📝 增强文档:包含使用示例的全面接口文档

🚀 核心功能

  • 🛠️ 完成MCP实施:带有工具、资源和提示的完整模型上下文协议服务器
  • 📁 高级文件操作:通过验证和安全检查确保文件系统管理的安全
  • 💻 系统集成:实时系统监控、流程管理和网络信息
  • 🤖 人工智能驱动开发:增强代码分析、审查和文档的AI集成
  • 🔍 智能搜索:支持正则表达式的高级文件和内容搜索

🔒 安全性和性能增强

  • 🛡️ 企业安全:路径遍历保护、输入验证和访问控制
  • ⚡ 性能优化:智能缓存、并发限制和内存管理
  • 📊 健康监测:实时系统健康检查和性能指标
  • 🔧 可配置功能:广泛的功能标志和基于环境的配置

🧪 质量保证

  • ✅ 综合测试:包含单元和集成测试的完整测试套件
  • 🔍 代码质量:ESLint配置,带有严格的TypeScript检查
  • 📖 文档:完整的自述文件、安装指南和API文档
  • 🚀 生产就绪:优化了构建过程和部署脚本