MCP Mode
Repl can expose your app’s command graph as an MCP server, making every command available as an MCP tool to any compatible AI agent — Claude, Cursor, Copilot, and others. Repl.Mcp is the component that lets your app become the MCP server; it is not itself the server users configure in an agent host.
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 to launch your app
{"mcpServers": {"myapp": {"command": "myapp","args": ["mcp", "serve"]}}}
That’s it — every Map(...) call in your app is now an MCP tool. In production, prefer configuring a stable executable or dotnet tool; for local samples, use an absolute project path because hosts do not always launch from your repository root.
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”- For Coding Agents — decision rules and copy/paste project instructions
- MCP Server cookbook — tools, resources, prompts, MCP Apps in depth
- Testing — test your MCP surface with
Repl.Testing