Cover image
Try Now
2025-04-09

钻机MCP服务器示例(2025年4月7日)

3 years

Works with Finder

1

Github Watches

0

Github Forks

0

Github Stars

Rust

🔍 Rust MCP Server + Inspector Example: SSE Transport with an Add Tool

credit : https://dev.to/joshmo_dev/using-model-context-protocol-with-rig-m7o

This project demonstrates how to set up an MCP (Model Context Protocol) server and client using Server-Sent Events (SSE) for communication. It includes a simple tool that adds two numbers and integrates with the RIG agent for LLM prompting.


🚀 Getting Started

Clone this repo and run with:

cargo run

In a separate terminal start the MCP Inspector with:

npx @modelcontextprotocol/inspector sse http://127.0.0.1:3001/sse

You'll see output like:

Starting MCP inspector...
Proxy server listening on port 3000
New SSE connection
Query parameters: { transportType: 'sse', url: 'http://localhost:3001/sse' }
SSE transport: url=http://localhost:3001/sse, headers=
Connected to SSE transport
Connected MCP client to backing server transport
Created web app transport
Set up MCP proxy
🔍 MCP Inspector is up and running at http://localhost:5173 🚀

You can now view the web interface at http://localhost:5173


🛠️ Features

  • ✅ Sets up a custom MCP server using ServerSseTransport
  • ✅ Connects a MCP client to the server
  • ✅ Registers a custom tool: AddTool, which adds two numbers
  • ✅ Lists registered tools via MCP
  • ✅ Integrates with RIG and prompts an LLM agent using the tool

🧠 Code Overview

#[tool(
    name = "Add",
    description = "Adds two numbers together.",
    params(a = "The first number to add", b = "The second number to add")
)]
async fn add_tool(a: f64, b: f64) -> Result<ToolResponseContent> {
    Ok(tool_text_content!((a + b).to_string()))
}

This defines the Add tool that is registered in the MCP server.

The main function sets up:

  • Tracing
  • The MCP server and transport (SSE)
  • A MCP client that initializes and lists available tools
  • A RIG agent with OpenAI backend, which uses the MCP tool

The agent then runs a prompt:

let response = agent.prompt("Add 10 + 10").await;

🧪 Sample Output

When run successfully, you'll see logs like:

Initialized: Ok(...)
Tools: Ok([...])
Building RIG agent
Prompting RIG agent
Agent response: Some("20")

🧰 Tech Stack

  • 🦀 Rust with tokio
  • 📡 SSE transport from mcp_core
  • 🔧 MCP server/client architecture
  • 🤖 RIG agent with OpenAI model
  • 🌐 MCP Inspector web interface

📦 Dependencies

Make sure you have these in your Cargo.toml:

[dependencies]
tokio = { version = "1", features = ["full"] }
anyhow = "1"
serde_json = "1"
mcp_core = "..."
mcp_core_macros = "..."
rig = "..."

Replace ... with the appropriate versions based on your environment.


📍 Inspector GUI

Visit http://localhost:5173 to view and interact with the MCP Inspector UI.


✅ Test Log Sample

Query parameters: { transportType: 'sse', url: 'http://localhost:3001/sse' }
Connected to SSE transport
Connected MCP client to backing server transport
Set up MCP proxy
Received message for sessionId cdd4a8be-57e2-44e3-9b81-3df300e86f22

Screenshot from 2025-04-07 23-22-21


📬 Questions or Feedback?

Feel free to open an issue or start a discussion!


相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Lists Tailwind CSS classes in monospaced font

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • modelcontextprotocol
  • 模型上下文协议服务器

    Reviews

    3 (1)
    Avatar
    user_ky9ZFWxg
    2025-04-17

    As a dedicated user of rig-mcp-server, I can confidently say that RGGH has crafted an exceptional product. The seamless integration and robust features make it a perfect choice for managing Minecraft servers efficiently. Its open-source nature and the support from its active community on GitHub ensure that you always have access to the latest updates and improvements. Highly recommended for any server admin looking for reliability and performance!