RepositoryMcpExtensions Class
Assembly: CodeEffects.Rule.Mcp.dll
Namespace: CodeEffects.Rule.Mcp
Summary
Adds the tools of the Rule Repository to the MCP server. It holds the extension method WithRepository(..).
Syntax
public static class RepositoryMcpExtensions
Call WithRepository(..) on the CodeEffectsMcpBuilder that AddCodeEffectsMcp(..) returned. With it, AI clients can read and, where the caller's permissions allow, author and test rules in your repository.
Each request is answered with the permissions of the McpCaller that your MapCaller delegate returned, together with the agent settings of the repository's configuration, so a client sees and can do only what the same person could do in the Rule Repository. See Rule Storage in Rule Repository.
You can add the Repository alone, the Audit library alone, or both. When you add both, the Repository serves the evaluation tools that the two have in common and adds evaluation_explain.
Methods
WithRepository(..)
Returns: CodeEffects.Rule.Mcp.CodeEffectsMcpBuilder - The same builder, so calls can be chained.
public static CodeEffectsMcpBuilder WithRepository(this CodeEffectsMcpBuilder builder, Action<RepositoryMcpOptions> configure)
An extension method of CodeEffectsMcpBuilder. Adds the tools of the Rule Repository: those the caller's permissions and the repository's agent settings allow. The configure delegate is called at once with a new RepositoryMcpOptions, and its values are read when the method runs.
Parameters
Exceptions
System.ArgumentNullException - builder or configure is null.
System.ArgumentException - DbProvider is not set.
System.InvalidOperationException - The Rule Repository was already added to the server.
Example
using CodeEffects.Rule.Mcp;
builder.Services
.AddCodeEffectsMcp(o => o.MapCaller = mapCaller)
.WithRepository(r => r.DbProvider = dbProvider);