Class McpManager
Aggregates MCP server definitions from all registered discovery providers, applies scope-based merge precedence (Project > User > BuiltIn), and tracks per-server runtime status.
public sealed class McpManager
- Inheritance
-
McpManager
- Inherited Members
Constructors
McpManager()
Creates an McpManager using the default provider set: Claude Code, Claude Desktop, VS Code, Codex, Copilot, and the JD.AI-managed config.
public McpManager()
McpManager(IMcpRegistry, JdAiMcpDiscoveryProvider?)
Creates an McpManager with a custom registry and optional write provider.
public McpManager(IMcpRegistry registry, JdAiMcpDiscoveryProvider? jdAiProvider = null)
Parameters
registryIMcpRegistryjdAiProviderJdAiMcpDiscoveryProvider
Methods
AddOrUpdateAsync(McpServerDefinition, CancellationToken)
Adds or updates a server in the JD.AI-managed config. Throws InvalidOperationException if no writable provider is available.
public Task AddOrUpdateAsync(McpServerDefinition server, CancellationToken ct = default)
Parameters
serverMcpServerDefinitionctCancellationToken
Returns
GetAllServersAsync(CancellationToken)
Discovers and merges servers from all providers via the registry.
public Task<IReadOnlyList<McpServerDefinition>> GetAllServersAsync(CancellationToken ct = default)
Parameters
Returns
- Task<IReadOnlyList<McpServerDefinition>>
GetImportCandidatesAsync(CancellationToken)
Returns servers discovered from external tool configs (Claude Code, Claude Desktop, VS Code, Codex, Copilot) that are not already present in the JD.AI-managed config.
public Task<IReadOnlyList<McpServerDefinition>> GetImportCandidatesAsync(CancellationToken ct = default)
Parameters
Returns
- Task<IReadOnlyList<McpServerDefinition>>
GetStatus(string)
Returns the cached status for a server, or Default if no check has been performed yet.
public McpServerStatus GetStatus(string serverName)
Parameters
serverNamestring
Returns
RemoveAsync(string, CancellationToken)
Removes a server from the JD.AI-managed config. Throws InvalidOperationException if no writable provider is available.
public Task RemoveAsync(string name, CancellationToken ct = default)
Parameters
namestringctCancellationToken
Returns
SetEnabledAsync(string, bool, CancellationToken)
Enables or disables a server in the JD.AI-managed config. Throws InvalidOperationException if no writable provider is available.
public Task SetEnabledAsync(string name, bool enabled, CancellationToken ct = default)
Parameters
namestringenabledboolctCancellationToken
Returns
SetStatus(string, McpServerStatus)
Updates the cached status for a server.
public void SetStatus(string serverName, McpServerStatus status)
Parameters
serverNamestringstatusMcpServerStatus