Token导航 LogoToken导航TokenDH.com
MCP Optimist logo
开发工具未说明官方级别未说明来源级核验

MCP Optimist

MCP Server

一个智能代码优化MCP服务器,通过多维度分析改进代码库,适用于开发效率提升和代码质量优化。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
代码分析代码质量TypeScriptClaude内存管理Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Atomic-Germ

提供方

Atomic-Germ

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

Optimist MCP服务器

智能代码优化MCP服务器,可跨多个维度分析和改进代码库

![License: MIT](https://opensource.org/licenses/MIT) ![TypeScript](https://www.typescriptlang.org/) ![MCP](https://modelcontextprotocol.io) ![CI/CD](https://github.com/Atomic-Germ/mcp-optimist/actions/workflows/ci.yml)

概述

Optimist是一个模型上下文协议(MCP)服务器,旨在与其他开发工具协同工作,提供全面的代码库优化。它分析代码的性能瓶颈、内存问题、代码异味和可维护性问题,提供可操作的改进建议。

主要特点

  • 🚀 性能分析 -识别瓶颈和热点路径
  • 💾 内存优化 -检测泄漏和低效分配
  • 📊 代码质量度量 -复杂性分析和可维护性评分
  • 🔍 死码检测 -查找并删除未使用的代码
  • 📦 依赖管理 -优化和分析依赖关系图
  • 🎯 智能重构 -基于人工智能的重构建议
  • 🔗 MCP集成 -与其他MCP工具无缝集成
  • 测试驱动 -使用TDD方法构建

快速开始

先决条件

  • Node.js 18+
  • npm或pnpm
  • MCP兼容客户端(例如Claude Desktop)
  • 要分析的代码库

安装

# Clone the repository
git clone https://github.com/Atomic-Germ/mcp-optimist.git
cd mcp-optimist
npm install
npm run build

测试服务器

# Run tests to verify everything works
npm test

# Run with coverage
npm run test:coverage

# Verify build output
ls -la dist/

配置MCP客户端

克劳德桌面

编辑配置文件:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • 视窗: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/claude/claude_desktop_config.json

添加服务器:

{
  "mcpServers": {
    "optimist": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-optimist/dist/index.js"],
      "env": {}
    }
  }
}

验证设置

  1. 重新启动MCP客户端
  2. 在可用工具中寻找“乐观主义者”
  3. 您应该看到8个可用的优化工具

首次代码分析

在您的MCP客户端中尝试以下示例:

分析代码复杂性

Use analyze_complexity tool on your project:
Path: "./src"
Max Complexity: 10
Report Format: "summary"

检测性能问题

Use analyze_performance tool:
Path: "./src"
Include Tests: false
Threshold: "medium"

查找代码气味

Use detect_code_smells tool:
Path: "./src"
Severity: "medium"

内存分析

Use optimize_memory tool:
Path: "./src"
Detect Leaks: true
Suggest Fixes: true

发展

开发命令

# Development
npm run dev              # Run with ts-node (development mode)
npm run build:watch      # Auto-rebuild on changes

# Testing
npm test                 # Run all tests
npm run test:watch       # Watch mode for tests
npm run test:coverage    # Generate coverage report

# Code Quality
npm run lint             # Check code with ESLint
npm run lint:fix         # Auto-fix linting issues
npm run format           # Format code with Prettier
npm run format:check     # Check formatting

# Build
npm run build            # Compile to dist/
npm run clean            # Remove dist/

项目结构

mcp-optimist/
├── src/
│   ├── index.ts         # MCP server entry point
│   ├── server.ts        # OptimistServer class
│   ├── types/           # TypeScript definitions
│   ├── tools/           # Tool implementations
│   ├── analyzers/       # Analysis engines
│   └── utils/           # Utility functions
│
├── tests/
│   ├── unit/            # Unit tests
│   ├── integration/     # Integration tests
│   └── fixtures/        # Test fixtures
│
├── docs/                # Documentation
├── archive/             # Archived documentation
├── README.md            # This file
├── package.json         # Dependencies and scripts
├── tsconfig.json        # TypeScript configuration
├── jest.config.js       # Test configuration
├── eslint.config.js     # Linting rules
├── .prettierrc          # Code formatting
└── dist/                # Compiled JavaScript

示例

基本项目分析

对整个项目进行全面分析:

// Analyze overall code quality
{
  tool: "detect_code_smells",
  arguments: {
    path: "./src",
    severity: "medium"
  }
}

// Check performance issues
{
  tool: "analyze_performance",
  arguments: {
    path: "./src",
    threshold: "medium",
    includeTests: false
  }
}

// Find complexity issues
{
  tool: "analyze_complexity",
  arguments: {
    path: "./src",
    maxComplexity: 8,
    reportFormat: "detailed"
  }
}

单文件分析

分析一个特定的有问题的文件:

{
  tool: "analyze_performance",
  arguments: {
    path: "./src/services/dataProcessor.ts",
    threshold: "low",
    profileHotPaths: true,
    trackAsyncOperations: true
  }
}

内存优化

查找并修复React组件中的内存泄漏:

{
  tool: "optimize_memory",
  arguments: {
    path: "./src/components",
    detectLeaks: true,
    analyzeClosures: true
  }
}

泄漏分析结果:

{
  data: {
    findings: [
      {
        type: 'event-listener-leak',
        file: 'src/components/DataChart.tsx',
        line: 23,
        description: 'Event listeners not cleaned up in useEffect',
        leakPotential: 'high',
      },
      {
        type: 'closure-retention',
        file: 'src/hooks/useDataFetch.ts',
        line: 15,
        description: 'Closure retaining large objects unnecessarily',
      },
    ];
  }
}

内存泄漏修复:

问题-事件侦听器泄漏:

// Problematic - no cleanup
function DataChart() {
  useEffect(() => {
    window.addEventListener('resize', handleResize);
    // Missing cleanup function
  }, []);
}

固定的:

// Fixed with proper cleanup
function DataChart() {
  useEffect(() => {
    const handleResize = () => {
      // Handle resize
    };

    window.addEventListener('resize', handleResize);

    // Cleanup function prevents leak
    return () => {
      window.removeEventListener('resize', handleResize);
    };
  }, []);
}

性能优化

识别并解决性能瓶颈:

{
  tool: "analyze_performance",
  arguments: {
    path: "./src/services/dataProcessor.ts",
    threshold: "low",
    profileHotPaths: true
  }
}

之前(有问题):

// O(n²) complexity - problematic
function processLargeDataset(items: Item[], lookup: LookupItem[]): ProcessedItem[] {
  return items.map((item) => {
    // Inner loop for each item - O(n²)
    const match = lookup.find((l) => l.id === item.lookupId);
    return { ...item, enrichedData: match?.data };
  });
}

之后(优化):

// O(n) complexity - optimized
function processLargeDataset(items: Item[], lookup: LookupItem[]): ProcessedItem[] {
  // Create lookup map once - O(n)
  const lookupMap = new Map(lookup.map((l) => [l.id, l.data]));

  // Single pass through items - O(n)
  return items.map((item) => ({
    ...item,
    enrichedData: lookupMap.get(item.lookupId),
  }));
}

代码质量分析

分析函数复杂性和代码气味:

{
  tool: "analyze_complexity",
  arguments: {
    path: "./src/utils/validation.ts",
    maxComplexity: 6,
    includeCognitive: true
  }
}

{
  tool: "detect_code_smells",
  arguments: {
    path: "./src/services/UserService.ts",
    severity: "high"
  }
}

______________________________________________________________________

有关更多示例,请参阅 api参考.

目录标签

目录标签

代码分析代码质量TypeScriptClaude内存管理本地部署性能优化AI重构

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP