Connect AI agents with MCP
Expose a Vox application to authenticated agents through the Model Context Protocol.
For the team workflow, see Work with an assistant.
CommerceMind.Vox.Mcp serves a Vox application over the Model Context Protocol, so
an agent can learn the domain, read data in an explicit scope and context, and make changes as an authenticated user or
API client. Everything goes through the same operations as the entity API: the same permissions, validation, actions,
drafts, history and audit trail. An agent has exactly the permissions of the principal it signed in as; changes are
recorded as that principal with the client it used, eg "Lisa (Claude Code)".
One endpoint
builder.AddVox(/* ... */).AddApi();
builder.Services.AddVoxMcp(server => server
.WithTools<ApplicationTools>() // the application's own tools,
.WithResources<ApplicationResources>() // resources
.WithPrompts<ApplicationPrompts>()); // and prompts, next to Vox's
var app = builder.Build();
app.MapVox(); // the server at /mcp, after authentication
The endpoint serves Streamable HTTP only. Every request needs an authenticated user or API client of the application, also when the application's own authorizer would allow anonymous requests.
The application's contributions are ordinary MCP SDK primitives, methods with [McpServerTool], [McpServerResource]
or [McpServerPrompt], created in the scope of each request. Inject VoxMcpRequestContext to know the server, the
entity types it exposes and the principal, and Vox's operations, eg VoxEntityReader, to read with the principal's
permissions. Name the entity types a class depends on with [VoxMcpEntities(typeof(Product))], which leaves it out of a
server that doesn't expose them. An application tool with the name of one of Vox's is an error at startup, unless the
server replaces Vox's with ReplaceBuiltIn("query_entities"); WithoutBuiltIn("delete_entity") leaves one of Vox's out.
Several named servers
Use several servers when agents should see separate parts of the domain. Each has its own endpoint, entity types and extensions; nothing is shared between them unless it's added to each.
builder.Services
.AddVoxMcp("catalog", server => server // at /mcp/catalog
.OnlyEntities(typeof(Product), typeof(Category))
.WithTools<CatalogTools>())
.AddVoxMcp("campaigns", server => server.OnlyEntities(typeof(Campaign))) // at /mcp/campaigns
.AddVoxMcp("general", server => server.ExcludeEntity<ProductImportRow>().MapTo("/mcp"));
MapVox()maps a named server at/mcp/{name}, unlessMapTo(pattern)gives it another endpoint, eg/mcpfor the main server of an application with several. A host that maps its pipeline itself maps each server withapp.MapVoxMcp(name, pattern).WithoutEndpoint()leaves a server unmapped, eg one that only Studio's language model uses in process.- A server exposes every entity type by default, including the ones that later deployments add;
ExcludeEntityleaves some out. OnlyEntities(types)selects an explicit set, which new entity types never join.OnlyEntities(names)selects by name, and a named entity type that doesn't exist yet joins when a deployment defines it.OnlyEntitiesWhere(predicate, description)is evaluated against the current model, so types added later join when they match.- Exclusions always win.
ConfigureVoxMcp(options => options.ExcludeEntity<Secret>())excludes an entity type from every server, a ceiling no server can override. - An entity type that a server doesn't expose doesn't exist there: not in its tools, resources, relations or calculations, and not when a client guesses its name or a resource URI. A relation to one keeps only the ids of its references. Related, context and calculation types aren't added automatically; select them if agents need them.
- Duplicate server names, a server mapped twice or two servers at one route fail at startup.
What agents get
| Tools | |
|---|---|
who_am_i, list_entity_types, describe_entity_type, list_contexts | Discovery: the principal, the domain with its descriptions and units, who owns each field, calculations, relations, contexts and actions. |
query_entities, get_entity, list_related, get_entity_cells, explain_entity, get_assessments, get_history, get_audit | Reads in an explicit scope (published, draft, release:{id}, release-draft:{id}) and context, eg { "market": "se" }. explain_entity tells where each value comes from in that context: the winning cell, varying value or fallback. get_entity reads the entity as it's published, with the values its own calculations calculated when it was saved. |
create_entity, update_entity, update_entities, delete_entity | Compact writes: update_entity takes { "name": "Rain jacket", "dimensions.height": 30 } and runs the default setters of the entity type in one atomic change, based on expectedVersion. update_entities does so for several entities of a type, atomically or per entity, like the entity API's batch actions. A write returns the entity as it's published, with the values its own calculations calculated in the save. |
{entity}_{action}, eg campaign_schedule | A typed tool per custom action, with the exact schema of its command. Generated setters are never tools of their own. |
set_entity_cell, reset_entity_cell, set_membership, mutate_relation | Contextual overrides, explicit memberships and index-backed relations. Resetting an override is not the same as setting null. |
publish_draft, discard_draft, schedule_publish, list_releases, create_release, release_action | Drafts and content releases. A release is only published through a server that exposes every entity type in it. |
restore_version, upload_asset, get_asset_content, projection_publications, get_calculation | Restores, assets (inline or with an upload URL), projection publications, and the deployed calculations. |
Rich text is read and written as HTML, unlike the entity API, which delivers its JSON document by default: HTML is
about a third of the tokens of the same document, and agents read and write it well. query_entities and get_entity
take richTextFormat: "Json" for the document. See Rich text and entity references.
Resources are at vox://{application}/{server}/...: schema, schema/{entityType},
schema/{entityType}/actions/{action}, entities/{entityType}/{id} and calculations/{id}. Prompts: explore_domain
and explain_value. Errors of tools have codes: validation, permission_denied, not_found, conflict,
action_rejected, unsupported, calculation_failed (a calculation of the saved entity, or of an entity saved with
it, failed, so nothing was saved) and unavailable (a transient failure, marked retryable, so the same call can be
made again a little later).
Perspectives
With user management, the MCP server reads from the default perspective of the user it acts for, since an MCP client has no switcher. A purchasing assistant connected for a buyer whose default is Buying then reads products without every text in every language. The line is the same as in the admin UI: browsing is narrowed, changes and history are whole.
- Narrowed: entity reads and queries, related entities, the entity resource, and the descriptions of entity types
from
describe_entity_typeand the schema resources leave out the fields the perspective hides. The title is always there. - Whole: the results of writes, cells, drafts and their effects, history and audit.
- Queries can use any field. Filters, sorts and searches on a hidden field still work, since a perspective isn't security. The agent doesn't see the field in the model, so it only uses one when the user names it: asked "which products have no English description?" in Buying, it lists the products without their descriptions.
- The agent is told. The server's instructions name the perspective, and
who_am_i, every narrowed result and the narrowed descriptions include it with a note that other fields exist, so the agent can tell the user to change their default rather than conclude that a field is missing or empty. An application's ownInstructionsreplace the server's, and then don't mention it; the notes still do.
A user without a default perspective, and an API client, reads everything.
Calculations and their source
Vox's source generator compiles the source of every calculation into its assembly, with its XML documentation, so the
deployed application can explain how a calculated field is calculated without its repository or PDBs. An agent reads it
with get_calculation, which needs the permission vox:ReadSource on top of reading the entity type: entity
read access alone never returns code. Anyone who has the DLL can read the embedded source, so review what's captured
and leave out source that mustn't be shipped:
[assembly: VoxCalculationDocumentation(EmbedSource = false)] // every calculation of the assembly
[VoxCalculationDocumentation(Helpers = [typeof(PriceRules)])] // include a helper the calculation calls
public class ProductPriceCalculation : IVoxCalculation<Product> { /* ... */ }
XML <summary> comments of entity types, commands and their properties are captured too, and describe them when
[Display(Description = ...)] doesn't. The MCP server's descriptions use the labels and descriptions from code, also
when the person it acts for has changed them for themselves
in the admin UI.
The manifest is ordinary compiled code, so it's in Release builds without PDBs or XML files too. To catch an assembly
that was built without the generator before it's deployed, turn on options.RequireCalculationSource where CI starts
the application, eg in a test: startup then fails if a calculation of the model, of fields or context memberships, has
no documented source, unless the application excluded it with EmbedSource = false.
A calculated field can also have a plain-language explanation, see
Explain calculated fields in plain language.
describe_entity_type gives it as the field's explanation, with its freshness, and get_calculation gives the
explanations of all the calculation's fields. They need no more than reading the entity type, since they contain no
code. A freshness of Outdated means the code changed after the explanation was written, and Unverifiable that Vox
couldn't check it against the deployed code; the text may no longer describe the calculation in either case.
Agents learn how a calculated field is calculated from its explanation and source, and what a calculation found for an
entity from its assessments with get_assessments. None of them is a trace of how a stored value was calculated.
Signing in
Agents sign in as the application's users, or as API clients with header-configurable credentials:
-
API keys of API clients:
Authorization: ApiKey {key}, as with the entity API. -
The embedded issuer (
CommerceMind.Vox.Mcp.OpenIddict), for users who sign in with their Vox account, or with the application's external provider:builder.Services.AddVoxMcpIssuer(issuer =>{issuer.ConfigureDbContext = (_, db) => db.UseSqlServer(connectionString);issuer.ConfigureServer = server => server.AddSigningCertificate(signingCertificate).AddEncryptionCertificate(encryptionCertificate);// With an external provider: its OpenID Connect scheme, which signs in to VoxMcpIssuerDefaults.SignInScheme// issuer.ExternalSignInScheme = "oidc";});MapVox()maps its endpoints under/connect,VoxMcpIssuerOptions.PathPrefix.MCP clients discover it from the endpoint's
/.well-known/oauth-protected-resource/..., register themselves, and send the user to sign in and allow the connection. Tokens are issued with PKCE for the endpoints the client asked for, and are refused at other endpoints. Access tokens last 15 minutes; refreshing checks that the user is still enabled, and every request does so within 30 seconds. The issuer stores clients, grants and tokens only: users stay in Vox. Once a day, one host removes the tokens and grants that are expired, redeemed or revoked and older than a day. Its sign in has no lockout of its own, like the admin UI's: limit the rate of its endpoints, eg with a global limiter of ASP.NET's rate limiting that partitions by path,app.UseRateLimiter()beforeMapVox(), or on a host that maps its pipeline itself withapp.MapVoxMcpIssuer().RequireRateLimiting("..."). -
The external provider directly, when it can issue tokens for the MCP endpoint: its JWT bearer scheme must accept the endpoint's URL as audience, and
VoxMcpOptions.Authorization.AuthorizationServersnames it (by default the provider's authority). Its users are linked to Vox users as for the admin UI.
The OAuth scope vox:mcp only allows connecting. What an agent may do is decided on every request by the principal's
current permissions; to give an agent fewer permissions, sign it in as a user or API client with fewer.
Hosting
- The default session mode serves 2026-07-28 clients per request and gives earlier clients a session, which lives on one
instance: use session affinity with several instances, or
options.SessionMode = HttpServerSessionMode.Stateless. options.AllowedOriginslists the browser origins that may call the endpoints; requests with another Origin header are refused.MaxRequestBodyBytes,MaxPageSize,MaxUploadBytesandMaxInlineContentBytesbound what a request can cost. Add rate limiting to the endpoints as for the issuer's above.- An MCP host can be an API-only host: background work runs on the processing hosts, as for the entity API.
- Sessions of earlier clients are told when their server's catalog changes with a newly activated model.
- Most of what an agent reads to get started is the tool list: about 50 KB for a broad server of Vox's test model, of which Vox's general tools are most, and one tool more per custom action. A whole workflow, from discovery to an audited edit, is about 80 KB there and 60 KB on a server of one entity type. Focused servers are the main way to keep an agent's view of the domain small.