onemodelcontextCookbook
onemodelcontext cookbook
Short recipes for common OneModelContext tasks, each with complete code you can copy.
Servers and clients
Build a server in C#Expose C# methods as tools that a client can discover and call. This example adds two integers over standard input and output (stdio).Connect to a server in C#A client discovers a server’s tools and calls them. You don’t need a language model or an API key to make a tool call.Host a server on ASP.NET CoreAdd a protocol endpoint to an ASP.NET Core app alongside your existing routes.Serve tools over HTTP in C#Streamable HTTP exposes tools at a URL. OneModelContext includes a loopback HTTP listener, so a local server doesn’t need ASP.NET Core.
Authorization
Require OAuth sign-in on a serverProtect tool calls with OAuth access tokens. This local example uses OneModelContext’s embedded authorization server and a simulated signed-in user.Sign in with OAuth to a protected server in C#An OAuth client signs in, obtains a token and sends it with tool calls. This example runs against an embedded local authorization server, with no external identity provider.