File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
pkgs/dart_mcp_server/lib/src/mixins Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -290,11 +290,17 @@ base mixin DartToolingDaemonSupport
290290 final dtd = _dtd! ;
291291
292292 if (clientCapabilities.sampling != null ) {
293- await dtd.registerService (
294- McpServiceConstants .serviceName,
295- McpServiceConstants .samplingRequest,
296- _handleSamplingRequest,
297- );
293+ try {
294+ await dtd.registerService (
295+ McpServiceConstants .serviceName,
296+ McpServiceConstants .samplingRequest,
297+ _handleSamplingRequest,
298+ );
299+ } on RpcException catch (e) {
300+ // It is expected for there to be an exception if the sampling service
301+ // was already registered by another Dart MCP Server.
302+ if (e.code != RpcErrorCodes .kServiceAlreadyRegistered) rethrow ;
303+ }
298304 }
299305 }
300306
You can’t perform that action at this time.
0 commit comments