NimCP turns Nim’s macro system on the Model Context Protocol. You declare servers, tools, resources and prompts in a declarative style, and the macros generate the JSON schemas from your Nim type signatures — so the schema and the handler cannot drift apart.

It is my most “written by an agent” project: the library was almost entirely built with Claude Code, which made it an interesting experiment in what a macro API looks like when the person writing it is mostly reviewing.

let server = mcpServer("my-server", "1.0.0"):
  mcpTool:
    proc echo(text: string): string =
      ## Echo back the input text
      text
  • Macro-driven API — tools, resources and prompts with declarative syntax.
  • Automatic schemas — generated from Nim types; objects, unions, enums, optionals and arrays all supported.
  • Several transports — stdio, SSE, HTTP and WebSocket.
  • Server composition — combine servers behind prefixes and routing.