Discover Awesome MCP Servers

Extend your agent with 84,517 capabilities via MCP servers.

All84,517
IACR Cryptology ePrint Archive MCP Server

IACR Cryptology ePrint Archive MCP Server

Espelho de

Grasshopper MCP サーバー

Grasshopper MCP サーバー

Implementação de um servidor de Protocolo de Contexto de Modelo (MCP) para integração com Rhinoceros/Grasshopper, permitindo que modelos de IA interajam com ferramentas de design paramétrico.

Polkassembly MCP Server

Polkassembly MCP Server

MCP Server for Polkassembly API

mcp-tools-cli

mcp-tools-cli

command-line client for interacting with Model Context Protocol (MCP) servers.

Weather App

Weather App

Okay, here's a breakdown of an example MCP (Microservice Communication Protocol) server implementation in Python for weather data, along with testing and pre-commit setup. I'll use Flask for the server and `pytest` for testing. This is a simplified example to illustrate the core concepts. **1. Project Structure** ``` weather_service/ ├── app.py # Main application logic ├── models.py # Data models (e.g., WeatherData) ├── services.py # Business logic (e.g., fetching weather) ├── tests/ │ ├── conftest.py # Pytest configuration │ └── test_app.py # Tests for the API endpoints ├── .pre-commit-config.yaml # Pre-commit configuration ├── requirements.txt # Dependencies └── README.md ``` **2. `requirements.txt`** ``` Flask requests pytest pytest-cov pre-commit flake8 mypy ``` Install dependencies: ```bash pip install -r requirements.txt ``` **3. `models.py`** ```python from dataclasses import dataclass from typing import Optional @dataclass class WeatherData: city: str temperature: float condition: str humidity: Optional[int] = None # Optional humidity ``` **4. `services.py`** ```python import requests from .models import WeatherData # Replace with a real weather API key and endpoint WEATHER_API_URL = "https://api.example.com/weather" API_KEY = "YOUR_API_KEY" # Store securely in a real application def get_weather(city: str) -> WeatherData: """Fetches weather data from an external API.""" try: params = {"q": city, "appid": API_KEY, "units": "metric"} response = requests.get(WEATHER_API_URL, params=params) response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx) data = response.json() return WeatherData( city=data["name"], temperature=data["main"]["temp"], condition=data["weather"][0]["description"], humidity=data["main"].get("humidity"), # Use .get() for optional fields ) except requests.exceptions.RequestException as e: raise Exception(f"Error fetching weather data: {e}") except (KeyError, TypeError) as e: raise Exception(f"Error parsing weather data: {e}") ``` **5. `app.py` (Flask Application)** ```python from flask import Flask, jsonify, request from .services import get_weather from .models import WeatherData app = Flask(__name__) @app.route("/weather", methods=["GET"]) def weather(): """ Endpoint to retrieve weather data for a given city. Example: /weather?city=London """ city = request.args.get("city") if not city: return jsonify({"error": "City parameter is required"}), 400 try: weather_data: WeatherData = get_weather(city) return jsonify({ "city": weather_data.city, "temperature": weather_data.temperature, "condition": weather_data.condition, "humidity": weather_data.humidity }) except Exception as e: return jsonify({"error": str(e)}), 500 if __name__ == "__main__": app.run(debug=True) ``` **6. `tests/conftest.py`** ```python import pytest from weather_service.app import app # Import your Flask app @pytest.fixture def client(): app.config['TESTING'] = True with app.test_client() as client: yield client ``` **7. `tests/test_app.py`** ```python import pytest from unittest.mock import patch from weather_service.models import WeatherData def test_weather_endpoint_success(client): """Test successful weather data retrieval.""" with patch("weather_service.services.get_weather") as mock_get_weather: mock_get_weather.return_value = WeatherData(city="Test City", temperature=25.0, condition="Sunny", humidity=60) response = client.get("/weather?city=TestCity") assert response.status_code == 200 data = response.get_json() assert data["city"] == "Test City" assert data["temperature"] == 25.0 assert data["condition"] == "Sunny" assert data["humidity"] == 60 def test_weather_endpoint_missing_city(client): """Test the endpoint when the city parameter is missing.""" response = client.get("/weather") assert response.status_code == 400 data = response.get_json() assert "error" in data assert data["error"] == "City parameter is required" def test_weather_endpoint_api_error(client): """Test the endpoint when the API returns an error.""" with patch("weather_service.services.get_weather") as mock_get_weather: mock_get_weather.side_effect = Exception("API Error") response = client.get("/weather?city=TestCity") assert response.status_code == 500 data = response.get_json() assert "error" in data assert data["error"] == "API Error" ``` **8. `.pre-commit-config.yaml`** ```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=120"] - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.8.0 hooks: - id: mypy exclude: ^tests/ # Exclude tests from mypy checks (optional) args: ["--ignore-missing-imports", "--strict"] ``` **Explanation and Key Concepts** * **MCP (Microservice Communication Protocol):** In this example, the HTTP API (`/weather` endpoint) *is* the MCP. It's a simple request/response protocol. For more complex scenarios, you might use message queues (like RabbitMQ or Kafka) or gRPC for more robust inter-service communication. This example focuses on the API aspect. * **Flask:** A lightweight Python web framework for creating the API. * **`models.py`:** Defines data structures using `dataclasses` for type safety and conciseness. * **`services.py`:** Contains the business logic for fetching weather data. This is where you would interact with an external weather API. **Important:** Replace `"YOUR_API_KEY"` with a real API key from a weather provider (e.g., OpenWeatherMap, AccuWeather). Store API keys securely (environment variables, secrets management). * **Error Handling:** The `get_weather` function includes error handling for network issues (`requests.exceptions.RequestException`) and data parsing problems (`KeyError`, `TypeError`). The Flask endpoint also handles exceptions and returns appropriate HTTP error codes (400 for bad requests, 500 for server errors). * **Testing (`tests/`)** * **`pytest`:** A popular Python testing framework. * **`conftest.py`:** Contains fixtures (like the `client` fixture) that are used by multiple tests. The `client` fixture creates a test client for the Flask application. * **`test_app.py`:** Contains the actual tests for the API endpoints. * **Mocking:** The `unittest.mock.patch` decorator is used to mock the `get_weather` function. This allows you to test the API endpoint without actually making external API calls. This is crucial for reliable and fast tests. You can simulate different API responses (success, error). * **Test Cases:** * `test_weather_endpoint_success`: Tests the successful retrieval of weather data. * `test_weather_endpoint_missing_city`: Tests the case where the `city` parameter is missing from the request. * `test_weather_endpoint_api_error`: Tests the case where the external weather API returns an error. * **Pre-commit Hooks (`.pre-commit-config.yaml`)** * **`pre-commit`:** A tool for automatically running checks (linters, formatters, etc.) on your code before you commit it. This helps to maintain code quality and consistency. * **Hooks:** The `.pre-commit-config.yaml` file defines the hooks that will be run. Some common hooks include: * `trailing-whitespace`: Removes trailing whitespace. * `end-of-file-fixer`: Ensures that files end with a newline. * `check-yaml`: Checks YAML files for syntax errors. * `black`: A code formatter that automatically formats your Python code according to a consistent style. * `flake8`: A linter that checks your code for style errors and potential problems. * `mypy`: A static type checker that helps you find type errors in your code. **How to Run** 1. **Install Dependencies:** `pip install -r requirements.txt` 2. **Install Pre-commit:** `pip install pre-commit` 3. **Install Pre-commit Hooks:** `pre-commit install` 4. **Run Tests:** `pytest` (or `pytest --cov` for coverage reporting) 5. **Run the Application:** `python app.py` (This will start the Flask development server) **Important Considerations** * **API Keys:** Never store API keys directly in your code. Use environment variables or a secrets management system. * **Error Handling:** Implement robust error handling to gracefully handle unexpected situations. * **Logging:** Add logging to your application to help with debugging and monitoring. * **Configuration:** Use a configuration file (e.g., a `.env` file) to store application settings. * **Security:** If your API is exposed to the public internet, implement appropriate security measures (authentication, authorization, rate limiting, etc.). * **Scalability:** For production environments, consider using a more scalable web server (e.g., Gunicorn or uWSGI) and a load balancer. * **Asynchronous Operations:** For long-running tasks (like API calls), consider using asynchronous operations (e.g., `asyncio` or Celery) to improve performance. * **Monitoring:** Implement monitoring to track the health and performance of your service. This example provides a basic foundation for building an MCP server for weather data. You can extend it to include more features, such as: * Support for different weather APIs. * Caching of weather data. * More sophisticated error handling. * More detailed weather information. * Integration with other services.

Playcanvas_editor Mcp Server

Playcanvas_editor Mcp Server

Espelho de

langchain-mcp

langchain-mcp

Model Context Protocol tool support for LangChain

mcptime

mcptime

SImple MCP server to return the current time

RapidAPI MCP Server

RapidAPI MCP Server

Here's a translation of "MCP Server implementation for RapidAPI Global Patent API integration with SQLite storage" into Portuguese: **Opção 1 (Mais direta):** * **Implementação de um Servidor MCP para integração com a API Global de Patentes da RapidAPI, utilizando armazenamento SQLite.** **Opção 2 (Um pouco mais descritiva):** * **Implementação de um servidor MCP para integrar a API Global de Patentes da RapidAPI, com armazenamento de dados em SQLite.** **Opção 3 (Focando na funcionalidade):** * **Implementação de um servidor MCP para consumir a API Global de Patentes da RapidAPI e armazenar os dados em um banco de dados SQLite.** **Explanation of Choices:** * **MCP Server:** This is generally understood as "Servidor MCP" in Portuguese, especially in technical contexts. If you have more context about what "MCP" stands for, you might be able to translate it more accurately. * **RapidAPI Global Patent API:** "API Global de Patentes da RapidAPI" is a direct and clear translation. * **SQLite storage:** "Armazenamento SQLite" or "armazenamento de dados em SQLite" are both good options. The latter is slightly more descriptive. * **Integration:** "Integração" is the standard translation. * **Utilizando:** Means "using" and is a good, clear choice. * **Consumir:** Means "to consume" and is a good choice if you want to emphasize the action of using the API. The best option depends on the specific context and the level of detail you want to convey. I would lean towards **Opção 1** or **Opção 2** as a general translation.

Sequential Thinking MCP Server

Sequential Thinking MCP Server

MCP BLE Server

MCP BLE Server

Swagger MCP 服务器

Swagger MCP 服务器

Um servidor baseado no Protocolo de Contexto de Modelo que analisa documentos Swagger/OpenAPI e gera tipos TypeScript e código de cliente API para diferentes frameworks (Axios, Fetch, React Query).

MalloryAI MCP Server

MalloryAI MCP Server

MCP Server for ICS API

Loxo MCP Server

Loxo MCP Server

Mirror of

YouTube MCP Server

YouTube MCP Server

Mirror of

VoiceStudio MCP Server

VoiceStudio MCP Server

MCP Community Contributions

MCP Community Contributions

This is a directory repo for anything related to MCP - servers, clients and projects around MCP.

MCP server for kintone

MCP server for kintone

Espelho de

MCP Servers Modified

MCP Servers Modified

MCP EV Assistant Server

MCP EV Assistant Server

Uma implementação de servidor poderosa para gerenciar estações de carregamento de Veículos Elétricos (VE), planejamento de viagens e gerenciamento de recursos. Este servidor fornece um conjunto abrangente de ferramentas e APIs para serviços relacionados a VE.

AB Component Server

AB Component Server

MCP Server for Replicate

MCP Server for Replicate

Mirror of

Model Context Protocol(MCP) 编程极速入门

Model Context Protocol(MCP) 编程极速入门

Introdução Rápida à Programação do Protocolo de Contexto do Modelo (MCP)

MCP Google Custom Search Server

MCP Google Custom Search Server

Espelho de

Serper

Serper

Worker17

Worker17

An MCP server to monitor workers productivity and fire them as needed.

MCP Server for Hacker News

MCP Server for Hacker News

Servidor MCP para Hacker News

MCPServerProject

MCPServerProject

created from MCP server demo

Local Claude MCP Servers Collection

Local Claude MCP Servers Collection

Enterprise MCP servers

MailPace MCP (Model Context Protocol) Server

MailPace MCP (Model Context Protocol) Server

Uma implementação de servidor MCP que permite o envio de e-mails através da API de e-mail transacional rápida da MailPace.