MCP Mode
Repl can expose your entire command graph as an MCP server, making every command available as an MCP tool to any compatible AI agent — Claude, Cursor, Copilot, and others.
Enable MCP
Section titled “Enable MCP”-
Add the package
Terminal window dotnet add package Repl.Mcp -
Register the MCP server
using Repl;using Repl.Mcp;var app = ReplApp.Create().UseDefaultInteractive();// ... your commands ...app.UseMcpServer(); // one linereturn app.Run(args); -
Configure your agent
{"mcpServers": {"myapp": {"command": "myapp","args": ["mcp", "serve"]}}}
That’s it — every Map(...) call is now an MCP tool.
How mapping works
Section titled “How mapping works”Repl translates your command graph to MCP concepts automatically:
| Repl concept | MCP concept |
|---|---|
app.Map("list", handler) | Tool list |
| Return value | Tool result |
[Description] attribute | Tool description |
Results.Error(...) | Tool error |
.AsResource() | Resource |
.AsPrompt() | Prompt |
MCP Apps
Section titled “MCP Apps”MCP Apps are host-rendered UI surfaces for capable clients (e.g., Claude). Register an HTML-returning command as an App resource:
app.Map("dashboard", (IContactStore contacts) => BuildHtml(contacts)) .WithDescription("Open the contacts dashboard") .AsMcpAppResource();The client renders the HTML in a webview panel — your command logic, surfaced as interactive UI.
Behavioral annotations
Section titled “Behavioral annotations”Control how the agent sees your commands:
app.Map("delete {id:int}", (int id) => Delete(id)) .Destructive() .WithDescription("Delete a record permanently.");Automation visibility
Section titled “Automation visibility”Some commands should be available to humans in REPL mode but hidden from agents:
app.Map("debug reset", Reset) .AutomationHidden();Next steps
Section titled “Next steps”- MCP Server cookbook — tools, resources, prompts, MCP Apps in depth
- Testing — test your MCP surface with
Repl.Testing