diff --git a/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerResource.cs b/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerResource.cs index 288a864fc..510806898 100644 --- a/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerResource.cs +++ b/src/ModelContextProtocol.Core/Server/AIFunctionMcpServerResource.cs @@ -317,15 +317,21 @@ private AIFunctionMcpServerResource(AIFunction function, ResourceTemplate resour public override bool IsMatch(string uri) { Throw.IfNull(uri); - return TryMatch(uri, out _); + + // For templates, use the Regex to parse. For static resources, we can just compare the URIs. + if (_uriParser is null) + { + // This resource is not templated. + return UriTemplate.UriTemplateComparer.Instance.Equals(uri, ProtocolResourceTemplate.UriTemplate); + } + + return _uriParser.IsMatch(uri); } private bool TryMatch(string uri, out Match? match) { - // For templates, use the Regex to parse. For static resources, we can just compare the URIs. if (_uriParser is null) { - // This resource is not templated. match = null; return UriTemplate.UriTemplateComparer.Instance.Equals(uri, ProtocolResourceTemplate.UriTemplate); }