cargo-pmcp: MCP Servers in Rust

# cargo pmcp

### Build, Test & Deploy MCP Servers

🦀 + 🤖 = ❤️

Press `Space` to navigate | `S` for speaker notes

Welcome! Today we'll see how Rust makes MCP servers production-ready. Lots of live demos ahead!

## Today's Journey

1 Myth Busting: MCP Beyond Local Dev
2 DEMO Chess MCP Server
3 Why Rust? Security · Performance · Cost
4 Myth Busting: Resources & Prompts
5 DEMO re:Invent Agenda Helper
6 DEMO Build Your First MCP Server
7 DEMO Deploy to AWS Lambda
8 Security: OAuth is the Standard
9 DEMO Interactive Fiction with OAuth
5 demos today! We'll bust some myths and write real code.

## Myth #1

🤔

> "MCP servers are for local development
> and software developers only"

BUSTED!

☁️

Cloud-Native

🏢

Enterprise Ready

👨‍⚕️

Any Domain

🔒

OAuth Security

📱

Any Client

🌍

Global Scale

MCP servers can run anywhere - Lambda, containers, edge. They're for doctors, lawyers, analysts - anyone who needs AI augmentation.

## Chess MCP Server DEMO

Show the chess server running. Play a game against the AI. Point out: this is a GAME, not a dev tool!

### What Just Happened?

🎮 A game - not a developer tool

☁️ Running on AWS Lambda - not locally

🌐 Accessible via HTTP - any client can connect

🦀 Built with cargo-pmcp in minutes

## Why Rust?

🦀

### 🔒 Security

SQL Injection

Buffer Overflow

Use After Free

Null Pointer

Compile-time guarantees

If it compiles, it's safe

🖥️ Remote MCP: No code downloaded or executed on your machine

Rust's ownership system prevents entire classes of vulnerabilities. No garbage collector surprises, no runtime errors.

### ⚡ Performance

~2ms cold start

vs 200-500ms for Python/Node.js

Lambda cold starts are nearly instant with Rust. No interpreter startup, no JIT warmup.

### 💰 Cost

📦

~3MB binary

No runtime needed

🧠

Minimal RAM

128MB is plenty

⏱️

Fast execution

Lower Lambda bills

### 🤖 Best Compiler for AI

✓ Detailed error messages

✓ Suggests exact fixes

✓ Catches bugs at compile time

✓ Strict type checking

AI + Rust Compiler

= Fewer iterations to working code

💡 The compiler tells the AI exactly what's wrong and how to fix it

Rust's compiler is famous for helpful error messages. When AI generates code, the compiler gives precise feedback that helps the AI iterate quickly to correct solutions.

## Myth #2

🔧

> "MCP is just about Tools"

BUSTED!

### The MCP Trinity

🔧

Tools

Actions the AI can take

📚

Resources

Data the AI can read

💬

Prompts

Templates for complex tasks

💡 Prompts = Help your AI client use your server correctly!

## 📖 Learn More: pmcp-book

📡

Protocol

🔔

Notifications

🚫

Cancellations

🔗

Middleware

📱

MCP App

🎓

Advanced

## re:Invent Agenda DEMO

📅

Using Prompts to build a full day agenda

### The Prompt

    Plan my re:Invent day on {topic}

    Include:
    - Sessions matching my interests
    - Travel time between venues
    - Lunch and break suggestions
    - Networking opportunities

One prompt. Complete day planned. ✨

Show the reinvent server prompt in action. The AI knows how to use resources + tools together.

## Let's Build! DEMO

🛠️

Advanced Calculator with Quadratic Equation Solver

### Step 1: Create Workspace

$ cargo pmcp new my-mcp-servers

$ cd my-mcp-servers

Workspace created with shared components 📁

### Step 2: Add Calculator Server

$ cargo pmcp add server calculator --template complete

Full calculator with tools + prompts! 🧮

Templates: `minimal` | `calculator` | `complete`

### What You Get: SequentialWorkflow

    SequentialWorkflow::new("solve_quadratic", "Solve ax² + bx + c = 0")
      .argument("a", "Coefficient of x²", true)
      .argument("b", "Coefficient of x", true)
      .argument("c", "Constant term", true)
      // Guide the AI with instructions
      .instruction(InternalPromptMessage::system(
          "Use calculator tools: power, multiply, subtract, sqrt...
           Show your work step by step. Coefficients: a={a}, b={b}, c={c}"
      ))
      // Fetch educational resource
      .step(WorkflowStep::fetch_resources("fetch_guide")
          .with_resource("calculator://help/quadratic-formula")?)

Resources + Instructions = Guided AI

### Two Prompts, Same Goal

solve_quadratic

SequentialWorkflow

✅ Fetches resources

✅ Guides AI with instructions

✅ Declarative

quadratic_simple

SimplePrompt

✅ Self-contained

✅ Pre-computed answer

✅ Custom logic

Same user experience. Different implementation. 🎯

## Test Locally DEMO

$ cargo pmcp dev

Server running. Claude Code connected. 🔌

Run cargo pmcp dev, then use Claude Code to solve x² - 5x + 6 = 0

### Try it!

Solve x² - 5x + 6 = 0

Answer: x = 2 or x = 3 ✓

## Deploy to AWS DEMO

$ cargo pmcp deploy --target aws-lambda

☁️

One command. Production ready.

### What Just Happened?

✅ Cross-compiled for AWS Lambda

✅ Created CloudFormation stack

✅ Deployed Lambda function

✅ Set up API Gateway

✅ Got public HTTPS endpoint

All in ~30 seconds

## Test Remotely DEMO

Same Claude Code. Same experience.

Now running on AWS Lambda 🌍

💡 Your users don't install anything.
They just connect to your endpoint.

## What About Security?

🔐

### OAuth 2.0 is the Standard

User → MCP Client → OAuth Provider → MCP Server

✅ Industry standard authentication

✅ No passwords in your server

✅ Works with any OAuth provider

✅ Built into cargo-pmcp

## Interactive Fiction DEMO

🎮

OAuth-protected text adventures

### The Flow

1️⃣ Connect to IF Games server

2️⃣ OAuth redirect → Login

3️⃣ Token received → Authenticated

4️⃣ Play your adventure! 🗡️

Show the OAuth flow in action. Player's game state is tied to their identity.

## What We Learned

🚀 MCP servers are production-ready

🦀 Rust = Security + Performance + Low Cost

💬 Prompts & Resources are powerful, not just tools

☁️ One command from code to cloud

🔐 OAuth built in for enterprise security

## Get Started Today

$ cargo install cargo-pmcp

$ cargo pmcp new my-server

$ cargo pmcp dev

github.com/paiml/rust-mcp-sdk

# Questions?

🦀 🤖 ❤️

Thank you!