Mcp-server-v2ex

Mcp-server-v2ex

Okay, here's a simplified explanation of how to build a basic Minecraft Protocol (MCP) server using TypeScript, focusing on the core concepts and a minimal example. Keep in mind that a full MCP server is a complex undertaking, and this is just a starting point. **Conceptual Overview** 1. **Minecraft Protocol (MCP):** Minecraft clients and servers communicate using a specific binary protocol. You need to understand the structure of packets (data messages) defined by this protocol. The protocol changes with each Minecraft version. [Wiki.vg](https://wiki.vg/Protocol) is *the* resource for protocol information. 2. **TCP Socket Server:** Your server will listen for incoming TCP connections from Minecraft clients. 3. **Packet Handling:** When a client connects, your server needs to: * Receive data from the socket. * Parse the data into MCP packets. * Process the packets (e.g., handle handshake, login, player movement). * Construct appropriate response packets. * Send the response packets back to the client. 4. **TypeScript:** TypeScript adds static typing to JavaScript, making your code more maintainable and easier to reason about. **Simplified Example (Conceptual - Requires Libraries)** This example outlines the basic structure. You'll need to install libraries for socket handling, data serialization/deserialization (for MCP packets), and potentially logging. ```typescript import * as net from 'net'; // You'll need to install a library for handling Minecraft packets. // Example: npm install prismarine-packet // import { createSerializer, createDeserializer } from 'prismarine-packet'; const serverPort = 25565; // Default Minecraft port // Basic server information (for the server list ping) const serverDescription = "My Simple TS Server"; const maxPlayers = 10; const onlinePlayers = 0; const protocolVersion = 763; // Example: Minecraft 1.17.1 protocol version const minecraftVersion = "1.17.1"; // Create the TCP server const server = net.createServer((socket) => { console.log('Client connected:', socket.remoteAddress, socket.remotePort); // **Packet Handling (Simplified)** socket.on('data', (data) => { // In a real server, you'd: // 1. Deserialize the data into a Minecraft packet. // 2. Determine the packet type (e.g., Handshake, Login Start). // 3. Process the packet based on its type. // 4. Construct a response packet. // 5. Serialize the response packet. // 6. Send the serialized data back to the client. // **Extremely Simplified Example: Responding to a Handshake (Very Incomplete)** // This is just to illustrate the concept. It's not a complete handshake implementation. const packetId = data[0]; // Assuming the first byte is the packet ID if (packetId === 0x00) { // Handshake packet ID (This is version-dependent!) console.log("Received Handshake"); // **In reality, you'd parse the handshake data to get the protocol version, server address, and port.** // **Create a Status Response (Server List Ping)** const statusResponse = { version: { name: minecraftVersion, protocol: protocolVersion }, players: { max: maxPlayers, online: onlinePlayers, sample: [] // Player list (optional) }, description: { text: serverDescription } }; // **Serialize the status response to JSON** const statusResponseJson = JSON.stringify(statusResponse); // **Create the Status Response packet (0x00)** // **This is where you'd use a proper packet serialization library.** // **The following is a placeholder and WILL NOT WORK without proper serialization.** const responsePacket = Buffer.from([ 0x00, // Packet ID (Status Response) statusResponseJson.length, // Length of the JSON string (This needs to be properly encoded) ...Buffer.from(statusResponseJson, 'utf8') // The JSON string itself ]); // Send the response socket.write(responsePacket); // Request socket.once('data', (requestData) => { if (requestData[0] === 0x00) { console.log("Received Request"); const pongResponse = Buffer.from([ 0x01, // Pong packet ID 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Payload (timestamp) ]); socket.write(pongResponse); socket.end(); } }); } else { console.log("Received unknown packet ID:", packetId); } }); socket.on('close', () => { console.log('Client disconnected:', socket.remoteAddress, socket.remotePort); }); socket.on('error', (err) => { console.error('Socket error:', err); }); }); // Start the server server.listen(serverPort, () => { console.log(`Server listening on port ${serverPort}`); }); ``` **Important Considerations and Next Steps** * **Minecraft Protocol Library:** You *absolutely* need a library to handle the Minecraft protocol. `prismarine-packet` is a popular choice, but there are others. This library will handle the complex serialization and deserialization of packets. Install it with `npm install prismarine-packet`. You'll need to adapt the example code to use the library's functions. * **Protocol Version:** The Minecraft protocol changes with each version. Make sure you're using the correct protocol version for the Minecraft client you're testing with. [Wiki.vg](https://wiki.vg/Protocol_version_IDs) lists protocol version IDs. * **Error Handling:** The example has minimal error handling. You need to add robust error handling to catch exceptions and prevent your server from crashing. * **Asynchronous Operations:** Use `async/await` or Promises to handle asynchronous operations (like socket reads and writes) properly. * **State Management:** You'll need to manage the state of each connected client (e.g., their username, position, inventory). * **Security:** Implement security measures to prevent exploits and attacks. * **World Generation:** If you want a playable world, you'll need to implement world generation. * **Multiplayer:** Handling multiple players concurrently adds significant complexity. **How to Run** 1. **Install Node.js:** Make sure you have Node.js installed. 2. **Create a Project:** Create a directory for your project and run `npm init -y` to create a `package.json` file. 3. **Install Dependencies:** `npm install net prismarine-packet` (or your chosen packet library). You might need other dependencies as you develop. 4. **Save the Code:** Save the TypeScript code as a `.ts` file (e.g., `server.ts`). 5. **Compile:** Compile the TypeScript code to JavaScript: `tsc server.ts` (you might need to configure `tsconfig.json` first). 6. **Run:** Run the server: `node server.js` **In summary, this is a very basic outline. Building a real Minecraft server is a significant project. Start small, focus on understanding the protocol, and use libraries to help you.**

funnythingfunnylove

开发者工具
访问服务器

README

Mcp-server-v2ex

描述

这个 mcp 服务器简单地封装了官方 Api 2.0,实现了所有 api 操作。

特性

  • notifications 获取最新提醒
  • delete notifications 删除指定提醒
  • member profile 获取当前用户档案,即生成 token 的用户
  • token 查看当前的 token
  • create new token 生成新 token
  • nodes 获取指定节点
  • nodes topics 获取指定节点下的话题
  • topic detail 获取指定话题的内容
  • topic comments 获取指定话题下的回复

如何使用

  • 在 https://www.v2ex.com/settings/tokens 获取 token
  • 通过 npm 安装包
  npm install -g mcp-server-v2ex
  • 在 claude 的 config 的 json 中添加
  "v2ex": 
    {"command": "%APP_DATA%\\local\\nvm\\v22.14.0\\node.exe",
     "args": ["%APP_DATA%\\Local\\nvm\\v22.14.0\\node_modules\\mcp-server-v2ex\\dist\\index.js"],
      "env": {
         "V2EX_API_KEY": "{替换自己的 token}",
          "NODE_TLS_REJECT_UNAUTHORIZED": "0" // 如运用了 surge 之类的 MitM
      }
     }

更新日志

  • v0.1.1 / 2025.04.02
    • 新增今日热点总结 img
  • v0.1.0
    • 完成基本功能实现

计划

  • 考虑添加每日热点话题,只需在 claude desktop 中询问 v2ex 的热点话题即可。

推荐服务器

Playwright MCP Server

Playwright MCP Server

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

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

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

官方
精选
本地
TypeScript
MCP Package Docs Server

MCP Package Docs Server

促进大型语言模型高效访问和获取 Go、Python 和 NPM 包的结构化文档,通过多语言支持和性能优化来增强软件开发。

精选
本地
TypeScript
Claude Code MCP

Claude Code MCP

一个实现了 Claude Code 作为模型上下文协议(Model Context Protocol, MCP)服务器的方案,它可以通过标准化的 MCP 接口来使用 Claude 的软件工程能力(代码生成、编辑、审查和文件操作)。

精选
本地
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

用于任务管理的模型上下文协议服务器。它允许 Claude Desktop(或任何 MCP 客户端)在基于队列的系统中管理和执行任务。

精选
本地
JavaScript
mermaid-mcp-server

mermaid-mcp-server

一个模型上下文协议 (MCP) 服务器,用于将 Mermaid 图表转换为 PNG 图像。

精选
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP 服务器向 AI 编码助手(如 Cursor)提供 Jira 工单信息。

精选
TypeScript
Linear MCP Server

Linear MCP Server

一个模型上下文协议(Model Context Protocol)服务器,它与 Linear 的问题跟踪系统集成,允许大型语言模型(LLM)通过自然语言交互来创建、更新、搜索和评论 Linear 问题。

精选
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

这个服务器通过将复杂问题分解为顺序步骤来促进结构化的问题解决,支持修订,并通过完整的 MCP 集成来实现多条解决方案路径。

精选
Python
Curri MCP Server

Curri MCP Server

通过管理文本笔记、提供笔记创建工具以及使用结构化提示生成摘要,从而实现与 Curri API 的交互。

官方
本地
JavaScript