# Getting Started Build an MCP server in minutes with FastRMCP. ## Install - CLI (recommended): `cargo install fastrmcp-cli` → `fastrmcp new my-server [--template complete|sse|websocket|middleware|subscriptions]` - Manual: add to `Cargo.toml` ```toml [dependencies] fastrmcp = "0.2" tokio = { version = "1", features = ["full"] } tracing = "0.1" tracing-subscriber = "0.3" ``` ## First Server (tools + resource + prompt) ```rust use fastrmcp::prelude::*; use fastrmcp_macros::{prompt, resource, tool}; #[tool] async fn add(a: i64, b: i64) -> Result { Ok(a + b) } // URI template parameters map into arguments; Context is optional and injects client/server info #[resource("echo://{value}")] async fn echo(value: String, ctx: Context) -> Result { ctx.log_info(format!("echo called by {:?}", ctx.client_info)).await.ok(); Ok(value) } #[prompt] async fn review() -> Result { Ok(PromptResult { description: Some("Simple review prompt".into()), messages: vec![PromptMessage::user("Please review the provided content.")], }) } #[tokio::main] async fn main() -> Result<()> { tracing_subscriber::fmt().init(); FastMCP::new("my-server").version("0.1.0").description("First FastRMCP server").run().await } ``` Run over STDIO: ```bash cargo run # in another shell printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"cli","version":"1.0.0"}}}' | cargo run ``` Call a tool: ```json {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"add","arguments":{"a":2,"b":3}}} ``` Read a resource: ```json {"jsonrpc":"2.0","id":3,"method":"resources/read","params":{"uri":"echo://hi"}} ``` Fetch a prompt: ```json {"jsonrpc":"2.0","id":4,"method":"prompts/get","params":{"name":"review","arguments":{}}} ``` Next steps: see [Core Concepts](Core-Concepts.md) for Context/State/registries and [Transports Guide](Transports-Guide.md) for SSE/WS. [Back to Home](Home.md)