Discover Awesome MCP Servers

Extend your agent with 50,638 capabilities via MCP servers.

All50,638
mariadb-mcp-server

mariadb-mcp-server

An mcp server that provides read-only access to MariaDB.

MCP Command History

MCP Command History

Một công cụ mạnh mẽ để khám phá, tìm kiếm và quản lý lịch sử lệnh shell của bạn thông qua giao diện MCP (Model Control Protocol). Dự án này cho phép bạn dễ dàng truy cập, tìm kiếm và truy xuất các lệnh shell đã thực thi trước đó.

kagi-server MCP Server

kagi-server MCP Server

Mirror of

WCGW

WCGW

Send code snippet and paths to Claude. Designed to work with wcgw mcp server.

MCP Image Generation Server

MCP Image Generation Server

Mirror of

mem0 MCP Server

mem0 MCP Server

Một triển khai TypeScript của máy chủ Model Context Protocol, cho phép tạo, quản lý và tìm kiếm ngữ nghĩa các luồng bộ nhớ với tích hợp Mem0.

mcp_server

mcp_server

mcp-server-web3

mcp-server-web3

The web3 function plugin server base on MCP of Anthropic.

Prompt Decorators

Prompt Decorators

A standardized framework for enhancing how LLMs process and respond to prompts through composable decorators, featuring an official open standard specification and Python reference implementation with MCP server integration.

Model Context Protocol (MCP) Server 🚀

Model Context Protocol (MCP) Server 🚀

Knowledge Graph Memory Server

Knowledge Graph Memory Server

Mirror of

MCP Server Docker

MCP Server Docker

Máy chủ MCP cho Docker

artifacts-mcp

artifacts-mcp

MCP Server for Artifacts MMO

mcp-server-bluesky

mcp-server-bluesky

Mirror of

SkySQL MCP Integration

SkySQL MCP Integration

mcp-cbs-cijfers-open-data

mcp-cbs-cijfers-open-data

Máy chủ MCP để làm việc với Dữ liệu Mở CBS Cijfers

Flights Mcp Server

Flights Mcp Server

MCP Server for Google Flights !!

Weather MCP Server

Weather MCP Server

gatherings MCP Server

gatherings MCP Server

Một máy chủ giao thức ngữ cảnh mô hình (Model Context Protocol server) giúp theo dõi chi phí và tính toán hoàn trả cho các sự kiện xã hội, giúp dễ dàng thanh toán số dư giữa bạn bè.

Choose MCP Server Setup

Choose MCP Server Setup

Gương của

Server

Server

Okay, here's a basic outline and code snippets to get you started with a simple "Weather MCP" (assuming you mean a Minecraft Protocol server that provides weather information) in Python. Keep in mind that a *full* implementation is quite complex and requires deep understanding of the Minecraft protocol. This example focuses on the core concepts. **Disclaimer:** This is a simplified example. A real Minecraft server needs to handle much more, including player authentication, world generation, chunk loading, entity management, and a lot more protocol details. This is just a starting point to illustrate the weather aspect. **Conceptual Outline** 1. **Minecraft Protocol Basics:** * Minecraft uses a custom TCP-based protocol. You'll need to understand how to send and receive packets in the correct format. The protocol has evolved over different Minecraft versions, so you'll need to target a specific version. * The protocol involves handshaking, status requests, login, and then gameplay packets. * We'll focus on sending the relevant weather-related packets. 2. **Networking:** * Use Python's `socket` module to listen for incoming connections from Minecraft clients. * Handle each client connection in a separate thread or using asynchronous programming (e.g., `asyncio`). 3. **Weather Data:** * For simplicity, we'll simulate weather. In a real application, you might fetch weather data from an external API. 4. **Packet Construction:** * You'll need to construct Minecraft packets according to the protocol specification. This involves packing data (integers, strings, etc.) into byte arrays in the correct order and format. **Simplified Code Example (Python)** ```python import socket import struct import threading import time # Configuration HOST = '0.0.0.0' # Listen on all interfaces PORT = 25565 # Default Minecraft port PROTOCOL_VERSION = 763 # Example: Minecraft 1.16.5 SERVER_VERSION_NAME = "WeatherMCP-0.1" MAX_PLAYERS = 10 # --- Minecraft Protocol Helper Functions --- def pack_varint(data): """Packs an integer into a Minecraft-style VarInt.""" out = bytearray() while True: byte = data & 0x7F data >>= 7 if data != 0: byte |= 0x80 out.append(byte) if data == 0: break return bytes(out) def pack_string(data): """Packs a string into a Minecraft-style string (VarInt length + UTF-8 encoded string).""" encoded = data.encode('utf-8') length = len(encoded) return pack_varint(length) + encoded def create_packet(packet_id, data): """Creates a Minecraft packet with a VarInt packet ID and data.""" packet_id_bytes = pack_varint(packet_id) packet_data = packet_id_bytes + data packet_length = pack_varint(len(packet_data)) return packet_length + packet_data # --- Weather Simulation --- is_raining = False rain_level = 0.0 # 0.0 = no rain, 1.0 = heavy rain thunder_level = 0.0 # 0.0 = no thunder, 1.0 = heavy thunder is_thundering = False def update_weather(): """Simulates weather changes.""" global is_raining, rain_level, thunder_level, is_thundering import random while True: # Simulate a chance of rain starting or stopping if random.random() < 0.01: # 1% chance per second is_raining = not is_raining if is_raining: print("It started raining!") rain_level = 0.1 # Start with light rain else: print("It stopped raining!") rain_level = 0.0 # Simulate rain intensity changes if is_raining: rain_level = min(1.0, rain_level + random.uniform(0.001, 0.005)) # Increase rain else: rain_level = max(0.0, rain_level - random.uniform(0.001, 0.005)) # Decrease rain # Simulate thunder (similar to rain) if random.random() < 0.005: is_thundering = not is_thundering if is_thundering: print("Thunder started!") thunder_level = 0.1 else: print("Thunder stopped!") thunder_level = 0.0 if is_thundering: thunder_level = min(1.0, thunder_level + random.uniform(0.001, 0.005)) else: thunder_level = max(0.0, thunder_level - random.uniform(0.001, 0.005)) time.sleep(1) # Check every second # --- Packet Sending Functions --- def send_time_update(client_socket, world_age, time_of_day): """Sends a Time Update packet (ID 0x4E for 1.16.5).""" packet_id = 0x4E # Time Update packet ID data = struct.pack("!qq", world_age, time_of_day) # Long Long packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending time update: {e}") def send_change_game_state(client_socket, reason, value): """Sends a Change Game State packet (ID 0x1F for 1.16.5).""" packet_id = 0x1F data = struct.pack("!bq", reason, value) # Byte Float packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending change game state: {e}") def send_login_success(client_socket, uuid, username): """Sends a Login Success packet (ID 0x26 for 1.16.5).""" packet_id = 0x26 uuid_bytes = uuid.encode('utf-8') username_bytes = username.encode('utf-8') data = pack_string(uuid) + pack_string(username) packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending login success: {e}") def send_join_game(client_socket): """Sends a Join Game packet (ID 0x25 for 1.16.5).""" packet_id = 0x25 entity_id = 0 gamemode = 1 # Creative dimension = 0 # Overworld hashed_seed = 0 max_players = 20 level_type = "default" view_distance = 32 reduced_debug_info = False enable_respawn_screen = True is_debug = False is_flat = False data = struct.pack("!ibbqql", entity_id, gamemode, dimension, hashed_seed, max_players, view_distance) data += pack_string(level_type) data += struct.pack("!??", reduced_debug_info, enable_respawn_screen) packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending join game: {e}") def send_player_position_and_look(client_socket): """Sends a Player Position and Look packet (ID 0x34 for 1.16.5).""" packet_id = 0x34 x = 0.0 y = 64.0 z = 0.0 yaw = 0.0 pitch = 0.0 flags = 0x00 teleport_id = 0 data = struct.pack("!ddddbff", x, y, z, yaw, pitch, flags, teleport_id) packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending player position and look: {e}") def send_world_border(client_socket): """Sends a World Border packet (ID 0x41 for 1.16.5).""" packet_id = 0x41 action = 3 # Initialize border_diameter = 60000000.0 new_border_diameter = 60000000.0 speed = 0 x = 0.0 z = 0.0 warning_time = 0 warning_blocks = 0 data = struct.pack("!iqqdqql", action, border_diameter, new_border_diameter, speed, x, z, warning_time, warning_blocks) packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending world border: {e}") def send_server_list_response(client_socket): """Sends a Server List Response packet (ID 0x00).""" packet_id = 0x00 description = { "version": { "name": SERVER_VERSION_NAME, "protocol": PROTOCOL_VERSION }, "players": { "max": MAX_PLAYERS, "online": 0 }, "description": { "text": "Weather MCP Server" } } import json json_data = json.dumps(description, separators=(',', ':')) data = pack_string(json_data) packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending server list response: {e}") def send_set_slot(client_socket): """Sends a Set Slot packet (ID 0x16 for 1.16.5).""" packet_id = 0x16 window_id = 0 slot = 36 item_id = 276 # Diamond Sword item_count = 1 nbt_data = b'\x0a\x00\x04Name\x08\x00\x00\x00\x0bWeather Sword\x00' data = struct.pack("!bh", window_id, slot) data += pack_varint(item_id) data += struct.pack("!b", item_count) data += nbt_data packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending set slot: {e}") def send_entity_equipment(client_socket): """Sends an Entity Equipment packet (ID 0x47 for 1.16.5).""" packet_id = 0x47 entity_id = 0 slot = 0 # Main Hand item_id = 276 # Diamond Sword item_count = 1 nbt_data = b'\x0a\x00\x04Name\x08\x00\x00\x00\x0bWeather Sword\x00' data = pack_varint(entity_id) data += struct.pack("!b", slot) data += pack_varint(item_id) data += struct.pack("!b", item_count) data += nbt_data data += b'\xff' # End of equipment list packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending entity equipment: {e}") def send_update_weather(client_socket, entity_id, type, value): """Sends an Update Weather packet (ID 0x08 for 1.16.5).""" packet_id = 0x08 data = struct.pack("!ibf", entity_id, type, value) packet = create_packet(packet_id, data) try: client_socket.sendall(packet) except Exception as e: print(f"Error sending update weather: {e}") # --- Client Handling --- def handle_client(client_socket, client_address): """Handles a single client connection.""" print(f"Accepted connection from {client_address}") try: # --- Handshaking --- packet_length_bytes = client_socket.recv(1) packet_length = struct.unpack("!b", packet_length_bytes)[0] packet_data = client_socket.recv(packet_length) packet_id = struct.unpack("!b", packet_data[:1])[0] if packet_id == 0x00: protocol_version, server_address_length = struct.unpack("!bi", packet_data[1:6]) server_address = client_socket.recv(server_address_length) server_port, next_state = struct.unpack("!hi", packet_data[6+server_address_length:12+server_address_length]) if next_state == 1: send_server_list_response(client_socket) client_socket.recv(1) # Ping client_socket.sendall(create_packet(0x01, struct.pack("!q", int(time.time() * 1000)))) elif next_state == 2: send_login_success(client_socket, "00000000-0000-0000-0000-000000000000", "WeatherPlayer") send_join_game(client_socket) send_player_position_and_look(client_socket) send_world_border(client_socket) send_set_slot(client_socket) send_entity_equipment(client_socket) # --- Main Game Loop (Send Weather Updates) --- while True: send_time_update(client_socket, 100, 6000) send_update_weather(client_socket, 0, 1, rain_level) # Rain send_update_weather(client_socket, 1, 2, thunder_level) # Thunder time.sleep(0.5) # Send weather updates every 0.5 seconds except Exception as e: print(f"Error handling client: {e}") finally: print(f"Closing connection from {client_address}") client_socket.close() # --- Main Server --- def main(): """Main server function.""" server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # Allow reuse of the address server_socket.bind((HOST, PORT)) server_socket.listen(5) # Listen for up to 5 incoming connections print(f"Weather MCP Server listening on {HOST}:{PORT}") # Start the weather simulation thread weather_thread = threading.Thread(target=update_weather) weather_thread.daemon = True # Exit when the main thread exits weather_thread.start() try: while True: client_socket, client_address = server_socket.accept() client_thread = threading.Thread(target=handle_client, args=(client_socket, client_address)) client_thread.daemon = True client_thread.start() except KeyboardInterrupt: print("Shutting down server...") finally: server_socket.close() if __name__ == "__main__": main() ``` **Key Improvements and Explanations:** * **Clearer Structure:** The code is organized into functions for packet packing, weather simulation, and client handling. * **VarInt Packing:** Includes `pack_varint` and `pack_string` functions to handle Minecraft's variable-length integer format. This is *essential* for the protocol. * **Packet Creation:** The `create_packet` function simplifies packet construction. * **Weather Simulation:** The `update_weather` function now simulates rain and thunder, changing the `rain_level` and `thunder_level` variables. It runs in its own thread. * **Weather Packets:** The `send_update_weather` function sends the correct packets to update the client's weather. It uses the `rain_level` and `thunder_level` values. The `send_change_game_state` function is *not* the correct way to change weather in modern Minecraft. The `Update Weather` packet is the correct one. * **Time Updates:** The `send_time_update` function sends time updates, which are important for the Minecraft client. * **Basic Handshaking and Login:** The `handle_client` function now includes basic handshaking and login to get the client into the game. It sends the necessary packets (Login Success, Join Game, Player Position and Look). This is *minimal* but allows the client to connect. * **Error Handling:** Includes `try...except` blocks to catch potential errors during network operations. * **Threading:** Uses threads to handle multiple clients concurrently. The weather simulation also runs in a separate thread. * **Comments:** More comments to explain the code. * **`struct.pack`:** Uses `struct.pack` for efficient packing of data into byte arrays. The `!` prefix in the format strings indicates network byte order (big-endian), which is required by the Minecraft protocol. * **Server List Ping:** Responds to the server list ping request so the server shows up in the Minecraft client's server list. * **Example Item:** Gives the player a diamond sword named "Weather Sword" to demonstrate sending item data. * **World Border:** Sends a world border packet to prevent the player from wandering too far. **How to Run:** 1. **Save:** Save the code as a Python file (e.g., `weather_mcp.py`). 2. **Run:** Execute the script from your terminal: `python weather_mcp.py` 3. **Minecraft Client:** * Start your Minecraft client (version 1.16.5 or the version you targeted). * Add a new server with the IP address of the machine running the script (usually `localhost` or `127.0.0.1`). * Connect to the server. **Important Considerations and Next Steps:** * **Minecraft Protocol Version:** The Minecraft protocol changes frequently. This example is based on 1.16.5. You'll need to adapt the packet IDs and data formats if you're targeting a different version. Refer to the Minecraft protocol documentation for your target version. A good resource is the [wiki.vg](https://wiki.vg/Protocol) wiki. * **Authentication:** This example skips authentication. In a real server, you'll need to handle player authentication with Mojang's servers. * **World Generation:** This example doesn't generate a world. You'll need to implement world generation and chunk loading to create a playable environment. * **Entity Management:** You'll need to manage entities (players, mobs, etc.) and send packets to update their positions and states. * **Asynchronous Programming:** For a more scalable server, consider using Python's `asyncio` library for asynchronous networking. This can handle many more concurrent connections than threading. * **Libraries:** Consider using a Minecraft server library to simplify protocol handling. However, be aware that many libraries may be outdated or incomplete. * **Security:** Be very careful about security when writing a Minecraft server. There are many potential vulnerabilities that can be exploited. This improved example provides a much better foundation for building a simple Minecraft server that can control the weather. Remember that building a full-fledged server is a significant undertaking. Start small, test frequently, and consult the Minecraft protocol documentation. Good luck!

testmcpgithubdemo1

testmcpgithubdemo1

created from MCP server demo

Linear MCP Server

Linear MCP Server

Mirror of

Telegram MCP Server

Telegram MCP Server

MCP server to send notifications to Telegram

mcp-server-testWhat is MCP Server Test?How to use MCP Server Test?Key features of MCP Server Test?Use cases of MCP Server Test?FAQ from MCP Server Test?

mcp-server-testWhat is MCP Server Test?How to use MCP Server Test?Key features of MCP Server Test?Use cases of MCP Server Test?FAQ from MCP Server Test?

Test MCP Server

🐋 Docker MCP server

🐋 Docker MCP server

Mirror of

Simple Memory Extension MCP Server

Simple Memory Extension MCP Server

Một máy chủ MCP (Memory, Context, and Persistence) mở rộng cửa sổ ngữ cảnh của các tác nhân AI bằng cách cung cấp các công cụ để lưu trữ, truy xuất và tìm kiếm ký ức, cho phép các tác nhân duy trì lịch sử và ngữ cảnh trong các tương tác dài.

MCP Server Pool

MCP Server Pool

MCP 服务合集

MCP System Monitor

MCP System Monitor

A system monitoring tool that exposes system metrics via the Model Context Protocol (MCP). This tool allows LLMs to retrieve real-time system information through an MCP-compatible interface.

mpc-csharp-semantickernel

mpc-csharp-semantickernel

Okay, here's an example demonstrating how to use Microsoft Semantic Kernel with OpenAI and a hypothetical "MCP Server" (assuming MCP stands for something like "Model Control Plane" or "Model Configuration Provider"). I'll outline the code structure, explain the concepts, and provide a basic implementation. Keep in mind that the "MCP Server" part is conceptual, as there isn't a standard, universally defined MCP Server. You'll need to adapt the MCP Server interaction to your specific implementation. **Conceptual Overview** 1. **Semantic Kernel:** The core framework for orchestrating AI tasks. It allows you to define skills (functions) that can be chained together to achieve complex goals. 2. **OpenAI:** Provides the large language models (LLMs) that power the AI capabilities. We'll use the OpenAI connector in Semantic Kernel to interact with OpenAI's APIs. 3. **MCP Server (Hypothetical):** This server is responsible for managing model configurations, potentially including: * API keys for OpenAI (or other LLM providers). * Model names (e.g., "gpt-3.5-turbo", "gpt-4"). * Temperature, top\_p, and other model parameters. * Rate limiting policies. * Potentially, even A/B testing configurations for different models. **Code Structure (Conceptual)** ```python # Assuming you have installed: # pip install semantic-kernel python-dotenv openai import semantic_kernel as sk from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion import os from dotenv import load_dotenv import requests # For interacting with the MCP Server # Load environment variables (e.g., from a .env file) load_dotenv() # --- 1. MCP Server Interaction (Hypothetical) --- MCP_SERVER_URL = os.getenv("MCP_SERVER_URL", "http://localhost:8000") # Default URL def get_model_config(model_name: str): """ Fetches model configuration from the MCP Server. Args: model_name: The name of the model to retrieve configuration for. Returns: A dictionary containing the model configuration, or None if not found. """ try: response = requests.get(f"{MCP_SERVER_URL}/models/{model_name}") response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx) return response.json() except requests.exceptions.RequestException as e: print(f"Error fetching model config from MCP Server: {e}") return None # --- 2. Semantic Kernel Setup --- async def main(): kernel = sk.Kernel() # Get OpenAI configuration from MCP Server model_name = "gpt-3.5-turbo" # Or "gpt-4", etc. model_config = get_model_config(model_name) if model_config is None: print("Failed to retrieve model configuration. Using environment variables.") # Fallback to environment variables if MCP Server is unavailable api_key = os.getenv("OPENAI_API_KEY") org_id = os.getenv("OPENAI_ORG_ID") if not api_key: raise Exception("OpenAI API key not found in environment variables or MCP Server.") kernel.add_chat_service("openai", OpenAIChatCompletion(model_name, api_key, org_id)) else: # Use configuration from MCP Server api_key = model_config.get("api_key") org_id = model_config.get("org_id") temperature = model_config.get("temperature", 0.7) # Default temperature top_p = model_config.get("top_p", 1.0) # Default top_p if not api_key: raise Exception("OpenAI API key not found in MCP Server configuration.") kernel.add_chat_service( "openai", OpenAIChatCompletion( model_name, api_key, org_id, temperature=temperature, top_p=top_p ) ) # --- 3. Define a Skill --- # Simple example: A skill to summarize text summarize_prompt = """ Summarize the following text: {{$text}} """ summarize_function = kernel.create_semantic_function( prompt_template=summarize_prompt, description="Summarizes text", max_tokens=200, # Limit the output length temperature=0.7, top_p=1.0, ) # --- 4. Use the Skill --- text_to_summarize = """ Microsoft Semantic Kernel is a powerful framework for building AI-powered applications. It allows developers to easily integrate large language models (LLMs) like OpenAI's GPT-3 and GPT-4 into their applications. Semantic Kernel provides a set of tools and abstractions for orchestrating AI tasks, managing prompts, and chaining skills together. This makes it easier to create complex AI workflows. """ context_variables = sk.ContextVariables(text_to_summarize) summary = await summarize_function.invoke(context_variables) print("Original Text:") print(text_to_summarize) print("\nSummary:") print(summary) if __name__ == "__main__": import asyncio asyncio.run(main()) ``` **Explanation:** 1. **MCP Server Interaction:** * `get_model_config(model_name)`: This function is the key to integrating with your MCP Server. It sends an HTTP GET request to the server to retrieve the configuration for a specific model. The URL (`MCP_SERVER_URL/models/{model_name}`) is just an example; adjust it to match your server's API. * Error Handling: The `try...except` block handles potential network errors or HTTP errors (e.g., 404 Not Found if the model isn't configured). * Configuration Retrieval: The function expects the MCP Server to return a JSON response containing the model's configuration (API key, model name, temperature, etc.). 2. **Semantic Kernel Setup:** * `kernel = sk.Kernel()`: Creates a Semantic Kernel instance. * `get_model_config()` is called to fetch the OpenAI configuration. * Conditional Logic: If the MCP Server is unavailable or doesn't have the configuration, the code falls back to using environment variables (a common practice). This provides a backup mechanism. * `kernel.add_chat_service()`: This is where you register the OpenAI connector with the Semantic Kernel. It's crucial to pass the API key and other parameters (temperature, top\_p) obtained from either the MCP Server or the environment variables. 3. **Skill Definition:** * `summarize_prompt`: A simple prompt that instructs the LLM to summarize the input text. The `{{$text}}` is a placeholder that will be replaced with the actual text to be summarized. * `kernel.create_semantic_function()`: Creates a semantic function (a skill) from the prompt. You can also specify other parameters like `max_tokens` (to limit the output length), `temperature`, and `top_p`. 4. **Skill Usage:** * `text_to_summarize`: The text you want to summarize. * `context_variables = sk.ContextVariables(text_to_summarize)`: Creates a context object to pass the input text to the skill. * `summary = await summarize_function.invoke(context_variables)`: Invokes the skill and gets the result. * Prints the original text and the summary. **MCP Server Implementation (Example - Flask)** Here's a very basic example of how you might implement the MCP Server using Flask (a Python web framework): ```python from flask import Flask, jsonify import os from dotenv import load_dotenv load_dotenv() app = Flask(__name__) # In a real application, this would likely be stored in a database model_configurations = { "gpt-3.5-turbo": { "api_key": os.getenv("OPENAI_API_KEY"), "org_id": os.getenv("OPENAI_ORG_ID"), "temperature": 0.7, "top_p": 1.0, }, "gpt-4": { "api_key": os.getenv("OPENAI_API_KEY"), "org_id": os.getenv("OPENAI_ORG_ID"), "temperature": 0.5, "top_p": 0.9, }, } @app.route("/models/<model_name>") def get_model(model_name): if model_name in model_configurations: return jsonify(model_configurations[model_name]) else: return jsonify({"error": "Model not found"}), 404 if __name__ == "__main__": app.run(debug=True, port=8000) ``` **To Run the Example:** 1. **Install Dependencies:** ```bash pip install semantic-kernel python-dotenv openai flask requests ``` 2. **Set Environment Variables:** * Create a `.env` file in the same directory as your Python scripts. * Add your OpenAI API key and organization ID to the `.env` file: ``` OPENAI_API_KEY=YOUR_OPENAI_API_KEY OPENAI_ORG_ID=YOUR_OPENAI_ORG_ID MCP_SERVER_URL=http://localhost:8000 # Optional, if you want to override the default ``` * Replace `YOUR_OPENAI_API_KEY` and `YOUR_OPENAI_ORG_ID` with your actual credentials. 3. **Run the MCP Server:** ```bash python your_mcp_server_script.py # Replace with the actual name of your MCP server script ``` 4. **Run the Semantic Kernel Script:** ```bash python your_semantic_kernel_script.py # Replace with the actual name of your Semantic Kernel script ``` **Important Considerations:** * **Security:** Never hardcode API keys directly into your code. Use environment variables or a secure configuration management system (like the MCP Server) to store sensitive information. * **Error Handling:** Implement robust error handling to gracefully handle network errors, API errors, and other potential issues. * **Scalability:** For production environments, consider using a more scalable MCP Server implementation (e.g., using a database to store model configurations and a more robust web framework). * **MCP Server Design:** The design of your MCP Server will depend on your specific requirements. You might want to add features like: * Authentication and authorization. * Rate limiting. * Model versioning. * A/B testing. * Monitoring and logging. * **Asynchronous Operations:** Use `async` and `await` for I/O-bound operations (like network requests) to improve performance. * **Prompt Engineering:** Experiment with different prompts to optimize the performance of your skills. * **Semantic Kernel Documentation:** Refer to the official Microsoft Semantic Kernel documentation for the most up-to-date information and examples: [https://learn.microsoft.com/en-us/semantic-kernel/](https://learn.microsoft.com/en-us/semantic-kernel/) This comprehensive example should give you a solid foundation for using Microsoft Semantic Kernel with OpenAI and a custom MCP Server. Remember to adapt the MCP Server implementation to your specific needs and security requirements.