Skip to content

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.

  1. Add the package

    Terminal window
    dotnet add package Repl.Mcp
  2. Register the MCP server

    using Repl;
    using Repl.Mcp;
    var app = ReplApp.Create().UseDefaultInteractive();
    // ... your commands ...
    app.UseMcpServer(); // one line
    return app.Run(args);
  3. 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. If .NET was installed per user with dotnetup and the host does not start from the user’s shell, myapp, dotnet and dnx may not be found; see dotnetup installs and agent hosts.

Repl translates your command graph to MCP concepts automatically:

Command graph contact add contact {id} show .ReadOnly() config {env} .AsResource() triage .AsPrompt() debug reset .AutomationHidden() not exposed to agents Tools contact_add, contact_show Resources repl://config/{env}, ... Prompts triage
Every mapped command becomes an MCP tool unless a modifier sends it elsewhere; read-only commands also become resources.
Repl conceptMCP concept
app.Map("list", handler)Tool list
Return valueTool result
[Description] attributeTool description
Results.Error(...)Tool error
.AsResource()Resource
.AsPrompt()Prompt

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.

Control how the agent sees your commands:

app.Map("delete {id:int}", (int id) => Delete(id))
.Destructive()
.WithDescription("Delete a record permanently.");

Some commands should be available to humans in REPL mode but hidden from agents:

app.Map("debug reset", Reset)
.AutomationHidden();