Skip to content

Commit 24090d5

Browse files
authored
fixed tool results by removed structedContent as clients does not use it yet - also updated MCP SDK (#1)
1 parent 4203c4a commit 24090d5

15 files changed

Lines changed: 182 additions & 138 deletions

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88

99
1. List tools: `curl -vs http://localhost:9001 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'`
1010
1. Get item: `curl -vs http://localhost:9001 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name": "get_item", "arguments": {"pathOrId": "/sitecore/content/home"}}}'`
11+
1. Or use the MCP inspector by running: `npx @modelcontextprotocol/inspector`

src/SitecoreBasicMcp.Http/SitecoreBasicMcp.Http.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.5.0-preview.1" />
10+
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.6.0-preview.1" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

src/SitecoreBasicMcp.Http/packages.lock.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"net10.0": {
55
"ModelContextProtocol.AspNetCore": {
66
"type": "Direct",
7-
"requested": "[0.5.0-preview.1, )",
8-
"resolved": "0.5.0-preview.1",
9-
"contentHash": "4KYK/rc6E8uuSJorludY/0Gpcm0wCXT5BGyZPcLRHisMT+cqW/P6lOv5luQZvy6iOxhwMmTMmY7DzU+VKVvjaw==",
7+
"requested": "[0.6.0-preview.1, )",
8+
"resolved": "0.6.0-preview.1",
9+
"contentHash": "UltrLduMY0CRzh4XZAx3hp9fQeprxeVqd8hXhKWlBRib2WUo8yAavTy5yQZrel4JnbjfGGN77dXPyphshpwvbQ==",
1010
"dependencies": {
11-
"ModelContextProtocol": "0.5.0-preview.1"
11+
"ModelContextProtocol": "0.6.0-preview.1"
1212
}
1313
},
1414
"GraphQL.Client": {
@@ -52,23 +52,23 @@
5252
},
5353
"Microsoft.Extensions.AI.Abstractions": {
5454
"type": "Transitive",
55-
"resolved": "10.0.0",
56-
"contentHash": "PHeuDm2tC6wJPEQvleUr2kNQaIMNqSf3aEbzkIPlZyQ0+0SYI9SwXVLdGD1NPBI+xB+Vb2lxZKhrFlIf9kP9WA=="
55+
"resolved": "10.1.1",
56+
"contentHash": "cgj8iHv4JwUpcPANZ0oLILz146Y1Oa+l280b1c1a3DjwZflH9nmYcrX952YUuqftz2sheAC2TPCGcEa6unKQgQ=="
5757
},
5858
"ModelContextProtocol": {
5959
"type": "Transitive",
60-
"resolved": "0.5.0-preview.1",
61-
"contentHash": "QJpuNEnMZLJmvASbZ2nvMqENTZk3HYF83IihoHs3EJ5vTlz4sYjji9bXh2HP5UxpXIdHGn0iuHu0X2Tpq2zilw==",
60+
"resolved": "0.6.0-preview.1",
61+
"contentHash": "onUtGV9yny1rFZQ1qGUp6XPJBB2VxvWXvEioq8+/8hYOX6zEoc/Mc4tX8u7KRhU1mLss48jMh5DHFBMKifMiVw==",
6262
"dependencies": {
63-
"ModelContextProtocol.Core": "0.5.0-preview.1"
63+
"ModelContextProtocol.Core": "0.6.0-preview.1"
6464
}
6565
},
6666
"ModelContextProtocol.Core": {
6767
"type": "Transitive",
68-
"resolved": "0.5.0-preview.1",
69-
"contentHash": "33V1Druluweou6x2LN6MSMbhiwHOYZxTUEJ1okFKjYDRIthctTVe0EJi//nifl4MRld2b5D5LnuV9sezz54p6g==",
68+
"resolved": "0.6.0-preview.1",
69+
"contentHash": "vjpbeJL7O4kNAgwv6wZtqlAAUX/tWaYLtbBzENDablIQfI1bH2tYTD/eK/6JvxP+Qp1H/lXaMvuRM6wohAzauA==",
7070
"dependencies": {
71-
"Microsoft.Extensions.AI.Abstractions": "10.0.0"
71+
"Microsoft.Extensions.AI.Abstractions": "10.1.1"
7272
}
7373
},
7474
"System.Reactive": {
@@ -81,7 +81,7 @@
8181
"dependencies": {
8282
"GraphQL.Client": "[6.1.0, )",
8383
"GraphQL.Client.Serializer.SystemTextJson": "[6.1.0, )",
84-
"ModelContextProtocol": "[0.5.0-preview.1, )"
84+
"ModelContextProtocol": "[0.6.0-preview.1, )"
8585
}
8686
}
8787
}

src/SitecoreBasicMcp.Stdio/SitecoreBasicMcp.Stdio.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="ModelContextProtocol" Version="0.5.0-preview.1" />
12+
<PackageReference Include="ModelContextProtocol" Version="0.6.0-preview.1" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

src/SitecoreBasicMcp.Stdio/packages.lock.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"net10.0": {
55
"ModelContextProtocol": {
66
"type": "Direct",
7-
"requested": "[0.5.0-preview.1, )",
8-
"resolved": "0.5.0-preview.1",
9-
"contentHash": "QJpuNEnMZLJmvASbZ2nvMqENTZk3HYF83IihoHs3EJ5vTlz4sYjji9bXh2HP5UxpXIdHGn0iuHu0X2Tpq2zilw==",
7+
"requested": "[0.6.0-preview.1, )",
8+
"resolved": "0.6.0-preview.1",
9+
"contentHash": "onUtGV9yny1rFZQ1qGUp6XPJBB2VxvWXvEioq8+/8hYOX6zEoc/Mc4tX8u7KRhU1mLss48jMh5DHFBMKifMiVw==",
1010
"dependencies": {
11-
"ModelContextProtocol.Core": "0.5.0-preview.1"
11+
"ModelContextProtocol.Core": "0.6.0-preview.1"
1212
}
1313
},
1414
"GraphQL.Client": {
@@ -52,15 +52,15 @@
5252
},
5353
"Microsoft.Extensions.AI.Abstractions": {
5454
"type": "Transitive",
55-
"resolved": "10.0.0",
56-
"contentHash": "PHeuDm2tC6wJPEQvleUr2kNQaIMNqSf3aEbzkIPlZyQ0+0SYI9SwXVLdGD1NPBI+xB+Vb2lxZKhrFlIf9kP9WA=="
55+
"resolved": "10.1.1",
56+
"contentHash": "cgj8iHv4JwUpcPANZ0oLILz146Y1Oa+l280b1c1a3DjwZflH9nmYcrX952YUuqftz2sheAC2TPCGcEa6unKQgQ=="
5757
},
5858
"ModelContextProtocol.Core": {
5959
"type": "Transitive",
60-
"resolved": "0.5.0-preview.1",
61-
"contentHash": "33V1Druluweou6x2LN6MSMbhiwHOYZxTUEJ1okFKjYDRIthctTVe0EJi//nifl4MRld2b5D5LnuV9sezz54p6g==",
60+
"resolved": "0.6.0-preview.1",
61+
"contentHash": "vjpbeJL7O4kNAgwv6wZtqlAAUX/tWaYLtbBzENDablIQfI1bH2tYTD/eK/6JvxP+Qp1H/lXaMvuRM6wohAzauA==",
6262
"dependencies": {
63-
"Microsoft.Extensions.AI.Abstractions": "10.0.0"
63+
"Microsoft.Extensions.AI.Abstractions": "10.1.1"
6464
}
6565
},
6666
"System.Reactive": {
@@ -73,7 +73,7 @@
7373
"dependencies": {
7474
"GraphQL.Client": "[6.1.0, )",
7575
"GraphQL.Client.Serializer.SystemTextJson": "[6.1.0, )",
76-
"ModelContextProtocol": "[0.5.0-preview.1, )"
76+
"ModelContextProtocol": "[0.6.0-preview.1, )"
7777
}
7878
}
7979
}

src/SitecoreBasicMcp/SitecoreBasicMcp.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88
<ItemGroup>
9-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.1" />
10-
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.1" />
11-
<PackageReference Include="ModelContextProtocol" Version="0.5.0-preview.1" />
9+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.2" />
10+
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.2" />
11+
<PackageReference Include="ModelContextProtocol" Version="0.6.0-preview.1" />
1212
<PackageReference Include="GraphQL.Client" Version="6.1.0" />
1313
<PackageReference Include="GraphQL.Client.Serializer.SystemTextJson" Version="6.1.0" />
1414
</ItemGroup>

src/SitecoreBasicMcp/Tools/CreateItemTool.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mutation CreateItem(
3939
record CreateItemData(BasicItem Item);
4040
record CreateItemMutationResponse(CreateItemData CreateItem);
4141

42-
[McpServerTool(Idempotent = false, ReadOnly = false, UseStructuredContent = true), Description("Create a new Sitecore item under parent id or path.")]
42+
[McpServerTool(Idempotent = false, ReadOnly = false), Description("Create a new Sitecore item under parent id or path.")]
4343
public async Task<object> CreateItem(string parentPathOrId, string name, string templateId, string language, Field[] fields, CancellationToken cancellationToken)
4444
{
4545
var client = await GetAuthoringClient(cancellationToken);
@@ -70,7 +70,7 @@ public async Task<object> CreateItem(string parentPathOrId, string name, string
7070
return ErrorResultFromGraphQL(response.Errors);
7171
}
7272

73-
return response.Data.CreateItem.Item;
73+
return ItemResult(response.Data.CreateItem.Item);
7474
}
7575
}
7676

src/SitecoreBasicMcp/Tools/CreateItemVersionTool.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using GraphQL;
22
using Microsoft.Extensions.Options;
3+
using ModelContextProtocol.Protocol;
34
using ModelContextProtocol.Server;
45
using SitecoreBasicMcp.Authentication;
56
using System.ComponentModel;
@@ -25,8 +26,8 @@ mutation AddItemVersion($itemId: ID!, $language: String!) {
2526
record AddItemVersionData(BasicItem Item);
2627
record AddItemVersionMutationResponse(AddItemVersionData AddItemVersion);
2728

28-
[McpServerTool(Idempotent = false, ReadOnly = false, UseStructuredContent = true), Description("Create a new language version to a Sitecore item by its path or id.")]
29-
public async Task<object> CreateItemVersion(string pathOrId, string language, CancellationToken cancellationToken)
29+
[McpServerTool(Idempotent = false, ReadOnly = false), Description("Create a new language version to a Sitecore item by its path or id.")]
30+
public async Task<CallToolResult> CreateItemVersion(string pathOrId, string language, CancellationToken cancellationToken)
3031
{
3132
var client = await GetAuthoringClient(cancellationToken);
3233
var resolveItemIdResult = await ResolveItemId(pathOrId, language, client, cancellationToken);
@@ -53,7 +54,7 @@ public async Task<object> CreateItemVersion(string pathOrId, string language, Ca
5354
return ErrorResultFromGraphQL(response.Errors);
5455
}
5556

56-
return response.Data.AddItemVersion.Item;
57+
return ItemResult(response.Data.AddItemVersion.Item);
5758
}
5859
}
5960

src/SitecoreBasicMcp/Tools/DeleteItemTool.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using GraphQL;
22
using Microsoft.Extensions.Options;
3+
using ModelContextProtocol.Protocol;
34
using ModelContextProtocol.Server;
45
using SitecoreBasicMcp.Authentication;
56
using System.ComponentModel;
@@ -24,8 +25,8 @@ mutation DeleteItem($path: String!) {
2425
record DeleteItemData(bool Successful);
2526
record DeleteItemMutationResponse(DeleteItemData DeleteItem);
2627

27-
[McpServerTool(Idempotent = false, ReadOnly = false, UseStructuredContent = true), Description("Delete a Sitecore item by its path or id.")]
28-
public async Task<object> DeleteItem(string pathOrId, CancellationToken cancellationToken)
28+
[McpServerTool(Idempotent = false, ReadOnly = false), Description("Delete a Sitecore item by its path or id.")]
29+
public async Task<CallToolResult> DeleteItem(string pathOrId, CancellationToken cancellationToken)
2930
{
3031
var client = await GetAuthoringClient(cancellationToken);
3132
var request = new GraphQLRequest(_deleteItemMutation)
@@ -43,6 +44,14 @@ public async Task<object> DeleteItem(string pathOrId, CancellationToken cancella
4344
return ErrorResultFromGraphQL(response.Errors);
4445
}
4546

46-
return response.Data.DeleteItem.Successful;
47+
if (!response.Data.DeleteItem.Successful)
48+
{
49+
return ErrorResult("Item was not deleted.");
50+
}
51+
52+
return new()
53+
{
54+
Content = [new TextContentBlock { Text = "Item was deleted." }],
55+
};
4756
}
4857
}

src/SitecoreBasicMcp/Tools/DeleteItemVersionTool.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using GraphQL;
22
using Microsoft.Extensions.Options;
3+
using ModelContextProtocol.Protocol;
34
using ModelContextProtocol.Server;
45
using SitecoreBasicMcp.Authentication;
56
using System.ComponentModel;
@@ -27,8 +28,8 @@ mutation DeleteVersionItem($itemId: ID!, $language: String!, $version: Int!) {
2728
record DeleteItemVersionData(BasicItem Item);
2829
record DeleteItemMutationResponse(DeleteItemVersionData DeleteItemVersion);
2930

30-
[McpServerTool(Idempotent = false, ReadOnly = false, UseStructuredContent = true), Description("Delete a language version on a Sitecore item by its path or id.")]
31-
public async Task<object> DeleteItemVersion(string pathOrId, string language, int version, CancellationToken cancellationToken)
31+
[McpServerTool(Idempotent = false, ReadOnly = false), Description("Delete a language version on a Sitecore item by its path or id.")]
32+
public async Task<CallToolResult> DeleteItemVersion(string pathOrId, string language, int version, CancellationToken cancellationToken)
3233
{
3334
var client = await GetAuthoringClient(cancellationToken);
3435
var resolveItemIdResult = await ResolveItemId(pathOrId, language, client, cancellationToken);
@@ -56,6 +57,6 @@ public async Task<object> DeleteItemVersion(string pathOrId, string language, in
5657
return ErrorResultFromGraphQL(response.Errors);
5758
}
5859

59-
return response.Data.DeleteItemVersion.Item;
60+
return ItemResult(response.Data.DeleteItemVersion.Item);
6061
}
6162
}

0 commit comments

Comments
 (0)