Skip to content

DevKit MCP

Use bdk mcp to give local coding agents official DevKit documentation plus a safe, workspace-aware diagnostics and operations surface for running DevKit applications.

Existing app
MCP recipe

Overview

The DevKit MCP feature exposes a local Model Context Protocol server through the bdk CLI. Developers configure their MCP-capable IDE or agent to start bdk mcp over STDIO. The CLI can return curated implementation guidance, search official DevKit documentation and API reference symbols, discover running DevKit web hosts in the current workspace, and forward runtime-bound tool calls to the selected host over local IPC.

Use MCP when you want a coding agent to understand DevKit patterns and inspect a running application while it works on code:

  • search official DevKit documentation before implementing a feature
  • load bounded DevKit docs content into the coding session
  • search DevKit API reference symbols before using concrete types or members
  • request curated DevKit guidance for common implementation tasks
  • summarize the selected project runtime, modules and advertised MCP capabilities
  • check local runtime availability and health
  • inspect retained logs and errors
  • query retained operation and HTTP request recordings, inspect segment costs and compare performance under different conditions
  • follow a correlation id across logs, operation recordings, jobs, messaging, queueing and orchestrations
  • inspect, retry, pause, resume, signal or trigger supported runtime features
  • search official DevKit documentation from any consuming project
  • inspect generated DevKit API reference details from any consuming project
  • call project-owned diagnostics exposed by the application

MCP is a local development feature. It is not an HTTP endpoint, not a production administration API and not a replacement for application authorization.

Challenges

Coding agents need exact framework guidance and bounded runtime evidence, but application internals should not be exposed through an unrestricted remote administration endpoint. Multiple local hosts also make runtime selection ambiguous unless discovery is tied to the current workspace.

Solution

bdk mcp hosts MCP over standard input and output. Documentation, API-reference and guidance tools run in the CLI process. Markdown and generated API metadata are embedded in the CLI assembly, so documentation lookup requires no GitHub access. Runtime tools resolve a ready workspace host and forward a bounded DevKit request over user-local IPC to a registered IMcpHandler. Stable toolsets separate inspection, controlled operations and destructive administration.

Key Features

  • Stable bdk_* tool names and JSON schemas.
  • Embedded documentation, generated API-reference and curated guidance tools that work without a running application or documentation network access.
  • Workspace-aware runtime discovery and selection.
  • Feature-owned and project-owned app-side handlers without an MCP SDK dependency.
  • Diagnostics enabled by default, with explicit operations and admin toolsets.
  • Structured unavailable responses, bounded data and suggested next calls.

Architecture

flowchart LR
    Developer["Developer"]
    Agent["IDE or agent MCP client"]
    Cli["bdk mcp STDIO server"]
    Registry["User-local host registry"]
    Host["Running DevKit web host"]
    Handler["Feature or project IMcpHandler"]
    Service["Application service"]
    Docs["Embedded DevKit docs"]
    Api["Embedded API reference metadata"]

    Developer --> Agent
    Agent -->|"tools/list and tools/call"| Cli
    Cli -->|"runtime discovery"| Registry
    Cli -->|"runtime-bound tools"| Host
    Host --> Handler
    Handler --> Service
    Cli -->|"docs tools"| Docs
    Cli -->|"api reference tools"| Api

The application must run separately. bdk mcp does not start the app. It only discovers hosts that already wrote a local descriptor through DevKitWebApplication.CreateBuilder(args).

Guidance and documentation tools are available even before a runtime is selected. Runtime tools require a running DevKit host.

Use Cases

  • Read DevKit guidance and exact API symbols before editing application code.
  • Orient an agent on the selected runtime, modules and advertised capabilities.
  • Inspect health, metrics, logs, errors and correlated activity.
  • Run supported retries, triggers, signals, pause or resume operations after enabling the operations toolset.
  • Perform explicitly confirmed cleanup with the admin toolset.
  • Expose bounded project-specific diagnostics through application-owned handlers.

Basic Usage

Restore the local tool and configure the MCP client to launch bdk mcp over STDIO. For VS Code, create a workspace-root .mcp.json:

{
  "mcpServers": {
    "bdk": {
      "command": "dotnet",
      "args": [
        "tool",
        "run",
        "bdk",
        "mcp",
        "--toolset",
        "diagnostics,operations,admin"
      ]
    }
  }
}

For Visual Studio (.vs/mcp.json) and other client setup, see MCP Client Configuration.

Restart or reload the MCP client, then call bdk_mcp_status. Check the response's available value before using data. A successful call identifies the resolved workspace and MCP server state. If no application is running, documentation and guidance tools remain available while runtime-bound calls return a structured no_runtime_found response.

Agent context model

MCP gives an agent four complementary angles while it codes:

flowchart LR
    Guidance["Guidance tools\nbdk_guidance_*"]
    Docs["Docs tools\nbdk_docs_*"]
    Api["API reference tools\nbdk_api_*"]
    Code["Code changes"]
    Runtime["Runtime tools\nbdk_project_summary + feature tools"]

    Guidance --> Docs
    Docs --> Api
    Api --> Code
    Code --> Runtime
    Runtime --> Code

Use guidance for compact task checklists, docs for official concepts, API reference for exact symbols and signatures, and runtime tools to verify the selected application after changes.

Prerequisites

  • Install or restore the bdk CLI.
  • Start a DevKit-aware web host in Development.
  • Configure an MCP client to run bdk mcp.
  • Keep the MCP client workspace aligned with the application workspace so runtime discovery filters correctly.

For client-specific setup, see MCP Client Configuration.

Detailed setup

For applications that consume the packaged CLI through a local .NET tool manifest:

dotnet tool restore
dotnet tool run bdk mcp

MCP clients usually need the command split into executable and arguments. VS Code (workspace-root .mcp.json):

{
  "mcpServers": {
    "bdk": {
      "command": "dotnet",
      "args": [
        "tool",
        "run",
        "bdk",
        "mcp",
        "--toolset",
        "diagnostics,operations,admin"
      ]
    }
  }
}

Visual Studio (.vs/mcp.json):

{
  "servers": {
    "bdk": {
      "type": "stdio",
      "command": "dotnet",
      "args": [
        "tool",
        "run",
        "bdk",
        "mcp",
        "--toolset",
        "diagnostics,operations,admin"
      ]
    }
  }
}

When developing the DevKit repository itself, run the CLI from source (mcpServers shape shown; wrap in servers with "type": "stdio" for Visual Studio):

{
  "mcpServers": {
    "bdk": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "src/Presentation.Cli/Presentation.Cli.csproj",
        "--",
        "mcp",
        "--toolset",
        "diagnostics,operations,admin"
      ]
    }
  }
}

Toolsets

bdk mcp starts with read-only diagnostics by default.

Toolset Enables Example tools
diagnostics Read-only inspection. bdk_health_snapshot, bdk_logs_query, bdk_jobs_runs
operations Controlled runtime actions that do not purge retained data. bdk_jobs_trigger, bdk_queueing_retry, bdk_orchestrations_signal
admin Destructive maintenance actions. bdk_logs_purge, bdk_messages_purge, bdk_orchestrations_purge

Enable additional toolsets explicitly:

bdk mcp --toolset diagnostics,operations
bdk mcp --toolset diagnostics,operations,admin

Admin tools also require operation-level confirmation arguments, such as confirm=true and an operation-specific confirmation phrase. This lets a client expose admin tools without allowing accidental purge calls.

Runtime selection

Runtime-bound tools need one selected running host.

Select the host when starting the server with either supported selector:

bdk mcp --runtime-id commerce-api-5001
bdk mcp --host commerce-api-5001
flowchart TD
    ToolCall([Runtime-bound tool call])
    RuntimeArg{bdk mcp --runtime-id or --host supplied?}
    Saved{Workspace selection saved?}
    Count{Ready MCP runtimes}
    Explicit[Use explicit runtime]
    Selected[Use saved runtime]
    Single[Use single ready runtime]
    Ask[Ask developer to select runtime]
    None[Report no ready runtime]

    ToolCall --> RuntimeArg
    RuntimeArg -->|Yes| Explicit
    RuntimeArg -->|No| Saved
    Saved -->|Yes| Selected
    Saved -->|No| Count
    Count -->|0| None
    Count -->|1| Single
    Count -->|More than 1| Ask

Useful runtime tools:

Tool Purpose
bdk_mcp_status Shows MCP server status, workspace, descriptors and selected runtime.
bdk_mcp_self_test Checks runtime selection, IPC connectivity, protocol compatibility and capabilities.
bdk_runtimes_list Lists ready MCP runtimes in the workspace with their URLs and, in a linked worktree, the instance slot.
bdk_runtimes_select Saves a selected runtime for the workspace.
bdk_capabilities_get Lists operations advertised by the selected runtime.
bdk_project_summary Summarizes selected runtime metadata, registered modules and MCP capabilities.

Common developer prompts

Use prompts that ask the agent to inspect first, then act only when necessary:

Use the bdk MCP docs tools to read the DevKit Jobs documentation first. Summarize the expected job pattern, then inspect this project for matching conventions before editing code.
Use bdk_guidance_get for queueing, then read the linked DevKit docs and inspect bdk_project_summary before changing code.
Use bdk_docs_search to find the DevKit guidance for modules and endpoints. Use that guidance while adding this new endpoint, then run the relevant tests.
Use bdk_guidance_get for results, read the linked docs, then use bdk_api_search and bdk_api_get for Result before changing error handling code.
Use the bdk MCP self-test and tell me whether the selected runtime is healthy.
Use the bdk MCP to inspect the latest errors. For the newest error, follow the correlation id and summarize the related logs.
Use the bdk MCP to check whether messaging, queueing, jobs and orchestrations are available in this runtime before changing code.
Use the bdk MCP docs tools to find the DevKit queueing retry guidance and compare it with the code in this project.
Use the bdk MCP to retry the failed queue message, then follow the logs for the resulting correlation id.

For destructive maintenance, be explicit:

Use the bdk MCP admin tools to purge retained local test data older than yesterday. Show me what you will call first, and only proceed with the required confirmation arguments after I approve.

Tool areas

The MCP catalog is stable. Tools can return structured unavailable responses when the selected runtime does not expose the required feature.

Area Selected tools
Runtime bdk_mcp_status, bdk_mcp_self_test, bdk_runtimes_*, bdk_capabilities_get
Health and metrics bdk_health_snapshot, bdk_metrics_snapshot, bdk_metrics_query
Logs and errors bdk_logs_query, bdk_logs_tail, bdk_errors_recent, bdk_errors_details, bdk_correlation_inspect
Operation and request profiling bdk_profiling_query, bdk_profiling_details, bdk_profiling_insights, bdk_profiling_compare
Messaging bdk_messages_summary, bdk_messages_list, bdk_messages_details, bdk_messages_retry, bdk_messages_archive, bdk_messages_purge
Queueing bdk_queueing_summary, bdk_queueing_messages, bdk_queueing_retry, bdk_queueing_pause_queue, bdk_queueing_purge
Blob Storage bdk_blobs_summary, bdk_blobs_clients, bdk_blobs_probe
Jobs bdk_jobs_list, bdk_jobs_details, bdk_jobs_runs, bdk_jobs_trigger, bdk_jobs_purge_runs
Orchestrations bdk_orchestrations_list, bdk_orchestrations_instance_details, bdk_orchestrations_signal, bdk_orchestrations_purge
Investigation bdk_investigate_recent_errors, bdk_investigate_correlation, bdk_investigate_job_run, bdk_investigate_orchestration_instance
Guidance bdk_guidance_list, bdk_guidance_get
Documentation bdk_docs_search, bdk_docs_get
API reference bdk_api_search, bdk_api_get
Project summary bdk_project_summary
Project operations bdk_project_operations, bdk_project_call

Inspect operation and request recordings

The four profiling tools run in the selected application through the existing local IPC bridge. ProfilingMcpHandler calls IOperationProfilingQueryService, the same service used by the profiling dashboard. MCP reads the configured runtime store, including process-local in-memory history or a shared provider. It does not require an open dashboard, a Runtime Profiling session or a separate copy of the recordings.

The DevKit web builder registers the profiling handler when local MCP is enabled. Enable operation capture in the application:

builder.Services.AddProfiling(options => options.Enabled(builder.Environment.IsDevelopment()))
    .WithOperationProfiling()
    .WithRequestProfiling(); // optional HTTP adapter

For a host that registers handlers explicitly, use services.AddMcpHandler<ProfilingMcpHandler>(). All four tools belong to the default diagnostics toolset and read retained data. An unavailable query service or disabled profiling returns a structured unavailable response. Capture must have been enabled when the work ran. Reads do not force a writer flush, so pending completions can appear on a later call. Process-local recordings disappear when that process stops.

Tool Arguments and result
bdk_profiling_query Shared filters, view (Recent, Slow, ByCount), take, cursor and grouped. Returns compact execution summaries with IDs, node IDs, outcomes and capture quality. grouped=true returns logical group counts and a real representative execution; HTTP methods remain separate.
bdk_profiling_details Required execution id, optional segmentTake. Returns retained dimensions, measurements, HTTP metadata, safe failures, wall-time buckets and aggregate segment paths ranked by self time.
bdk_profiling_insights Shared filters, rankBy (p95, total, count, failures), take and segmentTake. Returns exact hotspot rankings, outcome counts, completed latency samples, Total in milliseconds and segment bottlenecks.
bdk_profiling_compare Required exact key, kind, baseline and candidate; optional shared httpMethod and segmentTake. Each side accepts its own time, node, application version, correlation, outcome and dimension filters. Returns sample counts, latency and segment statistics, and p95 change. Both sides select the same logical operation.

Shared filters are fromUtc, toUtc, kind, key, keyContains, nodeId, applicationVersion, correlationId, outcomes, httpMethod, httpStatusCode, hasSegmentFailures, dimensions, segmentPath, segmentDimensions and segmentOutcomes. Query and insights also accept groupingDimensions; roots missing any selected grouping dimension are excluded. Kind is a string so custom kinds and storage behaviors are supported. Use kind="HttpRequest" for requests and their route-template keys.

Date bounds select execution start times. fromUtc is inclusive and toUtc is exclusive. Supply UTC timestamps with Z or +00:00. Omitted bounds use fifteen minutes before the resolved end and now; an existing paging cursor preserves its original boundary. Query and insights default to all root outcomes. Comparison defaults to Completed; an explicit empty outcomes array selects all outcomes. Insights always calculates latency, Total and segment costs from completed latency samples, while root failure rates use all selected outcomes.

take defaults to 25 and accepts 1–100, subject to the runtime's configured page limit. segmentTake accepts 1–100 and defaults to 20 for details, 5 for insights and 10 for comparison. Insights ranks the entire selection before applying take. Analysis uses at most 10,000 records, or a lower configured runtime bound. Exceeding that bound returns profiling_limit_exceeded, with instructions to narrow the filters. It never silently ranks a partial sample. Segment and group limits set truncated; segment responses also report the full segment count. Capture quality and retained sample counts remain visible.

For query paging, pass data.nextCursor as cursor and keep filters, view, grouped and take unchanged. Deletion, expiry or changed filters can return profiling_boundary_invalid; restart without the cursor. Empty results mean no matching retained evidence, rather than proving that the work never ran. Capture health reports the serving node's process-lifetime counters, separately from the selected history.

Find slow HTTP requests:

{
  "kind": "HttpRequest",
  "keyContains": "/cities/",
  "httpMethod": "GET",
  "view": "Slow",
  "take": 10
}

Call bdk_profiling_details with an ID from data.operations, or rank aggregate costs with bdk_profiling_insights:

{
  "kind": "DocumentStorage",
  "rankBy": "total",
  "take": 10,
  "segmentTake": 5
}

Compare the same request route across two time ranges with bdk_profiling_compare:

{
  "key": "/core/cities/{cityId}/weather",
  "kind": "HttpRequest",
  "httpMethod": "GET",
  "baseline": {
    "fromUtc": "2026-10-12T08:00:00Z",
    "toUtc": "2026-10-12T09:00:00Z"
  },
  "candidate": {
    "fromUtc": "2026-10-12T09:00:00Z",
    "toUtc": "2026-10-12T10:00:00Z"
  }
}

Use keys and dimension names returned by the selected runtime. A typed dimension filter has this form:

{
  "dimensions": [
    { "key": "filestorage.location", "value": { "type": "String", "scalar": "attachments" } }
  ]
}

operator defaults to Equal. Present and Missing omit value; segment conditions also support Mixed. Scalar types are String, Boolean, Int64, Decimal, Double and UtcDateTime, with scalar encoded as a string. Predicates share the runtime's limits and validation rules. Segment predicates apply to the same recorded segment summary. These recordings contain aggregate segment evidence, not exact invocation order. See Profiling for capture, sampling and timing semantics.

Correlation investigations

bdk_correlation_inspect and bdk_investigate_correlation now return logs, errors and a separate data.profiling response for the same correlationId. Existing log fields and continuationToken remain available. Profiling contributes compact execution summaries with IDs for subsequent details calls. Shared startTime and endTime bounds select log timestamps and profiling execution starts; profiling treats the end as exclusive. Without dates, profiling uses its last-15-minute default.

Use profilingTake (default 25, maximum 100) and profilingCursor for independent profiling paging. The profiling continuation is data.profiling.data.nextCursor; the log continuation is data.continuationToken. Preserve the correlation ID, dates and each source's page size while paging.

Logs and profiling are independently available. Profiling-only investigations work without a retained log service; unavailable profiling does not hide existing logs. Check logsAvailable, logsReason and profiling.available before interpreting the evidence. A read failure in one source does not discard evidence from the other. Correlation indicates related work; it does not establish that overlapping durations belong to one ordered or additive trace.

Example developer prompt:

Use bdk_profiling_insights to find the slowest request operation in the last 15 minutes. Inspect its representative execution, then follow its correlation id with bdk_investigate_correlation. Identify the dominant recorded segment costs and report the retained sample counts.

Curated guidance

bdk_guidance_list and bdk_guidance_get provide compact implementation guidance for agentic coding. Guidance is intentionally exposed through one generic operation to avoid tool explosion as more DevKit feature areas are added. Agents can call it with either an exact topic or a natural-language query.

When a user asks for "guidance", "how to implement", "add", "create" or "build" DevKit-specific code, the agent should call bdk_guidance_get first and pass the user's wording as query.

The current guidance topics cover the major DevKit feature areas:

  • jobs
  • messaging
  • queueing
  • orchestration
  • pipelines
  • profiling
  • caching
  • mapping
  • serialization
  • utilities
  • commands_queries
  • application_events
  • activeentity
  • domain_events
  • repositories
  • specifications
  • domain
  • filtering
  • modules
  • requester_notifier
  • results
  • rules
  • startuptasks
  • document_storage
  • blob_storage
  • file_storage
  • monitoring
  • dashboard
  • project_dashboard_page
  • project_mcp_tools

Each guidance response includes a summary, linked official docs, implementation steps, recommended MCP tools and a prompt the agent can use to continue. This sits between raw docs and live runtime diagnostics: it tells the agent how to approach the work before it edits files.

Example:

{
  "topic": "jobs"
}

Natural-language example:

{
  "query": "how to implement a new job that triggers an orchestration"
}

The generic guidance operation can infer multiple relevant topics from a query. For example, a job that triggers an orchestration returns both Jobs and Orchestration guidance, then points the agent to the linked docs and runtime verification tools.

Additional examples:

{
  "query": "how do I add a reusable repository specification"
}
{
  "query": "give me guidance for document storage and file monitoring"
}
{
  "query": "give me guidance for blob storage uploads and downloads"
}

Project-owned MCP tools guidance

Call bdk_guidance_get with topic="project_mcp_tools" before adding application-specific MCP operations:

{
  "topic": "project_mcp_tools"
}

The guide covers when a project-owned operation fits, client-safe operation names, McpCapability metadata and argument schemas, toolset selection, bounded McpResponse results, registration through AddMcp(...), tests, and verification with bdk_project_operations and bdk_project_call. Its examples array contains a handler, the builder registration and the discovery/call payloads. Queries such as "how do I add project specific MCP tools" infer this topic.

Operation profiling guidance

Call bdk_guidance_get with topic="profiling" for coding help before an application is running:

{
  "topic": "profiling"
}

The guide explains operation ownership, capture registration, HTTP request adapters, recording completion and persistence, nested and repeated segments, independent workers, explicit outcomes, IResult classification, correlation metadata, dimensions and measurements. It distinguishes operation elapsed time from process CPU/memory profiling and explains incomplete evidence, overlap, suppression and capture limits. Stable grouping keys and bounded dimensions are covered; IDs, file paths and blob keys remain unsuitable dimensions.

Its examples array includes C# registration, JoinOrStartAsync with a timed segment and result classification, and manual root/segment completion, failure and cancellation. Examples that call loadAsync assume the application's existing business delegate. The guide links to docs/features-profiling.md and suggests API lookup for IOperationProfiler and OperationProfilingHelpers. Runtime tools are optional verification after coding; they are not needed to retrieve guidance.

Natural-language queries about operation recordings, request profiling or segments infer this topic:

{
  "query": "how do I add operation recordings and nested segments to a service?"
}

A query about profiling a job or pipeline combines profiling guidance with the matching feature guides. The guide does not require exact invocation-order capture. Use the profiling runtime tools later to check what the running application actually retained.

Dashboard inspection

Open MCP from the robot icon in the dashboard header bar, or at /_bdk/dashboard/mcp, with the host MCP runtime and Dashboard registered. The page is not listed in the sidebar. The icon stays muted while no bdk mcp server is connected to the runtime and uses the theme accent colour with an accent border when one is; it updates every 10 seconds without a page reload. The page has four tabs:

  • Overview: registration counts, server status, target runtime, and operation counts by toolset and feature.
  • Connections: host bridge details and MCP server sessions.
  • Handlers: registered handler types, operation counts, and exposed features.
  • Operations: capability names, owners, categories, handlers, descriptions, and argument schemas.

Each tab has its own route and refreshes independently. The dashboard remembers the selected tab.

MCP dashboard inventory of registered handlers and their exposed features

The operation inventory helps identify the capability to call before inspecting its input schema. Use the braces button to see the arguments accepted by its handler.

MCP operation inventory with capability names, categories and argument-schema buttons

These figures predate the separate MCP tabs and common dialog spacing; their fields and workflow remain representative.

The host bridge and MCP server are separate parts of the connection. Registered handlers show what the host can expose. The Connections tab reports heartbeats from running bdk mcp processes and their selected runtime. An Offline server with registered handlers means no active server session is publishing a heartbeat; it does not mean the capability registrations are missing. Use the toolbar refresh controls to watch connection changes.

Documentation-aware development

bdk_docs_search, bdk_docs_get, bdk_api_search and bdk_api_get let an agent consult official DevKit documentation and API reference metadata while it works in a consuming project. This is intentionally owned by the CLI MCP server rather than the selected runtime, so docs and API lookup work even when the app is not running yet.

Use this when the agent is implementing or refactoring DevKit-specific code:

  • Jobs: read the Jobs docs before adding handlers, triggers, batches or run-history integration.
  • Queueing and messaging: read retry, archive, pause and retained-message guidance before changing operational flows.
  • Modules and endpoints: read module and endpoint conventions before adding presentation features.
  • Project-owned MCP tools: read MCP handler guidance before exposing application diagnostics.
  • Dashboards: read dashboard guidance before adding a developer page.
  • Exact DevKit APIs: use API search and get before writing code against concrete types, overloads, extension methods or interfaces.

Typical flow:

Docs -> API reference -> Code -> Runtime
  1. bdk_docs_search finds the relevant DevKit feature page.
  2. bdk_docs_get loads the bounded markdown source.
  3. bdk_api_search finds concrete DevKit symbols involved in the implementation.
  4. bdk_api_get loads bounded symbol details for the chosen uid.
  5. The agent compares the documented pattern and API shape with the current code.
  6. The agent implements the change.
  7. Runtime tools such as bdk_capabilities_get, bdk_jobs_list, bdk_queueing_summary or project-owned operations verify the running app.

Example API reference call:

{
  "query": "Result",
  "topic": "results"
}

Project summary

bdk_project_summary is the quickest runtime orientation tool. It returns selected runtime metadata, registered modules, MCP operation counts grouped by feature/toolset/owner, and project-owned operations. Use it before feature work so an agent can understand the app shape without scanning unrelated files.

Typical prompts:

Use bdk_project_summary to orient on this app before editing. Then choose the relevant guidance topic and docs.
Use bdk_project_summary and tell me which DevKit capabilities this runtime advertises before adding a dashboard page.

Project-owned operations

Applications can expose their own local diagnostics and controlled local operations through app-side IMcpHandler implementations. This is the supported extension point for customer and project-specific MCP tools: the CLI stays stable, while each consuming project can advertise its own operations from the running application.

Project-owned operations are not added as dynamic MCP tools by default. This keeps the public MCP tool catalog stable across projects and lets agents discover project capabilities at runtime.

Register a handler from the application presentation layer through the DevKit web application builder:

public sealed class CommerceMcpHandler(IRequester requester) : IMcpHandler
{
    public IReadOnlyCollection<McpCapability> Capabilities { get; } =
    [
        new("commerce_inspect_customer", McpToolset.Diagnostics, "project", "Inspects customer profile, order activity and account state.")
        {
            Owner = "commerce",
            Category = "customers"
        }
    ];

    public ValueTask<McpResponse> HandleAsync(McpRequest request, CancellationToken cancellationToken)
    {
        if (!string.Equals(request.Operation, "commerce_inspect_customer", StringComparison.Ordinal))
        {
            return ValueTask.FromResult(McpResponse.Unavailable(
                McpErrorCode.FeatureUnavailable,
                $"Operation '{request.Operation}' is not supported."));
        }

        var customerNumber = request.Arguments.TryGetProperty("customerNumber", out var value)
            ? value.GetString()
            : null;
        if (string.IsNullOrWhiteSpace(customerNumber))
        {
            return ValueTask.FromResult(McpResponse.Unavailable(
                McpErrorCode.OperationFailed,
                "customerNumber is required."));
        }

        // Use requester to load a bounded application model here.
        return ValueTask.FromResult(McpResponse.Success(
            $"Inspected customer '{customerNumber}'.",
            new { customerNumber, warnings = Array.Empty<string>() }));
    }
}

var builder = DevKitWebApplication.CreateBuilder(args)
    .AddConfiguration()
    .AddLogging()
    .AddModules(modules => modules
        .WithModule<CommerceModule>())
    .AddMcp(mcp => mcp
        .WithHandler<CommerceMcpHandler>());

Use assembly scanning when a module owns multiple MCP handlers:

var builder = DevKitWebApplication.CreateBuilder(args)
    .AddConfiguration()
    .AddLogging()
    .AddModules(modules => modules
        .WithModule<CommerceModule>())
    .AddMcp(mcp => mcp
        .WithHandlersFromAssembly<CommerceModule>());

AddMcp(...) follows the host's evaluated local MCP tooling decision by default. In normal applications this keeps project MCP handlers local-development only and disabled when DevKit:Cli:Mcp or the equivalent builder option disables MCP. Use .Enabled(true) or .Enabled(false) only when a project needs to override handler registration explicitly.

Project-owned operation names must be client-safe: use lowercase letters, digits, underscores or hyphens. Avoid dots and camelCase even though the operation is passed as an argument to bdk_project_call, because MCP clients still surface and cache these names.

The operation is then discoverable through:

{
  "name": "bdk_project_operations",
  "arguments": {}
}

Call it through bdk_project_call. Include the advertised toolset so future diagnostics, operations and admin project tools can be validated consistently:

{
  "name": "bdk_project_call",
  "arguments": {
    "operation": "commerce_inspect_customer",
    "toolset": "diagnostics",
    "arguments": {
      "customerNumber": "CUST-10042",
      "includeRecentOrders": true
    }
  }
}

Project-owned operations can advertise diagnostics, operations or admin. The MCP server must be started with the matching toolset, and admin operations should still require explicit confirmation arguments inside arguments.

Example prompt:

Use bdk_project_operations to inspect project-owned operations, then call the operation that checks whether customer CUST-10042 has recent failed orders or account warnings.

Documentation and API tools

bdk_docs_search and bdk_docs_get read public Markdown embedded in the installed CLI assembly. bdk_api_search and bdk_api_get read its embedded API index and symbol details. They make no documentation HTTP requests, use no checkout or writable documentation cache, and do not fall back to GitHub, GitHub Pages, or generated workspace files.

The installed local tool determines which docs are available. MCP ignores differences between the tool and application DevKit versions. GitHub blob and raw URLs are accepted as aliases for embedded document paths, regardless of the URL's branch, tag, or version. A returned URL is a reference link, not a retrieval source.

bdk_mcp_status reports documentation source embedded. Missing documents or symbol details return documentation_unavailable with a local reason. Guidance and unrelated runtime tools remain available.

Read a long document

Documentation search defaults to five results and returns at most twenty. API search defaults to eight and returns at most twenty-five. Document get defaults to 6,000 characters and returns at most 20,000 per call.

Start with a source returned by search, or a known public document path:

{
  "source": "docs/features-jobs.md",
  "maxChars": 6000,
  "offset": 0
}

bdk_docs_get returns offset, nextOffset, and totalChars alongside its content. Follow the suggested next call while nextOffset is present. Offsets use .NET UTF-16 character indices. Negative, non-integer, or out-of-range offsets return operation_failed.

Add documentation to the embedded set

The website and MCP share docs/public-documentation.props for the public-documentation selection. It includes root-level INDEX.md, introduction-ddd-guide.md, common-*.md, development-*.md, features-*.md, storage-*.md, and testing-*.md. ADRs, specifications, PRDs, presentations, generated site content, and binary assets are excluded.

  1. Add or edit a matching public document under docs/.
  2. Build the CLI. Matching additions, edits, renames, and removals are embedded automatically, without a clean build, manual sync, or per-file registration.
  3. Reinstall the rebuilt local tool and restart the MCP client. For source development, restart using the rebuilt CLI output.

New documents become available through search and get. Curated guidance topics still require separate authoring. Add a new public filename category to the shared selection rather than maintaining an MCP-only file list.

Build API documentation

Normal Debug builds skip API generation and can use existing generated API files. If those files are absent, API lookup returns documentation_unavailable, while Markdown and guidance still work.

Release builds and packaging generate the API metadata before embedding it. Generation uses the pinned DocFX tool and PowerShell, without building the website or requiring Docker. Restore the repository tools before generating API metadata:

dotnet tool restore
dotnet build src/Presentation.Cli/Presentation.Cli.csproj --configuration Release

For a Debug package prepared with --no-build, generate and embed the metadata first:

dotnet build src/Presentation.Cli/Presentation.Cli.csproj --configuration Debug -p:BdkGenerateMcpApiReference=true
dotnet pack src/Presentation.Cli/Presentation.Cli.csproj --configuration Debug --no-build

Release builds and packaging check only for api/agent-index.json as the completeness marker. There is no validation pass over individual links or symbol-detail references. --no-build inspects the index resource in the already-built assembly and does not pick up later documentation edits.

Safety model

  • App-side MCP hosting is enabled only for local Development hosts by default.
  • The app does not host an MCP network endpoint.
  • The CLI speaks MCP over STDIO to the client and local IPC to the app.
  • Runtime descriptors and IPC endpoints are stored in OS user-local locations.
  • IPC requests include a nonce from the host descriptor.
  • Toolsets limit broad classes of actions.
  • Admin operations require explicit confirmation arguments.
  • MCP handlers should return bounded data and avoid secrets.

Troubleshooting

The agent says no runtime was found

Start the application with DevKitWebApplication.CreateBuilder(args) in Development, then ask the agent to call bdk_runtimes_list.

You can also check manually:

bdk hosts list --feature mcp

Multiple runtimes are running

Ask the agent to call bdk_runtimes_list, then select one:

Use bdk_runtimes_list and select the commerce-api runtime.

Or select manually:

bdk hosts select commerce-api-5001

Operations are unauthorized

The MCP server may have been started with only diagnostics. Restart it with the needed toolset:

bdk mcp --toolset diagnostics,operations

For purge and other destructive maintenance, also provide the required confirmation arguments.

A feature is unavailable

The selected runtime may not register that DevKit feature or its presentation package. Ask the agent to call bdk_capabilities_get and compare the advertised operations with the tool you want to use.

Docs tools work but runtime tools do not

Documentation tools do not require a running app. Runtime tools do. Start the app and run bdk_mcp_self_test.