A Server Card is a public JSON document that tells AI clients where your server is and how to connect, before they connect.
dotnet add package RecursiveAI.OneModelContextRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using RecursiveAI.OneModelContext; using RecursiveAI.OneModelContext .Extensions.ServerCards; #pragma warning disable OMCX0003 var server = new ContextServer( "com.example/notes", "1.0.0"); await ModelContext.ServeHttpAsync( server, port: 0, path: "/tools", onListening: url => { server.UseServerCard( server.CreateServerCard( "com.example/notes", "Find public notes.", url.AbsoluteUri)); Console.WriteLine( url.AbsolutePath + "/server-card"); });
Unzip the example, then dotnet run.
The snippet publishes the card and prints its fetch path. It serves only on loopback and runs until stopped. The listener chooses a free port. OMCX0003 opts in to the experimental Server Card APIs.
/tools/server-cardThe full program
The download fetches /tools/server-card without a protocol connection. It prints the card’s name and advertised endpoint, then sends the first response’s ETag in the second GET’s If-None-Match header.
using System.Net; using System.Text.Json; using RecursiveAI.OneModelContext; using RecursiveAI.OneModelContext.Extensions.ServerCards; #pragma warning disable OMCX0003 // Opt in to experimental Server Card APIs. const string name = "com.example/notes"; var server = new ContextServer(name, "1.0.0"); using var stop = new CancellationTokenSource(TimeSpan.FromSeconds(10)); Uri? cardUrl = null; Task serving = ModelContext.ServeHttpAsync(server, port: 0, path: "/tools", onListening: endpoint => { server.UseServerCard(server.CreateServerCard(name, "Find public notes.", endpoint.AbsoluteUri)); cardUrl = new Uri(endpoint.AbsoluteUri + "/server-card"); }, cancellationToken: stop.Token); try { if (cardUrl is null) { await serving; throw new InvalidOperationException("The listener did not start."); } using var http = new HttpClient(); http.DefaultRequestHeaders.Accept.ParseAdd("application/mcp-server-card+json"); using var first = await http.GetAsync(cardUrl, stop.Token); first.EnsureSuccessStatusCode(); using var json = JsonDocument.Parse(await first.Content.ReadAsStringAsync(stop.Token)); var card = json.RootElement; var endpoint = new Uri(card.GetProperty("remotes")[0].GetProperty("url").GetString()!); Console.WriteLine($"Name: {card.GetProperty("name").GetString()}"); Console.WriteLine($"Endpoint: {endpoint.Scheme}://{(endpoint.IsLoopback ? "<loopback>" : endpoint.Host)}{endpoint.AbsolutePath}"); using var check = new HttpRequestMessage(HttpMethod.Get, cardUrl); check.Headers.IfNoneMatch.Add(first.Headers.ETag ?? throw new InvalidOperationException("No ETag returned.")); using var second = await http.SendAsync(check, stop.Token); if (second.StatusCode != HttpStatusCode.NotModified) throw new InvalidOperationException($"Expected 304, got {second.StatusCode}."); Console.WriteLine($"Second GET: {(int)second.StatusCode} Not Modified"); } finally { stop.Cancel(); await serving; }
Name: com.example/notes Endpoint: http://<loopback>/tools Second GET: 304 Not Modified
The output abbreviates the loopback host and omits the automatically assigned port. If the server has no card registered, the card URL returns 404.
Variations
To advertise a new description, replace the UseServerCard call in the first snippet’s onListening callback:
server.UseServerCard(server.CreateServerCard( "com.example/notes", "Search public meeting notes.", url.AbsoluteUri));
Related recipes
The short answer
Build the public JSON with CreateServerCard and register it with UseServerCard. For an endpoint at /tools, OneModelContext serves the card at GET /tools/server-card. The card tells a client where to connect; it isn’t a list of tools, resources or prompts.
Where should I publish a Server Card for discovery?
Put it next to the Streamable HTTP endpoint by appending /server-card to that endpoint’s path. The card’s advertised URL points back to the protocol endpoint, not to the card itself. The built-in listener used here is for local development. Publish over HTTPS in production, and put only public information in the document: the card is served before authentication.
A client that knows only the domain can look up /.well-known/ai-catalog.json, as described in the Server Card discovery draft. A catalog entry can link to the card or include it inline. Serving a card doesn’t publish a catalog or enroll the server in a directory. For the actual tool list, connect to the advertised endpoint and ask the running server.
How does a client check if a Server Card changed?
Save the ETag with the JSON from the first response. When checking again, send that tag as If-None-Match. A 304 Not Modified means the client can reuse the JSON it already has; there’s no replacement body. Treat the tag as opaque: send the header value back as received instead of rebuilding it from the card’s name or version.