Completion support (#15)

This commit is contained in:
Peder Holdgaard Pedersen 2025-01-19 12:59:21 +01:00 • committed by GitHub
commit 107c7acc8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 270 additions and 1 deletions

View file

@ -30,6 +30,7 @@ public class IntegrationTestFixture : IDisposable
TransportOptions = new Dictionary<string, string>
{
["command"] = "npx",
// Change to ["arguments"] = "mcp-server-everything" if you want to run the server locally after creating a symlink
["arguments"] = "-y @modelcontextprotocol/server-everything",
}
};

View file

@ -180,6 +180,68 @@ public class IntegrationTests : IClassFixture<IntegrationTestFixture>
Assert.NotNull(result.Contents[0].Blob);
}
/// <summary>
/// Note that as of 19th January 2025, the everything server published to npx does not support prompt completion.
/// However, the prompt completion is implemented in the github.com/modelcontextprotocol/servers repository.
/// You can clone this repo, and build locally then change the config to use a local symlink instead of npx until this is fixed, if you wish to run this test.
/// TransportOptions = new Dictionary<string, string>
/// {
/// ["command"] = "npx",
/// ["arguments"] = "mcp-server-everything" // changed from "-y @modelcontextprotocol/server-everything"
/// }
/// </summary>
[Fact]
public async Task GetCompletion_Stdio_ResourceReference()
{
// arrange
// act
var client = await _fixture.Factory.GetClientAsync("everything");
var result = await client.GetCompletionAsync(new Reference
{
Type = "ref/resource",
Uri = "test://static/resource/1"
},
"argument_name", "1",
CancellationToken.None
);
Assert.NotNull(result);
Assert.Single(result.Completion.Values);
Assert.True(result.Completion.Values[0] == "1");
}
/// <summary>
/// Note that as of 19th January 2025, the everything server published to npx does not support prompt completion.
/// However, the prompt completion is implemented in the github.com/modelcontextprotocol/servers repository.
/// You can clone this repo, and build locally then change the config to use a local symlink instead of npx until this is fixed, if you wish to run this test.
/// TransportOptions = new Dictionary<string, string>
/// {
/// ["command"] = "npx",
/// ["arguments"] = "mcp-server-everything" // changed from "-y @modelcontextprotocol/server-everything"
/// }
/// </summary>
[Fact]
public async Task GetCompletion_Stdio_PromptReference()
{
// arrange
// act
var client = await _fixture.Factory.GetClientAsync("everything");
var result = await client.GetCompletionAsync(new Reference
{
Type = "ref/prompt",
Name = "irrelevant"
},
argumentName:"style", argumentValue:"fo",
CancellationToken.None
);
Assert.NotNull(result);
Assert.Single(result.Completion.Values);
Assert.True(result.Completion.Values[0] == "formal");
}
[Fact]
public async Task Sampling_Stdio_EverythingServer()
{