包详细信息

ken-you-code

kenkai1.6kMIT1.3.0

Connect your codebase to Kimi: Ultra-fast AI code analysis with Kimi-K2 model via MCP

mcp, model-context-protocol, openrouter, claude-code

自述文件

Ken-You-Code

Connect your codebase to Kimi - Ultra-fast AI code analysis with Kimi-K2 model via MCP

A specialized Model Context Protocol (MCP) server built by Ken Kai does AI that enables Claude Code to delegate tasks to the powerful Kimi-K2 model via OpenRouter. Get lightning-fast code analysis, debugging, security reviews, and more.

Features

  • 10 Specialized Task Types: debug, analyze, review, optimize, style, document, test, refactor, migrate, design
  • Ultra-Fast Performance: Optimized prompts for 50x speed improvement (1-2 seconds vs 30+ seconds)
  • Kimi-K2 Integration: Leverage the powerful moonshotai/kimi-k2 model via OpenRouter
  • Secure File Operations: Read files with configurable security restrictions (.tsx, .jsx, .py, .js, .ts, etc.)
  • Diff-Based Workflow: Create and apply file changes with approval workflows and automatic backups
  • Type-Safe: Built with TypeScript and Zod validation

Task Types

debug

Find and fix bugs in your code

analyze

Analyze code structure, patterns, and potential issues

review

Review code quality, best practices, and security

optimize

Optimize performance and efficiency

style

Check and improve code style and formatting

document

Generate documentation and comments

test

Create and improve test coverage

refactor

Refactor code for better maintainability

migrate

Migrate code between frameworks or versions

design

Design UI/UX components and layouts

read_file

Read file content securely with path validation and size limits.

Parameters:

  • file_path: Absolute path to the file

create_diff

Generate a diff for proposed file changes without applying them.

Parameters:

  • file_path: Target file path
  • new_content: Proposed file content
  • reason: Explanation for the change

apply_diff

Apply a previously created diff with user approval.

Parameters:

  • operation_id: Diff operation identifier
  • approved: Boolean approval for the change

Quick Start

Prerequisites

  • Claude Code
  • OpenRouter API key

Installation

Add to Claude Code:

claude mcp add ken-you-code -s user -e OPENROUTER_API_KEY=<YOUR-OPENROUTER-API-KEY> -- npx -y ken-you-code

That's it! The MCP will be downloaded and configured automatically.

Environment Variables

Variable Required Default Description
OPENROUTER_API_KEY Yes - OpenRouter API key
WORKSPACE_ROOT No - Restrict file access to this directory
LOG_LEVEL No INFO Logging level
DEFAULT_MODEL No moonshotai/kimi-k2 Default model for tasks
MAX_FILE_SIZE_MB No 10 Maximum file size in MB
ALLOWED_EXTENSIONS No .py,.js,.ts,... Comma-separated allowed file extensions

Security

File Access Restrictions

  • Path Validation: Only absolute paths within allowed directories
  • Extension Filtering: Configurable allowed file extensions
  • Size Limits: Maximum file size enforcement
  • Forbidden Paths: Automatic blocking of sensitive directories (.env, .git/, node_modules/, etc.)

Approval Workflow

  • All file modifications require explicit user approval
  • Automatic backup creation before applying changes
  • Operation tracking with unique IDs

Development

Scripts

npm run dev        # Development mode with watch
npm run build      # Build TypeScript
npm run test       # Run tests
npm run lint       # Lint code
npm run lint:fix   # Fix linting issues
npm run format     # Format code

Project Structure

src/
├── server.ts              # Main MCP server
├── tools/
│   ├── fileOperations.ts  # Secure file reading
│   ├── specializedTask.ts # OpenRouter integration
│   └── diffManager.ts     # Diff creation and application
├── config/
│   └── index.ts          # Configuration management
└── types/
    └── index.ts          # Type definitions and validation

Usage Examples

Debugging a Performance Issue

// Claude Code can call:
await mcp.call('specialized_task', {
  task_type: 'debug',
  context: 'Performance issue with database queries',
  files: ['/project/src/database.ts', '/project/src/queries.ts'],
});

Code Review

await mcp.call('specialized_task', {
  task_type: 'review',
  context: 'Review this authentication implementation for security',
  files: ['/project/src/auth.ts'],
});

Applying Suggested Changes

// Create diff
const diffResult = await mcp.call('create_diff', {
  file_path: '/project/src/auth.ts',
  new_content: '// Updated code here...',
  reason: 'Fix security vulnerability identified in review',
});

// Apply with approval
await mcp.call('apply_diff', {
  operation_id: diffResult.operation_id,
  approved: true,
});

Model Support

Powered by Kimi-K2 (moonshotai/kimi-k2) via OpenRouter - known for exceptional code analysis, debugging capabilities, and ultra-fast performance.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Ensure linting and build pass
  6. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

For issues and questions:

  • Check the troubleshooting section
  • Review existing GitHub issues
  • Create a new issue with detailed information