Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/All.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@
</Folder>
<Folder Name="/HotChocolate/ModelContextProtocol/" />
<Folder Name="/HotChocolate/ModelContextProtocol/src/">
<Project Path="HotChocolate/ModelContextProtocol/src/HotChocolate.Fusion.ModelContextProtocol/HotChocolate.Fusion.ModelContextProtocol.csproj" />
<Project Path="HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol/HotChocolate.ModelContextProtocol.csproj" />
<Project Path="HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/HotChocolate.ModelContextProtocol.Core.csproj" />
</Folder>
<Folder Name="/HotChocolate/ModelContextProtocol/test/">
<Project Path="HotChocolate/ModelContextProtocol/test/HotChocolate.ModelContextProtocol.Tests/HotChocolate.ModelContextProtocol.Tests.csproj" />
Expand Down Expand Up @@ -366,4 +368,4 @@
<Folder Name="/StrawberryShake/Tooling/test/">
<Project Path="StrawberryShake/Tooling/test/Configuration.Tests/StrawberryShake.Tools.Configuration.Tests.csproj" />
</Folder>
</Solution>
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>HotChocolate.ModelContextProtocol.Fusion</AssemblyName>
<RootNamespace>HotChocolate.ModelContextProtocol</RootNamespace>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace HotChocolate.ModelContextProtocol.Extensions;

internal static class InputFieldExtensions
internal static class InputValueDefinitionExtensions
{
public static JsonSchema ToJsonSchema(this InputField inputField)
public static JsonSchema ToJsonSchema(this IInputValueDefinition inputField)
{
var type = inputField.Type;
var schemaBuilder = type.ToJsonSchemaBuilder(isOneOf: inputField.DeclaringType.IsOneOf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static JsonSchemaBuilder ToJsonSchemaBuilder(this IType type, bool isOneO

switch (type.NullableType())
{
case EnumType enumType:
case IEnumTypeDefinition enumType:
// Enum values.
List<JsonValue?> enumValues = [];

Expand All @@ -66,7 +66,7 @@ public static JsonSchemaBuilder ToJsonSchemaBuilder(this IType type, bool isOneO
schemaBuilder.Enum(enumValues);
break;

case InputObjectType inputObjectType:
case IInputObjectTypeDefinition inputObjectType:
// Object properties.
var objectProperties = new Dictionary<string, JsonSchema>();
var requiredObjectProperties = new List<string>();
Expand Down Expand Up @@ -123,11 +123,12 @@ private static SchemaValueType GetJsonSchemaValueType(this IType type)
{
return type switch
{
EnumType => SchemaValueType.String,
InputObjectType or InterfaceType or ObjectType or UnionType => SchemaValueType.Object,
IEnumTypeDefinition => SchemaValueType.String,
IInputObjectTypeDefinition or IInterfaceTypeDefinition or IObjectTypeDefinition or IUnionTypeDefinition
=> SchemaValueType.Object,
ListType => SchemaValueType.Array,
NonNullType => GetJsonSchemaValueType(type.NullableType()),
ScalarType => type switch
IScalarTypeDefinition => type switch
{
AnyType or JsonType =>
SchemaValueType.Object
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
EnumValueNode enumValueNode => JsonValue.Create(enumValueNode.Value),
FloatValueNode floatValueNode => nullableType switch
{
DecimalType => JsonValue.Create(floatValueNode.ToDecimal()),

Check failure on line 20 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/ValueNodeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'DecimalType' does not exist in the current context
FloatType => JsonValue.Create(floatValueNode.ToDouble()),

Check failure on line 21 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/ValueNodeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'FloatType' does not exist in the current context
// TODO: Treating all unknown scalar types as strings is a temporary solution.
_ => JsonValue.Create(floatValueNode.Value)
},
IntValueNode intValueNode => nullableType switch
{
ByteType => JsonValue.Create(intValueNode.ToByte()),

Check failure on line 27 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/ValueNodeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'ByteType' does not exist in the current context
DecimalType => JsonValue.Create(intValueNode.ToDecimal()),

Check failure on line 28 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/ValueNodeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'DecimalType' does not exist in the current context
FloatType => JsonValue.Create(intValueNode.ToDouble()),

Check failure on line 29 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/ValueNodeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'FloatType' does not exist in the current context
IntType => JsonValue.Create(intValueNode.ToInt32()),

Check failure on line 30 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/ValueNodeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'IntType' does not exist in the current context
LongType => JsonValue.Create(intValueNode.ToInt64()),

Check failure on line 31 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/ValueNodeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'LongType' does not exist in the current context
ShortType => JsonValue.Create(intValueNode.ToInt16()),

Check failure on line 32 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/ValueNodeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'ShortType' does not exist in the current context
// TODO: Treating all unknown scalar types as strings is a temporary solution.
_ => JsonValue.Create(intValueNode.Value)
},
Expand Down Expand Up @@ -63,9 +63,9 @@

foreach (var field in valueNode.Fields)
{
var graphQLFieldType = objectType is InputObjectType inputObjectType
var graphQLFieldType = objectType is IInputObjectTypeDefinition inputObjectType
? inputObjectType.Fields[field.Name.Value].Type
: new AnyType(); // Types like JsonType or AnyType have no schema.

Check failure on line 68 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/ValueNodeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The type or namespace name 'AnyType' could not be found (are you missing a using directive or an assembly reference?)

jsonObject.Add(field.Name.Value, field.Value.ToJsonNode(graphQLFieldType));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>HotChocolate.ModelContextProtocol.Core</AssemblyName>
<RootNamespace>HotChocolate.ModelContextProtocol</RootNamespace>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="HotChocolate.ModelContextProtocol" />
<InternalsVisibleTo Include="HotChocolate.ModelContextProtocol.Tests" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CaseConverter" />
<PackageReference Include="ChilliCream.ModelContextProtocol.AspNetCore" />
<PackageReference Include="JsonSchema.Net" />
<PackageReference Include="System.Reactive" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Core\src\Execution.Abstractions\HotChocolate.Execution.Abstractions.csproj" />
<ProjectReference Include="..\..\..\Core\src\Types.Abstractions\HotChocolate.Types.Abstractions.csproj" />
<ProjectReference Include="..\..\..\Core\src\Validation\HotChocolate.Validation.csproj" />
<ProjectReference Include="..\..\..\Language\src\Language\HotChocolate.Language.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\ModelContextProtocolResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ModelContextProtocolResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\ModelContextProtocolResources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ModelContextProtocolResources.resx</DependentUpon>
</Compile>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.Reflection;
using HotChocolate.ModelContextProtocol.Directives;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors;

namespace HotChocolate.ModelContextProtocol.Attributes;
namespace HotChocolate.ModelContextProtocol.Directives;

/// <summary>
/// Additional properties describing a Tool to clients.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using HotChocolate.ModelContextProtocol.Directives;
using HotChocolate.Types;

namespace HotChocolate.ModelContextProtocol.Types;
namespace HotChocolate.ModelContextProtocol.Directives;

/// <summary>
/// Additional properties describing a Tool to clients.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using HotChocolate.Execution;
using HotChocolate.Execution.Configuration;
using HotChocolate.ModelContextProtocol.Diagnostics;
using HotChocolate.ModelContextProtocol.Directives;
using HotChocolate.ModelContextProtocol.Handlers;
using HotChocolate.ModelContextProtocol.Proxies;
using HotChocolate.ModelContextProtocol.Storage;
using HotChocolate.ModelContextProtocol.Types;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using HotChocolate.ModelContextProtocol.Types;
namespace HotChocolate.ModelContextProtocol.Extensions;
public static class SchemaBuilderExtensions
{
public static ISchemaBuilder AddMcp(this ISchemaBuilder builder)
{
builder.AddDirectiveType<McpToolAnnotationsDirectiveType>();
return builder;
}
}
using HotChocolate.ModelContextProtocol.Directives;

namespace HotChocolate.ModelContextProtocol.Extensions;

public static class SchemaBuilderExtensions
{
public static ISchemaBuilder AddMcp(this ISchemaBuilder builder)
{
builder.AddDirectiveType<McpToolAnnotationsDirectiveType>();

return builder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,10 @@
<RootNamespace>HotChocolate.ModelContextProtocol</RootNamespace>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="HotChocolate.ModelContextProtocol.Tests" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CaseConverter" />
<PackageReference Include="ChilliCream.ModelContextProtocol.AspNetCore" />
<PackageReference Include="JsonSchema.Net" />
<PackageReference Include="System.Reactive" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Core\src\Execution\HotChocolate.Execution.csproj" />
<ProjectReference Include="..\..\..\Language\src\Language\HotChocolate.Language.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\ModelContextProtocolResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ModelContextProtocolResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\ModelContextProtocolResources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ModelContextProtocolResources.resx</DependentUpon>
</Compile>
<ProjectReference Include="..\..\..\Core\src\Types\HotChocolate.Types.csproj" />
<ProjectReference Include="..\HotChocolate.ModelContextProtocol.Core\HotChocolate.ModelContextProtocol.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Text.Json;
using HotChocolate.Authorization;
using HotChocolate.Language;
using HotChocolate.ModelContextProtocol.Attributes;
using HotChocolate.ModelContextProtocol.Directives;
using HotChocolate.Types;

namespace HotChocolate.ModelContextProtocol;
Expand Down
Loading