DEV Community

Cover image for Rust MCP Server Setup Guide for Vibe CLI
Jordan Hudgens
Jordan Hudgens

Posted on

Rust MCP Server Setup Guide for Vibe CLI

For anyone else trying to configure Mistral's Vibe CLI combined with the Rust Analyzer MCP server (or any MCP server that runs into the naming conflict that the Rust Analyzer does) - hopefully this guide will save you the 5 hours it stole from my life.

This comprehensive guide documents all the steps required to get the Rust MCP server working with Vibe CLI, including fixes for naming conflicts, JSON parsing issues, and tool discovery problems.

Table of Contents

  1. Prerequisites
  2. Initial Setup
  3. Issue 1: Conflicting Binary
  4. Issue 2: JSON Parsing Errors
  5. Issue 3: Tool Name Prefixing
  6. Final Configuration
  7. Testing the Setup
  8. Troubleshooting
  9. Complete File Changes

Prerequisites

Before starting, ensure you have:

  • Rust toolchain installed (rustup, cargo)
  • Node.js 22.x+ (for some MCP servers)
  • Docker (for containerized MCP servers)
  • Vibe CLI installed
  • Git

Initial Setup

1. Clone the Rust MCP Server Repository

cd /Users/jordanhudgens/code/dashtrack/tools
git clone https://github.com/dexwritescode/rust-mcp
cd rust-mcp
Enter fullscreen mode Exit fullscreen mode

2. Build the Server

cargo build --release
Enter fullscreen mode Exit fullscreen mode

The binary will be located at: /Users/jordanhudgens/code/dashtrack/tools/rust-mcp/target/release/rustmcp

Issue 1: Conflicting Binary

Problem

Vibe CLI auto-discovers MCP servers in your PATH. If you have the official rust-analyzer-mcp binary installed via cargo, it will conflict with your custom server. I'm assuming it's happening with other MCP servers, this is just the one I ran into.

Symptoms

  • Tools appear with rust-analyzer_* prefix
  • Naming conflicts between auto-discovered and configured servers
  • "Unknown tool" errors

Solution

Rename the conflicting binary:

mv ~/.cargo/bin/rust-analyzer-mcp ~/.cargo/bin/rust-analyzer-mcp-backup
Enter fullscreen mode Exit fullscreen mode

Verification

which rust-analyzer-mcp  # Should return "rust-analyzer-mcp not found"
ls ~/.cargo/bin/rust-analyzer-mcp-backup  # Should show the renamed binary
Enter fullscreen mode Exit fullscreen mode

Issue 2: JSON Parsing Errors

Problem

The Rust MCP server outputs plain text startup messages that break Vibe's JSON-RPC parser.

Symptoms

Failed to parse JSONRPC message from server
pydantic_core._pydantic_core.ValidationError: 1 validation error for JSONRPCMessage
  Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='Starting Rust MCP Server', input_type=str]
Enter fullscreen mode Exit fullscreen mode

Solution

Remove the println! statements from src/main.rs:

File: /Users/jordanhudgens/code/dashtrack/tools/rust-mcp/src/main.rs

// BEFORE (lines 12-13):
println!("Starting Rust MCP Server");
println!("Server running on stdio transport...");

// AFTER (remove these lines completely):
// No startup messages - MCP servers should only output JSON-RPC
Enter fullscreen mode Exit fullscreen mode

Complete Fixed main.rs

use anyhow::Result;
use rmcp::{ServiceExt, transport::stdio};
use rustmcp::server::RustMcpServer;

#[tokio::main]
async fn main() -> Result<()> {
    // Initialize the rust-analyzer integration
    let mut rust_server = RustMcpServer::new();
    rust_server.start().await?;

    // Note: The #[tool] macros generate additional tools beyond our manual list
    // Start the MCP server using the ServiceExt trait
    let service = rust_server.serve(stdio()).await?;
    service.waiting().await?;

    Ok(())
}
Enter fullscreen mode Exit fullscreen mode

Issue 3: Tool Name Prefixing

Problem

Initial assumption was that Vibe prefixes tool names with the server name (e.g., rustmcp_workspace_symbols), but this turned out to be incorrect.

Discovery Process

  1. Initial hypothesis: Vibe prefixes tools with server name
  2. Implemented stripping: Added splitn(2, '_').nth(1).unwrap_or(name)
  3. Found issue: Tools were being called as just symbols instead of workspace_symbols
  4. Realization: Vibe does NOT prefix tool names
  5. Final fix: Removed the prefix stripping logic entirely

Solution

Remove the prefix stripping logic from src/tools/types.rs:

File: /Users/jordanhudgens/code/dashtrack/tools/rust-mcp/src/tools/types.rs

// BEFORE:
pub async fn execute_tool(
    name: &str,
    args: Value,
    analyzer: &mut RustAnalyzerClient,
) -> Result<ToolResult> {
    // Strip any MCP host prefix (e.g. "rustmcp_analyze_manifest" → "analyze_manifest")
    let name = name.splitn(2, '_').nth(1).unwrap_or(name);
    match name {

// AFTER:
pub async fn execute_tool(
    name: &str,
    args: Value,
    analyzer: &mut RustAnalyzerClient,
) -> Result<ToolResult> {
    // Strip any MCP host prefix (e.g. "rustmcp_analyze_manifest" → "analyze_manifest")
    // Vibe doesn't actually prefix tool names, so we don't need to strip anything
    match name {
Enter fullscreen mode Exit fullscreen mode

Final Configuration

1. Update Vibe Config

File: /Users/jordanhudgens/.vibe/config.toml

Add the Rust MCP server configuration:

[[mcp_servers]]
name = "rustmcp"
transport = "stdio"
command = "/Users/jordanhudgens/code/dashtrack/tools/rust-mcp/target/release/rustmcp"
args = []
startup_timeout_sec = 30.0
Enter fullscreen mode Exit fullscreen mode

2. Rebuild the Server

cd /Users/jordanhudgens/code/dashtrack/tools/rust-mcp
cargo build --release
Enter fullscreen mode Exit fullscreen mode

3. Restart Terminal

Close and reopen your terminal to ensure all environment changes take effect.

Testing the Setup

Test Basic Functionality

vibe
Enter fullscreen mode Exit fullscreen mode

The Vibe CLI should start without JSON parsing errors.

Test Specific Tools

Workspace Symbols

rustmcp_workspace_symbols
Enter fullscreen mode Exit fullscreen mode

With parameters:

{"query": "test"}
Enter fullscreen mode Exit fullscreen mode

Find Definition

rustmcp_find_definition
Enter fullscreen mode Exit fullscreen mode

With parameters:

{"file_path": "/path/to/file.rs", "line": 10, "character": 5}
Enter fullscreen mode Exit fullscreen mode

Get Diagnostics

rustmcp_get_diagnostics
Enter fullscreen mode Exit fullscreen mode

With parameters:

{"file_path": "/path/to/file.rs"}
Enter fullscreen mode Exit fullscreen mode

Expected Results

  • No JSON parsing errors
  • Tools should execute and return proper responses
  • No "Unknown tool" errors
  • Server should be discovered as rustmcp with all available tools

Troubleshooting

"Unknown tool" Errors

Cause: Tool name mismatch or server not properly initialized.

Solution:

  1. Verify the server is running: ps aux | grep rustmcp
  2. Check tool names in the server code
  3. Ensure no prefix stripping logic is active

JSON Parsing Errors

Cause: Server outputting non-JSON text.

Solution:

  1. Remove all println!, eprintln!, and print! statements
  2. Ensure only JSON-RPC messages are output
  3. Check for any debug statements that might output to stdout

Server Not Discovered

Cause: Configuration issue or binary path incorrect.

Solution:

  1. Verify the binary path in config.toml
  2. Ensure the binary is executable: chmod +x /Users/jordanhudgens/code/dashtrack/tools/rust-mcp/target/release/rustmcp
  3. Check for typos in the server name

Conflicting Tools

Cause: Multiple MCP servers with overlapping tool names.

Solution:

  1. Ensure no other rust-analyzer-mcp binary exists in PATH
  2. Check for auto-discovered servers with vibe --debug
  3. Remove or rename conflicting binaries

Complete File Changes

1. /Users/jordanhudgens/code/dashtrack/tools/rust-mcp/src/main.rs

Before:

use anyhow::Result;
use rmcp::{ServiceExt, transport::stdio};
use rustmcp::server::RustMcpServer;

#[tokio::main]
async fn main() -> Result<()> {
    // Initialize the rust-analyzer integration
    let mut rust_server = RustMcpServer::new();
    rust_server.start().await?;

    // Note: The #[tool] macros generate additional tools beyond our manual list
    println!("Starting Rust MCP Server");
    println!("Server running on stdio transport...");

    // Start the MCP server using the ServiceExt trait
    let service = rust_server.serve(stdio()).await?;
    service.waiting().await?;

    Ok(())
}
Enter fullscreen mode Exit fullscreen mode

After:

use anyhow::Result;
use rmcp::{ServiceExt, transport::stdio};
use rustmcp::server::RustMcpServer;

#[tokio::main]
async fn main() -> Result<()> {
    // Initialize the rust-analyzer integration
    let mut rust_server = RustMcpServer::new();
    rust_server.start().await?;

    // Note: The #[tool] macros generate additional tools beyond our manual list
    // Start the MCP server using the ServiceExt trait
    let service = rust_server.serve(stdio()).await?;
    service.waiting().await?;

    Ok(())
}
Enter fullscreen mode Exit fullscreen mode

Changes: Removed lines 12-13 (println! statements)

2. /Users/jordanhudgens/code/dashtrack/tools/rust-mcp/src/tools/types.rs

Before:

pub async fn execute_tool(
    name: &str,
    args: Value,
    analyzer: &mut RustAnalyzerClient,
) -> Result<ToolResult> {
    match name {
Enter fullscreen mode Exit fullscreen mode

After:

pub async fn execute_tool(
    name: &str,
    args: Value,
    analyzer: &mut RustAnalyzerClient,
) -> Result<ToolResult> {
    // Strip any MCP host prefix (e.g. "rustmcp_analyze_manifest" → "analyze_manifest")
    // Vibe doesn't actually prefix tool names, so we don't need to strip anything
    match name {
Enter fullscreen mode Exit fullscreen mode

Changes: Added comment explaining that no prefix stripping is needed

3. /Users/jordanhudgens/.vibe/config.toml

Added:

[[mcp_servers]]
name = "rustmcp"
transport = "stdio"
command = "/Users/jordanhudgens/code/dashtrack/tools/rust-mcp/target/release/rustmcp"
args = []
startup_timeout_sec = 30.0
Enter fullscreen mode Exit fullscreen mode

4. Renamed Binary

mv ~/.cargo/bin/rust-analyzer-mcp ~/.cargo/bin/rust-analyzer-mcp-backup
Enter fullscreen mode Exit fullscreen mode

Available Rust MCP Tools

The Rust MCP server provides the following tools:

Analysis Tools

  • find_definition - Find the definition of a symbol
  • find_references - Find all references to a symbol
  • get_diagnostics - Get compiler diagnostics for a file
  • get_type_hierarchy - Get type hierarchy for a symbol
  • validate_lifetimes - Validate and suggest lifetime annotations

Navigation Tools

  • workspace_symbols - Search for symbols in the workspace
  • find_definition - Find symbol definitions

Refactoring Tools

  • rename_symbol - Rename a symbol with scope awareness
  • extract_function - Extract selected code into a new function
  • inline_function - Inline a function call
  • change_signature - Change the signature of a function
  • organize_imports - Organize and sort import statements

Code Generation Tools

  • generate_struct - Generate a struct with specified fields
  • generate_enum - Generate an enum with specified variants
  • generate_trait_impl - Generate a trait implementation
  • generate_tests - Generate unit tests for a function

Project Tools

  • analyze_manifest - Parse and analyze Cargo.toml
  • run_cargo_check - Execute cargo check
  • suggest_dependencies - Suggest crate dependencies
  • create_module - Create a new Rust module
  • move_items - Move code items between files

Formatting Tools

  • format_code - Apply rustfmt formatting
  • apply_clippy_suggestions - Apply clippy lint suggestions

Maintenance

Updating the Server

cd /Users/jordanhudgens/code/dashtrack/tools/rust-mcp
git pull origin main
cargo build --release
Enter fullscreen mode Exit fullscreen mode

Reapplying Fixes After Update

If you update the server and the issues reappear, reapply the fixes:

  1. Remove startup messages (if they were re-added):
   # Edit src/main.rs and remove any println! statements
Enter fullscreen mode Exit fullscreen mode
  1. Ensure no prefix stripping (if it was re-added):
   # Edit src/tools/types.rs and remove any prefix stripping logic
Enter fullscreen mode Exit fullscreen mode
  1. Rebuild:
   cargo build --release
Enter fullscreen mode Exit fullscreen mode

Conclusion

This guide documents the complete process to get the Rust MCP server working with Vibe CLI. The key issues were:

  1. Conflicting binary in PATH causing auto-discovery conflicts
  2. JSON parsing errors from startup messages breaking the protocol
  3. Incorrect assumption about tool name prefixing leading to unnecessary stripping logic

With these issues resolved, the Rust MCP server provides full Rust analysis capabilities directly within Vibe CLI.

References

Top comments (0)