-
Notifications
You must be signed in to change notification settings - Fork 680
Expand file tree
/
Copy pathDelegatingMcpServerResource.cs
More file actions
37 lines (29 loc) · 1.67 KB
/
DelegatingMcpServerResource.cs
File metadata and controls
37 lines (29 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using ModelContextProtocol.Protocol;
namespace ModelContextProtocol.Server;
/// <summary>Provides an <see cref="McpServerResource"/> that delegates all operations to an inner <see cref="McpServerResource"/>.</summary>
/// <remarks>
/// This is recommended as a base type when building resources that can be chained around an underlying <see cref="McpServerResource"/>.
/// The default implementation simply passes each call to the inner resource instance.
/// </remarks>
public abstract class DelegatingMcpServerResource : McpServerResource
{
private readonly McpServerResource _innerResource;
/// <summary>Initializes a new instance of the <see cref="DelegatingMcpServerResource"/> class around the specified <paramref name="innerResource"/>.</summary>
/// <param name="innerResource">The inner resource wrapped by this delegating resource.</param>
protected DelegatingMcpServerResource(McpServerResource innerResource)
{
Throw.IfNull(innerResource);
_innerResource = innerResource;
}
/// <inheritdoc />
public override Resource? ProtocolResource => _innerResource.ProtocolResource;
/// <inheritdoc />
public override ResourceTemplate ProtocolResourceTemplate => _innerResource.ProtocolResourceTemplate;
/// <inheritdoc />
public override bool IsMatch(string uri) => _innerResource.IsMatch(uri);
/// <inheritdoc />
public override ValueTask<ReadResourceResult> ReadAsync(RequestContext<ReadResourceRequestParams> request, CancellationToken cancellationToken = default) =>
_innerResource.ReadAsync(request, cancellationToken);
/// <inheritdoc />
public override string ToString() => _innerResource.ToString();
}