Recursive AI

Inspect tool server capabilities in C#

OneModelContext is a free, open-source .NET SDK for the Model Context Protocol® from Recursive AI. MIT or Apache-2.0, no native dependencies.

After connecting, client.ProtocolVersion gives the negotiated revision, and client.ServerCapabilities tells you which features the server advertises.

Terminal
dotnet add package RecursiveAI.OneModelContext

Requires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.

C#
using RecursiveAI.OneModelContext;
// args[0]: the server’s HTTP URL
await using var client =
    await ModelContext.ConnectAsync(args[0]);
var caps = client.ServerCapabilities;
Console.WriteLine(caps.Tools is not null);

Unzip the example, then dotnet run.

Running dotnet run in the downloaded project starts both sides and prints:

Text
Revision: 2026-07-28
Tools: True
Resources: False
Prompts: False
Tool list changes: True

To run just the snippet against the example server:

  1. Server console: In the unzipped project, run dotnet run -- --serve. Copy the URL it prints and leave this console running.
  2. Client console: In a separate, empty folder, run dotnet new console and the install command above. Replace Program.cs with the snippet.
  3. Client console: Run dotnet run -- <URL>, replacing <URL> with the server’s printed URL. The snippet prints:
    Text
    True

Press Enter in the server console to stop it.

The full program

The download starts the example server on loopback, connects to it, and prints the negotiated revision, three feature flags, and support for tool list change notifications. The package generates AddTo for the partial class that declares the greeting tool.

C#
using RecursiveAI.OneModelContext;
using RecursiveAI.OneModelContext.Hosting;
using RecursiveAI.OneModelContext.Http;
 
var server = new ContextServer("greeter", "1.0.0");
new GreetingTools().AddTo(server);
using var endpoint = new StreamableHttpEndpoint(server);
await using var host = new HttpServer(endpoint.HandleAsync);
host.Start();
if (args.Contains("--serve"))
{
    Console.WriteLine(host.BaseAddress);
    Console.ReadLine();
    return;
}
 
await using var client = await ModelContext.ConnectAsync(host.BaseAddress!.AbsoluteUri);
var caps = client.ServerCapabilities;
Console.WriteLine($"Revision: {client.ProtocolVersion}");
Console.WriteLine($"Tools: {caps.Tools is not null}");
Console.WriteLine($"Resources: {caps.Resources is not null}");
Console.WriteLine($"Prompts: {caps.Prompts is not null}");
Console.WriteLine($"Tool list changes: {caps.Tools?.ListChanged == true}");
 
public partial class GreetingTools
{
    [Tool]
    public string Greet() => "Hello!";
}

If the client and server have no protocol revision in common, the connection can throw ProtocolVersionException before there are any capabilities to inspect.

Variations

A capability is not a list of tools. To get their names, add this after the full program’s capability checks:

C#
if (caps.Tools is not null)
    foreach (var tool in await client.ListToolsAsync())
        Console.WriteLine(tool.Name);
Text
greet

The short answer

After connecting to an MCP server (Model Context Protocol®) in C#, read client.ServerCapabilities on the returned ContextClient. Test for a non-null Tools, Resources, or Prompts property to see which of those features the server advertises. Read client.ProtocolVersion alongside the flags when debugging. If you need the names and schemas of the tools rather than just the tool capability, call ListToolsAsync separately.

How does a client discover which features a server supports?

ConnectAsync negotiates the protocol before returning the client. Capabilities are part of the negotiation result in OneModelContext, not another request you have to send. The protocol’s 2026-07-28 lifecycle specification describes how clients discover server information. Record the revision that actually came back, not the one you expected: the library can negotiate an older revision with an older server. You can also use ServerInfo to identify the connected implementation.

In the download, only a tool is registered. That’s why Tools is present but Prompts and Resources are absent. This is a check of the particular server’s advertised features, not a checklist of everything OneModelContext can host. A client UI can use it to decide whether to show a tool picker or a resource browser before it makes a list request.

What’s the difference between server capabilities and the tool list?

The capability says the server offers tools; it doesn’t say it offers greet. The variation makes a tool-list request to learn that name. If you need to call a particular tool, check that it is in the list and use its input schema. Neither a non-null capability nor a discovered tool name proves that a particular call will succeed. For example, a server can require a scope for the operation or reject the arguments you provide.

The capability also has optional flags. Tools?.ListChanged == true is the explicit indication that the server advertises tool list change notifications; the mere presence of Tools doesn’t make that flag true. When a client caches the tool list, it can use a change notification as a signal to fetch the list again. The capability itself doesn’t contain those new tool definitions.

All onemodelcontext recipes