mcp-cli-project-ts

MCP CLI project with TypeScript

GitHub Stars

0

User Rating

Not Rated

Forks

0

Issues

0

Views

1

Favorites

0

README
MCP CLI Project (TypeScript)

A comprehensive Command Line Interface (CLI) project demonstrating Model Context Protocol (MCP) integration with multiple tools and servers, built in TypeScript.

๐ŸŒŸ Features

This CLI application showcases five main functionalities:

  • ๐Ÿ“ Todo Management: Add, list, mark done, and manage tasks
  • ๐Ÿงฎ Calculator: Perform basic and advanced mathematical calculations
  • ๐ŸŒค๏ธ Weather: Get weather information with MCP server integration
  • ๐Ÿ™ GitHub Integration: Comprehensive GitHub analysis, search, and discovery tools
  • ๐Ÿ”Œ MCP Integration: Test and explore multiple MCP servers with real-time tool discovery
๐Ÿ“‹ Prerequisites
  • Node.js: v18.x or higher
  • npm: v8 or higher
  • TypeScript: v5.x (installed as dev dependency)
  • GitHub Personal Access Token (optional): For enhanced GitHub functionality
๐Ÿš€ Installation
  1. Clone the repository:

    git clone <your-repo-url>
    cd mcp-cli-project-ts
    
  2. Install dependencies:

    npm install
    
  3. Build the project:

    npm run build
    
  4. Set up GitHub token (optional but recommended):

    npm run github:setup
    
๐Ÿ› ๏ธ Usage
Todo Management
# List all tasks
npm run todo -- --list

# Add a new task
npm run todo -- --add "Learn MCP protocol"

# Mark a task as done (use task ID from list)
npm run todo -- --done 1

# Clear completed tasks
npm run todo -- --clear

# Show todo statistics
npm run todo -- --stats
Calculator
# Basic calculation
npm run calc "2 + 3 * 4"

# Advanced calculations with functions
npm run calc -- --advanced "sin(pi/2) + cos(0)"

# Examples of supported functions: sin, cos, tan, sqrt, log, exp, abs
npm run calc -- --advanced "sqrt(16) + log(10)"
Weather
# Get weather for default city (San Francisco)
npm run weather

# Get weather for specific city
npm run weather -- --city "New York"

# Test with real MCP weather server
npm run weather -- --real --city "London"

# Test multiple MCP weather servers
npm run weather -- --test --city "Tokyo"
๐Ÿ™ GitHub Integration (NEW!)
Quick Start
# Test GitHub MCP server connection
npm run github connect

# Discover all available GitHub tools
npm run github tools

# Run comprehensive GitHub experiments
npm run github experiments
Search & Discovery
# Search repositories
npm run github search --repos "typescript"
npm run github search --repos "machine-learning" --limit 10

# Search users
npm run github search --users "developer-name"

# Search code patterns
npm run github search --code "async function" --lang typescript
Analysis & Insights
# Analyze trending repositories
npm run github trending

# Get developer insights
npm run github developer octocat
npm run github developer microsoft

# Explore technology communities  
npm run github community "machine-learning"
npm run github community "typescript"

# Analyze code patterns across GitHub
npm run github pattern "interface"
npm run github pattern "async/await"
Comprehensive Experiments
# Run all experiments for a topic
npm run github experiments --topic "python"
npm run github experiments --topic "react"

# Run GitHub test suite
npm run github:test
MCP Server Testing
# Test weather MCP server
npm run build && node dist/src/index.js mcp --server weather --list

# Test filesystem MCP server 
npm run build && node dist/src/index.js mcp --server filesystem --path ./data --list

# Test GitHub MCP server
npm run build && node dist/src/index.js mcp --server github --list

# Test specific MCP tool
npm run build && node dist/src/index.js mcp --server weather --test get_weather
Development Commands
# Development mode with auto-reload
npm run dev

# Watch mode (auto-rebuild on changes)
npm run watch

# Type checking without compilation
npm run type-check

# Clean build artifacts
npm run clean

# GitHub setup helper
npm run github:setup

# GitHub testing suite
npm run github:test
๐Ÿ—๏ธ Project Structure
mcp-cli-project-ts/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.ts          # Main CLI entry point
โ”‚   โ”œโ”€โ”€ mcp-client.ts     # MCP client implementation
โ”‚   โ””โ”€โ”€ github-cli.ts     # GitHub CLI interface (NEW!)
โ”œโ”€โ”€ tools/
โ”‚   โ”œโ”€โ”€ todo.ts           # Todo management functionality
โ”‚   โ”œโ”€โ”€ calculator.ts     # Calculator operations
โ”‚   โ”œโ”€โ”€ weather.ts        # Weather tools with MCP integration
โ”‚   โ””โ”€โ”€ github.ts         # GitHub analysis tools (NEW!)
โ”œโ”€โ”€ types/
โ”‚   โ”œโ”€โ”€ todo-types.ts     # Todo-related type definitions
โ”‚   โ”œโ”€โ”€ calculator-types.ts # Calculator type definitions
โ”‚   โ”œโ”€โ”€ weather-types.ts  # Weather type definitions
โ”‚   โ”œโ”€โ”€ mcp-types.ts      # MCP protocol types
โ”‚   โ”œโ”€โ”€ cli-types.ts      # CLI-specific types
โ”‚   โ”œโ”€โ”€ config-types.ts   # Configuration types (NEW!)
โ”‚   โ””โ”€โ”€ errors.ts         # Error handling types (NEW!)
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ mcp-config.json   # MCP server configurations
โ”‚   โ””โ”€โ”€ github-experiments.json # GitHub experiment presets (NEW!)
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ setup-github.sh   # GitHub setup script (NEW!)
โ”‚   โ””โ”€โ”€ test-github-experiments.sh # GitHub test suite (NEW!)
โ”œโ”€โ”€ data/                 # Data storage (todos.json, etc.)
โ”œโ”€โ”€ dist/                 # Compiled JavaScript output
โ”œโ”€โ”€ package.json          # Project configuration and dependencies
โ”œโ”€โ”€ tsconfig.json         # TypeScript configuration
โ””โ”€โ”€ README.md            # This file
๐Ÿ”ง Architecture
Core Components
  1. CLI Framework: Built with Commander.js for command parsing
  2. MCP Integration: Uses @modelcontextprotocol/sdk for protocol communication
  3. Type Safety: Full TypeScript implementation with strict type checking
  4. Modular Design: Separate tools for different functionalities
  5. GitHub Integration: Advanced GitHub analysis and discovery capabilities
MCP Integration

The project demonstrates real Model Context Protocol integration with multiple servers:

  • MCP Client: Connects to various MCP servers (weather, filesystem, git, github)
  • Tool Discovery: Dynamically lists available tools from connected servers
  • Resource Access: Reads resources exposed by MCP servers
  • Error Handling: Graceful fallbacks when MCP servers are unavailable
  • Multi-Server Support: Manages connections to multiple MCP servers simultaneously
๐Ÿ“š Model Context Protocol (MCP)

This project showcases MCP, an open protocol for connecting AI applications with external data sources and tools. Key MCP concepts demonstrated:

  • Servers: Provide tools, resources, and prompts
  • Clients: Connect to servers and make requests
  • Transports: Communication channels (stdio, HTTP, SSE)
  • Tools: Executable functions (like GitHub API calls, weather data)
  • Resources: Data sources (like file contents, repository data)
MCP Servers Used
  • Weather Server: @modelcontextprotocol/server-weather - Real weather data
  • Filesystem Server: @modelcontextprotocol/server-filesystem - File operations
  • Git Server: @modelcontextprotocol/server-git - Git repository access
  • GitHub Server: @modelcontextprotocol/server-github - GitHub API integration (NEW!)
๐Ÿ™ GitHub MCP Integration
Features

The GitHub integration provides comprehensive analysis and discovery capabilities:

๐Ÿ” Search & Discovery
  • Repository Search: Find repositories by topic, language, stars, creation date
  • User Search: Discover developers and organizations
  • Code Search: Find code patterns across GitHub (requires authentication)
  • Advanced Filtering: Date ranges, star counts, language filters
๐Ÿ“Š Analysis & Insights
  • Trending Analysis: Discover trending repositories and technologies
  • Developer Insights: Analyze developer profiles, repositories, and activity
  • Community Explorer: Explore technology communities and ecosystems
  • Code Pattern Analysis: Analyze usage patterns of programming constructs
  • Language Distribution: Statistical analysis of programming languages
๐Ÿงช Experiments
  • Technology Trends: Comprehensive analysis of technology adoption
  • Ecosystem Exploration: Deep dive into technology communities
  • Developer Profiling: Detailed analysis of developer contributions
  • Pattern Discovery: Find interesting code patterns and practices
GitHub Tools Available (26 total)

The GitHub MCP server provides access to 26 powerful tools:

Repository Management:

  • search_repositories - Search GitHub repositories
  • create_repository - Create new repositories
  • fork_repository - Fork repositories
  • get_file_contents - Read file contents
  • create_or_update_file - Create/update files
  • push_files - Batch file operations

Issue & PR Management:

  • list_issues - List repository issues
  • create_issue - Create new issues
  • update_issue - Update existing issues
  • add_issue_comment - Comment on issues
  • list_pull_requests - List pull requests
  • create_pull_request - Create pull requests
  • merge_pull_request - Merge pull requests

Search & Discovery:

  • search_code - Search code across GitHub
  • search_issues - Search issues and PRs
  • search_users - Search GitHub users

And many more advanced tools for repository analysis and management

Authentication

For full GitHub functionality, set up a GitHub Personal Access Token:

  1. Generate token: Visit https://github.com/settings/tokens
  2. Required scopes: repo (for repository access)
  3. Set environment variable:
    export GITHUB_PERSONAL_ACCESS_TOKEN=your_token_here
    
  4. Verify setup:
    npm run github connect
    

Without token: Basic search works with rate limits With token: Full API access (5000 requests/hour) + private repositories

๐Ÿงช Testing
Basic Functionality Tests
# Test todo functionality
npm run todo -- --add "Test task" && npm run todo -- --list

# Test calculator
npm run calc "sqrt(25)" && npm run calc -- --advanced "sin(pi/4)"

# Test weather (local simulation)
npm run weather -- --city "Paris"

# Test MCP integration
npm run build && node dist/src/index.js mcp --list
GitHub Integration Tests
# Quick connectivity test
npm run github connect

# Test repository search
npm run github search --repos "typescript"

# Test trending analysis
npm run github trending

# Test developer analysis
npm run github developer octocat

# Run comprehensive test suite
npm run github:test

# Test specific experiments
npm run github experiments --topic "machine-learning"
๐Ÿ”’ Security Considerations
  • Data Privacy: Todo data stored locally in data/todos.json
  • MCP Safety: All MCP server connections require explicit user consent
  • Input Validation: Calculator expressions are sanitized for safety
  • Environment Variables: Secure handling of API keys and credentials
  • GitHub Token: Store securely, never commit to version control
  • Rate Limiting: Respects GitHub API rate limits and provides graceful degradation
๐Ÿš€ Deployment
Local Development
npm run dev  # Start in development mode
Production Build
npm run build
npm start
Docker (Optional)
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY dist/ ./dist/
CMD ["node", "dist/src/index.js"]
๐Ÿ“Š Examples
Adding and Managing Todos
$ npm run todo -- --add "Learn TypeScript"
โœ… Added task: "Learn TypeScript"

$ npm run todo -- --add "Build MCP client"  
โœ… Added task: "Build MCP client"

$ npm run todo -- --list
๐Ÿ“ Your tasks:
  โณ 1698123456789: Learn TypeScript (10/24/2023)
  โณ 1698123456790: Build MCP client (10/24/2023)

$ npm run todo -- --done 1698123456789
โœ… Marked task "Learn TypeScript" as done

$ npm run todo -- --stats
๐Ÿ“Š Todo Statistics:
   Total tasks: 2
   Completed: 1  
   Pending: 1
   Completion rate: 50.0%
Calculator Examples
$ npm run calc "2 + 3 * 4"
๐Ÿงฎ Calculating: 2 + 3 * 4
Result: 14

$ npm run calc -- --advanced "sqrt(16) + sin(pi/2)"
๐Ÿงฎ Calculating: sqrt(16) + sin(pi/2)
Result: 5
Processed: Math.sqrt(16) + Math.sin(Math.PI/2)
Weather with MCP
$ npm run weather -- --city "London" --real
๐ŸŒค๏ธ Getting weather for London...
๐Ÿ“ก Connecting to real MCP weather server...
โœ… Connected to weather MCP server
๐ŸŒค๏ธ London: Partly cloudy, 18ยฐC, Humidity: 65%, Wind: 12 km/h
GitHub Analysis Examples
$ npm run github trending
๐Ÿš€ === TRENDING ANALYSIS EXPERIMENT === ๐Ÿš€
๐Ÿ“ˆ Top Trending Repositories:
  1. deepseek-ai/DeepSeek-V3
     โญ 15,234 stars | ๐Ÿ’ป Python
     ๐Ÿ“ Advanced AI reasoning model

  2. cline/cline  
     โญ 8,567 stars | ๐Ÿ’ป TypeScript
     ๐Ÿ“ Autonomous coding agent right in your IDE

$ npm run github developer microsoft
๐Ÿ‘จโ€๐Ÿ’ป === DEVELOPER INSIGHTS: microsoft === ๐Ÿ‘จโ€๐Ÿ’ป
๐Ÿ“Š Repository Statistics:
  ๐Ÿ“ Total Repositories: 1,247
  โญ Total Stars: 2,847,392
  ๐Ÿ“ˆ Average Stars per Repo: 2,284.5

๐Ÿ’ป Programming Languages:
  TypeScript: 234 repos (18.8%)
  Python: 187 repos (15.0%)
  JavaScript: 156 repos (12.5%)

$ npm run github community "machine-learning"
๐ŸŒ === COMMUNITY EXPLORER: "machine-learning" === ๐ŸŒ
๐Ÿ“š Top Repositories:
  1. josephmisiti/awesome-machine-learning
     โญ 67,234 stars | ๐Ÿ’ป Python
     ๐Ÿ“ A curated list of awesome Machine Learning frameworks

๐Ÿ‘ฅ Community Members:
  1. Machine-Learning-Tokyo
     ๐Ÿ‘ฅ 1,234 followers | ๐Ÿ“ 45 repos
๐Ÿค Contributing
  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request
๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ”— Related Links
๐ŸŽฏ What's New
v1.1.0 - GitHub Integration
  • โœจ New: Complete GitHub MCP server integration
  • ๐Ÿ” New: Advanced repository search and analysis
  • ๐Ÿ“Š New: Developer insights and community exploration
  • ๐Ÿงช New: Technology trend analysis experiments
  • ๐Ÿ› ๏ธ New: 26 GitHub API tools via MCP
  • ๐Ÿ“ New: Comprehensive testing suite
  • ๐Ÿš€ New: Setup automation scripts
Previous Features
  • ๐Ÿ“ Todo management system
  • ๐Ÿงฎ Advanced calculator with mathematical functions
  • ๐ŸŒค๏ธ Weather information with MCP integration
  • ๐Ÿ”Œ Multi-server MCP client support

Built with โค๏ธ using TypeScript and the Model Context Protocol

Explore the power of MCP with real GitHub integration, advanced analysis tools, and comprehensive development workflows.

Author Information
Krishna

Software professional

0

Followers

18

Repositories

0

Gists

2

Total Contributions

Top Contributors

Threads