Discover Awesome MCP Servers

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

All84,517
MCP to LangChain/LangGraph Adapter

MCP to LangChain/LangGraph Adapter

Okay, I understand. You want a way to wrap tools that interact with an MCP (Minecraft Protocol) server into a format that Langchain can use. This would allow you to build Langchain agents that can interact with and control a Minecraft server. Here's a breakdown of how you can approach this, along with code examples and explanations: **1. Understanding the Core Concepts** * **MCP (Minecraft Protocol):** This is the communication protocol used between Minecraft clients and servers. You'll need a library that can handle this protocol. Popular choices include: * **`mcstatus`:** A Python library specifically for querying Minecraft server status. It's good for basic information. * **`python-minecraft-nbt`:** For reading and writing NBT data (the format Minecraft uses for world data, player data, etc.). * **`minecraft-protocol`:** A more comprehensive library for interacting with the full Minecraft protocol. This is more complex but gives you more control. * **Langchain Tools:** Langchain tools are wrappers around functions that allow your Langchain agent to perform specific actions. They have a name, a description, and a function to execute. * **Langchain Agents:** Langchain agents use tools to interact with the environment and achieve goals. **2. General Structure** The basic structure will involve: 1. **MCP Interaction Logic:** Write Python functions that use your chosen MCP library to perform actions on the Minecraft server. Examples: * Get server status (player count, MOTD). * Send commands to the server console. * Read/write NBT data (more advanced). 2. **Tool Wrapping:** Wrap these functions into Langchain `Tool` objects. The `Tool` object will define the name, description, and the function to call. 3. **Agent Integration:** Provide these tools to your Langchain agent. **3. Example Code (using `mcstatus` for simplicity)** ```python from langchain.tools import Tool from mcstatus import JavaServer # --- MCP Interaction Functions --- def get_server_status(server_address): """Gets the status of a Minecraft server.""" try: server = JavaServer.lookup(server_address) status = server.status() return f"Server {server_address} has {status.players.online} players online. MOTD: {status.description}" except Exception as e: return f"Error getting server status: {e}" def send_server_command(server_address, command): """Sends a command to the Minecraft server console (requires RCON setup).""" # **IMPORTANT:** This requires RCON to be enabled and configured on the server. # RCON is a remote console protocol. It's a security risk if not properly secured. try: server = JavaServer.lookup(server_address) query = server.query() # Requires enabling query in server.properties # This is just an example, you'd need to use an RCON library for actual command execution # Example using mcrcon (install with pip install mcrcon): # from mcrcon import MCRcon # with MCRcon(server_address.split(":")[0], "your_rcon_password", int(server_address.split(":")[1])) as mcr: # resp = mcr.command(command) # return resp return f"Command '{command}' sent to server {server_address} (RCON not fully implemented in this example)." except Exception as e: return f"Error sending command: {e}" # --- Langchain Tool Definitions --- status_tool = Tool( name="Minecraft Server Status", func=get_server_status, description="Useful for getting the status of a Minecraft server, including player count and MOTD. Input should be a server address in the format 'host:port'." ) command_tool = Tool( name="Minecraft Server Command", func=send_server_command, description="Useful for sending commands to the Minecraft server console. Requires RCON to be enabled and configured. Input should be a server address in the format 'host:port' followed by the command to execute, separated by a comma. Example: 'localhost:25565,say Hello!'" ) # --- Example Usage (with a dummy agent) --- # In a real application, you'd integrate these tools into a Langchain agent. # This is a simplified example to show how the tools would be used. def dummy_agent(query): """A very simple agent that uses the tools based on keywords.""" if "status" in query.lower(): server_address = query.split("status of ")[-1].strip() # Extract server address return status_tool.run(server_address) elif "command" in query.lower(): parts = query.split("command")[-1].strip().split(",") if len(parts) != 2: return "Invalid command format. Use 'command <server_address>,<command>'." server_address = parts[0].strip() command = parts[1].strip() return command_tool.run(f"{server_address},{command}") else: return "I don't understand. Try asking for the server status or sending a command." # Example interaction print(dummy_agent("What is the status of localhost:25565")) print(dummy_agent("Send command localhost:25565,say Hello from Langchain!")) ``` **Explanation:** 1. **`get_server_status(server_address)`:** * Takes a server address (e.g., "localhost:25565") as input. * Uses `mcstatus` to query the server. * Returns a formatted string with the player count and MOTD. * Includes error handling. 2. **`send_server_command(server_address, command)`:** * Takes a server address and a command as input. * **Important:** This example *does not* fully implement RCON. It shows the basic structure but requires you to add the RCON library and authentication. I've included commented-out code using `mcrcon` as an example. * Returns a message indicating that the command was sent (or an error). 3. **`status_tool` and `command_tool`:** * `Tool` objects that wrap the functions. * `name`: A descriptive name for the tool. * `func`: The function to execute when the tool is called. * `description`: A crucial description for the Langchain agent. This is how the agent decides when to use the tool. Be very specific about the input format and what the tool does. 4. **`dummy_agent(query)`:** * This is a *very* basic example of how you might use the tools. In a real application, you would use a Langchain agent (e.g., `ZeroShotAgent`, `ReActAgent`) to intelligently decide when to use the tools based on the user's input. * The `dummy_agent` simply looks for keywords ("status", "command") in the query and calls the appropriate tool. * It extracts the server address and command from the query string. **Key Improvements and Considerations:** * **RCON Implementation:** The `send_server_command` function *must* be updated to use a proper RCON library (like `mcrcon`) to actually send commands to the server. You'll need to configure RCON on your Minecraft server (in `server.properties`) and provide the correct password. **Security is paramount with RCON.** Don't expose your RCON port to the internet without proper security measures. * **Error Handling:** Add more robust error handling to all functions. Catch exceptions and provide informative error messages to the agent. * **Input Validation:** Validate the input to the tools (e.g., server address format, command syntax) to prevent errors. * **Langchain Agent Integration:** Replace the `dummy_agent` with a real Langchain agent. You'll need to: * Choose an agent type (e.g., `ZeroShotAgent`, `ReActAgent`). * Define the agent's prompt (the instructions that tell the agent how to use the tools). The prompt is *critical* for agent performance. * Create an `AgentExecutor` to run the agent. * **More Advanced Tools:** Consider adding tools for: * Reading and writing NBT data (using `python-minecraft-nbt`). This would allow you to modify world data, player data, etc. * Managing server configuration (e.g., changing game rules). * Interacting with Minecraft plugins (if you have any installed). * **Security:** Be extremely careful about security, especially when dealing with RCON or NBT data. Sanitize inputs to prevent command injection or other vulnerabilities. Never hardcode passwords in your code. Use environment variables or a secure configuration file. * **Asynchronous Operations:** For more complex interactions, consider using asynchronous operations (using `asyncio`) to avoid blocking the main thread. This is especially important if you're running the agent in a web server or other interactive environment. **Example of integrating with a Langchain Agent (Conceptual):** ```python from langchain.agents import initialize_agent, AgentType from langchain.llms import OpenAI # Assuming you have the status_tool and command_tool defined as above llm = OpenAI(temperature=0) # Replace with your LLM tools = [status_tool, command_tool] agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True # Set to True for debugging ) # Now you can run the agent: response = agent.run("What is the status of localhost:25565? Then, send the command 'say Hello from the agent!' to localhost:25565") print(response) ``` **Important Notes about the Langchain Agent Example:** * **API Key:** You'll need an OpenAI API key to use the `OpenAI` LLM. * **Prompt Engineering:** The success of the agent depends heavily on the prompt used by the `ZERO_SHOT_REACT_DESCRIPTION` agent. You may need to experiment with different prompts to get the agent to behave as desired. The tool descriptions are a key part of the prompt. * **Dependencies:** Make sure you have all the necessary Langchain dependencies installed (`pip install langchain openai`). This comprehensive guide should give you a solid foundation for building Langchain tools that interact with your Minecraft server. Remember to prioritize security and error handling, and to carefully design your agent's prompt for optimal performance. Good luck!

Blender MCP Server

Blender MCP Server

Exposes 50+ Blender tools (object manipulation, materials, animation, etc.) via MCP for AI-driven 3D workflows and automation.

MCP Yandex Voice

MCP Yandex Voice

MCP server for Cursor that generates text responses via Yandex GPT and converts them to speech using Yandex SpeechKit TTS, enabling voice replies to user messages.

TradingView MCP Bridge

TradingView MCP Bridge

Connects AI assistants to your local TradingView Desktop app via Chrome DevTools Protocol for chart analysis, Pine Script development, and workflow automation while keeping all data local.

gx3-mcp-server

gx3-mcp-server

Provides read-only analysis of Mitsubishi GX Works3 PLC projects via MCP, enabling device tracing, cross-referencing, ladder inspection, linting, and report generation without modifying source projects.

discord-mcp

discord-mcp

MCP server for interacting with Discord via REST API, enabling guild, channel, and message operations using a bot token.

TreasuryOS

TreasuryOS

An AI-powered treasury management MCP server that enables users to perform commercial banking analysis, including cash flow forecasting, idle cash detection, and debt covenant monitoring. It provides tools to surface financial insights and optimize working capital through automated processing of bank and transaction data.

futu-opend-mcp

futu-opend-mcp

Read-only MCP server that exposes Futu OpenD's investment-research quote APIs (stocks, options, futures, financials, news, etc.) as MCP tools, leveraging an already-running OpenD gateway with no separate authentication.

diagram-mcp

diagram-mcp

Renders Mermaid diagrams and Plotly charts to SVG, PNG, or PDF formats via the Model Context Protocol.

us-gov-data-mcp

us-gov-data-mcp

MCP server for querying US federal contracts and public company financial data from USAspending and SEC EDGAR. Enables searching expiring contracts, screening companies by metrics, and retrieving financial histories.

sophtron-mcp

sophtron-mcp

Query bank accounts, credit cards, and transactions via Sophtron's financial data API. Works with Claude Desktop and any MCP-compatible client.

phison-mail-mcp

phison-mail-mcp

Enables AI models to send, receive, search, and manage emails via SMTP/IMAP, including support for attachments, contacts, and advanced search.

SSH MCP Server

SSH MCP Server

Enables AI apps to connect to remote servers via SSH, SFTP, and tunnels.

seeany-sun-mcp

seeany-sun-mcp

MCP server for SeeAny Sun enabling product image generation, smart creation, task polling, and download via natural language, with demo mode for offline simulation.

cysic-mcp

cysic-mcp

Exposes the Cysic AI model to any MCP client over stdio, with server-side session memory and a tone-rewriting tool.

Zulip MCP Server

Zulip MCP Server

A Model Context Protocol server that enables AI assistants to interact with Zulip workspaces by exposing REST API capabilities as tools for message operations, channel management, and user interactions.

Open Library MCP Server

Open Library MCP Server

Connects AI assistants to the Open Library API for searching books and authors, retrieving metadata, and comparing works.

oura-ring-mcp

oura-ring-mcp

Provides natural-language access to Oura health data through Claude, with a local SQLite mirror and MCP tools for analyzing patterns with personal annotations.

specrun

specrun

MCP server that turns OpenAPI specs into tools and calls API

OpenAlex MCP Server

OpenAlex MCP Server

Provides academic research tools via the OpenAlex API, enabling searches for papers, authors, concepts, institutions, and citation analysis.

spudcoach

spudcoach

A deterministic theorycrafter for the game Brotato, enabling natural language queries about weapons, items, characters, DPS calculations, and build evaluation.

Prompt Refiner MCP Server

Prompt Refiner MCP Server

Helps systematically refine vague ideas into well-structured prompts through guided clarification and export templates.

AWO MCP Server

AWO MCP Server

Exposes processed AWO facility, address, service, and provider datasets to AI assistants. Enables natural-language queries for counting, searching, detailing, comparing, and analyzing facilities.

capcut-mcp

capcut-mcp

An MCP server that reads and builds CapCut projects locally, enabling natural language queries about project contents, missing media, and creation of new edits including beat-synced cuts.

Online Boutique AI Assistant MCP Server

Online Boutique AI Assistant MCP Server

MCP server for Online Boutique AI Assistant that exposes 18 e-commerce microservice functions via the Model Context Protocol, enabling any MCP client to manage products, carts, checkout, payments, and shipping.

DREAMVFIA Windows MCP

DREAMVFIA Windows MCP

A lean local Windows automation server providing tools for mouse and keyboard control, screenshot capture, and process management. It enables programmatic interaction with the Windows desktop environment through the Model Context Protocol.

brainiall-mcp-server

brainiall-mcp-server

AI-powered speech tools by Brainiall: pronunciation assessment with phoneme-level feedback, speech-to-text with language detection, and text-to-speech with multiple voices.

Company API MCP Server

Company API MCP Server

Exposes internal company services as LLM-callable MCP tools, enabling AI agents to perform business operations like customer management, order processing, and support ticketing through natural language.

WordPress MCP Server

WordPress MCP Server

Enables AI assistants to interact with WordPress sites through the REST API. Supports multiple WordPress sites with secure authentication, enabling content management, post operations, and site configuration through natural language.

jira-mcp-server

jira-mcp-server

Integrates Jira tickets with GitHub Copilot Chat, fetching ticket details, linked tickets, and metadata to enhance context for AI-driven code suggestions.