π Rust MCP Server + Inspector Example: SSE Transport with an Add Tool
About
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.
Details
- Author
- RGGH
- GitHub stars
- 8
- Downloads
- 349
- Categories
- Developer Tools
Jump to
- Sets up a custom MCP server using ServerSseTransport
- Connects an MCP client to the server via SSE
- Registers a custom Add tool that adds two numbers
- Lists registered tools through MCP protocol
- Integrates with the RIG agent and OpenAI LLM
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
π Rust MCP Server + Inspector Example: SSE Transport with an Add ToolCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Clone the repository and run cargo run. In a separate terminal, start the MCP Inspector with npx @modelcontextprotocol/inspector sse http://127.0.0.1:3001/sse. Then open http://localhost:5173 in a web browser to view the Inspector UI.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"\ud83d\udd0d rust mcp server + inspector example: sse transport with an add tool": {
"rig-mcp-server": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector",
"sse",
"http://127.0.0.1:3001/sse"
]
}
}
}
}
McpServers
{
"rig-mcp-server": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector",
"sse",
"http://127.0.0.1:3001/sse"
]
}
}
π 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
---
π¬ Questions or Feedback?
Feel free to open an issue or start a discussion!
```
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





