TalksAWS re:Invent 2025 - Compile blazing-fast MCP servers in Rust (DEV405)

AWS re:Invent 2025 - Compile blazing-fast MCP servers in Rust (DEV405)

Building Blazing-Fast MCP Servers with Rust

Overview

  • Presenter is Darkco, an AWS developer advocate heavily involved in the Rust ecosystem
  • Presentation covers building MCP (Model Coordination Protocol) servers using the Rust programming language
  • MCP is an open protocol that allows language models and AI assistants to interact with tools and resources on a user's computer
  • Rust is positioned as a superior alternative to Python and other languages for building MCP servers

Advantages of Rust for MCP Servers

  • Rust binaries are compiled and self-contained, avoiding the pain of installing dependencies with tools like npm, pip, or cargo install
  • Rust's type safety and compile-time guarantees provide a more robust and secure foundation for MCP servers
  • Rust's performance characteristics enable building highly performant and responsive MCP servers

Anatomy of a Rust MCP Server

  1. Server Struct: Defines the core MCP server, including a ToolRouter for mapping tools to handler functions
  2. Tool Router Macro: Generates the necessary boilerplate for the ToolRouter implementation
  3. Server Handler: Implements the required MCP server methods like call_tool and list_tools
  4. Tool Functions: Implement the actual functionality exposed as MCP tools

Implementing MCP Tools

  1. Tool Struct: Defines the input parameters for the tool using a Rust struct and the schemars crate for JSON schema validation
  2. Tool Function: Implements the tool logic, potentially calling other helper functions to interact with external resources
  3. Tool Macro: Decorates the tool function with metadata like the tool name and description

Integrating with External Resources

  • Presenter demonstrates building an MCP server that interacts with a local to-do API and a thermal receipt printer
  • The MCP server exposes tools to:
    • Retrieve the list of to-dos
    • Create a new to-do
    • Print the details of a specific to-do on the receipt printer

Tooling and Testing

  • The presenter uses the just task runner for building and testing the MCP server
  • The MCP Inspector is a TypeScript-based tool that can be used to connect to and test MCP servers

Real-World Applications

  • The presenter shares examples of other Rust-based MCP servers they have built, including:
    • An "IM Policy Autopilot" MCP server that generates IAM policies based on code analysis
    • A "Grimmoire" MCP server that stores and retrieves useful code snippets

Key Takeaways

  • Rust provides a robust and performant foundation for building MCP servers, addressing the shortcomings of Python and other interpreted languages
  • The Rust MCP SDK (RMCP) simplifies the process of creating MCP servers by providing macros and abstractions
  • Integrating MCP servers with external resources like APIs and hardware devices is straightforward in Rust
  • Rust's tooling, like the just task runner and the MCP Inspector, facilitate development and testing of MCP servers

Your Digital Journey deserves a great story.

Build one with us.

Cookies Icon

These cookies are used to collect information about how you interact with this website and allow us to remember you. We use this information to improve and customize your browsing experience, as well as for analytics.

If you decline, your information won’t be tracked when you visit this website. A single cookie will be used in your browser to remember your preference.