Skip to content

Commit 63a60e5

Browse files
committed
Merge remote-tracking branch 'origin/main' into stateless
2 parents 8de5d49 + 4043538 commit 63a60e5

53 files changed

Lines changed: 4317 additions & 398 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ The following process is used when publishing new releases to NuGet.org:
1515
- Click the 'Target' dropdown button
1616
- Choose the 'Recent Commits' tab
1717
- Select the commit to use for the release, ensuring it's one from above where CI is known to be green
18-
- Click the 'Previous tag' dropdown button
19-
- Choose the previous release to use for generating release notes
18+
- The 'Previous tag' dropdown can remain on 'Auto' unless the previous release deviated from this process
2019
- Click the 'Generate release notes button'
2120
- This will add release notes into the Release description
2221
- The generated release notes include what has changed and the list of new contributors
@@ -26,7 +25,7 @@ The following process is used when publishing new releases to NuGet.org:
2625
- Augment the Release description as desired
2726
- This content is presented used on GitHub and is not persisted into any artifacts
2827
- Check the 'Set as a pre-release' button under the release description if appropriate
29-
- Click 'Public release'
28+
- Click 'Publish release'
3029

3130
3. **Monitor the Release workflow**
3231
- After publishing the release, a workflow will begin for producing the release's build artifacts and publishing the NuGet package to NuGet.org

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
<System10Version>10.0.0-preview.3.25171.5</System10Version>
5-
<MicrosoftExtensionsAIVersion>9.4.3-preview.1.25230.7</MicrosoftExtensionsAIVersion>
5+
<MicrosoftExtensionsAIVersion>9.4.4-preview.1.25259.16</MicrosoftExtensionsAIVersion>
66
</PropertyGroup>
77

88
<!-- Product dependencies netstandard -->
@@ -31,7 +31,7 @@
3131

3232
<!-- Product dependencies shared -->
3333
<ItemGroup>
34-
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="$(MicrosoftExtensionsAIVersion)" />
34+
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.4.4-preview.1.25259.16" />
3535
<PackageVersion Include="Microsoft.Extensions.AI" Version="$(MicrosoftExtensionsAIVersion)" />
3636
<PackageVersion Include="System.Net.ServerSentEvents" Version="$(System10Version)" />
3737
</ItemGroup>

THIRD-PARTY-NOTICES.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,20 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5959
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6060
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6161
SOFTWARE.
62+
63+
License notice for URI Template Tests
64+
-------------------------------------
65+
66+
Copyright 2011- The Authors
67+
68+
Licensed under the Apache License, Version 2.0 (the "License");
69+
you may not use this file except in compliance with the License.
70+
You may obtain a copy of the License at
71+
72+
http://www.apache.org/licenses/LICENSE-2.0
73+
74+
Unless required by applicable law or agreed to in writing, software
75+
distributed under the License is distributed on an "AS IS" BASIS,
76+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77+
See the License for the specific language governing permissions and
78+
limitations under the License.

samples/EverythingServer/Program.cs

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using EverythingServer;
22
using EverythingServer.Prompts;
3+
using EverythingServer.Resources;
34
using EverythingServer.Tools;
45
using Microsoft.Extensions.AI;
56
using Microsoft.Extensions.DependencyInjection;
@@ -14,8 +15,6 @@
1415
using OpenTelemetry.Resources;
1516
using OpenTelemetry.Trace;
1617

17-
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
18-
1918
var builder = Host.CreateApplicationBuilder(args);
2019
builder.Logging.AddConsole(consoleLogOptions =>
2120
{
@@ -38,82 +37,7 @@
3837
.WithTools<TinyImageTool>()
3938
.WithPrompts<ComplexPromptType>()
4039
.WithPrompts<SimplePromptType>()
41-
.WithListResourcesHandler(async (ctx, ct) =>
42-
{
43-
return new ListResourcesResult
44-
{
45-
Resources =
46-
[
47-
new ModelContextProtocol.Protocol.Types.Resource { Name = "Direct Text Resource", Description = "A direct text resource", MimeType = "text/plain", Uri = "test://direct/text/resource" },
48-
]
49-
};
50-
})
51-
.WithListResourceTemplatesHandler(async (ctx, ct) =>
52-
{
53-
return new ListResourceTemplatesResult
54-
{
55-
ResourceTemplates =
56-
[
57-
new ResourceTemplate { Name = "Template Resource", Description = "A template resource with a numeric ID", UriTemplate = "test://template/resource/{id}" }
58-
]
59-
};
60-
})
61-
.WithReadResourceHandler(async (ctx, ct) =>
62-
{
63-
var uri = ctx.Params?.Uri;
64-
65-
if (uri == "test://direct/text/resource")
66-
{
67-
return new ReadResourceResult
68-
{
69-
Contents = [new TextResourceContents
70-
{
71-
Text = "This is a direct resource",
72-
MimeType = "text/plain",
73-
Uri = uri,
74-
}]
75-
};
76-
}
77-
78-
if (uri is null || !uri.StartsWith("test://template/resource/"))
79-
{
80-
throw new NotSupportedException($"Unknown resource: {uri}");
81-
}
82-
83-
int index = int.Parse(uri["test://template/resource/".Length..]) - 1;
84-
85-
if (index < 0 || index >= ResourceGenerator.Resources.Count)
86-
{
87-
throw new NotSupportedException($"Unknown resource: {uri}");
88-
}
89-
90-
var resource = ResourceGenerator.Resources[index];
91-
92-
if (resource.MimeType == "text/plain")
93-
{
94-
return new ReadResourceResult
95-
{
96-
Contents = [new TextResourceContents
97-
{
98-
Text = resource.Description!,
99-
MimeType = resource.MimeType,
100-
Uri = resource.Uri,
101-
}]
102-
};
103-
}
104-
else
105-
{
106-
return new ReadResourceResult
107-
{
108-
Contents = [new BlobResourceContents
109-
{
110-
Blob = resource.Description!,
111-
MimeType = resource.MimeType,
112-
Uri = resource.Uri,
113-
}]
114-
};
115-
}
116-
})
40+
.WithResources<SimpleResourceType>()
11741
.WithSubscribeToResourcesHandler(async (ctx, ct) =>
11842
{
11943
var uri = ctx.Params?.Uri;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using ModelContextProtocol.Protocol.Types;
2+
using ModelContextProtocol.Server;
3+
using System.ComponentModel;
4+
5+
namespace EverythingServer.Resources;
6+
7+
[McpServerResourceType]
8+
public class SimpleResourceType
9+
{
10+
[McpServerResource(UriTemplate = "test://direct/text/resource", Name = "Direct Text Resource", MimeType = "text/plain")]
11+
[Description("A direct text resource")]
12+
public static string DirectTextResource() => "This is a direct resource";
13+
14+
[McpServerResource(UriTemplate = "test://template/resource/{id}", Name = "Template Resource")]
15+
[Description("A template resource with a numeric ID")]
16+
public static ResourceContents TemplateResource(RequestContext<ReadResourceRequestParams> requestContext, int id)
17+
{
18+
int index = id - 1;
19+
if ((uint)index >= ResourceGenerator.Resources.Count)
20+
{
21+
throw new NotSupportedException($"Unknown resource: {requestContext.Params?.Uri}");
22+
}
23+
24+
var resource = ResourceGenerator.Resources[index];
25+
return resource.MimeType == "text/plain" ?
26+
new TextResourceContents
27+
{
28+
Text = resource.Description!,
29+
MimeType = resource.MimeType,
30+
Uri = resource.Uri,
31+
} :
32+
new BlobResourceContents
33+
{
34+
Blob = resource.Description!,
35+
MimeType = resource.MimeType,
36+
Uri = resource.Uri,
37+
};
38+
}
39+
}

0 commit comments

Comments
 (0)