Discover Awesome MCP Servers
Extend your agent with 16,638 capabilities via MCP servers.
- All16,638
- Developer Tools3,867
- Search1,714
- Research & Data1,557
- AI Integration Systems229
- Cloud Platforms219
- Data & App Analysis181
- Database Interaction177
- Remote Shell Execution165
- Browser Automation147
- Databases145
- Communication137
- AI Content Generation127
- OS Automation120
- Programming Docs Access109
- Content Fetching108
- Note Taking97
- File Systems96
- Version Control93
- Finance91
- Knowledge & Memory90
- Monitoring79
- Security71
- Image & Video Processing69
- Digital Note Management66
- AI Memory Systems62
- Advanced AI Reasoning59
- Git Management Tools58
- Cloud Storage51
- Entertainment & Media43
- Virtualization42
- Location Services35
- Web Automation & Stealth32
- Media Content Processing32
- Calendar Management26
- Ecommerce & Retail18
- Speech Processing18
- Customer Data Platforms16
- Travel & Transportation14
- Education & Learning Tools13
- Home Automation & IoT13
- Web Search Integration12
- Health & Wellness10
- Customer Support10
- Marketing9
- Games & Gamification8
- Google Cloud Integrations7
- Art & Culture4
- Language Translation3
- Legal & Compliance2
Database Analyzer MCP Server
Mcp Servers Collection
Tuyển tập các máy chủ và tích hợp MCP đã được xác minh
Servidor MCP do Supabase
Servidor MCP do Supabase com funcionalidades de consulta e inserção de dados
Eka MCP Server
Máy chủ Eka MCP
@enemyrr/mcp-mysql-server
Gương của
MCP Actions Adapter
A simple adapter to convert a MCP server to a GPT actions compatible API
worker17
An MCP server to monitor workers productivity and fire them as needed.
xtrace-mcp
Alpaca MCP Server
Gương của
Playcanvas_editor Mcp Server
Gương của
mcp-tools-cli
command-line client for interacting with Model Context Protocol (MCP) servers.
IACR Cryptology ePrint Archive MCP Server
Gương của
Weather App
Okay, here's a breakdown of how you could implement a simple MCP (Microservice Communication Protocol) server for weather data in Python, along with testing and pre-commit setup. This example focuses on clarity and basic functionality. You'll likely want to expand upon it for a real-world application. **Conceptual Overview** 1. **MCP Server (Weather Service):** This service will listen for requests (likely over HTTP) to provide weather information for a given location. It will use a simple in-memory data store for demonstration purposes. In a real application, you'd integrate with a weather API or database. 2. **MCP Client (Example):** A simple client to send requests to the weather service. This is just for testing. 3. **Testing:** We'll use `pytest` to write unit tests for the server. 4. **Pre-Commit Hooks:** We'll use `pre-commit` to automatically run linters (like `flake8`) and formatters (like `black`) before each commit. **Code Structure** I'll present the code in a structured way, with explanations for each part. ``` weather_service/ ├── weather_service.py # Main server logic ├── tests/ │ └── test_weather_service.py # Unit tests ├── .pre-commit-config.yaml # Pre-commit configuration ├── requirements.txt # Dependencies └── README.md ``` **1. `weather_service/weather_service.py` (The Weather Service)** ```python from http.server import BaseHTTPRequestHandler, HTTPServer import json import urllib.parse class WeatherHandler(BaseHTTPRequestHandler): """Handles incoming HTTP requests for weather data.""" weather_data = { "london": {"temperature": 15, "condition": "Cloudy"}, "new_york": {"temperature": 25, "condition": "Sunny"}, "tokyo": {"temperature": 28, "condition": "Rainy"}, } def do_GET(self): """Handles GET requests.""" parsed_path = urllib.parse.urlparse(self.path) query_params = urllib.parse.parse_qs(parsed_path.query) if parsed_path.path == "/weather": location = query_params.get("location", [None])[0] # Get location from query params if location: weather = self.weather_data.get(location.lower()) if weather: self.send_response(200) self.send_header("Content-type", "application/json") self.end_headers() self.wfile.write(json.dumps(weather).encode("utf-8")) else: self.send_response(404) self.send_header("Content-type", "application/json") self.end_headers() self.wfile.write(json.dumps({"error": "Location not found"}).encode("utf-8")) else: self.send_response(400) # Bad Request self.send_header("Content-type", "application/json") self.end_headers() self.wfile.write(json.dumps({"error": "Location parameter is required"}).encode("utf-8")) else: self.send_response(404) self.send_header("Content-type", "application/json") self.end_headers() self.wfile.write(json.dumps({"error": "Not Found"}).encode("utf-8")) def run_server(server_class=HTTPServer, handler_class=WeatherHandler, port=8000): """Starts the weather service server.""" server_address = ("", port) httpd = server_class(server_address, handler_class) print(f"Starting weather service on port {port}...") try: httpd.serve_forever() except KeyboardInterrupt: print("\nStopping server...") httpd.server_close() if __name__ == "__main__": run_server() ``` **Explanation:** * **`WeatherHandler`:** This class inherits from `BaseHTTPRequestHandler` and handles incoming HTTP requests. * `weather_data`: A simple dictionary to store weather information. Replace this with a real data source. * `do_GET()`: Handles GET requests. It parses the URL path and query parameters. * It expects a `location` parameter in the query string (e.g., `/weather?location=london`). * It retrieves the weather data for the specified location from `weather_data`. * It returns the data as a JSON response with the appropriate HTTP status code (200 for success, 404 for not found, 400 for bad request). * **`run_server()`:** This function starts the HTTP server. It takes the server class, handler class, and port as arguments. It uses a `try...except` block to gracefully handle keyboard interrupts (Ctrl+C). * **`if __name__ == "__main__":`:** This ensures that the server is only started when the script is run directly (not when it's imported as a module). **2. `weather_service/tests/test_weather_service.py` (Unit Tests)** ```python import unittest import json from http.server import HTTPServer from threading import Thread import urllib.request import time from weather_service.weather_service import WeatherHandler, run_server class TestWeatherService(unittest.TestCase): """Tests for the weather service.""" @classmethod def setUpClass(cls): """Set up the server in a separate thread.""" cls.port = 8081 # Use a different port for testing cls.server = HTTPServer(("", cls.port), WeatherHandler) cls.server_thread = Thread(target=cls.server.serve_forever) cls.server_thread.daemon = True # Allow the main thread to exit even if the server thread is running cls.server_thread.start() time.sleep(0.1) # Give the server a moment to start @classmethod def tearDownClass(cls): """Shutdown the server.""" cls.server.shutdown() cls.server_thread.join() def test_get_weather_valid_location(self): """Test getting weather for a valid location.""" url = f"http://localhost:{self.port}/weather?location=london" response = urllib.request.urlopen(url) self.assertEqual(response.getcode(), 200) data = json.loads(response.read().decode("utf-8")) self.assertEqual(data["temperature"], 15) self.assertEqual(data["condition"], "Cloudy") def test_get_weather_invalid_location(self): """Test getting weather for an invalid location.""" url = f"http://localhost:{self.port}/weather?location=paris" try: response = urllib.request.urlopen(url) except urllib.error.HTTPError as e: self.assertEqual(e.code, 404) data = json.loads(e.read().decode("utf-8")) self.assertEqual(data["error"], "Location not found") else: self.fail("Expected HTTPError not raised") def test_get_weather_no_location(self): """Test getting weather without a location parameter.""" url = f"http://localhost:{self.port}/weather" try: response = urllib.request.urlopen(url) except urllib.error.HTTPError as e: self.assertEqual(e.code, 400) data = json.loads(e.read().decode("utf-8")) self.assertEqual(data["error"], "Location parameter is required") else: self.fail("Expected HTTPError not raised") def test_invalid_endpoint(self): """Test accessing an invalid endpoint.""" url = f"http://localhost:{self.port}/invalid" try: response = urllib.request.urlopen(url) except urllib.error.HTTPError as e: self.assertEqual(e.code, 404) data = json.loads(e.read().decode("utf-8")) self.assertEqual(data["error"], "Not Found") else: self.fail("Expected HTTPError not raised") if __name__ == "__main__": unittest.main() ``` **Explanation:** * **`TestWeatherService`:** This class inherits from `unittest.TestCase`. * **`setUpClass()`:** This method is called once before all tests in the class. It starts the weather service in a separate thread so that the tests can make requests to it. It uses a different port (8081) to avoid conflicts with the main server. `time.sleep(0.1)` is added to give the server a moment to start before the tests run. * **`tearDownClass()`:** This method is called once after all tests in the class. It shuts down the server and joins the server thread. * **`test_get_weather_valid_location()`:** Tests getting weather for a valid location (e.g., "london"). It checks that the response code is 200 and that the data is correct. * **`test_get_weather_invalid_location()`:** Tests getting weather for an invalid location (e.g., "paris"). It checks that the response code is 404 and that the error message is correct. It uses a `try...except` block to catch the `urllib.error.HTTPError` that is raised when the server returns a 404 error. * **`test_get_weather_no_location()`:** Tests getting weather without a location parameter. It checks that the response code is 400 and that the error message is correct. * **`test_invalid_endpoint()`:** Tests accessing an invalid endpoint. It checks that the response code is 404 and that the error message is correct. **3. `.pre-commit-config.yaml` (Pre-Commit Configuration)** ```yaml repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - repo: https://github.com/psf/black rev: 24.2.0 hooks: - id: black - repo: https://github.com/pycqa/flake8 rev: 7.0.0 hooks: - id: flake8 args: ["--max-line-length=88"] ``` **Explanation:** * This file configures the `pre-commit` tool. * `repos`: A list of Git repositories that contain pre-commit hooks. * `pre-commit/pre-commit-hooks`: A collection of useful hooks for checking whitespace, YAML files, and large files. * `psf/black`: The Black code formatter. * `pycqa/flake8`: The Flake8 linter. * `rev`: The version of the hook to use. It's important to pin versions to ensure consistent results. * `hooks`: A list of hooks to run. * `id`: The ID of the hook. * `args`: Arguments to pass to the hook (e.g., `--max-line-length=88` for Flake8). **4. `requirements.txt` (Dependencies)** ``` pytest pre-commit black flake8 ``` **Explanation:** This file lists the dependencies for the project. You can install them using `pip install -r requirements.txt`. **5. `README.md` (Optional README)** A basic README file to describe the project. ```markdown # Weather Service A simple MCP server for providing weather data. ## Usage 1. Install dependencies: `pip install -r requirements.txt` 2. Run the server: `python weather_service/weather_service.py` 3. Access the server at `http://localhost:8000/weather?location=city_name` ## Testing 1. Run tests: `pytest weather_service/tests/test_weather_service.py` ## Pre-Commit Hooks 1. Install pre-commit: `pip install pre-commit` 2. Install the pre-commit hooks: `pre-commit install` Now, pre-commit hooks will run automatically before each commit. ``` **How to Run the Code** 1. **Create the directory structure:** Create the `weather_service` directory and the `tests` subdirectory. 2. **Create the files:** Create the `weather_service.py`, `test_weather_service.py`, `.pre-commit-config.yaml`, `requirements.txt`, and `README.md` files and paste the code into them. 3. **Install dependencies:** ```bash pip install -r requirements.txt ``` 4. **Run the server:** ```bash python weather_service/weather_service.py ``` The server will start on port 8000. 5. **Test the server (manually):** Open a web browser or use `curl` to access the server: ```bash curl "http://localhost:8000/weather?location=london" ``` You should see a JSON response with the weather data for London. 6. **Run the tests:** ```bash pytest weather_service/tests/test_weather_service.py ``` The tests should pass. 7. **Install pre-commit:** ```bash pre-commit install ``` Now, pre-commit hooks will run automatically before each commit. **Important Considerations and Improvements** * **Error Handling:** The error handling in the `WeatherHandler` is basic. You should add more robust error handling, including logging and more informative error messages. * **Data Source:** The `weather_data` dictionary is a placeholder. You should replace it with a real data source, such as a weather API (e.g., OpenWeatherMap, AccuWeather) or a database. * **Asynchronous Operations:** For a production system, consider using an asynchronous framework like `asyncio` and a web framework like `aiohttp` or `FastAPI` to handle requests concurrently and improve performance. * **Configuration:** Use a configuration file (e.g., YAML or JSON) to store settings such as the port number, API keys, and database connection details. * **Logging:** Implement proper logging to track requests, errors, and other important events. Use the `logging` module. * **Deployment:** Consider how you will deploy the service (e.g., using Docker, Kubernetes, or a cloud platform). * **Security:** If the service will be exposed to the internet, implement appropriate security measures, such as authentication, authorization, and input validation. * **Monitoring:** Implement monitoring to track the health and performance of the service. * **MCP Implementation:** This example uses HTTP as the transport layer, which is a common approach for MCP. However, you could also use other protocols, such as gRPC or message queues (e.g., RabbitMQ, Kafka). The choice of protocol depends on the specific requirements of your application. For a true MCP implementation, you'd likely define a more formal message format and versioning scheme. * **Vietnamese Translation:** To provide weather information in Vietnamese, you would need to: * Translate the `condition` strings in the `weather_data` dictionary. * Implement localization (l10n) to handle different languages. This would involve using a library like `gettext` or `babel` to translate the text in the responses based on the user's locale. You would need to determine the user's locale from the request (e.g., from the `Accept-Language` header). **Example of Vietnamese Translation (Basic)** ```python # In weather_service.py weather_data = { "london": {"temperature": 15, "condition": {"en": "Cloudy", "vi": "Nhiều mây"}}, "new_york": {"temperature": 25, "condition": {"en": "Sunny", "vi": "Nắng"}}, "tokyo": {"temperature": 28, "condition": {"en": "Rainy", "vi": "Mưa"}}, } def do_GET(self): # ... (rest of the code) if location: weather = self.weather_data.get(location.lower()) if weather: # Determine the language (e.g., from a query parameter or header) language = query_params.get("lang", ["en"])[0] # Default to English # Get the translated condition condition = weather["condition"].get(language, weather["condition"]["en"]) # Fallback to English response_data = { "temperature": weather["temperature"], "condition": condition, } self.send_response(200) self.send_header("Content-type", "application/json") self.end_headers() self.wfile.write(json.dumps(response_data).encode("utf-8")) # ... (rest of the code) ``` In this example, the `condition` is now a dictionary with English ("en") and Vietnamese ("vi") translations. The `do_GET` method retrieves the appropriate translation based on the `lang` query parameter (e.g., `/weather?location=london&lang=vi`). If the language is not specified or not found, it defaults to English. This is a very basic example; a proper localization solution would be more complex. This comprehensive example provides a solid foundation for building a weather service with testing and pre-commit hooks. Remember to adapt and expand upon it to meet the specific requirements of your project. Good luck!
Atlassian Jira MCP Server
Máy chủ Node.js/TypeScript MCP cho Atlassian Jira. Trang bị cho các hệ thống AI (LLM) các công cụ để liệt kê/lấy thông tin dự án, tìm kiếm/lấy thông tin vấn đề (sử dụng JQL/ID) và xem thông tin phát triển (commits, PRs). Kết nối trực tiếp các khả năng AI vào quy trình quản lý dự án và theo dõi vấn đề của Jira.
mcp-server
Mirror of
📸 Smart Photo Journal MCP Server
Gương của
MCP Server Playground
Mirror of
🌱 mcp-origin
MCP server that manages MCP servers
Polkassembly MCP Server
MCP Server for Polkassembly API
ディーゼロ開発環境用 MCPサーバー
D-Zero frontend coding MCP server
RapidAPI MCP Server
Triển khai máy chủ MCP để tích hợp API Bằng sáng chế Toàn cầu RapidAPI với lưu trữ SQLite
MCP Community Contributions
This is a directory repo for anything related to MCP - servers, clients and projects around MCP.
VoiceStudio MCP Server
MCP server for kintone
Gương của
MCP Servers Modified
MCP BLE Server
Swagger MCP 服务器
Một máy chủ dựa trên Giao thức Ngữ cảnh Mô hình (Model Context Protocol) có chức năng phân tích cú pháp các tài liệu Swagger/OpenAPI và tạo ra các kiểu TypeScript và mã máy khách API cho các framework khác nhau (Axios, Fetch, React Query).
Grasshopper MCP サーバー
Triển khai máy chủ Giao thức Bối cảnh Mô hình (MCP) cho tích hợp Rhinoceros/Grasshopper, cho phép các mô hình AI tương tác với các công cụ thiết kế tham số.
mcptime
SImple MCP server to return the current time
MCP EV Assistant Server
Một máy chủ mạnh mẽ để quản lý các trạm sạc xe điện (EV), lập kế hoạch hành trình và quản lý tài nguyên. Máy chủ này cung cấp một bộ công cụ và API toàn diện cho các dịch vụ liên quan đến xe điện.