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 @@ -217,7 +217,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 @@ -349,4 +351,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,12 +3,12 @@

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);

Check failure on line 11 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/InputValueDefinitionExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

'IInputValueDefinition' does not contain a definition for 'DeclaringType' and no accessible extension method 'DeclaringType' accepting a first argument of type 'IInputValueDefinition' could be found (are you missing a using directive or an assembly reference?)

// Description.
if (inputField.Description is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

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

Expand All @@ -66,7 +66,7 @@
schemaBuilder.Enum(enumValues);
break;

case InputObjectType inputObjectType:
case IInputObjectTypeDefinition inputObjectType:
// Object properties.
var objectProperties = new Dictionary<string, JsonSchema>();
var requiredObjectProperties = new List<string>();
Expand All @@ -84,7 +84,7 @@
}

// OneOf.
if (inputObjectType.IsOneOf)

Check failure on line 87 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/TypeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

'IInputObjectTypeDefinition' does not contain a definition for 'IsOneOf' and no accessible extension method 'IsOneOf' accepting a first argument of type 'IInputObjectTypeDefinition' could be found (are you missing a using directive or an assembly reference?)
{
List<JsonSchema> oneOfSchemas = [];

Expand Down Expand Up @@ -123,21 +123,22 @@
{
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 =>

Check failure on line 133 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/TypeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'JsonType' does not exist in the current context

Check failure on line 133 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/TypeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'AnyType' does not exist in the current context
SchemaValueType.Object
| SchemaValueType.Array
| SchemaValueType.Boolean
| SchemaValueType.String
| SchemaValueType.Number
| SchemaValueType.Integer,
BooleanType => SchemaValueType.Boolean,

Check failure on line 140 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/TypeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'BooleanType' does not exist in the current context
ByteType or IntType or LongType or ShortType => SchemaValueType.Integer,

Check failure on line 141 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/TypeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'IntType' does not exist in the current context

Check failure on line 141 in src/HotChocolate/ModelContextProtocol/src/HotChocolate.ModelContextProtocol.Core/Extensions/TypeExtensions.cs

View workflow job for this annotation

GitHub Actions / Run HotChocolate.ModelContextProtocol.Tests

The name 'ByteType' does not exist in the current context
DecimalType or FloatType => SchemaValueType.Number,
IdType or StringType => SchemaValueType.String,
// The following types are serialized as strings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static JsonObject ToJsonNode(this ObjectValueNode valueNode, IType objec

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.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<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="..\..\..\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
@@ -1,9 +1,9 @@
using HotChocolate.Execution;
using HotChocolate.Execution.Configuration;
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