mcp-community-tools

mcp-community-tools

Enables querying community chatter data and world country information through tools like get_top_10_highest_comments and fetch_countries, designed for integration with GitHub Copilot.

Category
访问服务器

README

MCP Community Tools - Model Context Protocol Server

A professional-grade MCP (Model Context Protocol) server that provides tools for querying community and world databases. Designed with clean architecture patterns and ready for integration with GitHub Copilot.

🎯 Quick Start

1. Connect to GitHub Copilot (3 steps)

See QUICK_START.md for instant setup.

TL;DR:

  1. Open VS Code Settings (Cmd+,)
  2. Add this to settings.json:
{
  "github.copilot.mcp": [
    {
      "name": "mcp-community-tools",
      "command": "${workspaceFolder}/.venv/bin/python3",
      "args": ["${workspaceFolder}/hello_mcp.py"],
      "env": {"PYTHONPATH": "${workspaceFolder}"}
    }
  ]
}
  1. Restart VS Code

2. Ask Copilot

Now you can ask Copilot to use your tools:

  • "Get the top 10 highest comments"
  • "Show me 5 countries from Europe"
  • "Generate a random name"

📚 Available Tools

Tool Description Example
get_random_name() Generate a random name get_random_name()
get_top_10_highest_comments() Get top 10 users by message count Returns: Top 10 chatters
fetch_countries() Query countries by region and limit fetch_countries(region="Asia", limit=5)

🏗️ Project Structure

mcp-course/
├── hello_mcp.py                    # Main entry point (50 lines - clean!)
├── setup-copilot.sh               # Auto-generate config helper
├── QUICK_START.md                 # 3-step Copilot integration
├── SETUP_COPILOT.md              # Detailed setup guide
├── ARCHITECTURE.md                # Design patterns & structure
├── INTEGRATION_DIAGRAM.md         # Visual flow diagrams
├── REFACTORING_SUMMARY.md         # Before/after comparison
│
├── db_connection/
│   └── connection.py              # Database Connection Factory
│
├── repositories/
│   ├── base_repository.py         # Abstract Base Class
│   ├── chatters_repository.py     # Community data queries
│   └── countries_repository.py    # World data queries
│
├── tools/
│   └── tools.py                   # Tool implementations (DI)
│
└── db/
    ├── community.db               # Chatters data (251 records)
    └── world.db                   # Countries data (250 records)

✨ Key Features

🎯 Clean Architecture

  • Repository Pattern: Database access abstraction
  • Dependency Injection: Loose coupling between layers
  • Factory Pattern: Centralized connection management
  • SOLID Principles: All five principles applied

🛡️ Professional Code

  • ✅ Type hints throughout
  • ✅ Comprehensive error handling
  • ✅ Well-documented with docstrings
  • ✅ Easy to test and extend

🚀 Ready for Production

  • ✅ Works with GitHub Copilot
  • ✅ Works with Claude Desktop
  • ✅ Works with any MCP-compatible client
  • ✅ Secure local execution

📖 Documentation

Document Purpose
QUICK_START.md Get Copilot working in 3 steps
SETUP_COPILOT.md Detailed setup & troubleshooting
ARCHITECTURE.md Design patterns & principles
INTEGRATION_DIAGRAM.md Visual flows and connections
REFACTORING_SUMMARY.md Before/after code comparison

🚀 Running Locally

Prerequisites

  • Python 3.11+
  • Virtual environment (venv)

Setup

# Clone and enter directory
cd /Users/souravkumar/WebstormProjects/mcp-course

# Activate virtual environment
source .venv/bin/activate

# Install dependencies (if needed)
pip install -r requirements.txt

Run Server

python3 hello_mcp.py

Output should show:

Server started on stdio

🔌 Integration Options

Option 1: GitHub Copilot in VS Code ✅ RECOMMENDED

See QUICK_START.md

Option 2: Claude Desktop App

See SETUP_COPILOT.md - Claude Desktop section

Option 3: Manual Testing

# Terminal 1: Start server
python3 hello_mcp.py

# Terminal 2: Test tools
curl -X POST http://localhost:3000/call \
  -H "Content-Type: application/json" \
  -d '{"tool": "get_top_10_highest_comments"}'

💾 Databases

community.db

SELECT * FROM chatters;
-- id, name, messages, last_message_at

251 community members with activity tracking

world.db

SELECT * FROM countries;
-- id, name, iso2, iso3, capital, region, subregion, currency, currency_symbol, phonecode, emoji

250 countries with detailed information


🛠️ Example Usage with Copilot

Example 1: Get Top Commenters

You: "Who are the top 10 most active community members?"

Copilot:
✓ Calls: get_top_10_highest_comments()
✓ Returns: Top 10 users with message counts
✓ Shows: Their last activity timestamps

Example 2: Find Countries

You: "Show me all European countries and their capitals"

Copilot:
✓ Calls: fetch_countries(region="Europe")
✓ Returns: All 50 European countries
✓ Shows: Capital, currency, phone code, flag emoji

Example 3: Generate Names

You: "Give me 5 random names"

Copilot:
✓ Calls: get_random_name() (5 times)
✓ Returns: 5 random names from the list

🏛️ Architecture at a Glance

┌─────────────────────────────────────────┐
│      GitHub Copilot / Claude            │
└──────────────────┬──────────────────────┘
                   │ MCP Protocol (JSON-RPC)
                   ▼
┌─────────────────────────────────────────┐
│  hello_mcp.py (Tool Registration)       │
│  ├─ @mcp.tool() decorators             │
│  └─ Dependency injection setup          │
└──────────────────┬──────────────────────┘
                   │
                   ▼
┌─────────────────────────────────────────┐
│  tools/tools.py (Business Logic)        │
│  ├─ TopCommentsTool                    │
│  ├─ CountriesTool                      │
│  └─ RandomNameTool                     │
└──────────────────┬──────────────────────┘
                   │
                   ▼
┌─────────────────────────────────────────┐
│  repositories/ (Data Access)            │
│  ├─ ChattersRepository                 │
│  ├─ CountriesRepository                │
│  └─ BaseRepository (Abstract)          │
└──────────────────┬──────────────────────┘
                   │
                   ▼
┌─────────────────────────────────────────┐
│  db_connection/ (Connection Factory)    │
└──────────────────┬──────────────────────┘
                   │
                   ▼
┌─────────────────────────────────────────┐
│  db/ (SQLite Databases)                 │
│  ├─ community.db                       │
│  └─ world.db                           │
└─────────────────────────────────────────┘

📊 SOLID Principles Applied

Single Responsibility: Each class has one reason to change
Open/Closed: Open for extension, closed for modification
Liskov Substitution: Repositories are interchangeable
Interface Segregation: Minimal required interfaces
Dependency Inversion: Depend on abstractions, not concretions


🔐 Security

  • Local Execution: Runs on your machine only
  • No Data Upload: All data stays local
  • No Authentication: Local database access
  • Read-Only: Tools only query, don't modify data

🧪 Testing

Run Tests (when available)

pytest tests/

Manual Testing

from repositories.chatters_repository import ChattersRepository
from db_connection.connection import DatabaseConnection

conn = DatabaseConnection.get_connection("community.db")
repo = ChattersRepository(conn)
results = repo.get_top_highest_comments(10)
print(results)
repo.close()

🤝 Contributing

To add a new tool:

  1. Create a Repository (if needed):

    # repositories/my_data_repository.py
    class MyDataRepository(BaseRepository):
        def get_data(self): 
            return self.execute_query("SELECT * FROM my_table")
    
  2. Create a Tool:

    # In tools/tools.py
    class MyDataTool:
        def __init__(self, repository):
            self.repository = repository
        def execute(self):
            return self.repository.get_data()
    
  3. Register in hello_mcp.py:

    @mcp.tool()
    def my_data_tool() -> list[dict]:
        conn = DatabaseConnection.get_connection("my_db.db")
        repo = MyDataRepository(conn)
        tool = MyDataTool(repo)
        return tool.execute()
    

📞 Troubleshooting

Common Issues

Issue Solution
"Tool not found" in Copilot Restart VS Code completely (Cmd+Q)
"ModuleNotFoundError" Check PYTHONPATH in config
Connection timeout Verify hello_mcp.py runs without errors
Tools not available Wait 10 seconds after restart for extension load

For detailed troubleshooting, see SETUP_COPILOT.md


📝 License

MIT License - Feel free to use, modify, and distribute.


🎓 Learning Resources


✅ Quick Checklist


🚀 You're Ready!

Your MCP server is production-ready. Enjoy using it with GitHub Copilot! 🎉

Questions? Check the documentation files or the troubleshooting section above.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选