发现优秀的 MCP 服务器

通过 MCP 服务器扩展您的代理能力,拥有 62,820 个能力。

开发者工具3,065
Typescript Mcp Server Usage

Typescript Mcp Server Usage

Okay, I will provide you with a basic example of how to create an MCP (Minecraft Protocol) server using TypeScript. Keep in mind that building a full-fledged Minecraft server from scratch is a complex undertaking. This example will focus on the core networking and handshake aspects. You'll need to install some dependencies first. **1. Project Setup and Dependencies:** First, create a new TypeScript project: ```bash mkdir mcp-server cd mcp-server npm init -y npm install typescript ts-node ws --save npm install @types/node @types/ws --save-dev ``` * `ws`: A popular WebSocket library for Node.js. Minecraft uses a custom protocol over TCP, but WebSocket provides a convenient way to handle the underlying socket communication for this example. In a real Minecraft server, you'd implement the protocol directly over TCP. * `typescript`: The TypeScript compiler. * `ts-node`: Allows you to execute TypeScript files directly. * `@types/node`, `@types/ws`: TypeScript type definitions for Node.js and WebSocket, respectively. Create a `tsconfig.json` file: ```json { "compilerOptions": { "target": "es2017", "module": "commonjs", "outDir": "./dist", "rootDir": "./src", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true }, "include": ["src/**/*"], "exclude": ["node_modules"] } ``` **2. `src/index.ts` (Main Server Code):** ```typescript import * as WebSocket from 'ws'; const PORT = 25565; // Or any port you prefer const wss = new WebSocket.Server({ port: PORT }, () => { console.log(`Server started on port ${PORT}`); }); wss.on('connection', ws => { console.log('Client connected'); ws.on('message', message => { // In a real Minecraft server, you'd parse the Minecraft protocol packets here. // This is a simplified example, so we're just echoing the message. console.log(`Received: ${message}`); // Example: Echo the message back to the client ws.send(`Server received: ${message}`); }); ws.on('close', () => { console.log('Client disconnected'); }); ws.on('error', error => { console.error('WebSocket error:', error); }); }); wss.on('error', error => { console.error('Server error:', error); }); console.log('MCP Server is starting...'); ``` **Explanation:** * **Import `ws`:** Imports the WebSocket library. * **`PORT`:** Defines the port the server will listen on. Minecraft's default port is 25565. * **`WebSocket.Server`:** Creates a new WebSocket server instance. * **`wss.on('connection', ...)`:** This is the core of the server. It's called whenever a new client connects. * `ws`: Represents the WebSocket connection to the client. * `ws.on('message', ...)`: Handles incoming messages from the client. **This is where you would implement the Minecraft protocol parsing and handling.** In this example, it simply logs the message and echoes it back. * `ws.on('close', ...)`: Handles client disconnections. * `ws.on('error', ...)`: Handles errors on the WebSocket connection. * **`wss.on('error', ...)`:** Handles errors on the server itself. **3. Building and Running:** 1. **Compile:** Run `npm run tsc` (or just `tsc` if you have it globally installed) to compile the TypeScript code into JavaScript. This will create a `dist` directory with the compiled `index.js` file. You might need to add `"build": "tsc"` to your `package.json` scripts section. 2. **Run:** Execute the server using `node dist/index.js` or `ts-node src/index.ts`. **Important Considerations and Next Steps (for a *real* Minecraft server):** * **Minecraft Protocol:** The code above uses WebSockets for simplicity. A *real* Minecraft server communicates using a custom binary protocol over TCP. You'll need to: * **Understand the Protocol:** Study the Minecraft protocol documentation (see links below). It involves packets with specific IDs, data types, and structures. * **Implement Packet Parsing/Serialization:** Write code to read incoming TCP data, parse it into Minecraft packets, and serialize packets to send back to the client. Libraries exist that can help with this, but you'll still need to understand the protocol. * **Handshake:** The initial connection involves a handshake where the client and server exchange protocol versions. You need to implement this handshake correctly. * **Authentication:** Minecraft servers typically require authentication. You'll need to handle login requests and verify user credentials. * **Game Logic:** This example has *no* game logic. You'll need to implement the core game mechanics: world generation, player movement, entity management, block updates, etc. * **Threading/Asynchronous Operations:** Minecraft servers are highly concurrent. You'll need to use threading or asynchronous programming (e.g., `async/await` in TypeScript) to handle multiple clients efficiently. * **World Storage:** You'll need a way to store the game world data (blocks, entities, etc.). This could involve files, databases, or other storage mechanisms. **Example of a very basic handshake (to illustrate the concept):** ```typescript // Inside the 'connection' handler: ws.on('message', message => { const buffer = Buffer.from(message); // Convert to Buffer for binary data // Example: Very basic handshake (replace with actual protocol parsing) if (buffer[0] === 0x00) { // Assuming 0x00 is a handshake packet ID const protocolVersion = buffer.readInt32BE(1); // Read protocol version const serverAddressLength = buffer.readInt8(5); const serverAddress = buffer.toString('utf8', 6, 6 + serverAddressLength); const serverPort = buffer.readUInt32BE(6 + serverAddressLength); const nextState = buffer.readInt8(10 + serverAddressLength); console.log(`Handshake: Protocol ${protocolVersion}, Address ${serverAddress}:${serverPort}, Next State ${nextState}`); // Send a response (e.g., a status response) const response = JSON.stringify({ version: { name: "My TypeScript Server", protocol: protocolVersion }, players: { max: 10, online: 0, sample: [] }, description: { text: "A simple TypeScript Minecraft server" } }); const responseBuffer = Buffer.from(response); const length = responseBuffer.length; const lengthBuffer = Buffer.alloc(1); lengthBuffer.writeInt8(length); ws.send(Buffer.concat([lengthBuffer, responseBuffer])); } else { console.log(`Received other message: ${message}`); } }); ``` **Important Resources:** * **Minecraft Protocol Documentation:** This is essential. Search for "Minecraft Protocol" or "wiki.vg Minecraft Protocol". `wiki.vg` is a good starting point. * **Existing Minecraft Server Implementations:** Look at open-source Minecraft server projects (e.g., in Java or other languages) to see how they handle the protocol and game logic. This can be a great learning resource. However, be aware that the protocol changes over time, so make sure the implementation you're looking at is relatively up-to-date. **Chinese Translation of Key Terms:** * **Minecraft Protocol:** 我的世界协议 (Wǒ de shìjiè xiéyì) * **Server:** 服务器 (Fúwùqì) * **Client:** 客户端 (Kèhùduān) * **Packet:** 数据包 (Shùjù bāo) * **Handshake:** 握手 (Wòshǒu) * **Authentication:** 身份验证 (Shēnfèn yànzhèng) * **WebSocket:** WebSocket (Websocket, no direct translation is commonly used) * **TCP:** TCP (TCP, no direct translation is commonly used) * **Port:** 端口 (Duānkǒu) * **Connection:** 连接 (Liánjiē) * **Message:** 消息 (Xiāoxī) * **Error:** 错误 (Cuòwù) * **Protocol Version:** 协议版本 (Xiéyì bǎnběn) This is a very basic starting point. Building a real Minecraft server is a significant project. Good luck!

MCP Chat Adapter

MCP Chat Adapter

用于使用 OpenAI 兼容聊天端点的 MCP 服务器

Remix Icon MCP

Remix Icon MCP

github-mcp-server-test

github-mcp-server-test

Code Review MCP Tool for Cursor

Code Review MCP Tool for Cursor

remote-mcp-server

remote-mcp-server

openwrt-mcp-server

openwrt-mcp-server

mcp-sqlite-manager

mcp-sqlite-manager

一个用于与 SQLite 数据库交互的 MCP 服务器 (Yī gè yòng yú yǔ SQLite shùjùkù jiāohù de MCP fúwùqì)

GitHub Actions for Plane-MCP

GitHub Actions for Plane-MCP

✈ 飞机适用MCP (Fēijī shìyòng MCP)

anitabi-mcp-server

anitabi-mcp-server

anitabi 巡礼地图的 MCP Server (This translates directly to the same phrase in Chinese, as it appears to be a proper noun or technical term.)

Ollama Pydantic Project

Ollama Pydantic Project

创建了一个示例项目,用于使用本地 Ollama 模型和 MCP 服务器集成来实现 Pydantic 代理。

Query MCP (Supabase MCP Server)

Query MCP (Supabase MCP Server)

镜子 (jìng zi)

Remote MCP Server on Cloudflare

Remote MCP Server on Cloudflare

mcp-remote-server

mcp-remote-server

镜子 (jìng zi)

prometheus-mcp-server

prometheus-mcp-server

GitHub MCP Server

GitHub MCP Server

ai-test-gen-poc

ai-test-gen-poc

一个由人工智能驱动的测试脚本生成器,它使用 Playwright MCP Server 以 BDD 风格的提示生成 TypeScript 测试脚本。

🛡️ BurpSuite MCP Server

🛡️ BurpSuite MCP Server

镜子 (jìng zi)

first-mcp-server

first-mcp-server

Prefect MCP Server

Prefect MCP Server

镜子 (jìng zi)

mcp-servers

mcp-servers

模型上下文协议服务器的存储库

OpenAPITools SDK

OpenAPITools SDK

你的 API,现在是 AI 工具。一分钟内构建 MCP 服务器。

MCP TypeScript SDK

MCP TypeScript SDK

Raindrop.io MCP Server (Go)

Raindrop.io MCP Server (Go)

Pokemon MCP Demo

Pokemon MCP Demo

一个快速的宝可梦演示,用于展示 MCP 服务器、客户端和主机。

pyATS MCP Server

pyATS MCP Server

用于 pyATS 的 MCP 服务器(实验性)

Mcp Server

Mcp Server

DemiCode

DemiCode

好的,这是对 awesome-mcp-servers 的一个中文总结: **awesome-mcp-servers 是一个精选的 Model Context Protocol (MCP) 服务器列表。** 简单来说,它是一个资源集合,汇集了各种各样的 MCP 服务器。MCP 是一种协议,用于在不同的模型之间共享上下文信息。这个列表可以帮助开发者和研究人员找到并利用现有的 MCP 服务器,从而更方便地构建和集成各种模型。 **更具体地说,这个列表可能包含以下内容:** * **不同类型的 MCP 服务器:** 例如,用于自然语言处理、计算机视觉、语音识别等领域的服务器。 * **服务器的描述:** 包括服务器的功能、API、使用方法等。 * **服务器的链接:** 指向服务器的官方网站、代码仓库或文档。 * **其他相关资源:** 例如,教程、示例代码、论文等。 **总而言之,awesome-mcp-servers 是一个非常有用的资源,可以帮助人们发现和使用 MCP 服务器,从而促进模型之间的互操作性和集成。**

tts-mcp-server

tts-mcp-server

基于 MCP 的 TTS 服务器

Supabase MCP Server

Supabase MCP Server