Introduction
nimwire gives you the server side of the Model Context Protocol in native Nim code. You can expose functions as tools, publish files or generated data as resources, offer reusable prompts, and serve the same application over stdio or Streamable HTTP.
Your first server
Section titled “Your first server”Install nimwire with Nimble, then create echo.nim:
import nimwire
type EchoInput = object text*: string
let server = mcpServer("nimwire-echo", "0.1.0"): server.tool "echo", "Echo text back to the caller", proc (input: EchoInput): string = input.text
server.serveStdio()Compile it with:
nimble install nimwirenim c echo.nimThe executable reads newline-delimited JSON-RPC messages from stdin and writes responses to stdout. An MCP client normally launches it for you.
What you can build
Section titled “What you can build”- Tools: use typed Nim procedures and let nimwire derive their input and output schemas, or provide raw JSON when you need full schema control.
- Resources: serve static text, generated data, binary contents, files, and URI templates.
- Prompts: return text, media, resource links, or embedded resources from typed string arguments.
- Transports: use stdio for local clients, Streamable HTTP for remote clients, or an in-process transport for composition and tests.
- Long-running work: opt into MCP Tasks with expiring in-memory storage or durable storage callbacks.
- Production features: add authorization, principal-based visibility, cancellation, progress, limits, request logs, metrics, and tracing hooks.
A small, focused API
Section titled “A small, focused API”Most applications can start with the umbrella import:
import nimwireAs the application grows, focused imports such as nimwire/server, nimwire/resources, or nimwire/transports/http keep compile-time dependencies obvious. The API reference lists the public modules and entry points.
Next steps
Section titled “Next steps”- Quickstart: build, run, and inspect a complete stdio server.
- Server basics: register tools and understand MCP responses.
- Transports: choose stdio, HTTP, or in-process delivery.
- Examples: copy the runnable servers from the repository.